vue-renderer-markdown-monaco
Version:
A Vue 3 component that renders Markdown string content as HTML, supporting custom components and advanced markdown features.
2 lines • 3.59 MB
JavaScript
"use strict";var Hee=Object.defineProperty,Vee=Object.defineProperties;var zee=Object.getOwnPropertyDescriptors;var B0=Object.getOwnPropertySymbols,Uee=Object.getPrototypeOf,q9=Object.prototype.hasOwnProperty,j9=Object.prototype.propertyIsEnumerable,$ee=Reflect.get;var XC=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),qee=s=>{throw TypeError(s)},Cl=Math.pow,PT=(s,e,t)=>e in s?Hee(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,V=(s,e)=>{for(var t in e||(e={}))q9.call(e,t)&&PT(s,t,e[t]);if(B0)for(var t of B0(e))j9.call(e,t)&&PT(s,t,e[t]);return s},ne=(s,e)=>Vee(s,zee(e));var AT=(s,e)=>{var t={};for(var i in s)q9.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&B0)for(var i of B0(s))e.indexOf(i)<0&&j9.call(s,i)&&(t[i]=s[i]);return t};var de=(s,e,t)=>PT(s,typeof e!="symbol"?e+"":e,t);var K9=(s,e,t)=>$ee(Uee(s),t,e);var I=(s,e,t)=>new Promise((i,n)=>{var o=l=>{try{a(t.next(l))}catch(c){n(c)}},r=l=>{try{a(t.throw(l))}catch(c){n(c)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,r);a((t=t.apply(s,e)).next())}),jee=function(s,e){this[0]=s,this[1]=e};var QC=s=>{var e=s[XC("asyncIterator")],t=!1,i,n={};return e==null?(e=s[XC("iterator")](),i=o=>n[o]=r=>e[o](r)):(e=e.call(s),i=o=>n[o]=r=>{if(t){if(t=!1,o==="throw")throw r;return r}return t=!0,{done:!1,value:new jee(new Promise(a=>{var l=e[o](r);l instanceof Object||qee("Object expected"),a(l)}),1)}}),n[XC("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=o=>{throw o},"return"in e&&i("return"),n},Fc=(s,e,t)=>(e=s[XC("asyncIterator")])?e.call(s):(s=s[XC("iterator")](),e={},t=(i,n)=>(n=s[i])&&(e[i]=o=>new Promise((r,a,l)=>(o=n.call(s,o),l=o.done,Promise.resolve(o.value).then(c=>r({value:c,done:l}),a)))),t("next"),t("return"),e);const M=require("vue"),j$=require("uuid"),K$=require("katex"),P3=require("vue-i18n"),G$=require("@vueuse/core"),hg=require("@iconify/vue"),Kee=require("mermaid"),Gee=require("class-variance-authority"),Zee=require("radix-vue"),Yee=require("clsx"),Xee=require("tailwind-merge"),Z$=require("markdown-it"),Qee=require("markdown-it-mathjax3"),Jee=require("markdown-it-sub"),ete=require("markdown-it-sup"),tte=require("markdown-it-mark"),ite=require("markdown-it-emoji"),nte=require("markdown-it-ins"),ste=require("markdown-it-task-checkbox"),ote=require("markdown-it-footnote"),rte=require("markdown-it-container"),ate={class:"whitespace-pre-wrap break-normal",style:{"font-weight":"inherit"}},ic=M.defineComponent({__name:"TextNode",props:{node:{}},emits:["copy"],setup(s){const e=s;return(t,i)=>(M.openBlock(),M.createElementBlock("span",ate,M.toDisplayString(e.node.content),1))}});ic.install=s=>{s.component(ic.__name,ic)};let Y$=null;function qS(){return Y$}function lte(s){Y$=s}const T_=M.defineComponent({__name:"ParagraphNode",props:{node:{}},setup(s){const e=qS();return(t,i)=>(M.openBlock(),M.createElementBlock("p",null,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(M.unref(e)[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}});T_.install=s=>{s.component(T_.__name,T_)};const cte={class:"inline-block px-1 py-0.5 rounded text-xs font-mono bg-secondary before:content-[''] after:content-['']"},nc=M.defineComponent({__name:"InlineCodeNode",props:{node:{}},setup(s){return(e,t)=>(M.openBlock(),M.createElementBlock("code",cte,M.toDisplayString(e.node.code),1))}});nc.install=s=>{s.component(nc.__name,nc)};const Zn=(s,e)=>{const t=s.__vccOpts||s;for(const[i,n]of e)t[i]=n;return t},dte=["href","title"],hte=M.defineComponent({__name:"LinkNode",props:{node:{}},emits:["copy"],setup(s){return(e,t)=>(M.openBlock(),M.createElementBlock("a",{class:"link-node",href:e.node.href,title:e.node.title||"",target:"_blank",rel:"noopener noreferrer"},[M.createVNode(M.unref(Ar),{nodes:e.node.children,onCopy:t[0]||(t[0]=i=>e.$emit("copy",i))},null,8,["nodes"])],8,dte))}}),sc=Zn(hte,[["__scopeId","data-v-8b20099e"]]);sc.install=s=>{s.component(sc.__name,sc)};const ute={class:"text-center my-4"},gte=["src","alt","title"],fte={key:0,class:"mt-2 text-sm text-gray-500 italic"},Jg=M.defineComponent({__name:"ImageNode",props:{node:{}},setup(s){const e=M.ref(!1),t=M.ref(!1);function i(){t.value=!0}function n(){e.value=!0}return(o,r)=>(M.openBlock(),M.createElementBlock("figure",ute,[M.createElementVNode("img",{class:"max-w-96 h-auto rounded-lg",src:o.node.src,alt:o.node.alt,title:o.node.title||o.node.alt,onError:i,onLoad:n},null,40,gte),o.node.alt?(M.openBlock(),M.createElementBlock("figcaption",fte,M.toDisplayString(o.node.alt),1)):M.createCommentVNode("",!0)]))}});Jg.install=s=>{s.component(Jg.__name,Jg)};const mte={class:"strong-node"},pte=M.defineComponent({__name:"StrongNode",props:{node:{}},setup(s){const e=qS();return(t,i)=>(M.openBlock(),M.createElementBlock("strong",mte,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(M.unref(e)[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}}),oc=Zn(pte,[["__scopeId","data-v-80635e1c"]]);oc.install=s=>{s.component(oc.__name,oc)};const _te={class:"strikethrough-node"},bte=M.defineComponent({__name:"StrikethroughNode",props:{node:{}},setup(s){const e=qS();return(t,i)=>(M.openBlock(),M.createElementBlock("del",_te,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(M.unref(e)[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}}),rc=Zn(bte,[["__scopeId","data-v-0acbeccf"]]);rc.install=s=>{s.component(rc.__name,rc)};const Cte={class:"subscript-node"},vte=M.defineComponent({__name:"SubscriptNode",props:{node:{}},setup(s){const e=qS();return(t,i)=>(M.openBlock(),M.createElementBlock("sub",Cte,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(M.unref(e)[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}}),ac=Zn(vte,[["__scopeId","data-v-49d625ea"]]);ac.install=s=>{s.component(ac.__name,ac)};const wte={class:"superscript-node"},Ste=M.defineComponent({__name:"SuperscriptNode",props:{node:{}},setup(s){const e=qS();return(t,i)=>(M.openBlock(),M.createElementBlock("sup",wte,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(M.unref(e)[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}}),lc=Zn(Ste,[["__scopeId","data-v-490b7261"]]);lc.install=s=>{s.component(lc.__name,lc)};const yte={class:"emoji-node"},Lte=M.defineComponent({__name:"EmojiNode",props:{node:{}},setup(s){return(e,t)=>(M.openBlock(),M.createElementBlock("span",yte,M.toDisplayString(e.node.emoji),1))}}),cc=Zn(Lte,[["__scopeId","data-v-574a91fb"]]);cc.install=s=>{s.component(cc.__name,cc)};const xte=["title"],kte=M.defineComponent({__name:"FootnoteReferenceNode",props:{node:{}},setup(s){const t=`#footnote-${s.node.id}`;function i(){const n=document.querySelector(t);n?n.scrollIntoView({behavior:"smooth"}):console.warn(`Element with href: ${t} not found`)}return(n,o)=>(M.openBlock(),M.createElementBlock("sup",{class:"footnote-reference",onClick:i},[M.createElementVNode("span",{href:t,title:`查看脚注 ${n.node.id}`,class:"footnote-link cursor-pointer"},"["+M.toDisplayString(n.node.id)+"]",9,xte)]))}}),dc=Zn(kte,[["__scopeId","data-v-340dc096"]]);dc.install=s=>{s.component(dc.__name,dc)};const hc=M.defineComponent({__name:"MathInlineNode",props:{node:{}},setup(s){const e=s,t=M.ref(null);function i(){if(!(!t.value||!e.node.content))try{K$.render(e.node.content,t.value,{throwOnError:!1,displayMode:!1,output:"html"})}catch(n){console.error("KaTeX rendering error:",n),t.value.textContent=e.node.raw}}return M.onMounted(()=>{i()}),M.watch(()=>e.node.content,()=>{i()}),(n,o)=>(M.openBlock(),M.createElementBlock("span",{ref_key:"mathElement",ref:t,class:"math-inline"},null,512))}});hc.install=s=>{s.component(hc.__name,hc)};const Dte={class:"insert-node"},Ite=M.defineComponent({__name:"InsertNode",props:{node:{}},setup(s){const e={text:ic,inline_code:nc,link:sc,strong:oc,emphasis:ef,strikethrough:rc,highlight:Id,subscript:ac,superscript:lc,emoji:cc,footnote_reference:dc,math_inline:hc};return(t,i)=>(M.openBlock(),M.createElementBlock("ins",Dte,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(e[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}}),Dd=Zn(Ite,[["__scopeId","data-v-0df8a784"]]);Dd.install=s=>{s.component(Dd.__name,Dd)};const Nte={class:"highlight-node"},Ete=M.defineComponent({__name:"HighlightNode",props:{node:{}},setup(s){const e={text:ic,inline_code:nc,link:sc,strong:oc,emphasis:ef,strikethrough:rc,insert:Dd,subscript:ac,superscript:lc,emoji:cc,footnote_reference:dc,math_inline:hc};return(t,i)=>(M.openBlock(),M.createElementBlock("mark",Nte,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(e[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}}),Id=Zn(Ete,[["__scopeId","data-v-f00ab1c4"]]);Id.install=s=>{s.component(Id.__name,Id)};const Tte={class:"emphasis-node"},Rte=M.defineComponent({__name:"EmphasisNode",props:{node:{}},setup(s){const e={text:ic,inline_code:nc,link:sc,strong:oc,strikethrough:rc,highlight:Id,insert:Dd,subscript:ac,superscript:lc,emoji:cc,footnote_reference:dc,math_inline:hc};return(t,i)=>(M.openBlock(),M.createElementBlock("em",Tte,[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(e[n.type]),{key:o,node:n},null,8,["node"]))),128))]))}}),ef=Zn(Rte,[["__scopeId","data-v-f789330e"]]);ef.install=s=>{s.component(ef.__name,ef)};const Mte={class:"checkbox-node"},Pte=["checked"],Ate=M.defineComponent({__name:"CheckboxNode",props:{node:{}},setup(s){return(e,t)=>(M.openBlock(),M.createElementBlock("span",Mte,[M.createElementVNode("input",{type:"checkbox",checked:e.node.checked,disabled:"",class:"checkbox-input"},null,8,Pte)]))}}),tf=Zn(Ate,[["__scopeId","data-v-52198b9c"]]);tf.install=s=>{s.component(tf.__name,tf)};const Ote={class:"hard-break"},Fte=M.defineComponent({__name:"HardBreakNode",props:{node:{}},setup(s){return(e,t)=>(M.openBlock(),M.createElementBlock("br",Ote))}}),nf=Zn(Fte,[["__scopeId","data-v-7be625c1"]]);nf.install=s=>{s.component(nf.__name,nf)};const Bte=M.defineComponent({__name:"HeadingNode",props:{node:{}},setup(s){const e={text:ic,inline_code:nc,link:sc,image:Jg,strong:oc,emphasis:ef,strikethrough:rc,highlight:Id,insert:Dd,subscript:ac,superscript:lc,emoji:cc,checkbox:tf,footnote_reference:dc,hardbreak:nf,math_inline:hc};return(t,i)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(`h${t.node.level}`),{class:M.normalizeClass(["heading-node",[`heading-${t.node.level}`]])},{default:M.withCtx(()=>[(M.openBlock(!0),M.createElementBlock(M.Fragment,null,M.renderList(t.node.children,(n,o)=>(M.openBlock(),M.createBlock(M.resolveDynamicComponent(e[n.type]),{key:o,node:n},null,8,["node"]))),128))]),_:1},8,["class"]))}}),R_=Zn(Bte,[["__scopeId","data-v-f011d008"]]);R_.install=s=>{s.component(R_.__name,R_)};const Wte=[["bash",[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],["html",[/<\/?[a-z-][^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],["http",[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],["js",[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require)\b/g,10]],["ts",[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|implements|interface|namespace)\b/g,10]],["py",[/\b(def|print|class|and|or|lambda)\b/g,10]],["sql",[/\b(SELECT|INSERT|FROM)\b/g,50]],["pl",[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],["lua",[/#!(\/usr)?\/bin\/lua/g,500]],["make",[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],["uri",[/https?:|mailto:|tel:|ftp:/g,30]],["css",[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],["diff",[/^[+><-]/gm,10],[/^@@[-+,0-9 ]+@@/gm,25]],["md",[/^(>|\t\*|\t\d+.|#{1,6} |-\s+|\*\s+)/gm,25],[/\[.*\](.*)/g,10]],["docker",[/^(FROM|ENTRYPOINT|RUN)/gm,500]],["xml",[/<\/?[a-z-][^\n>]*>/g,10],[/^<\?xml/g,500]],["c",[/#include\b|\bprintf\s+\(/g,100]],["rs",[/^\s+(use|fn|mut|match)\b/gm,100]],["go",[/\b(func|fmt|package)\b/g,100]],["java",[/^import\s+java/gm,500]],["asm",[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],["css",[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],["json",[/\b(true|false|null|\{\})\b|"[^"]+":/g,10]],["yaml",[/^(\s+)?[a-z][a-z0-9]*:/gim,10]],["toml",[/^\s*\[.*\]\s*$/gm,100],[/^\s*[\w-]+ *= */gm,20]],["mermaid",[/^(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|mindmap)/gm,500],[/\b(-->|--o|--x|=>|\[\]|[{}])\b/g,10]]];function X$(s){var e;return((e=Wte.map(([t,...i])=>[t,i.reduce((n,[o,r])=>n+[...s.matchAll(o)].length*r,0)]).filter(([,t])=>t>20).sort((t,i)=>i[1]-t[1])[0])==null?void 0:e[0])||"plain"}function Q$(s){switch(s){case"javascript":case"js":return"vscode-icons:file-type-js-official";case"typescript":case"ts":return"vscode-icons:file-type-typescript";case"jsx":return"vscode-icons:file-type-reactjs";case"tsx":return"vscode-icons:file-type-reactts";case"html":return"vscode-icons:file-type-html";case"css":return"vscode-icons:file-type-css";case"scss":return"vscode-icons:file-type-scss";case"json":return"vscode-icons:file-type-json";case"python":case"py":return"vscode-icons:file-type-python";case"ruby":case"rb":return"vscode-icons:file-type-ruby";case"go":case"golang":return"vscode-icons:file-type-go";case"r":return"vscode-icons:file-type-r";case"java":return"vscode-icons:file-type-java";case"kotlin":case"kt":return"vscode-icons:file-type-kotlin";case"c":return"vscode-icons:file-type-c";case"cpp":case"c++":return"vscode-icons:file-type-cpp";case"cs":case"csharp":return"vscode-icons:file-type-csharp";case"php":return"vscode-icons:file-type-php";case"scala":return"vscode-icons:file-type-scala";case"shell":case"sh":case"bash":case"zsh":case"powershell":case"ps1":case"bat":case"batch":return"vscode-icons:file-type-powershell";case"sql":return"vscode-icons:file-type-sql";case"yaml":case"yml":return"vscode-icons:file-type-yaml";case"markdown":case"md":return"vscode-icons:file-type-markdown";case"xml":return"vscode-icons:file-type-xml";case"rust":case"rs":return"vscode-icons:file-type-rust";case"swift":return"vscode-icons:file-type-swift";case"perl":return"vscode-icons:file-type-perl";case"lua":return"vscode-icons:file-type-lua";case"haskell":return"vscode-icons:file-type-haskell";case"erlang":return"vscode-icons:file-type-erlang";case"clojure":return"vscode-icons:file-type-clojure";case"vue":return"vscode-icons:file-type-vue";case"svg":return"vscode-icons:file-type-svg";case"mermaid":return"vscode-icons:file-type-mermaid";case"dart":return"vscode-icons:file-type-dartlang";case"assembly":return"vscode-icons:file-type-assembly";case"dockerfile":return"vscode-icons:file-type-docker";case"fortran":return"vscode-icons:file-type-fortran";case"lisp":return"vscode-icons:file-type-lisp";case"ocaml":return"vscode-icons:file-type-ocaml";case"prolog":return"vscode-icons:file-type-prolog";case"groovy":return"vscode-icons:file-type-groovy";case"matlab":return"vscode-icons:file-type-matlab";case"cobol":return"vscode-icons:file-type-cobol";case"ada":return"vscode-icons:file-type-ada";case"julia":return"vscode-icons:file-type-julia";case"elixir":return"vscode-icons:file-type-elixir";case"vb.net":return"vscode-icons:file-type-vb";case"nim":return"vscode-icons:file-type-nim";case"crystal":return"vscode-icons:file-type-crystal";case"d":return"vscode-icons:file-type-dlang";case"applescript":return"vscode-icons:file-type-applescript";case"solidity":return"vscode-icons:file-type-solidity";case"objectivec":return"vscode-icons:file-type-objectivec";case"objectivecpp":return"vscode-icons:file-type-objectivecpp";case"terraform":return"vscode-icons:file-type-terraform";case"plain":case"text":return"vscode-icons:file-type-text";default:return"lucide:square-code"}}function Hte(s){return A3(s)}function A3(s){return Array.isArray(s)?Vte(s):s instanceof RegExp?s:typeof s=="object"?zte(s):s}function Vte(s){let e=[];for(let t=0,i=s.length;t<i;t++)e[t]=A3(s[t]);return e}function zte(s){let e={};for(let t in s)e[t]=A3(s[t]);return e}function J$(s,...e){return e.forEach(t=>{for(let i in t)s[i]=t[i]}),s}function eq(s){const e=~s.lastIndexOf("/")||~s.lastIndexOf("\\");return e===0?s:~e===s.length-1?eq(s.substring(0,s.length-1)):s.substr(~e+1)}var OT=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,W0=class{static hasCaptures(s){return s===null?!1:(OT.lastIndex=0,OT.test(s))}static replaceCaptures(s,e,t){return s.replace(OT,(i,n,o,r)=>{let a=t[parseInt(n||o,10)];if(a){let l=e.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(r){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return i})}};function tq(s,e){return s<e?-1:s>e?1:0}function iq(s,e){if(s===null&&e===null)return 0;if(!s)return-1;if(!e)return 1;let t=s.length,i=e.length;if(t===i){for(let n=0;n<t;n++){let o=tq(s[n],e[n]);if(o!==0)return o}return 0}return t-i}function G9(s){return!!(/^#[0-9a-f]{6}$/i.test(s)||/^#[0-9a-f]{8}$/i.test(s)||/^#[0-9a-f]{3}$/i.test(s)||/^#[0-9a-f]{4}$/i.test(s))}function nq(s){return s.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var sq=class{constructor(s){de(this,"cache",new Map);this.fn=s}get(s){if(this.cache.has(s))return this.cache.get(s);const e=this.fn(s);return this.cache.set(s,e),e}},jL=class{constructor(s,e,t){de(this,"_cachedMatchRoot",new sq(s=>this._root.match(s)));this._colorMap=s,this._defaults=e,this._root=t}static createFromRawTheme(s,e){return this.createFromParsedTheme(qte(s),e)}static createFromParsedTheme(s,e){return Kte(s,e)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(s){if(s===null)return this._defaults;const e=s.scopeName,i=this._cachedMatchRoot.get(e).find(n=>Ute(s.parent,n.parentScopes));return i?new oq(i.fontStyle,i.foreground,i.background):null}},FT=class iL{constructor(e,t){this.parent=e,this.scopeName=t}static push(e,t){for(const i of t)e=new iL(e,i);return e}static from(...e){let t=null;for(let i=0;i<e.length;i++)t=new iL(t,e[i]);return t}push(e){return new iL(this,e)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let i=this;for(;i&&i!==e;)t.push(i.scopeName),i=i.parent;return i===e?t.reverse():void 0}};function Ute(s,e){if(e.length===0)return!0;for(let t=0;t<e.length;t++){let i=e[t],n=!1;if(i===">"){if(t===e.length-1)return!1;i=e[++t],n=!0}for(;s&&!$te(s.scopeName,i);){if(n)return!1;s=s.parent}if(!s)return!1;s=s.parent}return!0}function $te(s,e){return e===s||s.startsWith(e)&&s[e.length]==="."}var oq=class{constructor(s,e,t){this.fontStyle=s,this.foregroundId=e,this.backgroundId=t}};function qte(s){if(!s)return[];if(!s.settings||!Array.isArray(s.settings))return[];let e=s.settings,t=[],i=0;for(let n=0,o=e.length;n<o;n++){let r=e[n];if(!r.settings)continue;let a;if(typeof r.scope=="string"){let h=r.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else Array.isArray(r.scope)?a=r.scope:a=[""];let l=-1;if(typeof r.settings.fontStyle=="string"){l=0;let h=r.settings.fontStyle.split(" ");for(let u=0,g=h.length;u<g;u++)switch(h[u]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof r.settings.foreground=="string"&&G9(r.settings.foreground)&&(c=r.settings.foreground);let d=null;typeof r.settings.background=="string"&&G9(r.settings.background)&&(d=r.settings.background);for(let h=0,u=a.length;h<u;h++){let f=a[h].trim().split(" "),p=f[f.length-1],_=null;f.length>1&&(_=f.slice(0,f.length-1),_.reverse()),t[i++]=new jte(p,_,n,l,c,d)}}return t}var jte=class{constructor(s,e,t,i,n,o){this.scope=s,this.parentScopes=e,this.index=t,this.fontStyle=i,this.foreground=n,this.background=o}},Ks=(s=>(s[s.NotSet=-1]="NotSet",s[s.None=0]="None",s[s.Italic=1]="Italic",s[s.Bold=2]="Bold",s[s.Underline=4]="Underline",s[s.Strikethrough=8]="Strikethrough",s))(Ks||{});function Kte(s,e){s.sort((l,c)=>{let d=tq(l.scope,c.scope);return d!==0||(d=iq(l.parentScopes,c.parentScopes),d!==0)?d:l.index-c.index});let t=0,i="#000000",n="#ffffff";for(;s.length>=1&&s[0].scope==="";){let l=s.shift();l.fontStyle!==-1&&(t=l.fontStyle),l.foreground!==null&&(i=l.foreground),l.background!==null&&(n=l.background)}let o=new Gte(e),r=new oq(t,o.getId(i),o.getId(n)),a=new Yte(new JM(0,null,-1,0,0),[]);for(let l=0,c=s.length;l<c;l++){let d=s[l];a.insert(0,d.scope,d.parentScopes,d.fontStyle,o.getId(d.foreground),o.getId(d.background))}return new jL(o,r,a)}var Gte=class{constructor(e){de(this,"_isFrozen");de(this,"_lastColorId");de(this,"_id2color");de(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,i=e.length;t<i;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Zte=Object.freeze([]),JM=class rq{constructor(e,t,i,n,o){de(this,"scopeDepth");de(this,"parentScopes");de(this,"fontStyle");de(this,"foreground");de(this,"background");this.scopeDepth=e,this.parentScopes=t||Zte,this.fontStyle=i,this.foreground=n,this.background=o}clone(){return new rq(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let i=0,n=e.length;i<n;i++)t[i]=e[i].clone();return t}acceptOverwrite(e,t,i,n){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),i!==0&&(this.foreground=i),n!==0&&(this.background=n)}},Yte=class eP{constructor(e,t=[],i={}){de(this,"_rulesWithParentScopes");this._mainRule=e,this._children=i,this._rulesWithParentScopes=t}static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let i=0,n=0;for(;e.parentScopes[i]===">"&&i++,t.parentScopes[n]===">"&&n++,!(i>=e.parentScopes.length||n>=t.parentScopes.length);){const o=t.parentScopes[n].length-e.parentScopes[i].length;if(o!==0)return o;i++,n++}return t.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let i=e.indexOf("."),n,o;if(i===-1?(n=e,o=""):(n=e.substring(0,i),o=e.substring(i+1)),this._children.hasOwnProperty(n))return this._children[n].match(o)}const t=this._rulesWithParentScopes.concat(this._mainRule);return t.sort(eP._cmpBySpecificity),t}insert(e,t,i,n,o,r){if(t===""){this._doInsertHere(e,i,n,o,r);return}let a=t.indexOf("."),l,c;a===-1?(l=t,c=""):(l=t.substring(0,a),c=t.substring(a+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new eP(this._mainRule.clone(),JM.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(e+1,c,i,n,o,r)}_doInsertHere(e,t,i,n,o){if(t===null){this._mainRule.acceptOverwrite(e,i,n,o);return}for(let r=0,a=this._rulesWithParentScopes.length;r<a;r++){let l=this._rulesWithParentScopes[r];if(iq(l.parentScopes,t)===0){l.acceptOverwrite(e,i,n,o);return}}i===-1&&(i=this._mainRule.fontStyle),n===0&&(n=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new JM(e,t,i,n,o))}},fm=class Zr{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const t=Zr.getLanguageId(e),i=Zr.getTokenType(e),n=Zr.getFontStyle(e),o=Zr.getForeground(e),r=Zr.getBackground(e);console.log({languageId:t,tokenType:i,fontStyle:n,foreground:o,background:r})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,t,i,n,o,r,a){let l=Zr.getLanguageId(e),c=Zr.getTokenType(e),d=Zr.containsBalancedBrackets(e)?1:0,h=Zr.getFontStyle(e),u=Zr.getForeground(e),g=Zr.getBackground(e);return t!==0&&(l=t),i!==8&&(c=i),n!==null&&(d=n?1:0),o!==-1&&(h=o),r!==0&&(u=r),a!==0&&(g=a),(l<<0|c<<8|d<<10|h<<11|u<<15|g<<24)>>>0}};function KL(s,e){const t=[],i=Xte(s);let n=i.next();for(;n!==null;){let l=0;if(n.length===2&&n.charAt(1)===":"){switch(n.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${n} in scope selector`)}n=i.next()}let c=r();if(t.push({matcher:c,priority:l}),n!==",")break;n=i.next()}return t;function o(){if(n==="-"){n=i.next();const l=o();return c=>!!l&&!l(c)}if(n==="("){n=i.next();const l=a();return n===")"&&(n=i.next()),l}if(Z9(n)){const l=[];do l.push(n),n=i.next();while(Z9(n));return c=>e(l,c)}return null}function r(){const l=[];let c=o();for(;c;)l.push(c),c=o();return d=>l.every(h=>h(d))}function a(){const l=[];let c=r();for(;c&&(l.push(c),n==="|"||n===",");){do n=i.next();while(n==="|"||n===",");c=r()}return d=>l.some(h=>h(d))}}function Z9(s){return!!s&&!!s.match(/[\w\.:]+/)}function Xte(s){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,t=e.exec(s);return{next:()=>{if(!t)return null;const i=t[0];return t=e.exec(s),i}}}function aq(s){typeof s.dispose=="function"&&s.dispose()}var o1=class{constructor(s){this.scopeName=s}toKey(){return this.scopeName}},Qte=class{constructor(s,e){this.scopeName=s,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},Jte=class{constructor(){de(this,"_references",[]);de(this,"_seenReferenceKeys",new Set);de(this,"visitedRule",new Set)}get references(){return this._references}add(s){const e=s.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(s))}},eie=class{constructor(s,e){de(this,"seenFullScopeRequests",new Set);de(this,"seenPartialScopeRequests",new Set);de(this,"Q");this.repo=s,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new o1(this.initialScopeName)]}processQueue(){const s=this.Q;this.Q=[];const e=new Jte;for(const t of s)tie(t,this.initialScopeName,this.repo,e);for(const t of e.references)if(t instanceof o1){if(this.seenFullScopeRequests.has(t.scopeName))continue;this.seenFullScopeRequests.add(t.scopeName),this.Q.push(t)}else{if(this.seenFullScopeRequests.has(t.scopeName)||this.seenPartialScopeRequests.has(t.toKey()))continue;this.seenPartialScopeRequests.add(t.toKey()),this.Q.push(t)}}};function tie(s,e,t,i){const n=t.lookup(s.scopeName);if(!n){if(s.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const o=t.lookup(e);s instanceof o1?nL({baseGrammar:o,selfGrammar:n},i):tP(s.ruleName,{baseGrammar:o,selfGrammar:n,repository:n.repository},i);const r=t.injections(s.scopeName);if(r)for(const a of r)i.add(new o1(a))}function tP(s,e,t){if(e.repository&&e.repository[s]){const i=e.repository[s];GL([i],e,t)}}function nL(s,e){s.selfGrammar.patterns&&Array.isArray(s.selfGrammar.patterns)&&GL(s.selfGrammar.patterns,ne(V({},s),{repository:s.selfGrammar.repository}),e),s.selfGrammar.injections&&GL(Object.values(s.selfGrammar.injections),ne(V({},s),{repository:s.selfGrammar.repository}),e)}function GL(s,e,t){for(const i of s){if(t.visitedRule.has(i))continue;t.visitedRule.add(i);const n=i.repository?J$({},e.repository,i.repository):e.repository;Array.isArray(i.patterns)&&GL(i.patterns,ne(V({},e),{repository:n}),t);const o=i.include;if(!o)continue;const r=lq(o);switch(r.kind){case 0:nL(ne(V({},e),{selfGrammar:e.baseGrammar}),t);break;case 1:nL(e,t);break;case 2:tP(r.ruleName,ne(V({},e),{repository:n}),t);break;case 3:case 4:const a=r.scopeName===e.selfGrammar.scopeName?e.selfGrammar:r.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(a){const l={baseGrammar:e.baseGrammar,selfGrammar:a,repository:n};r.kind===4?tP(r.ruleName,l,t):nL(l,t)}else r.kind===4?t.add(new Qte(r.scopeName,r.ruleName)):t.add(new o1(r.scopeName));break}}}var iie=class{constructor(){de(this,"kind",0)}},nie=class{constructor(){de(this,"kind",1)}},sie=class{constructor(s){de(this,"kind",2);this.ruleName=s}},oie=class{constructor(s){de(this,"kind",3);this.scopeName=s}},rie=class{constructor(s,e){de(this,"kind",4);this.scopeName=s,this.ruleName=e}};function lq(s){if(s==="$base")return new iie;if(s==="$self")return new nie;const e=s.indexOf("#");if(e===-1)return new oie(s);if(e===0)return new sie(s.substring(1));{const t=s.substring(0,e),i=s.substring(e+1);return new rie(t,i)}}var aie=/\\(\d+)/,Y9=/\\(\d+)/g,lie=-1,cq=-2;var jS=class{constructor(e,t,i,n){de(this,"$location");de(this,"id");de(this,"_nameIsCapturing");de(this,"_name");de(this,"_contentNameIsCapturing");de(this,"_contentName");this.$location=e,this.id=t,this._name=i||null,this._nameIsCapturing=W0.hasCaptures(this._name),this._contentName=n||null,this._contentNameIsCapturing=W0.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${eq(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:W0.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:W0.replaceCaptures(this._contentName,e,t)}},cie=class extends jS{constructor(e,t,i,n,o){super(e,t,i,n);de(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,i,n){throw new Error("Not supported!")}},die=class extends jS{constructor(e,t,i,n,o){super(e,t,i,null);de(this,"_match");de(this,"captures");de(this,"_cachedCompiledPatterns");this._match=new r1(n,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,n){return this._getCachedCompiledPatterns(e).compileAG(e,i,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new a1,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},X9=class extends jS{constructor(e,t,i,n,o){super(e,t,i,n);de(this,"hasMissingPatterns");de(this,"patterns");de(this,"_cachedCompiledPatterns");this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const i of this.patterns)e.getRule(i).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,n){return this._getCachedCompiledPatterns(e).compileAG(e,i,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new a1,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},iP=class extends jS{constructor(e,t,i,n,o,r,a,l,c,d){super(e,t,i,n);de(this,"_begin");de(this,"beginCaptures");de(this,"_end");de(this,"endHasBackReferences");de(this,"endCaptures");de(this,"applyEndPatternLast");de(this,"hasMissingPatterns");de(this,"patterns");de(this,"_cachedCompiledPatterns");this._begin=new r1(o,this.id),this.beginCaptures=r,this._end=new r1(a||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=c||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,i,n){return this._getCachedCompiledPatterns(e,t).compileAG(e,i,n)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new a1;for(const i of this.patterns)e.getRule(i).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},ZL=class extends jS{constructor(e,t,i,n,o,r,a,l,c){super(e,t,i,n);de(this,"_begin");de(this,"beginCaptures");de(this,"whileCaptures");de(this,"_while");de(this,"whileHasBackReferences");de(this,"hasMissingPatterns");de(this,"patterns");de(this,"_cachedCompiledPatterns");de(this,"_cachedCompiledWhilePatterns");this._begin=new r1(o,this.id),this.beginCaptures=r,this.whileCaptures=l,this._while=new r1(a,cq),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,n){return this._getCachedCompiledPatterns(e).compileAG(e,i,n)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new a1;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,i,n){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,i,n)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new a1,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},dq=class Hs{static createCaptureRule(e,t,i,n,o){return e.registerRule(r=>new cie(t,r,i,n,o))}static getCompiledRuleId(e,t,i){return e.id||t.registerRule(n=>{if(e.id=n,e.match)return new die(e.$vscodeTextmateLocation,e.id,e.name,e.match,Hs._compileCaptures(e.captures,t,i));if(typeof e.begin=="undefined"){e.repository&&(i=J$({},i,e.repository));let o=e.patterns;return typeof o=="undefined"&&e.include&&(o=[{include:e.include}]),new X9(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,Hs._compilePatterns(o,t,i))}return e.while?new ZL(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Hs._compileCaptures(e.beginCaptures||e.captures,t,i),e.while,Hs._compileCaptures(e.whileCaptures||e.captures,t,i),Hs._compilePatterns(e.patterns,t,i)):new iP(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Hs._compileCaptures(e.beginCaptures||e.captures,t,i),e.end,Hs._compileCaptures(e.endCaptures||e.captures,t,i),e.applyEndPatternLast,Hs._compilePatterns(e.patterns,t,i))}),e.id}static _compileCaptures(e,t,i){let n=[];if(e){let o=0;for(const r in e){if(r==="$vscodeTextmateLocation")continue;const a=parseInt(r,10);a>o&&(o=a)}for(let r=0;r<=o;r++)n[r]=null;for(const r in e){if(r==="$vscodeTextmateLocation")continue;const a=parseInt(r,10);let l=0;e[r].patterns&&(l=Hs.getCompiledRuleId(e[r],t,i)),n[a]=Hs.createCaptureRule(t,e[r].$vscodeTextmateLocation,e[r].name,e[r].contentName,l)}}return n}static _compilePatterns(e,t,i){let n=[];if(e)for(let o=0,r=e.length;o<r;o++){const a=e[o];let l=-1;if(a.include){const c=lq(a.include);switch(c.kind){case 0:case 1:l=Hs.getCompiledRuleId(i[a.include],t,i);break;case 2:let d=i[c.ruleName];d&&(l=Hs.getCompiledRuleId(d,t,i));break;case 3:case 4:const h=c.scopeName,u=c.kind===4?c.ruleName:null,g=t.getExternalGrammar(h,i);if(g)if(u){let f=g.repository[u];f&&(l=Hs.getCompiledRuleId(f,t,g.repository))}else l=Hs.getCompiledRuleId(g.repository.$self,t,g.repository);break}}else l=Hs.getCompiledRuleId(a,t,i);if(l!==-1){const c=t.getRule(l);let d=!1;if((c instanceof X9||c instanceof iP||c instanceof ZL)&&c.hasMissingPatterns&&c.patterns.length===0&&(d=!0),d)continue;n.push(l)}}return{patterns:n,hasMissingPatterns:(e?e.length:0)!==n.length}}},r1=class hq{constructor(e,t){de(this,"source");de(this,"ruleId");de(this,"hasAnchor");de(this,"hasBackReferences");de(this,"_anchorCache");if(e&&typeof e=="string"){const i=e.length;let n=0,o=[],r=!1;for(let a=0;a<i;a++)if(e.charAt(a)==="\\"&&a+1<i){const c=e.charAt(a+1);c==="z"?(o.push(e.substring(n,a)),o.push("$(?!\\n)(?<!\\n)"),n=a+2):(c==="A"||c==="G")&&(r=!0),a++}this.hasAnchor=r,n===0?this.source=e:(o.push(e.substring(n,i)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source=="string"?this.hasBackReferences=aie.test(this.source):this.hasBackReferences=!1}clone(){return new hq(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let i=t.map(n=>e.substring(n.start,n.end));return Y9.lastIndex=0,this.source.replace(Y9,(n,o)=>nq(i[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],t=[],i=[],n=[],o,r,a,l;for(o=0,r=this.source.length;o<r;o++)a=this.source.charAt(o),e[o]=a,t[o]=a,i[o]=a,n[o]=a,a==="\\"&&o+1<r&&(l=this.source.charAt(o+1),l==="A"?(e[o+1]="",t[o+1]="",i[o+1]="A",n[o+1]="A"):l==="G"?(e[o+1]="",t[o+1]="G",i[o+1]="",n[o+1]="G"):(e[o+1]=l,t[o+1]=l,i[o+1]=l,n[o+1]=l),o++);return{A0_G0:e.join(""),A0_G1:t.join(""),A1_G0:i.join(""),A1_G1:n.join("")}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},a1=class{constructor(){de(this,"_items");de(this,"_hasAnchors");de(this,"_cached");de(this,"_anchorCache");this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(s){this._items.push(s),this._hasAnchors=this._hasAnchors||s.hasAnchor}unshift(s){this._items.unshift(s),this._hasAnchors=this._hasAnchors||s.hasAnchor}length(){return this._items.length}setSource(s,e){this._items[s].source!==e&&(this._disposeCaches(),this._items[s].setSource(e))}compile(s){if(!this._cached){let e=this._items.map(t=>t.source);this._cached=new Q9(s,e,this._items.map(t=>t.ruleId))}return this._cached}compileAG(s,e,t){return this._hasAnchors?e?t?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(s,e,t)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(s,e,t)),this._anchorCache.A1_G0):t?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(s,e,t)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(s,e,t)),this._anchorCache.A0_G0):this.compile(s)}_resolveAnchors(s,e,t){let i=this._items.map(n=>n.resolveAnchors(e,t));return new Q9(s,i,this._items.map(n=>n.ruleId))}},Q9=class{constructor(s,e,t){de(this,"scanner");this.regExps=e,this.rules=t,this.scanner=s.createOnigScanner(e)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const s=[];for(let e=0,t=this.rules.length;e<t;e++)s.push(" - "+this.rules[e]+": "+this.regExps[e]);return s.join(`
`)}findNextMatchSync(s,e,t){const i=this.scanner.findNextMatchSync(s,e,t);return i?{ruleId:this.rules[i.index],captureIndices:i.captureIndices}:null}},BT=class{constructor(s,e){this.languageId=s,this.tokenType=e}},ud,hie=(ud=class{constructor(e,t){de(this,"_defaultAttributes");de(this,"_embeddedLanguagesMatcher");de(this,"_getBasicScopeAttributes",new sq(e=>{const t=this._scopeToLanguage(e),i=this._toStandardTokenType(e);return new BT(t,i)}));this._defaultAttributes=new BT(e,8),this._embeddedLanguagesMatcher=new uie(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?ud._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const t=e.match(ud.STANDARD_TOKEN_TYPE_REGEXP);if(!t)return 8;switch(t[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}},de(ud,"_NULL_SCOPE_METADATA",new BT(0,0)),de(ud,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),ud),uie=class{constructor(s){de(this,"values");de(this,"scopesRegExp");if(s.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(s);const e=s.map(([t,i])=>nq(t));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(s){if(!this.scopesRegExp)return;const e=s.match(this.scopesRegExp);if(e)return this.values.get(e[1])}};typeof process!="undefined"&&process.env.VSCODE_TEXTMATE_DEBUG;var J9=class{constructor(s,e){this.stack=s,this.stoppedEarly=e}};function uq(s,e,t,i,n,o,r,a){const l=e.content.length;let c=!1,d=-1;if(r){const g=gie(s,e,t,i,n,o);n=g.stack,i=g.linePos,t=g.isFirstLine,d=g.anchorPosition}const h=Date.now();for(;!c;){if(a!==0&&Date.now()-h>a)return new J9(n,!0);u()}return new J9(n,!1);function u(){const g=fie(s,e,t,i,n,d);if(!g){o.produce(n,l),c=!0;return}const f=g.captureIndices,p=g.matchedRuleId,_=f&&f.length>0?f[0].end>i:!1;if(p===lie){const b=n.getRule(s);o.produce(n,f[0].start),n=n.withContentNameScopesList(n.nameScopesList),Nv(s,e,t,n,o,b.endCaptures,f),o.produce(n,f[0].end);const C=n;if(n=n.parent,d=C.getAnchorPos(),!_&&C.getEnterPos()===i){n=C,o.produce(n,l),c=!0;return}}else{const b=s.getRule(p);o.produce(n,f[0].start);const C=n,v=b.getName(e.content,f),w=n.contentNameScopesList.pushAttributed(v,s);if(n=n.push(p,i,d,f[0].end===l,null,w,w),b instanceof iP){const S=b;Nv(s,e,t,n,o,S.beginCaptures,f),o.produce(n,f[0].end),d=f[0].end;const y=S.getContentName(e.content,f),x=w.pushAttributed(y,s);if(n=n.withContentNameScopesList(x),S.endHasBackReferences&&(n=n.withEndRule(S.getEndWithResolvedBackReferences(e.content,f))),!_&&C.hasSameRuleAs(n)){n=n.pop(),o.produce(n,l),c=!0;return}}else if(b instanceof ZL){const S=b;Nv(s,e,t,n,o,S.beginCaptures,f),o.produce(n,f[0].end),d=f[0].end;const y=S.getContentName(e.content,f),x=w.pushAttributed(y,s);if(n=n.withContentNameScopesList(x),S.whileHasBackReferences&&(n=n.withEndRule(S.getWhileWithResolvedBackReferences(e.content,f))),!_&&C.hasSameRuleAs(n)){n=n.pop(),o.produce(n,l),c=!0;return}}else if(Nv(s,e,t,n,o,b.captures,f),o.produce(n,f[0].end),n=n.pop(),!_){n=n.safePop(),o.produce(n,l),c=!0;return}}f[0].end>i&&(i=f[0].end,t=!1)}}function gie(s,e,t,i,n,o){let r=n.beginRuleCapturedEOL?0:-1;const a=[];for(let l=n;l;l=l.pop()){const c=l.getRule(s);c instanceof ZL&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){const{ruleScanner:c,findOptions:d}=_ie(l.rule,s,l.stack.endRule,t,i===r),h=c.findNextMatchSync(e,i,d);if(h){if(h.ruleId!==cq){n=l.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(o.produce(l.stack,h.captureIndices[0].start),Nv(s,e,t,l.stack,o,l.rule.whileCaptures,h.captureIndices),o.produce(l.stack,h.captureIndices[0].end),r=h.captureIndices[0].end,h.captureIndices[0].end>i&&(i=h.captureIndices[0].end,t=!1))}else{n=l.stack.pop();break}}return{stack:n,linePos:i,anchorPosition:r,isFirstLine:t}}function fie(s,e,t,i,n,o){const r=mie(s,e,t,i,n,o),a=s.getInjections();if(a.length===0)return r;const l=pie(a,s,e,t,i,n,o);if(!l)return r;if(!r)return l;const c=r.captureIndices[0].start,d=l.captureIndices[0].start;return d<c||l.priorityMatch&&d===c?l:r}function mie(s,e,t,i,n,o){const r=n.getRule(s),{ruleScanner:a,findOptions:l}=gq(r,s,n.endRule,t,i===o),c=a.findNextMatchSync(e,i,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function pie(s,e,t,i,n,o,r){let a=Number.MAX_VALUE,l=null,c,d=0;const h=o.contentNameScopesList.getScopeNames();for(let u=0,g=s.length;u<g;u++){const f=s[u];if(!f.matcher(h))continue;const p=e.getRule(f.ruleId),{ruleScanner:_,findOptions:b}=gq(p,e,null,i,n===r),C=_.findNextMatchSync(t,n,b);if(!C)continue;const v=C.captureIndices[0].start;if(!(v>=a)&&(a=v,l=C.captureIndices,c=C.ruleId,d=f.priority,a===n))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:c}:null}function gq(s,e,t,i,n){return{ruleScanner:s.compileAG(e,t,i,n),findOptions:0}}function _ie(s,e,t,i,n){return{ruleScanner:s.compileWhileAG(e,t,i,n),findOptions:0}}function Nv(s,e,t,i,n,o,r){if(o.length===0)return;const a=e.content,l=Math.min(o.length,r.length),c=[],d=r[0].end;for(let h=0;h<l;h++){const u=o[h];if(u===null)continue;const g=r[h];if(g.length===0)continue;if(g.start>d)break;for(;c.length>0&&c[c.length-1].endPos<=g.start;)n.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?n.produceFromScopes(c[c.length-1].scopes,g.start):n.produce(i,g.start),u.retokenizeCapturedWithRuleId){const p=u.getName(a,r),_=i.contentNameScopesList.pushAttributed(p,s),b=u.getContentName(a,r),C=_.pushAttributed(b,s),v=i.push(u.retokenizeCapturedWithRuleId,g.start,-1,!1,null,_,C),w=s.createOnigString(a.substring(0,g.end));uq(s,w,t&&g.start===0,g.start,v,n,!1,0),aq(w);continue}const f=u.getName(a,r);if(f!==null){const _=(c.length>0?c[c.length-1].scopes:i.contentNameScopesList).pushAttributed(f,s);c.push(new bie(_,g.end))}}for(;c.length>0;)n.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var bie=class{constructor(s,e){de(this,"scopes");de(this,"endPos");this.scopes=s,this.endPos=e}};function Cie(s,e,t,i,n,o,r,a){return new wie(s,e,t,i,n,o,r,a)}function e8(s,e,t,i,n){const o=KL(e,YL),r=dq.getCompiledRuleId(t,i,n.repository);for(const a of o)s.push({debugSelector:e,matcher:a.matcher,ruleId:r,grammar:n,priority:a.priority})}function YL(s,e){if(e.length<s.length)return!1;let t=0;return s.every(i=>{for(let n=t;n<e.length;n++)if(vie(e[n],i))return t=n+1,!0;return!1})}function vie(s,e){if(!s)return!1;if(s===e)return!0;const t=e.length;return s.length>t&&s.substr(0,t)===e&&s[t]==="."}var wie=class{constructor(s,e,t,i,n,o,r,a){de(this,"_rootId");de(this,"_lastRuleId");de(this,"_ruleId2desc");de(this,"_includedGrammars");de(this,"_grammarRepository");de(this,"_grammar");de(this,"_injections");de(this,"_basicScopeAttributesProvider");de(this,"_tokenTypeMatchers");if(this._rootScopeName=s,this.balancedBracketSelectors=o,this._onigLib=a,this._basicScopeAttributesProvider=new hie(t,i),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=r,this._grammar=t8(e,null),this._injections=null,this._tokenTypeMatchers=[],n)for(const l of Object.keys(n)){const c=KL(l,YL);for(const d of c)this._tokenTypeMatchers.push({matcher:d.matcher,type:n[l]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const s of this._ruleId2desc)s&&s.dispose()}createOnigScanner(s){return this._onigLib.createOnigScanner(s)}createOnigString(s){return this._onigLib.createOnigString(s)}getMetadataForScope(s){return this._basicScopeAttributesProvider.getBasicScopeAttributes(s)}_collectInjections(){const s={lookup:n=>n===this._rootScopeName?this._grammar:this.getExternalGrammar(n),injections:n=>this._grammarRepository.injections(n)},e=[],t=this._rootScopeName,i=s.lookup(t);if(i){const n=i.injections;if(n)for(let r in n)e8(e,r,n[r],this,i);const o=this._grammarRepository.injections(t);o&&o.forEach(r=>{const a=this.getExternalGrammar(r);if(a){const l=a.injectionSelector;l&&e8(e,l,a,this,a)}})}return e.sort((n,o)=>n.priority-o.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(s){const e=++this._lastRuleId,t=s(e);return this._ruleId2desc[e]=t,t}getRule(s){return this._ruleId2desc[s]}getExternalGrammar(s,e){if(this._includedGrammars[s])return this._includedGrammars[s];if(this._grammarRepository){const t=this._grammarRepository.lookup(s);if(t)return this._includedGrammars[s]=t8(t,e&&e.$base),this._includedGrammars[s]}}tokenizeLine(s,e,t=0){const i=this._tokenize(s,e,!1,t);return{tokens:i.lineTokens.getResult(i.ruleStack,i.lineLeng