@openchamber/web 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +55 -2
- package/dist/assets/{ToolOutputDialog-68nQ6kiw.js → ToolOutputDialog-CBMeCbbW.js} +2 -2
- package/dist/assets/{index-DbT28rmj.js → index-CbGhBA-v.js} +2 -2
- package/dist/assets/index-Cx6NUrC-.css +1 -0
- package/dist/assets/main-BJvFwyGz.js +122 -0
- package/dist/assets/vendor--Jn2c0Clh.css +1 -0
- package/dist/assets/{vendor-.bun-BhxSBVb2.js → vendor-.bun-CpaXrlrC.js} +630 -561
- package/dist/assets/{worker-Doc90iwx.js → worker-NULm4lOi.js} +18 -18
- package/dist/index.html +4 -4
- package/package.json +4 -4
- package/server/index.js +41 -21
- package/dist/assets/index-BK6z1XIy.css +0 -1
- package/dist/assets/main-DPWbnEr6.js +0 -122
- package/dist/assets/vendor--swUGvSZA.css +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
function ye(t){if([...t].length!==1)throw new Error(`Expected "${t}" to be a single code point`);return t.codePointAt(0)}function ws(t,e,n){return t.has(e)||t.set(e,n),t.get(e)}const Qt=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),P=String.raw;function be(t,e){if(t==null)throw new Error(e??"Value expected");return t}const hr=P`\[\^?`,fr=`c.? | C(?:-.?)?|${P`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${P`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${P`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${P`o\{[^\}]*\}?`}|${P`\d{1,3}`}`,Yt=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,De=new RegExp(P`
|
|
2
2
|
\\ (?:
|
|
3
|
-
${
|
|
3
|
+
${fr}
|
|
4
4
|
| [gk]<[^>]*>?
|
|
5
5
|
| [gk]'[^']*'?
|
|
6
6
|
| .
|
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
)?
|
|
18
18
|
| \*[^\)]*\)?
|
|
19
19
|
)?
|
|
20
|
-
| (?:${
|
|
21
|
-
| ${
|
|
20
|
+
| (?:${Yt.source})+
|
|
21
|
+
| ${hr}
|
|
22
22
|
| .
|
|
23
|
-
`.replace(/\s+/g,""),"gsu"),pt=new RegExp(
|
|
23
|
+
`.replace(/\s+/g,""),"gsu"),pt=new RegExp(P`
|
|
24
24
|
\\ (?:
|
|
25
|
-
${
|
|
25
|
+
${fr}
|
|
26
26
|
| .
|
|
27
27
|
)
|
|
28
28
|
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
29
|
-
| ${
|
|
29
|
+
| ${hr}
|
|
30
30
|
| &&
|
|
31
31
|
| .
|
|
32
|
-
`.replace(/\s+/g,""),"gsu");function Cs(t,e={}){const n={flags:"",...e,rules:{captureGroup:!1,singleline:!1,...e.rules}};if(typeof t!="string")throw new Error("String expected as pattern");const r=Bs(n.flags),s=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop()},pushModX(h){s.push(h)},replaceCurrentModX(h){s[s.length-1]=h},singleline:n.rules.singleline};let a=[],i;for(
|
|
33
|
-
`,r);return{lastIndex:a===-1?e.length:a}}if(/^\s$/.test(n)){const a=/\s+/y;return a.lastIndex=r,{lastIndex:a.exec(e)?a.lastIndex:r}}}if(n===".")return{token:ee("dot",n)};if(n==="^"||n==="$"){const a=t.singleline?{"^":$`\A`,$:$`\Z`}[n]:n;return{token:mn(a,n)}}return n==="|"?{token:vs(n)}:dt.test(n)?{tokens:Us(n)}:{token:q(ie(n),n)}}function Ss(t,e,n){const r=[bn(e[1]==="^",e)];let s=1,o;for(pt.lastIndex=n;o=pt.exec(t);){const a=o[0];if(a[0]==="["&&a[1]!==":")s++,r.push(bn(a[1]==="^",a));else if(a==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(q(93,a));else if(s--,r.push(xs(a)),!s)break}else{const i=ks(a);Array.isArray(i)?r.push(...i):r.push(i)}}return{tokens:r,lastIndex:pt.lastIndex||t.length}}function ks(t){if(t[0]==="\\")return gn(t,{inCharClass:!0});if(t[0]==="["){const e=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(t);if(!e||!ft.has(e.groups.name))throw new Error(`Invalid POSIX class "${t}"`);return ee("posix",t,{value:e.groups.name,negate:!!e.groups.negate})}return t==="-"?Es(t):t==="&&"?As(t):q(ie(t),t)}function gn(t,{inCharClass:e}){const n=t[1];if(n==="c"||n==="C")return Ts(t);if("dDhHsSwW".includes(n))return Gs(t);if(t.startsWith($`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${t}"`);if(/^\\[pP]\{/.test(t)){if(t.length===3)throw new Error(`Incomplete or invalid Unicode property "${t}"`);return Ds(t)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(t))try{const r=t.split(/\\x/).slice(1).map(a=>parseInt(a,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...s].map(a=>{const i=[...o.encode(a)].map(l=>`\\x${l.toString(16)}`).join("");return q(ie(a),i)})}catch{throw new Error(`Multibyte code "${t}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return q(Fs(t),t);if(Cn.has(n))return q(Cn.get(n),t);if(/\d/.test(n))return Is(e,t);if(t==="\\")throw new Error($`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${t}"`);if([...t].length===2)return q(t.codePointAt(1),t);throw new Error(`Unexpected escape "${t}"`)}function vs(t){return{type:"Alternator",raw:t}}function mn(t,e){return{type:"Assertion",kind:t,raw:e}}function yn(t){return{type:"Backreference",raw:t}}function q(t,e){return{type:"Character",value:t,raw:e}}function xs(t){return{type:"CharacterClassClose",raw:t}}function Es(t){return{type:"CharacterClassHyphen",raw:t}}function As(t){return{type:"CharacterClassIntersector",raw:t}}function bn(t,e){return{type:"CharacterClassOpen",negate:t,raw:e}}function ee(t,e,n={}){return{type:"CharacterSet",kind:t,...n,raw:e}}function wn(t,e,n={}){return t==="keep"?{type:"Directive",kind:t,raw:e}:{type:"Directive",kind:t,flags:le(n.flags),raw:e}}function Is(t,e){return{type:"EscapedNumber",inCharClass:t,raw:e}}function Rs(t){return{type:"GroupClose",raw:t}}function ce(t,e,n={}){return{type:"GroupOpen",kind:t,...n,raw:e}}function Ns(t,e,n,r){return{type:"NamedCallout",kind:t,tag:e,arguments:n,raw:r}}function $s(t,e,n,r){return{type:"Quantifier",kind:t,min:e,max:n,raw:r}}function Ps(t){return{type:"Subroutine",raw:t}}const Ls=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Cn=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Ts(t){const e=t[1]==="c"?t[2]:t[3];if(!e||!/[A-Za-z]/.test(e))throw new Error(`Unsupported control character "${t}"`);return q(ie(e.toUpperCase())-64,t)}function Ms(t,e){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(t).groups;r??="";const s=(e.getCurrentModX()||n.includes("x"))&&!r.includes("x"),o=Sn(n),a=Sn(r),i={};if(o&&(i.enable=o),a&&(i.disable=a),t.endsWith(")"))return e.replaceCurrentModX(s),wn("flags",t,{flags:i});if(t.endsWith(":"))return e.pushModX(s),e.numOpenGroups++,ce("group",t,{...(o||a)&&{flags:i}});throw new Error(`Unexpected flag modifier "${t}"`)}function Os(t){const e=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(t);if(!e)throw new Error(`Incomplete or invalid named callout "${t}"`);const{name:n,tag:r,args:s}=e.groups;if(!n)throw new Error(`Invalid named callout "${t}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${t}"`);const o=s?s.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[a,i,l]=o,c=Ls.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof a=="string")throw new Error(`Named callout argument must be a number "${a}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(o.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return Ns(c,r??null,s?.split(",")??null,t)}function _n(t){let e=null,n,r;if(t[0]==="{"){const{minStr:s,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(t).groups,a=1e5;if(+s>a||o&&+o>a)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+s,r=o===void 0?+s:o===""?1/0:+o,n>r&&(e="possessive",[n,r]=[r,n]),t.endsWith("?")){if(e==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');e="lazy"}else e||(e="greedy")}else n=t[0]==="+"?1:0,r=t[0]==="?"?1:1/0,e=t[1]==="+"?"possessive":t[1]==="?"?"lazy":"greedy";return $s(e,n,r,t)}function Gs(t){const e=t[1].toLowerCase();return ee({d:"digit",h:"hex",s:"space",w:"word"}[e],t,{negate:t[1]!==e})}function Ds(t){const{p:e,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(t).groups;return ee("property",t,{value:r,negate:e==="P"&&!n||e==="p"&&!!n})}function Sn(t){const e={};return t.includes("i")&&(e.ignoreCase=!0),t.includes("m")&&(e.dotAll=!0),t.includes("x")&&(e.extended=!0),Object.keys(e).length?e:null}function Bs(t){const e={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<t.length;n++){const r=t[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(t.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');e.textSegmentMode=t[n+2]==="g"?"grapheme":"word",n+=3;continue}e[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return e}function Fs(t){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(t))throw new Error(`Incomplete or invalid escape "${t}"`);const e=t[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(t).groups.hex:t.slice(2);return parseInt(e,16)}function js(t,e){const{raw:n,inCharClass:r}=t,s=n.slice(1);if(!r&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=e))return[yn(n)];const o=[],a=s.match(/^[0-7]+|\d/g);for(let i=0;i<a.length;i++){const l=a[i];let c;if(i===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error($`Octal encoded byte above 177 unsupported "${n}"`)}else c=ie(l);o.push(q(c,(i===0?"\\":"")+l))}return o}function Us(t){const e=[],n=new RegExp(dt,"gy");let r;for(;r=n.exec(t);){const s=r[0];if(s[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(o){const{min:a,max:i}=o.groups;if(+a>+i&&s.endsWith("?")){n.lastIndex--,e.push(_n(s.slice(0,-1)));continue}}}e.push(_n(s))}return e}function kn(t,e){if(!Array.isArray(t.body))throw new Error("Expected node with body array");if(t.body.length!==1)return!1;const n=t.body[0];return!e||Object.keys(e).every(r=>e[r]===n[r])}function zs(t){return Ws.has(t.type)}const Ws=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function vn(t,e={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e,rules:{captureGroup:!1,singleline:!1,...e.rules}},r=Cs(t,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(f,d)=>{const p=r.tokens[o.nextIndex];switch(o.parent=f,o.nextIndex++,p.type){case"Alternator":return te();case"Assertion":return qs(p);case"Backreference":return Hs(p,o);case"Character":return De(p.value,{useLastValid:!!d.isCheckingRangeEnd});case"CharacterClassHyphen":return Vs(p,o,d);case"CharacterClassOpen":return Xs(p,o,d);case"CharacterSet":return Ks(p,o);case"Directive":return to(p.kind,{flags:p.flags});case"GroupOpen":return Zs(p,o,d);case"NamedCallout":return ro(p.kind,p.tag,p.arguments);case"Quantifier":return Qs(p,o);case"Subroutine":return Ys(p,o);default:throw new Error(`Unexpected token type "${p.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},a=oo(no(r.flags));let i=a.body[0];for(;o.nextIndex<r.tokens.length;){const f=s(i,{});f.type==="Alternative"?(a.body.push(f),i=f):i.body.push(f)}const{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:h}=o;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:f}of h)if(typeof f=="number"){if(f>l.length)throw new Error("Subroutine uses a group number that's not defined");f&&(l[f-1].isSubroutined=!0)}else if(u.has(f)){if(u.get(f).length>1)throw new Error($`Subroutine uses a duplicate group name "\g<${f}>"`);u.get(f)[0].isSubroutined=!0}else throw new Error($`Subroutine uses a group name that's not defined "\g<${f}>"`);return a}function qs({kind:t}){return gt(le({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[t],`Unexpected assertion kind "${t}"`),{negate:t===$`\B`||t===$`\Y`})}function Hs({raw:t},e){const n=/^\\k[<']/.test(t),r=n?t.slice(3,-1):t.slice(1),s=(o,a=!1)=>{const i=e.capturingGroups.length;let l=!1;if(o>i)if(e.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,mt(a?i+1-o:o,{orphan:l})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${t}"`);return mt(r)}return s(+r)}function Vs(t,e,n){const{tokens:r,walk:s}=e,o=e.parent,a=o.body.at(-1),i=r[e.nextIndex];if(!n.isCheckingRangeEnd&&a&&a.type!=="CharacterClass"&&a.type!=="CharacterClassRange"&&i&&i.type!=="CharacterClassOpen"&&i.type!=="CharacterClassClose"&&i.type!=="CharacterClassIntersector"){const l=s(o,{...n,isCheckingRangeEnd:!0});if(a.type==="Character"&&l.type==="Character")return o.body.pop(),eo(a,l);throw new Error("Invalid character class range")}return De(ie("-"))}function Xs({negate:t},e,n){const{tokens:r,walk:s}=e,o=r[e.nextIndex],a=[Be()];let i=$n(o);for(;i.type!=="CharacterClassClose";){if(i.type==="CharacterClassIntersector")a.push(Be()),e.nextIndex++;else{const c=a.at(-1);c.body.push(s(c,n))}i=$n(r[e.nextIndex],o)}const l=Be({negate:t});return a.length===1?l.body=a[0].body:(l.kind="intersection",l.body=a.map(c=>c.body.length===1?c.body[0]:c)),e.nextIndex++,l}function Ks({kind:t,negate:e,value:n},r){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a}=r;if(t==="property"){const i=Fe(n);if(ft.has(i)&&!a?.has(i))t="posix",n=i;else return ue(n,{negate:e,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a})}return t==="posix"?so(n,{negate:e}):yt(t,{negate:e})}function Zs(t,e,n){const{tokens:r,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:a,walk:i}=e,l=ao(t),c=l.type==="AbsenceFunction",u=Nn(l),h=u&&l.negate;if(l.type==="CapturingGroup"&&(s.push(l),l.name&&ws(o,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=Pn(r[e.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")l.body.push(te()),e.nextIndex++;else{const d=l.body.at(-1),p=i(d,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||h});if(d.body.push(p),(u||n.isInLookbehind)&&!a){const w="Lookbehind includes a pattern not allowed by Oniguruma";if(h||n.isInNegLookbehind){if(Rn(p)||p.type==="CapturingGroup")throw new Error(w)}else if(Rn(p)||Nn(p)&&p.negate)throw new Error(w)}}f=Pn(r[e.nextIndex])}return e.nextIndex++,l}function Qs({kind:t,min:e,max:n},r){const s=r.parent,o=s.body.at(-1);if(!o||!zs(o))throw new Error("Quantifier requires a repeatable token");const a=En(t,e,n,o);return s.body.pop(),a}function Ys({raw:t},e){const{capturingGroups:n,subroutines:r}=e;let s=t.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const i=+o.groups.num,l=n.length;if(e.hasNumberedRef=!0,s={"":i,"+":l+i,"-":l+1-i}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const a=An(s);return r.push(a),a}function Js(t,e){return{type:"AbsenceFunction",kind:t,body:_e(e?.body)}}function te(t){return{type:"Alternative",body:In(t?.body)}}function gt(t,e){const n={type:"Assertion",kind:t};return(t==="word_boundary"||t==="text_segment_boundary")&&(n.negate=!!e?.negate),n}function mt(t,e){const n=!!e?.orphan;return{type:"Backreference",ref:t,...n&&{orphan:n}}}function xn(t,e){const n={name:void 0,isSubroutined:!1,...e};if(n.name!==void 0&&!io(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:t,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:_e(e?.body)}}function De(t,e){const n={useLastValid:!1,...e};if(t>1114111){const r=t.toString(16);if(n.useLastValid)t=1114111;else throw t>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:t}}function Be(t){const e={kind:"union",negate:!1,...t};return{type:"CharacterClass",kind:e.kind,negate:e.negate,body:In(t?.body)}}function eo(t,e){if(e.value<t.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:t,max:e}}function yt(t,e){const n=!!e?.negate,r={type:"CharacterSet",kind:t};return(t==="digit"||t==="hex"||t==="newline"||t==="space"||t==="word")&&(r.negate=n),(t==="text_segment"||t==="newline"&&!n)&&(r.variableLength=!0),r}function to(t,e={}){if(t==="keep")return{type:"Directive",kind:t};if(t==="flags")return{type:"Directive",kind:t,flags:le(e.flags)};throw new Error(`Unexpected directive kind "${t}"`)}function no(t){return{type:"Flags",...t}}function z(t){const e=t?.atomic,n=t?.flags;if(e&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...e&&{atomic:e},...n&&{flags:n},body:_e(t?.body)}}function ne(t){const e={behind:!1,negate:!1,...t};return{type:"LookaroundAssertion",kind:e.behind?"lookbehind":"lookahead",negate:e.negate,body:_e(t?.body)}}function ro(t,e,n){return{type:"NamedCallout",kind:t,tag:e,arguments:n}}function so(t,e){const n=!!e?.negate;if(!ft.has(t))throw new Error(`Invalid POSIX class "${t}"`);return{type:"CharacterSet",kind:"posix",value:t,negate:n}}function En(t,e,n,r){if(e>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:t,min:e,max:n,body:r}}function oo(t,e){return{type:"Regex",body:_e(e?.body),flags:t}}function An(t){return{type:"Subroutine",ref:t}}function ue(t,e){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e};let r=n.unicodePropertyMap?.get(Fe(t));if(!r){if(n.normalizeUnknownPropertyNames)r=lo(t);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error($`Invalid Unicode property "\p{${t}}"`)}return{type:"CharacterSet",kind:"property",value:r??t,negate:n.negate}}function ao({flags:t,kind:e,name:n,negate:r,number:s}){switch(e){case"absence_repeater":return Js("repeater");case"atomic":return z({atomic:!0});case"capturing":return xn(s,{name:n});case"group":return z({flags:t});case"lookahead":case"lookbehind":return ne({behind:e==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${e}"`)}}function _e(t){if(t===void 0)t=[te()];else if(!Array.isArray(t)||!t.length||!t.every(e=>e.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return t}function In(t){if(t===void 0)t=[];else if(!Array.isArray(t)||!t.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return t}function Rn(t){return t.type==="LookaroundAssertion"&&t.kind==="lookahead"}function Nn(t){return t.type==="LookaroundAssertion"&&t.kind==="lookbehind"}function io(t){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(t)}function lo(t){return t.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function Fe(t){return t.replace(/[- _]+/g,"").toLowerCase()}function $n(t,e){return le(t,`${e?.type==="Character"&&e.value===93?"Empty":"Unclosed"} character class`)}function Pn(t){return le(t,"Unclosed group")}function Se(t,e,n=null){function r(o,a){for(let i=0;i<o.length;i++){const l=s(o[i],a,i,o);i=Math.max(-1,i+l)}}function s(o,a=null,i=null,l=null){let c=0,u=!1;const h={node:o,parent:a,key:i,container:l,root:t,remove(){je(l).splice(Math.max(0,he(i)+c),1),c--,u=!0},removeAllNextSiblings(){return je(l).splice(he(i)+1)},removeAllPrevSiblings(){const g=he(i)+c;return c-=g,je(l).splice(0,Math.max(0,g))},replaceWith(g,y={}){const m=!!y.traverse;l?l[Math.max(0,he(i)+c)]=g:le(a,"Can't replace root node")[i]=g,m&&s(g,a,i,l),u=!0},replaceWithMultiple(g,y={}){const m=!!y.traverse;if(je(l).splice(Math.max(0,he(i)+c),1,...g),c+=g.length-1,m){let _=0;for(let S=0;S<g.length;S++)_+=s(g[S],a,he(i)+S+_,l)}u=!0},skip(){u=!0}},{type:f}=o,d=e["*"],p=e[f],w=typeof d=="function"?d:d?.enter,C=typeof p=="function"?p:p?.enter;if(w?.(h,n),C?.(h,n),!u)switch(f){case"AbsenceFunction":case"CapturingGroup":case"Group":r(o.body,o);break;case"Alternative":case"CharacterClass":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":s(o.min,o,"min"),s(o.max,o,"max");break;case"LookaroundAssertion":r(o.body,o);break;case"Quantifier":s(o.body,o,"body");break;case"Regex":r(o.body,o),s(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${f}"`)}return p?.exit?.(h,n),d?.exit?.(h,n),c}return s(t),t}function je(t){if(!Array.isArray(t))throw new Error("Container expected");return t}function he(t){if(typeof t!="number")throw new Error("Numeric key expected");return t}const co=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function uo(t,e){for(let n=0;n<t.length;n++)t[n]>=e&&t[n]++}function ho(t,e,n,r){return t.slice(0,e)+r+t.slice(e+n.length)}const B=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function bt(t,e,n,r){const s=new RegExp(String.raw`${e}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let a=0,i="";for(const l of t.matchAll(s)){const{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===B.DEFAULT==!a)){n instanceof Function?i+=n(l,{context:a?B.CHAR_CLASS:B.DEFAULT,negated:o[o.length-1]}):i+=n;continue}c[0]==="["?(a++,o.push(c[1]==="^")):c==="]"&&a&&(a--,o.pop()),i+=c}return i}function Ln(t,e,n,r){bt(t,e,n,r)}function fo(t,e,n=0,r){if(!new RegExp(e,"su").test(t))return null;const s=new RegExp(`${e}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let o=0,a;for(;a=s.exec(t);){const{0:i,groups:{$skip:l}}=a;if(!l&&(!r||r===B.DEFAULT==!o))return a;i==="["?o++:i==="]"&&o&&o--,s.lastIndex==a.index&&s.lastIndex++}return null}function Ue(t,e,n){return!!fo(t,e,0,n)}function po(t,e){const n=/\\?./gsu;n.lastIndex=e;let r=t.length,s=0,o=1,a;for(;a=n.exec(t);){const[i]=a;if(i==="[")s++;else if(s)i==="]"&&s--;else if(i==="(")o++;else if(i===")"&&(o--,!o)){r=a.index;break}}return t.slice(e,r)}const Tn=new RegExp(String.raw`(?<noncapturingStart>${co})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function go(t,e){const n=e?.hiddenCaptures??[];let r=e?.captureTransfers??new Map;if(!/\(\?>/.test(t))return{pattern:t,captureTransfers:r,hiddenCaptures:n};const s="(?>",o="(?:(?=(",a=[0],i=[];let l=0,c=0,u=NaN,h;do{h=!1;let f=0,d=0,p=!1,w;for(Tn.lastIndex=Number.isNaN(u)?0:u+o.length;w=Tn.exec(t);){const{0:C,index:g,groups:{capturingStart:y,noncapturingStart:m}}=w;if(C==="[")f++;else if(f)C==="]"&&f--;else if(C===s&&!p)u=g,p=!0;else if(p&&m)d++;else if(y)p?d++:(l++,a.push(l+c));else if(C===")"&&p){if(!d){c++;const _=l+c;if(t=`${t.slice(0,u)}${o}${t.slice(u+s.length,g)}))<$$${_}>)${t.slice(g+1)}`,h=!0,i.push(_),uo(n,_),r.size){const S=new Map;r.forEach((E,L)=>{S.set(L>=_?L+1:L,E.map(j=>j>=_?j+1:j))}),r=S}break}d--}}}while(h);return n.push(...i),t=bt(t,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:d,wrappedBackrefNum:p}})=>{if(d){const w=+d;if(w>a.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${a[w]}`}return`\\${p}`},B.DEFAULT),{pattern:t,captureTransfers:r,hiddenCaptures:n}}const Mn=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,wt=new RegExp(String.raw`
|
|
32
|
+
`.replace(/\s+/g,""),"gsu");function Cs(t,e={}){const n={flags:"",...e,rules:{captureGroup:!1,singleline:!1,...e.rules}};if(typeof t!="string")throw new Error("String expected as pattern");const r=Bs(n.flags),s=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop()},pushModX(h){s.push(h)},replaceCurrentModX(h){s[s.length-1]=h},singleline:n.rules.singleline};let a=[],i;for(De.lastIndex=0;i=De.exec(t);){const h=_s(o,t,i[0],De.lastIndex);h.tokens?a.push(...h.tokens):h.token&&a.push(h.token),h.lastIndex!==void 0&&(De.lastIndex=h.lastIndex)}const l=[];let c=0;a.filter(h=>h.type==="GroupOpen").forEach(h=>{h.kind==="capturing"?h.number=++c:h.raw==="("&&l.push(h)}),c||l.forEach((h,f)=>{h.kind="capturing",h.number=f+1});const u=c||l.length;return{tokens:a.map(h=>h.type==="EscapedNumber"?js(h,u):h).flat(),flags:r}}function _s(t,e,n,r){const[s,o]=n;if(n==="["||n==="[^"){const a=Ss(e,n,r);return{tokens:a.tokens,lastIndex:a.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(o))return{token:pn(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Ps(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:pr(n)}}if(o==="K")return{token:gr("keep",n)};if(o==="N"||o==="R")return{token:re("newline",n,{negate:o==="N"})};if(o==="O")return{token:re("any",n)};if(o==="X")return{token:re("text_segment",n)};const a=dr(n,{inCharClass:!1});return Array.isArray(a)?{tokens:a}:{token:a}}if(s==="("){if(o==="*")return{token:Os(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(e[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:Ms(n,t)};if(t.pushModX(t.getCurrentModX()),t.numOpenGroups++,n==="("&&!t.captureGroup||n==="(?:")return{token:ue("group",n)};if(n==="(?>")return{token:ue("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:ue(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&t.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:ue("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:ue("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(t.popModX(),t.numOpenGroups--,t.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Rs(n)}}if(t.getCurrentModX()){if(n==="#"){const a=e.indexOf(`
|
|
33
|
+
`,r);return{lastIndex:a===-1?e.length:a}}if(/^\s$/.test(n)){const a=/\s+/y;return a.lastIndex=r,{lastIndex:a.exec(e)?a.lastIndex:r}}}if(n===".")return{token:re("dot",n)};if(n==="^"||n==="$"){const a=t.singleline?{"^":P`\A`,$:P`\Z`}[n]:n;return{token:pn(a,n)}}return n==="|"?{token:vs(n)}:Yt.test(n)?{tokens:Us(n)}:{token:X(ye(n),n)}}function Ss(t,e,n){const r=[gn(e[1]==="^",e)];let s=1,o;for(pt.lastIndex=n;o=pt.exec(t);){const a=o[0];if(a[0]==="["&&a[1]!==":")s++,r.push(gn(a[1]==="^",a));else if(a==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(X(93,a));else if(s--,r.push(xs(a)),!s)break}else{const i=ks(a);Array.isArray(i)?r.push(...i):r.push(i)}}return{tokens:r,lastIndex:pt.lastIndex||t.length}}function ks(t){if(t[0]==="\\")return dr(t,{inCharClass:!0});if(t[0]==="["){const e=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(t);if(!e||!Qt.has(e.groups.name))throw new Error(`Invalid POSIX class "${t}"`);return re("posix",t,{value:e.groups.name,negate:!!e.groups.negate})}return t==="-"?Es(t):t==="&&"?As(t):X(ye(t),t)}function dr(t,{inCharClass:e}){const n=t[1];if(n==="c"||n==="C")return Ts(t);if("dDhHsSwW".includes(n))return Gs(t);if(t.startsWith(P`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${t}"`);if(/^\\[pP]\{/.test(t)){if(t.length===3)throw new Error(`Incomplete or invalid Unicode property "${t}"`);return Ds(t)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(t))try{const r=t.split(/\\x/).slice(1).map(a=>parseInt(a,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...s].map(a=>{const i=[...o.encode(a)].map(l=>`\\x${l.toString(16)}`).join("");return X(ye(a),i)})}catch{throw new Error(`Multibyte code "${t}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return X(Fs(t),t);if(mn.has(n))return X(mn.get(n),t);if(/\d/.test(n))return Is(e,t);if(t==="\\")throw new Error(P`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${t}"`);if([...t].length===2)return X(t.codePointAt(1),t);throw new Error(`Unexpected escape "${t}"`)}function vs(t){return{type:"Alternator",raw:t}}function pn(t,e){return{type:"Assertion",kind:t,raw:e}}function pr(t){return{type:"Backreference",raw:t}}function X(t,e){return{type:"Character",value:t,raw:e}}function xs(t){return{type:"CharacterClassClose",raw:t}}function Es(t){return{type:"CharacterClassHyphen",raw:t}}function As(t){return{type:"CharacterClassIntersector",raw:t}}function gn(t,e){return{type:"CharacterClassOpen",negate:t,raw:e}}function re(t,e,n={}){return{type:"CharacterSet",kind:t,...n,raw:e}}function gr(t,e,n={}){return t==="keep"?{type:"Directive",kind:t,raw:e}:{type:"Directive",kind:t,flags:be(n.flags),raw:e}}function Is(t,e){return{type:"EscapedNumber",inCharClass:t,raw:e}}function Rs(t){return{type:"GroupClose",raw:t}}function ue(t,e,n={}){return{type:"GroupOpen",kind:t,...n,raw:e}}function Ns(t,e,n,r){return{type:"NamedCallout",kind:t,tag:e,arguments:n,raw:r}}function $s(t,e,n,r){return{type:"Quantifier",kind:t,min:e,max:n,raw:r}}function Ps(t){return{type:"Subroutine",raw:t}}const Ls=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),mn=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Ts(t){const e=t[1]==="c"?t[2]:t[3];if(!e||!/[A-Za-z]/.test(e))throw new Error(`Unsupported control character "${t}"`);return X(ye(e.toUpperCase())-64,t)}function Ms(t,e){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(t).groups;r??="";const s=(e.getCurrentModX()||n.includes("x"))&&!r.includes("x"),o=bn(n),a=bn(r),i={};if(o&&(i.enable=o),a&&(i.disable=a),t.endsWith(")"))return e.replaceCurrentModX(s),gr("flags",t,{flags:i});if(t.endsWith(":"))return e.pushModX(s),e.numOpenGroups++,ue("group",t,{...(o||a)&&{flags:i}});throw new Error(`Unexpected flag modifier "${t}"`)}function Os(t){const e=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(t);if(!e)throw new Error(`Incomplete or invalid named callout "${t}"`);const{name:n,tag:r,args:s}=e.groups;if(!n)throw new Error(`Invalid named callout "${t}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${t}"`);const o=s?s.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[a,i,l]=o,c=Ls.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof a=="string")throw new Error(`Named callout argument must be a number "${a}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(o.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return Ns(c,r??null,s?.split(",")??null,t)}function yn(t){let e=null,n,r;if(t[0]==="{"){const{minStr:s,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(t).groups,a=1e5;if(+s>a||o&&+o>a)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+s,r=o===void 0?+s:o===""?1/0:+o,n>r&&(e="possessive",[n,r]=[r,n]),t.endsWith("?")){if(e==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');e="lazy"}else e||(e="greedy")}else n=t[0]==="+"?1:0,r=t[0]==="?"?1:1/0,e=t[1]==="+"?"possessive":t[1]==="?"?"lazy":"greedy";return $s(e,n,r,t)}function Gs(t){const e=t[1].toLowerCase();return re({d:"digit",h:"hex",s:"space",w:"word"}[e],t,{negate:t[1]!==e})}function Ds(t){const{p:e,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(t).groups;return re("property",t,{value:r,negate:e==="P"&&!n||e==="p"&&!!n})}function bn(t){const e={};return t.includes("i")&&(e.ignoreCase=!0),t.includes("m")&&(e.dotAll=!0),t.includes("x")&&(e.extended=!0),Object.keys(e).length?e:null}function Bs(t){const e={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<t.length;n++){const r=t[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(t.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');e.textSegmentMode=t[n+2]==="g"?"grapheme":"word",n+=3;continue}e[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return e}function Fs(t){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(t))throw new Error(`Incomplete or invalid escape "${t}"`);const e=t[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(t).groups.hex:t.slice(2);return parseInt(e,16)}function js(t,e){const{raw:n,inCharClass:r}=t,s=n.slice(1);if(!r&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=e))return[pr(n)];const o=[],a=s.match(/^[0-7]+|\d/g);for(let i=0;i<a.length;i++){const l=a[i];let c;if(i===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(P`Octal encoded byte above 177 unsupported "${n}"`)}else c=ye(l);o.push(X(c,(i===0?"\\":"")+l))}return o}function Us(t){const e=[],n=new RegExp(Yt,"gy");let r;for(;r=n.exec(t);){const s=r[0];if(s[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(o){const{min:a,max:i}=o.groups;if(+a>+i&&s.endsWith("?")){n.lastIndex--,e.push(yn(s.slice(0,-1)));continue}}}e.push(yn(s))}return e}function mr(t,e){if(!Array.isArray(t.body))throw new Error("Expected node with body array");if(t.body.length!==1)return!1;const n=t.body[0];return!e||Object.keys(e).every(r=>e[r]===n[r])}function zs(t){return Ws.has(t.type)}const Ws=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function yr(t,e={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e,rules:{captureGroup:!1,singleline:!1,...e.rules}},r=Cs(t,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(f,d)=>{const p=r.tokens[o.nextIndex];switch(o.parent=f,o.nextIndex++,p.type){case"Alternator":return oe();case"Assertion":return qs(p);case"Backreference":return Hs(p,o);case"Character":return at(p.value,{useLastValid:!!d.isCheckingRangeEnd});case"CharacterClassHyphen":return Vs(p,o,d);case"CharacterClassOpen":return Xs(p,o,d);case"CharacterSet":return Ks(p,o);case"Directive":return to(p.kind,{flags:p.flags});case"GroupOpen":return Zs(p,o,d);case"NamedCallout":return ro(p.kind,p.tag,p.arguments);case"Quantifier":return Qs(p,o);case"Subroutine":return Ys(p,o);default:throw new Error(`Unexpected token type "${p.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},a=oo(no(r.flags));let i=a.body[0];for(;o.nextIndex<r.tokens.length;){const f=s(i,{});f.type==="Alternative"?(a.body.push(f),i=f):i.body.push(f)}const{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:h}=o;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:f}of h)if(typeof f=="number"){if(f>l.length)throw new Error("Subroutine uses a group number that's not defined");f&&(l[f-1].isSubroutined=!0)}else if(u.has(f)){if(u.get(f).length>1)throw new Error(P`Subroutine uses a duplicate group name "\g<${f}>"`);u.get(f)[0].isSubroutined=!0}else throw new Error(P`Subroutine uses a group name that's not defined "\g<${f}>"`);return a}function qs({kind:t}){return $t(be({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[t],`Unexpected assertion kind "${t}"`),{negate:t===P`\B`||t===P`\Y`})}function Hs({raw:t},e){const n=/^\\k[<']/.test(t),r=n?t.slice(3,-1):t.slice(1),s=(o,a=!1)=>{const i=e.capturingGroups.length;let l=!1;if(o>i)if(e.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,Pt(a?i+1-o:o,{orphan:l})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${t}"`);return Pt(r)}return s(+r)}function Vs(t,e,n){const{tokens:r,walk:s}=e,o=e.parent,a=o.body.at(-1),i=r[e.nextIndex];if(!n.isCheckingRangeEnd&&a&&a.type!=="CharacterClass"&&a.type!=="CharacterClassRange"&&i&&i.type!=="CharacterClassOpen"&&i.type!=="CharacterClassClose"&&i.type!=="CharacterClassIntersector"){const l=s(o,{...n,isCheckingRangeEnd:!0});if(a.type==="Character"&&l.type==="Character")return o.body.pop(),eo(a,l);throw new Error("Invalid character class range")}return at(ye("-"))}function Xs({negate:t},e,n){const{tokens:r,walk:s}=e,o=r[e.nextIndex],a=[qe()];let i=_n(o);for(;i.type!=="CharacterClassClose";){if(i.type==="CharacterClassIntersector")a.push(qe()),e.nextIndex++;else{const c=a.at(-1);c.body.push(s(c,n))}i=_n(r[e.nextIndex],o)}const l=qe({negate:t});return a.length===1?l.body=a[0].body:(l.kind="intersection",l.body=a.map(c=>c.body.length===1?c.body[0]:c)),e.nextIndex++,l}function Ks({kind:t,negate:e,value:n},r){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a}=r;if(t==="property"){const i=it(n);if(Qt.has(i)&&!a?.has(i))t="posix",n=i;else return he(n,{negate:e,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a})}return t==="posix"?so(n,{negate:e}):Lt(t,{negate:e})}function Zs(t,e,n){const{tokens:r,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:a,walk:i}=e,l=ao(t),c=l.type==="AbsenceFunction",u=Cn(l),h=u&&l.negate;if(l.type==="CapturingGroup"&&(s.push(l),l.name&&ws(o,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=Sn(r[e.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")l.body.push(oe()),e.nextIndex++;else{const d=l.body.at(-1),p=i(d,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||h});if(d.body.push(p),(u||n.isInLookbehind)&&!a){const w="Lookbehind includes a pattern not allowed by Oniguruma";if(h||n.isInNegLookbehind){if(wn(p)||p.type==="CapturingGroup")throw new Error(w)}else if(wn(p)||Cn(p)&&p.negate)throw new Error(w)}}f=Sn(r[e.nextIndex])}return e.nextIndex++,l}function Qs({kind:t,min:e,max:n},r){const s=r.parent,o=s.body.at(-1);if(!o||!zs(o))throw new Error("Quantifier requires a repeatable token");const a=wr(t,e,n,o);return s.body.pop(),a}function Ys({raw:t},e){const{capturingGroups:n,subroutines:r}=e;let s=t.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const i=+o.groups.num,l=n.length;if(e.hasNumberedRef=!0,s={"":i,"+":l+i,"-":l+1-i}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const a=Cr(s);return r.push(a),a}function Js(t,e){return{type:"AbsenceFunction",kind:t,body:Le(e?.body)}}function oe(t){return{type:"Alternative",body:_r(t?.body)}}function $t(t,e){const n={type:"Assertion",kind:t};return(t==="word_boundary"||t==="text_segment_boundary")&&(n.negate=!!e?.negate),n}function Pt(t,e){const n=!!e?.orphan;return{type:"Backreference",ref:t,...n&&{orphan:n}}}function br(t,e){const n={name:void 0,isSubroutined:!1,...e};if(n.name!==void 0&&!io(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:t,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Le(e?.body)}}function at(t,e){const n={useLastValid:!1,...e};if(t>1114111){const r=t.toString(16);if(n.useLastValid)t=1114111;else throw t>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:t}}function qe(t){const e={kind:"union",negate:!1,...t};return{type:"CharacterClass",kind:e.kind,negate:e.negate,body:_r(t?.body)}}function eo(t,e){if(e.value<t.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:t,max:e}}function Lt(t,e){const n=!!e?.negate,r={type:"CharacterSet",kind:t};return(t==="digit"||t==="hex"||t==="newline"||t==="space"||t==="word")&&(r.negate=n),(t==="text_segment"||t==="newline"&&!n)&&(r.variableLength=!0),r}function to(t,e={}){if(t==="keep")return{type:"Directive",kind:t};if(t==="flags")return{type:"Directive",kind:t,flags:be(e.flags)};throw new Error(`Unexpected directive kind "${t}"`)}function no(t){return{type:"Flags",...t}}function z(t){const e=t?.atomic,n=t?.flags;if(e&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...e&&{atomic:e},...n&&{flags:n},body:Le(t?.body)}}function ne(t){const e={behind:!1,negate:!1,...t};return{type:"LookaroundAssertion",kind:e.behind?"lookbehind":"lookahead",negate:e.negate,body:Le(t?.body)}}function ro(t,e,n){return{type:"NamedCallout",kind:t,tag:e,arguments:n}}function so(t,e){const n=!!e?.negate;if(!Qt.has(t))throw new Error(`Invalid POSIX class "${t}"`);return{type:"CharacterSet",kind:"posix",value:t,negate:n}}function wr(t,e,n,r){if(e>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:t,min:e,max:n,body:r}}function oo(t,e){return{type:"Regex",body:Le(e?.body),flags:t}}function Cr(t){return{type:"Subroutine",ref:t}}function he(t,e){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e};let r=n.unicodePropertyMap?.get(it(t));if(!r){if(n.normalizeUnknownPropertyNames)r=lo(t);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(P`Invalid Unicode property "\p{${t}}"`)}return{type:"CharacterSet",kind:"property",value:r??t,negate:n.negate}}function ao({flags:t,kind:e,name:n,negate:r,number:s}){switch(e){case"absence_repeater":return Js("repeater");case"atomic":return z({atomic:!0});case"capturing":return br(s,{name:n});case"group":return z({flags:t});case"lookahead":case"lookbehind":return ne({behind:e==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${e}"`)}}function Le(t){if(t===void 0)t=[oe()];else if(!Array.isArray(t)||!t.length||!t.every(e=>e.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return t}function _r(t){if(t===void 0)t=[];else if(!Array.isArray(t)||!t.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return t}function wn(t){return t.type==="LookaroundAssertion"&&t.kind==="lookahead"}function Cn(t){return t.type==="LookaroundAssertion"&&t.kind==="lookbehind"}function io(t){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(t)}function lo(t){return t.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function it(t){return t.replace(/[- _]+/g,"").toLowerCase()}function _n(t,e){return be(t,`${e?.type==="Character"&&e.value===93?"Empty":"Unclosed"} character class`)}function Sn(t){return be(t,"Unclosed group")}function xe(t,e,n=null){function r(o,a){for(let i=0;i<o.length;i++){const l=s(o[i],a,i,o);i=Math.max(-1,i+l)}}function s(o,a=null,i=null,l=null){let c=0,u=!1;const h={node:o,parent:a,key:i,container:l,root:t,remove(){Be(l).splice(Math.max(0,le(i)+c),1),c--,u=!0},removeAllNextSiblings(){return Be(l).splice(le(i)+1)},removeAllPrevSiblings(){const g=le(i)+c;return c-=g,Be(l).splice(0,Math.max(0,g))},replaceWith(g,y={}){const m=!!y.traverse;l?l[Math.max(0,le(i)+c)]=g:be(a,"Can't replace root node")[i]=g,m&&s(g,a,i,l),u=!0},replaceWithMultiple(g,y={}){const m=!!y.traverse;if(Be(l).splice(Math.max(0,le(i)+c),1,...g),c+=g.length-1,m){let _=0;for(let S=0;S<g.length;S++)_+=s(g[S],a,le(i)+S+_,l)}u=!0},skip(){u=!0}},{type:f}=o,d=e["*"],p=e[f],w=typeof d=="function"?d:d?.enter,C=typeof p=="function"?p:p?.enter;if(w?.(h,n),C?.(h,n),!u)switch(f){case"AbsenceFunction":case"CapturingGroup":case"Group":r(o.body,o);break;case"Alternative":case"CharacterClass":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":s(o.min,o,"min"),s(o.max,o,"max");break;case"LookaroundAssertion":r(o.body,o);break;case"Quantifier":s(o.body,o,"body");break;case"Regex":r(o.body,o),s(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${f}"`)}return p?.exit?.(h,n),d?.exit?.(h,n),c}return s(t),t}function Be(t){if(!Array.isArray(t))throw new Error("Container expected");return t}function le(t){if(typeof t!="number")throw new Error("Numeric key expected");return t}const co=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function uo(t,e){for(let n=0;n<t.length;n++)t[n]>=e&&t[n]++}function ho(t,e,n,r){return t.slice(0,e)+r+t.slice(e+n.length)}const U=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Jt(t,e,n,r){const s=new RegExp(String.raw`${e}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let a=0,i="";for(const l of t.matchAll(s)){const{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===U.DEFAULT==!a)){n instanceof Function?i+=n(l,{context:a?U.CHAR_CLASS:U.DEFAULT,negated:o[o.length-1]}):i+=n;continue}c[0]==="["?(a++,o.push(c[1]==="^")):c==="]"&&a&&(a--,o.pop()),i+=c}return i}function Sr(t,e,n,r){Jt(t,e,n,r)}function fo(t,e,n=0,r){if(!new RegExp(e,"su").test(t))return null;const s=new RegExp(`${e}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let o=0,a;for(;a=s.exec(t);){const{0:i,groups:{$skip:l}}=a;if(!l&&(!r||r===U.DEFAULT==!o))return a;i==="["?o++:i==="]"&&o&&o--,s.lastIndex==a.index&&s.lastIndex++}return null}function Fe(t,e,n){return!!fo(t,e,0,n)}function po(t,e){const n=/\\?./gsu;n.lastIndex=e;let r=t.length,s=0,o=1,a;for(;a=n.exec(t);){const[i]=a;if(i==="[")s++;else if(s)i==="]"&&s--;else if(i==="(")o++;else if(i===")"&&(o--,!o)){r=a.index;break}}return t.slice(e,r)}const kn=new RegExp(String.raw`(?<noncapturingStart>${co})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function go(t,e){const n=e?.hiddenCaptures??[];let r=e?.captureTransfers??new Map;if(!/\(\?>/.test(t))return{pattern:t,captureTransfers:r,hiddenCaptures:n};const s="(?>",o="(?:(?=(",a=[0],i=[];let l=0,c=0,u=NaN,h;do{h=!1;let f=0,d=0,p=!1,w;for(kn.lastIndex=Number.isNaN(u)?0:u+o.length;w=kn.exec(t);){const{0:C,index:g,groups:{capturingStart:y,noncapturingStart:m}}=w;if(C==="[")f++;else if(f)C==="]"&&f--;else if(C===s&&!p)u=g,p=!0;else if(p&&m)d++;else if(y)p?d++:(l++,a.push(l+c));else if(C===")"&&p){if(!d){c++;const _=l+c;if(t=`${t.slice(0,u)}${o}${t.slice(u+s.length,g)}))<$$${_}>)${t.slice(g+1)}`,h=!0,i.push(_),uo(n,_),r.size){const S=new Map;r.forEach((E,L)=>{S.set(L>=_?L+1:L,E.map(B=>B>=_?B+1:B))}),r=S}break}d--}}}while(h);return n.push(...i),t=Jt(t,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:d,wrappedBackrefNum:p}})=>{if(d){const w=+d;if(w>a.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${a[w]}`}return`\\${p}`},U.DEFAULT),{pattern:t,captureTransfers:r,hiddenCaptures:n}}const kr=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,gt=new RegExp(String.raw`
|
|
34
34
|
\\(?: \d+
|
|
35
35
|
| c[A-Za-z]
|
|
36
36
|
| [gk]<[^>]+>
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
| [A-Za-z\-]+:
|
|
44
44
|
| \(DEFINE\)
|
|
45
45
|
))?
|
|
46
|
-
| (?<qBase>${
|
|
46
|
+
| (?<qBase>${kr})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
47
47
|
| \\?.
|
|
48
|
-
`.replace(/\s+/g,""),"gsu");function mo(t){if(!new RegExp(`${
|
|
48
|
+
`.replace(/\s+/g,""),"gsu");function mo(t){if(!new RegExp(`${kr}\\+`).test(t))return{pattern:t};const e=[];let n=null,r=null,s="",o=0,a;for(gt.lastIndex=0;a=gt.exec(t);){const{0:i,index:l,groups:{qBase:c,qMod:u,invalidQ:h}}=a;if(i==="[")o||(r=l),o++;else if(i==="]")o?o--:r=null;else if(!o)if(u==="+"&&s&&!s.startsWith("(")){if(h)throw new Error(`Invalid quantifier "${i}"`);let f=-1;if(/^\{\d+\}$/.test(c))t=ho(t,l+c.length,u,"");else{if(s===")"||s==="]"){const d=s===")"?n:r;if(d===null)throw new Error(`Invalid unmatched "${s}"`);t=`${t.slice(0,d)}(?>${t.slice(d,l)}${c})${t.slice(l+i.length)}`}else t=`${t.slice(0,l-s.length)}(?>${s}${c})${t.slice(l+i.length)}`;f+=4}gt.lastIndex+=f}else i[0]==="("?e.push(l):i===")"&&(n=e.length?e.pop():null);s=i}return{pattern:t}}const j=String.raw,yo=j`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Tt=j`\(\?R=(?<rDepth>[^\)]+)\)|${yo}`,lt=j`\(\?<(?![=!])(?<captureName>[^>]+)>`,vr=j`${lt}|(?<unnamed>\()(?!\?)`,ee=new RegExp(j`${lt}|${Tt}|\(\?|\\?.`,"gsu"),mt="Cannot use multiple overlapping recursions";function bo(t,e){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...e};let s=e?.captureTransfers??new Map;if(!new RegExp(Tt,"su").test(t))return{pattern:t,captureTransfers:s,hiddenCaptures:n};if(r==="plugin"&&Fe(t,j`\(\?\(DEFINE\)`,U.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],a=Fe(t,j`\\[1-9]`,U.DEFAULT),i=new Map,l=[];let c=!1,u=0,h=0,f;for(ee.lastIndex=0;f=ee.exec(t);){const{0:d,groups:{captureName:p,rDepth:w,gRNameOrNum:C,gRDepth:g}}=f;if(d==="[")u++;else if(u)d==="]"&&u--;else if(w){if(vn(w),c)throw new Error(mt);if(a)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const y=t.slice(0,f.index),m=t.slice(ee.lastIndex);if(Fe(m,Tt,U.DEFAULT))throw new Error(mt);const _=+w-1;t=xn(y,m,_,!1,n,o,h),s=An(s,y,_,o.length,0,h);break}else if(C){vn(g);let y=!1;for(const Z of l)if(Z.name===C||Z.num===+C){if(y=!0,Z.hasRecursedWithin)throw new Error(mt);break}if(!y)throw new Error(j`Recursive \g cannot be used outside the referenced group "${r==="external"?C:j`\g<${C}&R=${g}>`}"`);const m=i.get(C),_=po(t,m);if(a&&Fe(_,j`${lt}|\((?!\?)`,U.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const S=t.slice(m,f.index),E=_.slice(S.length+d.length),L=o.length,B=+g-1,Ge=xn(S,E,B,!0,n,o,h);s=An(s,S,B,o.length-L,L,h);const ft=t.slice(0,m),_e=t.slice(m+_.length);t=`${ft}${Ge}${_e}`,ee.lastIndex+=Ge.length-d.length-S.length-E.length,l.forEach(Z=>Z.hasRecursedWithin=!0),c=!0}else if(p)h++,i.set(String(h),ee.lastIndex),i.set(p,ee.lastIndex),l.push({num:h,name:p});else if(d[0]==="("){const y=d==="(";y&&(h++,i.set(String(h),ee.lastIndex)),l.push(y?{num:h}:{})}else d===")"&&l.pop()}return n.push(...o),{pattern:t,captureTransfers:s,hiddenCaptures:n}}function vn(t){const e=`Max depth must be integer between 2 and 100; used ${t}`;if(!/^[1-9]\d*$/.test(t))throw new Error(e);if(t=+t,t<2||t>100)throw new Error(e)}function xn(t,e,n,r,s,o,a){const i=new Set;r&&Sr(t+e,lt,({groups:{captureName:c}})=>{i.add(c)},U.DEFAULT);const l=[n,r?i:null,s,o,a];return`${t}${En(`(?:${t}`,"forward",...l)}(?:)${En(`${e})`,"backward",...l)}${e}`}function En(t,e,n,r,s,o,a){const l=u=>e==="forward"?u+2:n-u+2-1;let c="";for(let u=0;u<n;u++){const h=l(u);c+=Jt(t,j`${vr}|\\k<(?<backref>[^>]+)>`,({0:f,groups:{captureName:d,unnamed:p,backref:w}})=>{if(w&&r&&!r.has(w))return f;const C=`_$${h}`;if(p||d){const g=a+o.length+1;return o.push(g),wo(s,g),p?f:`(?<${d}${C}>`}return j`\k<${w}${C}>`},U.DEFAULT)}return c}function wo(t,e){for(let n=0;n<t.length;n++)t[n]>=e&&t[n]++}function An(t,e,n,r,s,o){if(t.size&&r){let a=0;Sr(e,vr,()=>a++,U.DEFAULT);const i=o-a+s,l=new Map;return t.forEach((c,u)=>{const h=(r-a*n)/n,f=a*n,d=u>i+a?u+r:u,p=[];for(const w of c)if(w<=i)p.push(w);else if(w>i+a+h)p.push(w+r);else if(w<=i+a)for(let C=0;C<=n;C++)p.push(w+a*C);else for(let C=0;C<=n;C++)p.push(w+f+h*C);l.set(d,p)}),l}return t}var R=String.fromCodePoint,k=String.raw,K={flagGroups:(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),unicodeSets:(()=>{try{new RegExp("[[]]","v")}catch{return!1}return!0})()};K.bugFlagVLiteralHyphenIsRange=K.unicodeSets?(()=>{try{new RegExp(k`[\d\-a]`,"v")}catch{return!0}return!1})():!1;K.bugNestedClassIgnoresNegation=K.unicodeSets&&new RegExp("[[^a]]","v").test("a");function Xe(t,{enable:e,disable:n}){return{dotAll:!n?.dotAll&&!!(e?.dotAll||t.dotAll),ignoreCase:!n?.ignoreCase&&!!(e?.ignoreCase||t.ignoreCase)}}function Ae(t,e,n){return t.has(e)||t.set(e,n),t.get(e)}function Mt(t,e){return In[t]>=In[e]}function Co(t,e){if(t==null)throw new Error(e??"Value expected");return t}var In={ES2025:2025,ES2024:2024,ES2018:2018},_o={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function xr(t={}){if({}.toString.call(t)!=="[object Object]")throw new Error("Unexpected options");if(t.target!==void 0&&!_o[t.target])throw new Error(`Unexpected target "${t.target}"`);const e={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...t,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...t.rules}};return e.target==="auto"&&(e.target=K.flagGroups?"ES2025":K.unicodeSets?"ES2024":"ES2018"),e}var So="[ -\r ]",ko=new Set([R(304),R(305)]),H=k`[\p{L}\p{M}\p{N}\p{Pc}]`;function Er(t){if(ko.has(t))return[t];const e=new Set,n=t.toLowerCase(),r=n.toUpperCase(),s=Eo.get(n),o=vo.get(n),a=xo.get(n);return[...r].length===1&&e.add(r),a&&e.add(a),s&&e.add(s),e.add(n),o&&e.add(o),[...e]}var en=new Map(`C Other
|
|
49
49
|
Cc Control cntrl
|
|
50
50
|
Cf Format
|
|
51
51
|
Cn Unassigned
|
|
@@ -135,12 +135,12 @@ Uppercase Upper
|
|
|
135
135
|
Variation_Selector VS
|
|
136
136
|
White_Space space
|
|
137
137
|
XID_Continue XIDC
|
|
138
|
-
XID_Start XIDS`.split(/\s/).map(t=>[
|
|
138
|
+
XID_Start XIDS`.split(/\s/).map(t=>[it(t),t])),vo=new Map([["s",R(383)],[R(383),"s"]]),xo=new Map([[R(223),R(7838)],[R(107),R(8490)],[R(229),R(8491)],[R(969),R(8486)]]),Eo=new Map([Q(453),Q(456),Q(459),Q(498),...yt(8072,8079),...yt(8088,8095),...yt(8104,8111),Q(8124),Q(8140),Q(8188)]),Ao=new Map([["alnum",k`[\p{Alpha}\p{Nd}]`],["alpha",k`\p{Alpha}`],["ascii",k`\p{ASCII}`],["blank",k`[\p{Zs}\t]`],["cntrl",k`\p{Cc}`],["digit",k`\p{Nd}`],["graph",k`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",k`\p{Lower}`],["print",k`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",k`[\p{P}\p{S}]`],["space",k`\p{space}`],["upper",k`\p{Upper}`],["word",k`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",k`\p{AHex}`]]);function Io(t,e){const n=[];for(let r=t;r<=e;r++)n.push(r);return n}function Q(t){const e=R(t);return[e.toLowerCase(),e]}function yt(t,e){return Io(t,e).map(n=>Q(n))}var Ar=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function Ro(t,e){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...e};Ir(t);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Mt(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:t.flags.digitIsAscii,spaceIsAscii:t.flags.spaceIsAscii,wordIsAscii:t.flags.wordIsAscii};xe(t,No,r);const s={dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},o={currentFlags:s,prevFlags:null,globalFlags:s,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};xe(t,$o,o);const a={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return xe(t,Po,a),t._originMap=o.groupOriginByCopy,t._strategy=r.strategy,t}var No={AbsenceFunction({node:t,parent:e,replaceWith:n}){const{body:r,kind:s}=t;if(s==="repeater"){const o=z();o.body[0].body.push(ne({negate:!0,body:r}),he("Any"));const a=z();a.body[0].body.push(wr("greedy",0,1/0,o)),n(A(a,e),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:t,parent:e,key:n},{flagDirectivesByAlt:r}){const s=t.body.filter(o=>o.kind==="flags");for(let o=n+1;o<e.body.length;o++){const a=e.body[o];Ae(r,a,[]).push(...s)}},exit({node:t},{flagDirectivesByAlt:e}){if(e.get(t)?.length){const n=Nr(e.get(t));if(n){const r=z({flags:n});r.body[0].body=t.body,t.body=[A(r,t)]}}}},Assertion({node:t,parent:e,key:n,container:r,root:s,remove:o,replaceWith:a},i){const{kind:l,negate:c}=t,{asciiWordBoundaries:u,avoidSubclass:h,supportedGNodes:f,wordIsAscii:d}=i;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")a(A(ne({body:[oe({body:[$t("string_end")]}),oe({body:[at(10)]})]}),e));else if(l==="line_start")a(A(V(k`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),e));else if(l==="search_start")if(f.has(t))s.flags.sticky=!0,o();else{const p=r[n-1];if(p&&Do(p))a(A(ne({negate:!0}),e));else{if(h)throw new Error(k`Uses "\G" in a way that requires a subclass`);a(Y($t("string_start"),e)),i.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")a(A(V(k`(?=\n?\z)`),e));else if(l==="word_boundary"){if(!d&&!u){const p=`(?:(?<=${H})(?!${H})|(?<!${H})(?=${H}))`,w=`(?:(?<=${H})(?=${H})|(?<!${H})(?!${H}))`;a(A(V(c?w:p),e))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!wt(n)&&(n=bt(n,e),t.ref=n)},CapturingGroup({node:t},{jsGroupNameMap:e,subroutineRefMap:n}){let{name:r}=t;r&&!wt(r)&&(r=bt(r,e),t.name=r),n.set(t.number,t),r&&n.set(r,t)},CharacterClassRange({node:t,parent:e,replaceWith:n}){if(e.kind==="intersection"){const r=qe({body:[t]});n(A(r,e),{traverse:!0})}},CharacterSet({node:t,parent:e,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:o,spaceIsAscii:a,wordIsAscii:i}){const{kind:l,negate:c,value:u}=t;if(o&&(l==="digit"||u==="digit")){n(Y(Lt("digit",{negate:c}),e));return}if(a&&(l==="space"||u==="space")){n(A(Ct(V(So),c),e));return}if(i&&(l==="word"||u==="word")){n(Y(Lt("word",{negate:c}),e));return}if(l==="any")n(Y(he("Any"),e));else if(l==="digit")n(Y(he("Nd",{negate:c}),e));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(k`Use of "\X" requires non-strict accuracy`);const h="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=k`\p{RI}{2}|${h}(?:\u200D${h})*`;n(A(V(k`(?>\r\n|${s?k`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),e))}else if(l==="hex")n(Y(he("AHex",{negate:c}),e));else if(l==="newline")n(A(V(c?`[^
|
|
139
139
|
]`:`(?>\r
|
|
140
140
|
?|[
|
|
141
|
-
\v\f
\u2028\u2029])`),e));else if(l==="posix")if(!s&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let h={graph:"!-~",print:" -~"}[u];c&&(h=`\0-${R(h.codePointAt(0)-1)}${R(h.codePointAt(2)+1)}-`),n(A(X(`[${h}]`),e))}else n(A(At(X(Ao.get(u)),c),e));else if(l==="property")kt.has(Fe(u))||(t.key="sc");else if(l==="space")n(Q(ue("space",{negate:c}),e));else if(l==="word")n(A(At(X(V),c),e));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:t,parent:e,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:a}){const{kind:i,flags:l}=t;if(i==="flags")if(!l.enable&&!l.disable)r();else{const c=z({flags:l});c.body[0].body=a(),s(A(c,e),{traverse:!0})}else if(i==="keep"){const c=n.body[0],h=n.body.length===1&&kn(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(e.parent!==h||h.body.length>1)throw new Error(k`Uses "\K" in a way that's unsupported`);const f=ne({behind:!0});f.body[0].body=o(),s(A(f,e))}else throw new Error(`Unexpected directive kind "${i}"`)},Flags({node:t,parent:e}){if(t.posixIsAscii)throw new Error('Unsupported flag "P"');if(t.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete t[n]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:n}=t.flags;e?.extended&&delete e.extended,n?.extended&&delete n.extended,e?.dotAll&&n?.dotAll&&delete e.dotAll,e?.ignoreCase&&n?.ignoreCase&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,n&&!Object.keys(n).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},LookaroundAssertion({node:t},e){const{kind:n}=t;n==="lookbehind"&&(e.passedLookbehind=!0)},NamedCallout({node:t,parent:e,replaceWith:n}){const{kind:r}=t;if(r==="fail")n(A(ne({negate:!0}),e));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:t}){if(t.body.type==="Quantifier"){const e=z();e.body[0].body.push(t.body),t.body=A(e,t)}},Regex:{enter({node:t},{supportedGNodes:e}){const n=[];let r=!1,s=!1;for(const o of t.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const a=Zn(o.body);a?(r=!0,Array.isArray(a)?n.push(...a):n.push(a)):s=!0}r&&!s&&n.forEach(o=>e.add(o))},exit(t,{accuracy:e,passedLookbehind:n,strategy:r}){if(e==="strict"&&n&&r)throw new Error(k`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!Et(n)&&(n=xt(n,e),t.ref=n)}},$o={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=t;r||n.set(t,[...e.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:t,parent:e,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:a,openRefs:i,reffedNodesByReferencer:l}){const c=s.get(t);if(c&&i.has(t.number)){const h=Q(Vn(t.number),e);l.set(h,i.get(t.number)),n(h);return}i.set(t.number,t),a.set(t.number,[]),t.name&&ke(a,t.name,[]);const u=a.get(t.name??t.number);for(let h=0;h<u.length;h++){const f=u[h];if(c===f.node||c&&c===f.origin||t===f.origin){u.splice(h,1);break}}if(a.get(t.number).push({node:t,origin:c}),t.name&&a.get(t.name).push({node:t,origin:c}),t.name){const h=ke(o,t.name,new Map);let f=!1;if(c)f=!0;else for(const d of h.values())if(!d.hasDuplicateNameToRemove){f=!0;break}o.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:f})}},exit({node:t},{openRefs:e}){e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=We(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Subroutine({node:t,parent:e,replaceWith:n},r){const{isRecursive:s,ref:o}=t;if(s){let u=e;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===o||u.number===o)););r.reffedNodesByReferencer.set(t,u);return}const a=r.subroutineRefMap.get(o),i=o===0,l=i?Vn(0):Hn(a,r.groupOriginByCopy,null);let c=l;if(!i){const u=Xn(Mo(a,f=>f.type==="Group"&&!!f.flags)),h=u?We(r.globalFlags,u):r.globalFlags;Lo(h,r.currentFlags)||(c=z({flags:Oo(h)}),c.body[0].body.push(l))}n(A(c,e),{traverse:!i})}},Po={Backreference({node:t,parent:e,replaceWith:n},r){if(t.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,t.ref);return}const o=r.reffedNodesByReferencer.get(t).filter(a=>To(a,t));if(!o.length)n(A(ne({negate:!0}),e));else if(o.length>1){const a=z({atomic:!0,body:o.reverse().map(i=>te({body:[mt(i.number)]}))});n(A(a,e))}else t.ref=o[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Regex:{exit({node:t},e){const n=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=xn();t.body.at(-1).body.push(s)}}},Subroutine({node:t},e){!t.isRecursive||t.ref===0||(t.ref=e.reffedNodesByReferencer.get(t).number)}};function qn(t){Se(t,{"*"({node:e,parent:n}){e.parent=n}})}function Lo(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function To(t,e){let n=e;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===t)return!1;const r=Kn(n.parent);for(const s of r){if(s===n)break;if(s===t||Qn(s,t))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Hn(t,e,n,r){const s=Array.isArray(t)?[]:{};for(const[o,a]of Object.entries(t))o==="parent"?s.parent=Array.isArray(n)?r:n:a&&typeof a=="object"?s[o]=Hn(a,e,s,n):(o==="type"&&a==="CapturingGroup"&&e.set(s,e.get(t)??t),s[o]=a);return s}function Vn(t){const e=An(t);return e.isRecursive=!0,e}function Mo(t,e){const n=[];for(;t=t.parent;)(!e||e(t))&&n.push(t);return n}function xt(t,e){if(e.has(t))return e.get(t);const n=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,n),n}function Xn(t){const e=["dotAll","ignoreCase"],n={enable:{},disable:{}};return t.forEach(({flags:r})=>{e.forEach(s=>{r.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),r.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Oo({dotAll:t,ignoreCase:e}){const n={};return(t||e)&&(n.enable={},t&&(n.enable.dotAll=!0),e&&(n.enable.ignoreCase=!0)),(!t||!e)&&(n.disable={},!t&&(n.disable.dotAll=!0),!e&&(n.disable.ignoreCase=!0)),n}function Kn(t){if(!t)throw new Error("Node expected");const{body:e}=t;return Array.isArray(e)?e:e?[e]:null}function Zn(t){const e=t.find(n=>n.kind==="search_start"||Bo(n,{negate:!1})||!Go(n));if(!e)return null;if(e.kind==="search_start")return e;if(e.type==="LookaroundAssertion")return e.body[0].body[0];if(e.type==="CapturingGroup"||e.type==="Group"){const n=[];for(const r of e.body){const s=Zn(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function Qn(t,e){const n=Kn(t)??[];for(const r of n)if(r===e||Qn(r,e))return!0;return!1}function Go({type:t}){return t==="Assertion"||t==="Directive"||t==="LookaroundAssertion"}function Do(t){const e=["Character","CharacterClass","CharacterSet"];return e.includes(t.type)||t.type==="Quantifier"&&t.min&&e.includes(t.body.type)}function Bo(t,e){const n={negate:null,...e};return t.type==="LookaroundAssertion"&&(n.negate===null||t.negate===n.negate)&&t.body.length===1&&kn(t.body[0],{type:"Assertion",kind:"search_start"})}function Et(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function X(t,e){const r=vn(t,{...e,unicodePropertyMap:kt}).body;return r.length>1||r[0].body.length>1?z({body:r}):r[0].body[0]}function At(t,e){return t.negate=e,t}function Q(t,e){return t.parent=e,t}function A(t,e){return qn(t),t.parent=e,t}function Fo(t,e){const n=Un(e),r=St(n.target,"ES2024"),s=St(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let a=null,i=null;if(!s){const d=[t.flags.ignoreCase];Se(t,jo,{getCurrentModI:()=>d.at(-1),popModI(){d.pop()},pushModI(p){d.push(p)},setHasCasedChar(){d.at(-1)?a=!0:i=!0}})}const l={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||a)&&!i)};let c=t;const u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:t._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&a&&i),useFlagMods:s,useFlagV:r,verbose:n.verbose};function h(d){return u.lastNode=c,c=d,Co(Uo[d.type],`Unexpected node type "${d.type}"`)(d,u,h)}const f={pattern:t.body.map(h).join("|"),flags:h(t.flags),options:{...t.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((d,p)=>{d.hidden&&f._hiddenCaptures.push(p),d.transferTo&&ke(f._captureTransfers,d.transferTo,[]).push(p)}),f}var jo={"*":{enter({node:t},e){if(er(t)){const n=e.getCurrentModI();e.pushModI(t.flags?We({ignoreCase:n},t.flags).ignoreCase:n)}},exit({node:t},e){er(t)&&e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){It(R(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},n){e(),Jn(t,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:t},e){t.kind==="property"&&Wn.has(t.value)&&e.setHasCasedChar()}},Uo={Alternative({body:t},e,n){return t.map(n).join("")},Assertion({kind:t,negate:e}){if(t==="string_end")return"$";if(t==="string_start")return"^";if(t==="word_boundary")return e?k`\B`:k`\b`;throw new Error(`Unexpected assertion kind "${t}"`)},Backreference({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t},CapturingGroup(t,e,n){const{body:r,name:s,number:o}=t,a={ignoreCase:e.currentFlags.ignoreCase},i=e.originMap.get(t);return i&&(a.hidden=!0,o>i.number&&(a.transferTo=i.number)),e.captureMap.set(o,a),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:t},e){const n=R(t),r=fe(t,{escDigit:e.lastNode.type==="Backreference",inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(r!==n)return r;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&It(n)){const s=zn(n);return e.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(t,e,n){const{kind:r,negate:s,parent:o}=t;let{body:a}=t;if(r==="intersection"&&!e.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");H.bugFlagVLiteralHyphenIsRange&&e.useFlagV&&a.some(tr)&&(a=[De(45),...a.filter(c=>!tr(c))]);const i=()=>`[${s?"^":""}${a.map(n).join(r==="intersection"?"&&":"")}]`;if(!e.inCharClass){if((!e.useFlagV||H.bugNestedClassIgnoresNegation)&&!s){const u=a.filter(h=>h.type==="CharacterClass"&&h.kind==="union"&&h.negate);if(u.length){const h=z(),f=h.body[0];return h.parent=o,f.parent=h,a=a.filter(d=>!u.includes(d)),t.body=a,a.length?(t.parent=f,f.body.push(t)):h.body.pop(),u.forEach(d=>{const p=te({body:[d]});d.parent=p,p.parent=h,h.body.push(p)}),n(h)}}e.inCharClass=!0;const c=i();return e.inCharClass=!1,c}const l=a[0];if(r==="union"&&!s&&l&&((!e.useFlagV||!e.verbose)&&o.kind==="union"&&!(H.bugFlagVLiteralHyphenIsRange&&e.useFlagV)||!e.verbose&&o.kind==="intersection"&&a.length===1&&l.type!=="CharacterClassRange"))return a.map(n).join("");if(!e.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return i()},CharacterClassRange(t,e){const n=t.min.value,r=t.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:e.useFlagV},o=fe(n,s),a=fe(r,s),i=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const l=Jn(t);Vo(l).forEach(u=>{i.add(Array.isArray(u)?`${fe(u[0],s)}-${fe(u[1],s)}`:fe(u,s))})}return`${o}-${a}${[...i].join("")}`},CharacterSet({kind:t,negate:e,value:n,key:r},s){if(t==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":k`[^\n]`;if(t==="digit")return e?k`\D`:k`\d`;if(t==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&Wn.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${e?k`\P`:k`\p`}{${r?`${r}=`:""}${n}}`}if(t==="word")return e?k`\W`:k`\w`;throw new Error(`Unexpected character set kind "${t}"`)},Flags(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")},Group({atomic:t,body:e,flags:n,parent:r},s,o){const a=s.currentFlags;n&&(s.currentFlags=We(a,n));const i=e.map(o).join("|"),l=!s.verbose&&e.length===1&&r.type!=="Quantifier"&&!t&&(!s.useFlagMods||!n)?i:`(?${Xo(t,n,s.useFlagMods)}${i})`;return s.currentFlags=a,l},LookaroundAssertion({body:t,kind:e,negate:n},r,s){return`(?${`${e==="lookahead"?"":"<"}${n?"!":"="}`}${t.map(s).join("|")})`},Quantifier(t,e,n){return n(t.body)+Ko(t)},Subroutine({isRecursive:t,ref:e},n){if(!t)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return e===0?`(?R=${r})`:k`\g<${e}&R=${r}>`}},zo=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Wo=new Set(["-","\\","]","^","["]),qo=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Yn=new Map([[9,k`\t`],[10,k`\n`],[11,k`\v`],[12,k`\f`],[13,k`\r`],[8232,k`\u2028`],[8233,k`\u2029`],[65279,k`\uFEFF`]]),Ho=new RegExp("^\\p{Cased}$","u");function It(t){return Ho.test(t)}function Jn(t,e){const n=!!e?.firstOnly,r=t.min.value,s=t.max.value,o=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return o;for(let a=r;a<=s;a++){const i=R(a);if(!It(i))continue;const l=zn(i).filter(c=>{const u=c.codePointAt(0);return u<r||u>s});if(l.length&&(o.push(...l),n))break}return o}function fe(t,{escDigit:e,inCharClass:n,useFlagV:r}){if(Yn.has(t))return Yn.get(t);if(t<32||t>126&&t<160||t>262143||e&&Zo(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?qo:Wo:zo,o=R(t);return(s.has(o)?"\\":"")+o}function Vo(t){const e=t.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),n=[];let r=null;for(let s=0;s<e.length;s++)e[s+1]===e[s]+1?r??=e[s]:r===null?n.push(e[s]):(n.push([r,e[s]]),r=null);return n}function Xo(t,e,n){if(t)return">";let r="";if(e&&n){const{enable:s,disable:o}=e;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function Ko({kind:t,max:e,min:n}){let r;return!n&&e===1?r="?":!n&&e===1/0?r="*":n===1&&e===1/0?r="+":n===e?r=`{${n}}`:r=`{${n},${e===1/0?"":e}}`,r+{greedy:"",lazy:"?",possessive:"+"}[t]}function er({type:t}){return t==="CapturingGroup"||t==="Group"||t==="LookaroundAssertion"}function Zo(t){return t>47&&t<58}function tr({type:t,value:e}){return t==="Character"&&e===45}var Qo=class un extends RegExp{#t=new Map;#e=null;#r;#n=null;#s=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(e,n,r){const s=!!r?.lazyCompile;if(e instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const o=e;super(o,n),this.#r=o.source,o instanceof un&&(this.#t=o.#t,this.#n=o.#n,this.#s=o.#s,this.rawOptions=o.rawOptions)}else{const o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":e,n),this.#r=e,this.#t=Jo(o.hiddenCaptures,o.transfers),this.#s=o.strategy,this.rawOptions=r??{}}s||(this.#e=this)}exec(e){if(!this.#e){const{lazyCompile:s,...o}=this.rawOptions;this.#e=new un(this.#r,this.flags,o)}const n=this.global||this.sticky,r=this.lastIndex;if(this.#s==="clip_search"&&n&&r){this.lastIndex=0;const s=this.#o(e.slice(r));return s&&(Yo(s,r,e,this.hasIndices),this.lastIndex+=r),s}return this.#o(e)}#o(e){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,e);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const r=[...n];n.length=1;let s;this.hasIndices&&(s=[...n.indices],n.indices.length=1);const o=[0];for(let a=1;a<r.length;a++){const{hidden:i,transferTo:l}=this.#t.get(a)??{};if(i?o.push(null):(o.push(n.length),n.push(r[a]),this.hasIndices&&n.indices.push(s[a])),l&&r[a]!==void 0){const c=o[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[a],this.hasIndices&&(n.indices[c]=s[a]),n.groups){this.#n||(this.#n=ea(this.source));const u=this.#n.get(l);u&&(n.groups[u]=r[a],this.hasIndices&&(n.indices.groups[u]=s[a]))}}}return n}};function Yo(t,e,n,r){if(t.index+=e,t.input=n,r){const s=t.indices;for(let a=0;a<s.length;a++){const i=s[a];i&&(s[a]=[i[0]+e,i[1]+e])}const o=s.groups;o&&Object.keys(o).forEach(a=>{const i=o[a];i&&(o[a]=[i[0]+e,i[1]+e])})}}function Jo(t,e){const n=new Map;for(const r of t)n.set(r,{hidden:!0});for(const[r,s]of e)for(const o of s)ke(n,o,{}).transferTo=r;return n}function ea(t){const e=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,s=0,o;for(;o=e.exec(t);){const{0:a,groups:{capture:i,name:l}}=o;a==="["?r++:r?a==="]"&&r--:i&&(s++,l&&n.set(s,l))}return n}function ta(t,e){const n=na(t,e);return n.options?new Qo(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function na(t,e){const n=Un(e),r=vn(t,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:kt}),s=Ro(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=Fo(s,n),a=bo(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),i=mo(a.pattern),l=go(i.pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const u=l.hiddenCaptures.sort((p,w)=>p-w),h=Array.from(l.captureTransfers),f=s._strategy,d=c.pattern.length>=n.lazyCompileLength;(u.length||h.length||f||d)&&(c.options={...u.length&&{hiddenCaptures:u},...h.length&&{transfers:h},...f&&{strategy:f},...d&&{lazyCompile:d}})}return c}const nr=4294967295;class ra{constructor(e,n={}){this.patterns=e,this.options=n;const{forgiving:r=!1,cache:s,regexConstructor:o}=n;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(a=>{if(typeof a!="string")return a;const i=s?.get(a);if(i){if(i instanceof RegExp)return i;if(r)return null;throw i}try{const l=o(a);return s?.set(a,l),l}catch(l){if(s?.set(a,l),r)return null;throw l}})}regexps;findNextMatchSync(e,n,r){const s=typeof e=="string"?e:e.content,o=[];function a(i,l,c=0){return{index:i,captureIndices:l.indices.map(u=>u==null?{start:nr,end:nr,length:0}:{start:u[0]+c,end:u[1]+c,length:u[1]-u[0]})}}for(let i=0;i<this.regexps.length;i++){const l=this.regexps[i];if(l)try{l.lastIndex=n;const c=l.exec(s);if(!c)continue;if(c.index===n)return a(i,c,0);o.push([i,c,0])}catch(c){if(this.options.forgiving)continue;throw c}}if(o.length){const i=Math.min(...o.map(l=>l[1].index));for(const[l,c,u]of o)if(c.index===i)return a(l,c,u)}return null}}function sa(t,e){return ta(t,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function oa(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||=n=>sa(n,{target:e.target}),{createScanner(n){return new ra(n,e)},createString(n){return{content:n}}}}let P=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function aa(t){return Rt(t)}function Rt(t){return Array.isArray(t)?ia(t):t instanceof RegExp?t:typeof t=="object"?la(t):t}function ia(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=Rt(t[n]);return e}function la(t){let e={};for(let n in t)e[n]=Rt(t[n]);return e}function rr(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function sr(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?sr(t.substring(0,t.length-1)):t.substr(~e+1)}var Nt=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,qe=class{static hasCaptures(t){return t===null?!1:(Nt.lastIndex=0,Nt.test(t))}static replaceCaptures(t,e,n){return t.replace(Nt,(r,s,o,a)=>{let i=n[parseInt(s||o,10)];if(i){let l=e.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(a){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function or(t,e){return t<e?-1:t>e?1:0}function ar(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let o=or(t[s],e[s]);if(o!==0)return o}return 0}return n-r}function ir(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function lr(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var cr=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},He=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(ha(t),e)}static createFromParsedTheme(t,e){return da(t,e)}_cachedMatchRoot=new cr(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,r=this._cachedMatchRoot.get(e).find(s=>ca(t.parent,s.parentScopes));return r?new ur(r.fontStyle,r.foreground,r.background):null}},$t=class ht{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new ht(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new ht(n,e[r]);return n}push(e){return new ht(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function ca(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}for(;t&&!ua(t.scopeName,r);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function ua(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var ur=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function ha(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,o=e.length;s<o;s++){let a=e[s];if(!a.settings)continue;let i;if(typeof a.scope=="string"){let h=a.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),i=h.split(",")}else Array.isArray(a.scope)?i=a.scope:i=[""];let l=-1;if(typeof a.settings.fontStyle=="string"){l=0;let h=a.settings.fontStyle.split(" ");for(let f=0,d=h.length;f<d;f++)switch(h[f]){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 a.settings.foreground=="string"&&ir(a.settings.foreground)&&(c=a.settings.foreground);let u=null;typeof a.settings.background=="string"&&ir(a.settings.background)&&(u=a.settings.background);for(let h=0,f=i.length;h<f;h++){let p=i[h].trim().split(" "),w=p[p.length-1],C=null;p.length>1&&(C=p.slice(0,p.length-1),C.reverse()),n[r++]=new fa(w,C,s,l,c,u)}}return n}var fa=class{constructor(t,e,n,r,s,o){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}},T=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(T||{});function da(t,e){t.sort((l,c)=>{let u=or(l.scope,c.scope);return u!==0||(u=ar(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let l=t.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(s=l.background)}let o=new pa(e),a=new ur(n,o.getId(r),o.getId(s)),i=new ma(new Pt(0,null,-1,0,0),[]);for(let l=0,c=t.length;l<c;l++){let u=t[l];i.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new He(o,a,i)}var pa=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},ga=Object.freeze([]),Pt=class ys{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,o){this.scopeDepth=e,this.parentScopes=n||ga,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new ys(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},ma=class hn{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=e.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-e.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,o;if(r===-1?(s=e,o=""):(s=e.substring(0,r),o=e.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(hn._cmpBySpecificity),n}insert(e,n,r,s,o,a){if(n===""){this._doInsertHere(e,r,s,o,a);return}let i=n.indexOf("."),l,c;i===-1?(l=n,c=""):(l=n.substring(0,i),c=n.substring(i+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new hn(this._mainRule.clone(),Pt.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(e+1,c,r,s,o,a)}_doInsertHere(e,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(e,r,s,o);return}for(let a=0,i=this._rulesWithParentScopes.length;a<i;a++){let l=this._rulesWithParentScopes[a];if(ar(l.parentScopes,n)===0){l.acceptOverwrite(e,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Pt(e,n,r,s,o))}},de=class U{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=U.getLanguageId(e),r=U.getTokenType(e),s=U.getFontStyle(e),o=U.getForeground(e),a=U.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:a})}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,n,r,s,o,a,i){let l=U.getLanguageId(e),c=U.getTokenType(e),u=U.containsBalancedBrackets(e)?1:0,h=U.getFontStyle(e),f=U.getForeground(e),d=U.getBackground(e);return n!==0&&(l=n),r!==8&&(c=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),a!==0&&(f=a),i!==0&&(d=i),(l<<0|c<<8|u<<10|h<<11|f<<15|d<<24)>>>0}};function yc(t){return t}function bc(t){return t}function Ve(t,e){const n=[],r=ya(t);let s=r.next();for(;s!==null;){let l=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let c=a();if(n.push({matcher:c,priority:l}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const l=o();return c=>!!l&&!l(c)}if(s==="("){s=r.next();const l=i();return s===")"&&(s=r.next()),l}if(hr(s)){const l=[];do l.push(s),s=r.next();while(hr(s));return c=>e(l,c)}return null}function a(){const l=[];let c=o();for(;c;)l.push(c),c=o();return u=>l.every(h=>h(u))}function i(){const l=[];let c=a();for(;c&&(l.push(c),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");c=a()}return u=>l.some(h=>h(u))}}function hr(t){return!!t&&!!t.match(/[\w\.:]+/)}function ya(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function fr(t){typeof t.dispose=="function"&&t.dispose()}var ve=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},ba=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},wa=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},Ca=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ve(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new wa;for(const n of t)_a(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof ve){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function _a(t,e,n,r){const s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const o=n.lookup(e);t instanceof ve?Xe({baseGrammar:o,selfGrammar:s},r):Lt(t.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const a=n.injections(t.scopeName);if(a)for(const i of a)r.add(new ve(i))}function Lt(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];Ke([r],e,n)}}function Xe(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Ke(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Ke(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Ke(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?rr({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&Ke(r.patterns,{...e,repository:s},n);const o=r.include;if(!o)continue;const a=dr(o);switch(a.kind){case 0:Xe({...e,selfGrammar:e.baseGrammar},n);break;case 1:Xe(e,n);break;case 2:Lt(a.ruleName,{...e,repository:s},n);break;case 3:case 4:const i=a.scopeName===e.selfGrammar.scopeName?e.selfGrammar:a.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(i){const l={baseGrammar:e.baseGrammar,selfGrammar:i,repository:s};a.kind===4?Lt(a.ruleName,l,n):Xe(l,n)}else a.kind===4?n.add(new ba(a.scopeName,a.ruleName)):n.add(new ve(a.scopeName));break}}}var Sa=class{kind=0},ka=class{kind=1},va=class{constructor(t){this.ruleName=t}kind=2},xa=class{constructor(t){this.scopeName=t}kind=3},Ea=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function dr(t){if(t==="$base")return new Sa;if(t==="$self")return new ka;const e=t.indexOf("#");if(e===-1)return new xa(t);if(e===0)return new va(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new Ea(n,r)}}var Aa=/\\(\d+)/,pr=/\\(\d+)/g,Ia=-1,gr=-2;function wc(t){return t}function Cc(t){return t}var xe=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=qe.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=qe.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${sr(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:qe.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:qe.replaceCaptures(this._contentName,t,e)}},Ra=class extends xe{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},Na=class extends xe{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null),this._match=new Ee(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ae,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},mr=class extends xe{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ae,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Tt=class extends xe{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,o,a,i,l,c){super(t,e,n,r),this._begin=new Ee(s,this.id),this.beginCaptures=o,this._end=new Ee(a||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.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(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ae;for(const n of this.patterns)t.getRule(n).collectPatterns(t,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,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},Ze=class extends xe{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,o,a,i,l){super(t,e,n,r),this._begin=new Ee(s,this.id),this.beginCaptures=o,this.whileCaptures=i,this._while=new Ee(a,gr),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.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(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ae;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Ae,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||""),this._cachedCompiledWhilePatterns}},yr=class M{static createCaptureRule(e,n,r,s,o){return e.registerRule(a=>new Ra(n,a,r,s,o))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(s=>{if(e.id=s,e.match)return new Na(e.$vscodeTextmateLocation,e.id,e.name,e.match,M._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=rr({},r,e.repository));let o=e.patterns;return typeof o>"u"&&e.include&&(o=[{include:e.include}]),new mr(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,M._compilePatterns(o,n,r))}return e.while?new Ze(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,M._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,M._compileCaptures(e.whileCaptures||e.captures,n,r),M._compilePatterns(e.patterns,n,r)):new Tt(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,M._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,M._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,M._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let s=[];if(e){let o=0;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const i=parseInt(a,10);i>o&&(o=i)}for(let a=0;a<=o;a++)s[a]=null;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const i=parseInt(a,10);let l=0;e[a].patterns&&(l=M.getCompiledRuleId(e[a],n,r)),s[i]=M.createCaptureRule(n,e[a].$vscodeTextmateLocation,e[a].name,e[a].contentName,l)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let o=0,a=e.length;o<a;o++){const i=e[o];let l=-1;if(i.include){const c=dr(i.include);switch(c.kind){case 0:case 1:l=M.getCompiledRuleId(r[i.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=M.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=c.scopeName,f=c.kind===4?c.ruleName:null,d=n.getExternalGrammar(h,r);if(d)if(f){let p=d.repository[f];p&&(l=M.getCompiledRuleId(p,n,d.repository))}else l=M.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else l=M.getCompiledRuleId(i,n,r);if(l!==-1){const c=n.getRule(l);let u=!1;if((c instanceof mr||c instanceof Tt||c instanceof Ze)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;s.push(l)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},Ee=class bs{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let s=0,o=[],a=!1;for(let i=0;i<r;i++)if(e.charAt(i)==="\\"&&i+1<r){const c=e.charAt(i+1);c==="z"?(o.push(e.substring(s,i)),o.push("$(?!\\n)(?<!\\n)"),s=i+2):(c==="A"||c==="G")&&(a=!0),i++}this.hasAnchor=a,s===0?this.source=e:(o.push(e.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Aa.test(this.source):this.hasBackReferences=!1}clone(){return new bs(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>e.substring(s.start,s.end));return pr.lastIndex=0,this.source.replace(pr,(s,o)=>lr(r[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=[],n=[],r=[],s=[],o,a,i,l;for(o=0,a=this.source.length;o<a;o++)i=this.source.charAt(o),e[o]=i,n[o]=i,r[o]=i,s[o]=i,i==="\\"&&o+1<a&&(l=this.source.charAt(o+1),l==="A"?(e[o+1]="",n[o+1]="",r[o+1]="A",s[o+1]="A"):l==="G"?(e[o+1]="",n[o+1]="G",r[o+1]="",s[o+1]="G"):(e[o+1]=l,n[o+1]=l,r[o+1]=l,s[o+1]=l),o++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Ae=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){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(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new br(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(s=>s.resolveAnchors(e,n));return new br(t,r,this._items.map(s=>s.ruleId))}},br=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
|
|
142
|
-
`)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},
|
|
143
|
-
`;const o=this.createOnigString(t),a=o.content.length,i=new za(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Cr(this,o,s,0,e,i,!0,r);return fr(o),{lineLength:a,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function kr(t,e){return t=aa(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Re=class W{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,s=e?.scopePath??null;for(const o of n)s=$t.push(s,o.scopeNames),r=new W(r,s,o.encodedTokenAttributes);return r}static createRoot(e,n){return new W(null,new $t(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const s=r.getMetadataForScope(e),o=new $t(null,e),a=r.themeProvider.themeMatch(o),i=W.mergeAttributes(n,s,a);return new W(null,o,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return W.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let s=-1,o=0,a=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,a=r.backgroundId),de.set(e,n.languageId,n.tokenType,null,s,o,a)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return W._pushAttributed(this,e,n);const r=e.split(/ /g);let s=this;for(const o of r)s=W._pushAttributed(s,o,n);return s}static _pushAttributed(e,n,r){const s=r.getMetadataForScope(n),o=e.scopePath.push(n),a=r.themeProvider.themeMatch(o),i=W.mergeAttributes(e.tokenAttributes,s,a);return new W(e,o,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},Ot=class ae{constructor(e,n,r,s,o,a,i,l){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=a,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new ae(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:ae._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Re.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){ae._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,s,o,a,i){return new ae(this,e,n,r,s,o,a,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new ae(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=Re.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new ae(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Re.fromExtension(r,n.contentNameScopesList))}},Ua=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Ve(n,Qe).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>Ve(n,Qe).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},za=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=t?.getScopeNames()??[];for(const a of this._tokenTypeOverrides)a.matcher(o)&&(r=de.set(r,0,a.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=de.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},Wa=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,s){if(!this._grammars.has(t)){let o=this._rawGrammars.get(t);if(!o)return null;this._grammars.set(t,Ba(t,o,e,n,r,s,this,this._onigLib))}return this._grammars.get(t)}},qa=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Wa(He.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(He.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,r){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,n,r){return this._loadGrammar(e,n,r.embeddedLanguages,r.tokenTypes,new Ua(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,s,o){const a=new Ca(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(i=>this._loadSingleGrammar(i.scopeName)),a.processQueue();return this._grammarForScopeName(e,n,r,s,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(e,n=[],r=0,s=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,r,s)}_grammarForScopeName(e,n=0,r=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(e,n,r,s,o)}},Gt=Ot.NULL;const Ha=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Ne{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}Ne.prototype.normal={},Ne.prototype.property={},Ne.prototype.space=void 0;function vr(t,e){const n={},r={};for(const s of t)Object.assign(n,s.property),Object.assign(r,s.normal);return new Ne(n,r,e)}function Dt(t){return t.toLowerCase()}class O{constructor(e,n){this.attribute=n,this.property=e}}O.prototype.attribute="",O.prototype.booleanish=!1,O.prototype.boolean=!1,O.prototype.commaOrSpaceSeparated=!1,O.prototype.commaSeparated=!1,O.prototype.defined=!1,O.prototype.mustUseProperty=!1,O.prototype.number=!1,O.prototype.overloadedBoolean=!1,O.prototype.property="",O.prototype.spaceSeparated=!1,O.prototype.space=void 0;let Va=0;const v=se(),I=se(),Bt=se(),b=se(),x=se(),pe=se(),G=se();function se(){return 2**++Va}var Ft=Object.freeze({__proto__:null,boolean:v,booleanish:I,commaOrSpaceSeparated:G,commaSeparated:pe,number:b,overloadedBoolean:Bt,spaceSeparated:x});const jt=Object.keys(Ft);class Ut extends O{constructor(e,n,r,s){let o=-1;if(super(e,n),xr(this,"space",s),typeof r=="number")for(;++o<jt.length;){const a=jt[o];xr(this,jt[o],(r&Ft[a])===Ft[a])}}}Ut.prototype.defined=!0;function xr(t,e,n){n&&(t[e]=n)}function ge(t){const e={},n={};for(const[r,s]of Object.entries(t.properties)){const o=new Ut(r,t.transform(t.attributes||{},r),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),e[r]=o,n[Dt(r)]=r,n[Dt(o.attribute)]=r}return new Ne(e,n,t.space)}const Er=ge({properties:{ariaActiveDescendant:null,ariaAtomic:I,ariaAutoComplete:null,ariaBusy:I,ariaChecked:I,ariaColCount:b,ariaColIndex:b,ariaColSpan:b,ariaControls:x,ariaCurrent:null,ariaDescribedBy:x,ariaDetails:null,ariaDisabled:I,ariaDropEffect:x,ariaErrorMessage:null,ariaExpanded:I,ariaFlowTo:x,ariaGrabbed:I,ariaHasPopup:null,ariaHidden:I,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:x,ariaLevel:b,ariaLive:null,ariaModal:I,ariaMultiLine:I,ariaMultiSelectable:I,ariaOrientation:null,ariaOwns:x,ariaPlaceholder:null,ariaPosInSet:b,ariaPressed:I,ariaReadOnly:I,ariaRelevant:null,ariaRequired:I,ariaRoleDescription:x,ariaRowCount:b,ariaRowIndex:b,ariaRowSpan:b,ariaSelected:I,ariaSetSize:b,ariaSort:null,ariaValueMax:b,ariaValueMin:b,ariaValueNow:b,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function Ar(t,e){return e in t?t[e]:e}function Ir(t,e){return Ar(t,e.toLowerCase())}const Xa=ge({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:pe,acceptCharset:x,accessKey:x,action:null,allow:null,allowFullScreen:v,allowPaymentRequest:v,allowUserMedia:v,alt:null,as:null,async:v,autoCapitalize:null,autoComplete:x,autoFocus:v,autoPlay:v,blocking:x,capture:null,charSet:null,checked:v,cite:null,className:x,cols:b,colSpan:null,content:null,contentEditable:I,controls:v,controlsList:x,coords:b|pe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:v,defer:v,dir:null,dirName:null,disabled:v,download:Bt,draggable:I,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:v,formTarget:null,headers:x,height:b,hidden:Bt,high:b,href:null,hrefLang:null,htmlFor:x,httpEquiv:x,id:null,imageSizes:null,imageSrcSet:null,inert:v,inputMode:null,integrity:null,is:null,isMap:v,itemId:null,itemProp:x,itemRef:x,itemScope:v,itemType:x,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:v,low:b,manifest:null,max:null,maxLength:b,media:null,method:null,min:null,minLength:b,multiple:v,muted:v,name:null,nonce:null,noModule:v,noValidate:v,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:v,optimum:b,pattern:null,ping:x,placeholder:null,playsInline:v,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:v,referrerPolicy:null,rel:x,required:v,reversed:v,rows:b,rowSpan:b,sandbox:x,scope:null,scoped:v,seamless:v,selected:v,shadowRootClonable:v,shadowRootDelegatesFocus:v,shadowRootMode:null,shape:null,size:b,sizes:null,slot:null,span:b,spellCheck:I,src:null,srcDoc:null,srcLang:null,srcSet:null,start:b,step:null,style:null,tabIndex:b,target:null,title:null,translate:null,type:null,typeMustMatch:v,useMap:null,value:I,width:b,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:x,axis:null,background:null,bgColor:null,border:b,borderColor:null,bottomMargin:b,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:v,declare:v,event:null,face:null,frame:null,frameBorder:null,hSpace:b,leftMargin:b,link:null,longDesc:null,lowSrc:null,marginHeight:b,marginWidth:b,noResize:v,noHref:v,noShade:v,noWrap:v,object:null,profile:null,prompt:null,rev:null,rightMargin:b,rules:null,scheme:null,scrolling:I,standby:null,summary:null,text:null,topMargin:b,valueType:null,version:null,vAlign:null,vLink:null,vSpace:b,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:v,disableRemotePlayback:v,prefix:null,property:null,results:b,security:null,unselectable:null},space:"html",transform:Ir}),Ka=ge({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:G,accentHeight:b,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:b,amplitude:b,arabicForm:null,ascent:b,attributeName:null,attributeType:null,azimuth:b,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:b,by:null,calcMode:null,capHeight:b,className:x,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:b,diffuseConstant:b,direction:null,display:null,dur:null,divisor:b,dominantBaseline:null,download:v,dx:null,dy:null,edgeMode:null,editable:null,elevation:b,enableBackground:null,end:null,event:null,exponent:b,externalResourcesRequired:null,fill:null,fillOpacity:b,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:pe,g2:pe,glyphName:pe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:b,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:b,horizOriginX:b,horizOriginY:b,id:null,ideographic:b,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:b,k:b,k1:b,k2:b,k3:b,k4:b,kernelMatrix:G,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:b,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:b,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:b,overlineThickness:b,paintOrder:null,panose1:null,path:null,pathLength:b,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:x,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:b,pointsAtY:b,pointsAtZ:b,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:G,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:G,rev:G,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:G,requiredFeatures:G,requiredFonts:G,requiredFormats:G,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:b,specularExponent:b,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:b,strikethroughThickness:b,string:null,stroke:null,strokeDashArray:G,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:b,strokeOpacity:b,strokeWidth:null,style:null,surfaceScale:b,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:G,tabIndex:b,tableValues:null,target:null,targetX:b,targetY:b,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:G,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:b,underlineThickness:b,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:b,values:null,vAlphabetic:b,vMathematical:b,vectorEffect:null,vHanging:b,vIdeographic:b,version:null,vertAdvY:b,vertOriginX:b,vertOriginY:b,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:b,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ar}),Rr=ge({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),Nr=ge({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ir}),$r=ge({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),Za=/[A-Z]/g,Pr=/-[a-z]/g,Qa=/^data[-\w.:]+$/i;function Ya(t,e){const n=Dt(e);let r=e,s=O;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Qa.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(Pr,ei);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!Pr.test(o)){let a=o.replace(Za,Ja);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}s=Ut}return new s(r,e)}function Ja(t){return"-"+t.toLowerCase()}function ei(t){return t.charAt(1).toUpperCase()}const ti=vr([Er,Xa,Rr,Nr,$r],"html"),Lr=vr([Er,Ka,Rr,Nr,$r],"svg"),Tr={}.hasOwnProperty;function ni(t,e){const n=e||{};function r(s,...o){let a=r.invalid;const i=r.handlers;if(s&&Tr.call(s,t)){const l=String(s[t]);a=Tr.call(i,l)?i[l]:r.unknown}if(a)return a.call(this,s,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const ri=/["&'<>`]/g,si=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,oi=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ai=/[|\\{}()[\]^$+*?.]/g,Mr=new WeakMap;function ii(t,e){if(t=t.replace(e.subset?li(e.subset):ri,r),e.subset||e.escapeOnly)return t;return t.replace(si,n).replace(oi,r);function n(s,o,a){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,a.charCodeAt(o+2),e)}function r(s,o,a){return e.format(s.charCodeAt(0),a.charCodeAt(o+1),e)}}function li(t){let e=Mr.get(t);return e||(e=ci(t),Mr.set(t,e)),e}function ci(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(ai,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const ui=/[\dA-Fa-f]/;function hi(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!ui.test(String.fromCharCode(e))?r:r+";"}const fi=/\d/;function di(t,e,n){const r="&#"+String(t);return n&&e&&!fi.test(String.fromCharCode(e))?r:r+";"}const pi=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],zt={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},gi=["cent","copy","divide","gt","lt","not","para","times"],Or={}.hasOwnProperty,Wt={};let Ye;for(Ye in zt)Or.call(zt,Ye)&&(Wt[zt[Ye]]=Ye);const mi=/[^\dA-Za-z]/;function yi(t,e,n,r){const s=String.fromCharCode(t);if(Or.call(Wt,s)){const o=Wt[s],a="&"+o;return n&&pi.includes(o)&&!gi.includes(o)&&(!r||e&&e!==61&&mi.test(String.fromCharCode(e)))?a:a+";"}return""}function bi(t,e,n){let r=hi(t,e,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=yi(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const o=di(t,e,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function me(t,e){return ii(t,Object.assign({format:bi},e))}const wi=/^>|^->|<!--|-->|--!>|<!-$/g,Ci=[">"],_i=["<",">"];function Si(t,e,n,r){return r.settings.bogusComments?"<?"+me(t.value,Object.assign({},r.settings.characterReferences,{subset:Ci}))+">":"<!--"+t.value.replace(wi,s)+"-->";function s(o){return me(o,Object.assign({},r.settings.characterReferences,{subset:_i}))}}function ki(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function Gr(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(e);for(;s!==-1;)r++,s=n.indexOf(e,s+e.length);return r}function vi(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function xi(t){return t.join(" ").trim()}const Ei=/[ \t\n\f\r]/g;function qt(t){return typeof t=="object"?t.type==="text"?Dr(t.value):!1:Dr(t)}function Dr(t){return t.replace(Ei,"")===""}const N=Fr(1),Br=Fr(-1),Ai=[];function Fr(t){return e;function e(n,r,s){const o=n?n.children:Ai;let a=(r||0)+t,i=o[a];if(!s)for(;i&&qt(i);)a+=t,i=o[a];return i}}const Ii={}.hasOwnProperty;function jr(t){return e;function e(n,r,s){return Ii.call(t,n.tagName)&&t[n.tagName](n,r,s)}}const Ht=jr({body:Ni,caption:Vt,colgroup:Vt,dd:Ti,dt:Li,head:Vt,html:Ri,li:Pi,optgroup:Mi,option:Oi,p:$i,rp:Ur,rt:Ur,tbody:Di,td:zr,tfoot:Bi,th:zr,thead:Gi,tr:Fi});function Vt(t,e,n){const r=N(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&qt(r.value.charAt(0)))}function Ri(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function Ni(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function $i(t,e,n){const r=N(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function Pi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="li"}function Li(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Ti(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Ur(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Mi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function Oi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Gi(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Di(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Bi(t,e,n){return!N(n,e)}function Fi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function zr(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const ji=jr({body:Wi,colgroup:qi,head:zi,html:Ui,tbody:Hi});function Ui(t){const e=N(t,-1);return!e||e.type!=="comment"}function zi(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function Wi(t){const e=N(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&qt(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function qi(t,e,n){const r=Br(n,e),s=N(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Ht(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function Hi(t,e,n){const r=Br(n,e),s=N(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Ht(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const Je={name:[[`
|
|
141
|
+
\v\f
\u2028\u2029])`),e));else if(l==="posix")if(!s&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let h={graph:"!-~",print:" -~"}[u];c&&(h=`\0-${R(h.codePointAt(0)-1)}${R(h.codePointAt(2)+1)}-`),n(A(V(`[${h}]`),e))}else n(A(Ct(V(Ao.get(u)),c),e));else if(l==="property")en.has(it(u))||(t.key="sc");else if(l==="space")n(Y(he("space",{negate:c}),e));else if(l==="word")n(A(Ct(V(H),c),e));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:t,parent:e,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:a}){const{kind:i,flags:l}=t;if(i==="flags")if(!l.enable&&!l.disable)r();else{const c=z({flags:l});c.body[0].body=a(),s(A(c,e),{traverse:!0})}else if(i==="keep"){const c=n.body[0],h=n.body.length===1&&mr(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(e.parent!==h||h.body.length>1)throw new Error(k`Uses "\K" in a way that's unsupported`);const f=ne({behind:!0});f.body[0].body=o(),s(A(f,e))}else throw new Error(`Unexpected directive kind "${i}"`)},Flags({node:t,parent:e}){if(t.posixIsAscii)throw new Error('Unsupported flag "P"');if(t.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete t[n]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:n}=t.flags;e?.extended&&delete e.extended,n?.extended&&delete n.extended,e?.dotAll&&n?.dotAll&&delete e.dotAll,e?.ignoreCase&&n?.ignoreCase&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,n&&!Object.keys(n).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},LookaroundAssertion({node:t},e){const{kind:n}=t;n==="lookbehind"&&(e.passedLookbehind=!0)},NamedCallout({node:t,parent:e,replaceWith:n}){const{kind:r}=t;if(r==="fail")n(A(ne({negate:!0}),e));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:t}){if(t.body.type==="Quantifier"){const e=z();e.body[0].body.push(t.body),t.body=A(e,t)}},Regex:{enter({node:t},{supportedGNodes:e}){const n=[];let r=!1,s=!1;for(const o of t.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const a=Pr(o.body);a?(r=!0,Array.isArray(a)?n.push(...a):n.push(a)):s=!0}r&&!s&&n.forEach(o=>e.add(o))},exit(t,{accuracy:e,passedLookbehind:n,strategy:r}){if(e==="strict"&&n&&r)throw new Error(k`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!wt(n)&&(n=bt(n,e),t.ref=n)}},$o={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=t;r||n.set(t,[...e.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:t,parent:e,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:a,openRefs:i,reffedNodesByReferencer:l}){const c=s.get(t);if(c&&i.has(t.number)){const h=Y(Rn(t.number),e);l.set(h,i.get(t.number)),n(h);return}i.set(t.number,t),a.set(t.number,[]),t.name&&Ae(a,t.name,[]);const u=a.get(t.name??t.number);for(let h=0;h<u.length;h++){const f=u[h];if(c===f.node||c&&c===f.origin||t===f.origin){u.splice(h,1);break}}if(a.get(t.number).push({node:t,origin:c}),t.name&&a.get(t.name).push({node:t,origin:c}),t.name){const h=Ae(o,t.name,new Map);let f=!1;if(c)f=!0;else for(const d of h.values())if(!d.hasDuplicateNameToRemove){f=!0;break}o.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:f})}},exit({node:t},{openRefs:e}){e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=Xe(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Subroutine({node:t,parent:e,replaceWith:n},r){const{isRecursive:s,ref:o}=t;if(s){let u=e;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===o||u.number===o)););r.reffedNodesByReferencer.set(t,u);return}const a=r.subroutineRefMap.get(o),i=o===0,l=i?Rn(0):Rr(a,r.groupOriginByCopy,null);let c=l;if(!i){const u=Nr(Mo(a,f=>f.type==="Group"&&!!f.flags)),h=u?Xe(r.globalFlags,u):r.globalFlags;Lo(h,r.currentFlags)||(c=z({flags:Oo(h)}),c.body[0].body.push(l))}n(A(c,e),{traverse:!i})}},Po={Backreference({node:t,parent:e,replaceWith:n},r){if(t.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,t.ref);return}const o=r.reffedNodesByReferencer.get(t).filter(a=>To(a,t));if(!o.length)n(A(ne({negate:!0}),e));else if(o.length>1){const a=z({atomic:!0,body:o.reverse().map(i=>oe({body:[Pt(i.number)]}))});n(A(a,e))}else t.ref=o[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Regex:{exit({node:t},e){const n=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=br();t.body.at(-1).body.push(s)}}},Subroutine({node:t},e){!t.isRecursive||t.ref===0||(t.ref=e.reffedNodesByReferencer.get(t).number)}};function Ir(t){xe(t,{"*"({node:e,parent:n}){e.parent=n}})}function Lo(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function To(t,e){let n=e;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===t)return!1;const r=$r(n.parent);for(const s of r){if(s===n)break;if(s===t||Lr(s,t))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Rr(t,e,n,r){const s=Array.isArray(t)?[]:{};for(const[o,a]of Object.entries(t))o==="parent"?s.parent=Array.isArray(n)?r:n:a&&typeof a=="object"?s[o]=Rr(a,e,s,n):(o==="type"&&a==="CapturingGroup"&&e.set(s,e.get(t)??t),s[o]=a);return s}function Rn(t){const e=Cr(t);return e.isRecursive=!0,e}function Mo(t,e){const n=[];for(;t=t.parent;)(!e||e(t))&&n.push(t);return n}function bt(t,e){if(e.has(t))return e.get(t);const n=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,n),n}function Nr(t){const e=["dotAll","ignoreCase"],n={enable:{},disable:{}};return t.forEach(({flags:r})=>{e.forEach(s=>{r.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),r.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Oo({dotAll:t,ignoreCase:e}){const n={};return(t||e)&&(n.enable={},t&&(n.enable.dotAll=!0),e&&(n.enable.ignoreCase=!0)),(!t||!e)&&(n.disable={},!t&&(n.disable.dotAll=!0),!e&&(n.disable.ignoreCase=!0)),n}function $r(t){if(!t)throw new Error("Node expected");const{body:e}=t;return Array.isArray(e)?e:e?[e]:null}function Pr(t){const e=t.find(n=>n.kind==="search_start"||Bo(n,{negate:!1})||!Go(n));if(!e)return null;if(e.kind==="search_start")return e;if(e.type==="LookaroundAssertion")return e.body[0].body[0];if(e.type==="CapturingGroup"||e.type==="Group"){const n=[];for(const r of e.body){const s=Pr(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function Lr(t,e){const n=$r(t)??[];for(const r of n)if(r===e||Lr(r,e))return!0;return!1}function Go({type:t}){return t==="Assertion"||t==="Directive"||t==="LookaroundAssertion"}function Do(t){const e=["Character","CharacterClass","CharacterSet"];return e.includes(t.type)||t.type==="Quantifier"&&t.min&&e.includes(t.body.type)}function Bo(t,e){const n={negate:null,...e};return t.type==="LookaroundAssertion"&&(n.negate===null||t.negate===n.negate)&&t.body.length===1&&mr(t.body[0],{type:"Assertion",kind:"search_start"})}function wt(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function V(t,e){const r=yr(t,{...e,unicodePropertyMap:en}).body;return r.length>1||r[0].body.length>1?z({body:r}):r[0].body[0]}function Ct(t,e){return t.negate=e,t}function Y(t,e){return t.parent=e,t}function A(t,e){return Ir(t),t.parent=e,t}function Fo(t,e){const n=xr(e),r=Mt(n.target,"ES2024"),s=Mt(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let a=null,i=null;if(!s){const d=[t.flags.ignoreCase];xe(t,jo,{getCurrentModI:()=>d.at(-1),popModI(){d.pop()},pushModI(p){d.push(p)},setHasCasedChar(){d.at(-1)?a=!0:i=!0}})}const l={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||a)&&!i)};let c=t;const u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:t._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&a&&i),useFlagMods:s,useFlagV:r,verbose:n.verbose};function h(d){return u.lastNode=c,c=d,Co(Uo[d.type],`Unexpected node type "${d.type}"`)(d,u,h)}const f={pattern:t.body.map(h).join("|"),flags:h(t.flags),options:{...t.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((d,p)=>{d.hidden&&f._hiddenCaptures.push(p),d.transferTo&&Ae(f._captureTransfers,d.transferTo,[]).push(p)}),f}var jo={"*":{enter({node:t},e){if($n(t)){const n=e.getCurrentModI();e.pushModI(t.flags?Xe({ignoreCase:n},t.flags).ignoreCase:n)}},exit({node:t},e){$n(t)&&e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){tn(R(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},n){e(),Tr(t,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:t},e){t.kind==="property"&&Ar.has(t.value)&&e.setHasCasedChar()}},Uo={Alternative({body:t},e,n){return t.map(n).join("")},Assertion({kind:t,negate:e}){if(t==="string_end")return"$";if(t==="string_start")return"^";if(t==="word_boundary")return e?k`\B`:k`\b`;throw new Error(`Unexpected assertion kind "${t}"`)},Backreference({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t},CapturingGroup(t,e,n){const{body:r,name:s,number:o}=t,a={ignoreCase:e.currentFlags.ignoreCase},i=e.originMap.get(t);return i&&(a.hidden=!0,o>i.number&&(a.transferTo=i.number)),e.captureMap.set(o,a),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:t},e){const n=R(t),r=ce(t,{escDigit:e.lastNode.type==="Backreference",inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(r!==n)return r;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&tn(n)){const s=Er(n);return e.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(t,e,n){const{kind:r,negate:s,parent:o}=t;let{body:a}=t;if(r==="intersection"&&!e.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");K.bugFlagVLiteralHyphenIsRange&&e.useFlagV&&a.some(Pn)&&(a=[at(45),...a.filter(c=>!Pn(c))]);const i=()=>`[${s?"^":""}${a.map(n).join(r==="intersection"?"&&":"")}]`;if(!e.inCharClass){if((!e.useFlagV||K.bugNestedClassIgnoresNegation)&&!s){const u=a.filter(h=>h.type==="CharacterClass"&&h.kind==="union"&&h.negate);if(u.length){const h=z(),f=h.body[0];return h.parent=o,f.parent=h,a=a.filter(d=>!u.includes(d)),t.body=a,a.length?(t.parent=f,f.body.push(t)):h.body.pop(),u.forEach(d=>{const p=oe({body:[d]});d.parent=p,p.parent=h,h.body.push(p)}),n(h)}}e.inCharClass=!0;const c=i();return e.inCharClass=!1,c}const l=a[0];if(r==="union"&&!s&&l&&((!e.useFlagV||!e.verbose)&&o.kind==="union"&&!(K.bugFlagVLiteralHyphenIsRange&&e.useFlagV)||!e.verbose&&o.kind==="intersection"&&a.length===1&&l.type!=="CharacterClassRange"))return a.map(n).join("");if(!e.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return i()},CharacterClassRange(t,e){const n=t.min.value,r=t.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:e.useFlagV},o=ce(n,s),a=ce(r,s),i=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const l=Tr(t);Vo(l).forEach(u=>{i.add(Array.isArray(u)?`${ce(u[0],s)}-${ce(u[1],s)}`:ce(u,s))})}return`${o}-${a}${[...i].join("")}`},CharacterSet({kind:t,negate:e,value:n,key:r},s){if(t==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":k`[^\n]`;if(t==="digit")return e?k`\D`:k`\d`;if(t==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&Ar.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${e?k`\P`:k`\p`}{${r?`${r}=`:""}${n}}`}if(t==="word")return e?k`\W`:k`\w`;throw new Error(`Unexpected character set kind "${t}"`)},Flags(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")},Group({atomic:t,body:e,flags:n,parent:r},s,o){const a=s.currentFlags;n&&(s.currentFlags=Xe(a,n));const i=e.map(o).join("|"),l=!s.verbose&&e.length===1&&r.type!=="Quantifier"&&!t&&(!s.useFlagMods||!n)?i:`(?${Xo(t,n,s.useFlagMods)}${i})`;return s.currentFlags=a,l},LookaroundAssertion({body:t,kind:e,negate:n},r,s){return`(?${`${e==="lookahead"?"":"<"}${n?"!":"="}`}${t.map(s).join("|")})`},Quantifier(t,e,n){return n(t.body)+Ko(t)},Subroutine({isRecursive:t,ref:e},n){if(!t)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return e===0?`(?R=${r})`:k`\g<${e}&R=${r}>`}},zo=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Wo=new Set(["-","\\","]","^","["]),qo=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Nn=new Map([[9,k`\t`],[10,k`\n`],[11,k`\v`],[12,k`\f`],[13,k`\r`],[8232,k`\u2028`],[8233,k`\u2029`],[65279,k`\uFEFF`]]),Ho=new RegExp("^\\p{Cased}$","u");function tn(t){return Ho.test(t)}function Tr(t,e){const n=!!e?.firstOnly,r=t.min.value,s=t.max.value,o=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return o;for(let a=r;a<=s;a++){const i=R(a);if(!tn(i))continue;const l=Er(i).filter(c=>{const u=c.codePointAt(0);return u<r||u>s});if(l.length&&(o.push(...l),n))break}return o}function ce(t,{escDigit:e,inCharClass:n,useFlagV:r}){if(Nn.has(t))return Nn.get(t);if(t<32||t>126&&t<160||t>262143||e&&Zo(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?qo:Wo:zo,o=R(t);return(s.has(o)?"\\":"")+o}function Vo(t){const e=t.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),n=[];let r=null;for(let s=0;s<e.length;s++)e[s+1]===e[s]+1?r??=e[s]:r===null?n.push(e[s]):(n.push([r,e[s]]),r=null);return n}function Xo(t,e,n){if(t)return">";let r="";if(e&&n){const{enable:s,disable:o}=e;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function Ko({kind:t,max:e,min:n}){let r;return!n&&e===1?r="?":!n&&e===1/0?r="*":n===1&&e===1/0?r="+":n===e?r=`{${n}}`:r=`{${n},${e===1/0?"":e}}`,r+{greedy:"",lazy:"?",possessive:"+"}[t]}function $n({type:t}){return t==="CapturingGroup"||t==="Group"||t==="LookaroundAssertion"}function Zo(t){return t>47&&t<58}function Pn({type:t,value:e}){return t==="Character"&&e===45}var Qo=class Ot extends RegExp{#t=new Map;#e=null;#r;#n=null;#s=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(e,n,r){const s=!!r?.lazyCompile;if(e instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const o=e;super(o,n),this.#r=o.source,o instanceof Ot&&(this.#t=o.#t,this.#n=o.#n,this.#s=o.#s,this.rawOptions=o.rawOptions)}else{const o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":e,n),this.#r=e,this.#t=Jo(o.hiddenCaptures,o.transfers),this.#s=o.strategy,this.rawOptions=r??{}}s||(this.#e=this)}exec(e){if(!this.#e){const{lazyCompile:s,...o}=this.rawOptions;this.#e=new Ot(this.#r,this.flags,o)}const n=this.global||this.sticky,r=this.lastIndex;if(this.#s==="clip_search"&&n&&r){this.lastIndex=0;const s=this.#o(e.slice(r));return s&&(Yo(s,r,e,this.hasIndices),this.lastIndex+=r),s}return this.#o(e)}#o(e){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,e);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const r=[...n];n.length=1;let s;this.hasIndices&&(s=[...n.indices],n.indices.length=1);const o=[0];for(let a=1;a<r.length;a++){const{hidden:i,transferTo:l}=this.#t.get(a)??{};if(i?o.push(null):(o.push(n.length),n.push(r[a]),this.hasIndices&&n.indices.push(s[a])),l&&r[a]!==void 0){const c=o[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[a],this.hasIndices&&(n.indices[c]=s[a]),n.groups){this.#n||(this.#n=ea(this.source));const u=this.#n.get(l);u&&(n.groups[u]=r[a],this.hasIndices&&(n.indices.groups[u]=s[a]))}}}return n}};function Yo(t,e,n,r){if(t.index+=e,t.input=n,r){const s=t.indices;for(let a=0;a<s.length;a++){const i=s[a];i&&(s[a]=[i[0]+e,i[1]+e])}const o=s.groups;o&&Object.keys(o).forEach(a=>{const i=o[a];i&&(o[a]=[i[0]+e,i[1]+e])})}}function Jo(t,e){const n=new Map;for(const r of t)n.set(r,{hidden:!0});for(const[r,s]of e)for(const o of s)Ae(n,o,{}).transferTo=r;return n}function ea(t){const e=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,s=0,o;for(;o=e.exec(t);){const{0:a,groups:{capture:i,name:l}}=o;a==="["?r++:r?a==="]"&&r--:i&&(s++,l&&n.set(s,l))}return n}function ta(t,e){const n=na(t,e);return n.options?new Qo(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function na(t,e){const n=xr(e),r=yr(t,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:en}),s=Ro(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=Fo(s,n),a=bo(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),i=mo(a.pattern),l=go(i.pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const u=l.hiddenCaptures.sort((p,w)=>p-w),h=Array.from(l.captureTransfers),f=s._strategy,d=c.pattern.length>=n.lazyCompileLength;(u.length||h.length||f||d)&&(c.options={...u.length&&{hiddenCaptures:u},...h.length&&{transfers:h},...f&&{strategy:f},...d&&{lazyCompile:d}})}return c}const Ln=4294967295;class ra{constructor(e,n={}){this.patterns=e,this.options=n;const{forgiving:r=!1,cache:s,regexConstructor:o}=n;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(a=>{if(typeof a!="string")return a;const i=s?.get(a);if(i){if(i instanceof RegExp)return i;if(r)return null;throw i}try{const l=o(a);return s?.set(a,l),l}catch(l){if(s?.set(a,l),r)return null;throw l}})}regexps;findNextMatchSync(e,n,r){const s=typeof e=="string"?e:e.content,o=[];function a(i,l,c=0){return{index:i,captureIndices:l.indices.map(u=>u==null?{start:Ln,end:Ln,length:0}:{start:u[0]+c,end:u[1]+c,length:u[1]-u[0]})}}for(let i=0;i<this.regexps.length;i++){const l=this.regexps[i];if(l)try{l.lastIndex=n;const c=l.exec(s);if(!c)continue;if(c.index===n)return a(i,c,0);o.push([i,c,0])}catch(c){if(this.options.forgiving)continue;throw c}}if(o.length){const i=Math.min(...o.map(l=>l[1].index));for(const[l,c,u]of o)if(c.index===i)return a(l,c,u)}return null}}function sa(t,e){return ta(t,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function oa(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||=n=>sa(n,{target:e.target}),{createScanner(n){return new ra(n,e)},createString(n){return{content:n}}}}let $=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function aa(t){return nn(t)}function nn(t){return Array.isArray(t)?ia(t):t instanceof RegExp?t:typeof t=="object"?la(t):t}function ia(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=nn(t[n]);return e}function la(t){let e={};for(let n in t)e[n]=nn(t[n]);return e}function Mr(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function Or(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Or(t.substring(0,t.length-1)):t.substr(~e+1)}var _t=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,je=class{static hasCaptures(t){return t===null?!1:(_t.lastIndex=0,_t.test(t))}static replaceCaptures(t,e,n){return t.replace(_t,(r,s,o,a)=>{let i=n[parseInt(s||o,10)];if(i){let l=e.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(a){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Gr(t,e){return t<e?-1:t>e?1:0}function Dr(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let o=Gr(t[s],e[s]);if(o!==0)return o}return 0}return n-r}function Tn(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function Br(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Fr=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},Ke=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(ha(t),e)}static createFromParsedTheme(t,e){return da(t,e)}_cachedMatchRoot=new Fr(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,r=this._cachedMatchRoot.get(e).find(s=>ca(t.parent,s.parentScopes));return r?new jr(r.fontStyle,r.foreground,r.background):null}},St=class He{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new He(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new He(n,e[r]);return n}push(e){return new He(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function ca(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}for(;t&&!ua(t.scopeName,r);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function ua(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var jr=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function ha(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,o=e.length;s<o;s++){let a=e[s];if(!a.settings)continue;let i;if(typeof a.scope=="string"){let h=a.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),i=h.split(",")}else Array.isArray(a.scope)?i=a.scope:i=[""];let l=-1;if(typeof a.settings.fontStyle=="string"){l=0;let h=a.settings.fontStyle.split(" ");for(let f=0,d=h.length;f<d;f++)switch(h[f]){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 a.settings.foreground=="string"&&Tn(a.settings.foreground)&&(c=a.settings.foreground);let u=null;typeof a.settings.background=="string"&&Tn(a.settings.background)&&(u=a.settings.background);for(let h=0,f=i.length;h<f;h++){let p=i[h].trim().split(" "),w=p[p.length-1],C=null;p.length>1&&(C=p.slice(0,p.length-1),C.reverse()),n[r++]=new fa(w,C,s,l,c,u)}}return n}var fa=class{constructor(t,e,n,r,s,o){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}},M=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(M||{});function da(t,e){t.sort((l,c)=>{let u=Gr(l.scope,c.scope);return u!==0||(u=Dr(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let l=t.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(s=l.background)}let o=new pa(e),a=new jr(n,o.getId(r),o.getId(s)),i=new ma(new Gt(0,null,-1,0,0),[]);for(let l=0,c=t.length;l<c;l++){let u=t[l];i.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new Ke(o,a,i)}var pa=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},ga=Object.freeze([]),Gt=class Ur{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,o){this.scopeDepth=e,this.parentScopes=n||ga,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new Ur(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},ma=class Dt{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=e.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-e.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,o;if(r===-1?(s=e,o=""):(s=e.substring(0,r),o=e.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Dt._cmpBySpecificity),n}insert(e,n,r,s,o,a){if(n===""){this._doInsertHere(e,r,s,o,a);return}let i=n.indexOf("."),l,c;i===-1?(l=n,c=""):(l=n.substring(0,i),c=n.substring(i+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new Dt(this._mainRule.clone(),Gt.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(e+1,c,r,s,o,a)}_doInsertHere(e,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(e,r,s,o);return}for(let a=0,i=this._rulesWithParentScopes.length;a<i;a++){let l=this._rulesWithParentScopes[a];if(Dr(l.parentScopes,n)===0){l.acceptOverwrite(e,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Gt(e,n,r,s,o))}},ge=class F{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=F.getLanguageId(e),r=F.getTokenType(e),s=F.getFontStyle(e),o=F.getForeground(e),a=F.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:a})}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,n,r,s,o,a,i){let l=F.getLanguageId(e),c=F.getTokenType(e),u=F.containsBalancedBrackets(e)?1:0,h=F.getFontStyle(e),f=F.getForeground(e),d=F.getBackground(e);return n!==0&&(l=n),r!==8&&(c=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),a!==0&&(f=a),i!==0&&(d=i),(l<<0|c<<8|u<<10|h<<11|f<<15|d<<24)>>>0}};function Ze(t,e){const n=[],r=ya(t);let s=r.next();for(;s!==null;){let l=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let c=a();if(n.push({matcher:c,priority:l}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const l=o();return c=>!!l&&!l(c)}if(s==="("){s=r.next();const l=i();return s===")"&&(s=r.next()),l}if(Mn(s)){const l=[];do l.push(s),s=r.next();while(Mn(s));return c=>e(l,c)}return null}function a(){const l=[];let c=o();for(;c;)l.push(c),c=o();return u=>l.every(h=>h(u))}function i(){const l=[];let c=a();for(;c&&(l.push(c),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");c=a()}return u=>l.some(h=>h(u))}}function Mn(t){return!!t&&!!t.match(/[\w\.:]+/)}function ya(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function zr(t){typeof t.dispose=="function"&&t.dispose()}var Ie=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},ba=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},wa=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},Ca=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Ie(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new wa;for(const n of t)_a(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof Ie){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function _a(t,e,n,r){const s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const o=n.lookup(e);t instanceof Ie?Ve({baseGrammar:o,selfGrammar:s},r):Bt(t.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const a=n.injections(t.scopeName);if(a)for(const i of a)r.add(new Ie(i))}function Bt(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];Qe([r],e,n)}}function Ve(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Qe(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Qe(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Qe(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?Mr({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&Qe(r.patterns,{...e,repository:s},n);const o=r.include;if(!o)continue;const a=Wr(o);switch(a.kind){case 0:Ve({...e,selfGrammar:e.baseGrammar},n);break;case 1:Ve(e,n);break;case 2:Bt(a.ruleName,{...e,repository:s},n);break;case 3:case 4:const i=a.scopeName===e.selfGrammar.scopeName?e.selfGrammar:a.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(i){const l={baseGrammar:e.baseGrammar,selfGrammar:i,repository:s};a.kind===4?Bt(a.ruleName,l,n):Ve(l,n)}else a.kind===4?n.add(new ba(a.scopeName,a.ruleName)):n.add(new Ie(a.scopeName));break}}}var Sa=class{kind=0},ka=class{kind=1},va=class{constructor(t){this.ruleName=t}kind=2},xa=class{constructor(t){this.scopeName=t}kind=3},Ea=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Wr(t){if(t==="$base")return new Sa;if(t==="$self")return new ka;const e=t.indexOf("#");if(e===-1)return new xa(t);if(e===0)return new va(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new Ea(n,r)}}var Aa=/\\(\d+)/,On=/\\(\d+)/g,Ia=-1,qr=-2;var Te=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=je.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=je.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${Or(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:je.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:je.replaceCaptures(this._contentName,t,e)}},Ra=class extends Te{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},Na=class extends Te{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null),this._match=new Re(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ne,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Gn=class extends Te{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ne,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ft=class extends Te{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,o,a,i,l,c){super(t,e,n,r),this._begin=new Re(s,this.id),this.beginCaptures=o,this._end=new Re(a||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.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(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ne;for(const n of this.patterns)t.getRule(n).collectPatterns(t,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,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},Ye=class extends Te{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,o,a,i,l){super(t,e,n,r),this._begin=new Re(s,this.id),this.beginCaptures=o,this.whileCaptures=i,this._while=new Re(a,qr),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.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(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ne;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Ne,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||""),this._cachedCompiledWhilePatterns}},Hr=class T{static createCaptureRule(e,n,r,s,o){return e.registerRule(a=>new Ra(n,a,r,s,o))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(s=>{if(e.id=s,e.match)return new Na(e.$vscodeTextmateLocation,e.id,e.name,e.match,T._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=Mr({},r,e.repository));let o=e.patterns;return typeof o>"u"&&e.include&&(o=[{include:e.include}]),new Gn(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,T._compilePatterns(o,n,r))}return e.while?new Ye(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,T._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,T._compileCaptures(e.whileCaptures||e.captures,n,r),T._compilePatterns(e.patterns,n,r)):new Ft(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,T._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,T._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,T._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let s=[];if(e){let o=0;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const i=parseInt(a,10);i>o&&(o=i)}for(let a=0;a<=o;a++)s[a]=null;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const i=parseInt(a,10);let l=0;e[a].patterns&&(l=T.getCompiledRuleId(e[a],n,r)),s[i]=T.createCaptureRule(n,e[a].$vscodeTextmateLocation,e[a].name,e[a].contentName,l)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let o=0,a=e.length;o<a;o++){const i=e[o];let l=-1;if(i.include){const c=Wr(i.include);switch(c.kind){case 0:case 1:l=T.getCompiledRuleId(r[i.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=T.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=c.scopeName,f=c.kind===4?c.ruleName:null,d=n.getExternalGrammar(h,r);if(d)if(f){let p=d.repository[f];p&&(l=T.getCompiledRuleId(p,n,d.repository))}else l=T.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else l=T.getCompiledRuleId(i,n,r);if(l!==-1){const c=n.getRule(l);let u=!1;if((c instanceof Gn||c instanceof Ft||c instanceof Ye)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;s.push(l)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},Re=class Vr{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let s=0,o=[],a=!1;for(let i=0;i<r;i++)if(e.charAt(i)==="\\"&&i+1<r){const c=e.charAt(i+1);c==="z"?(o.push(e.substring(s,i)),o.push("$(?!\\n)(?<!\\n)"),s=i+2):(c==="A"||c==="G")&&(a=!0),i++}this.hasAnchor=a,s===0?this.source=e:(o.push(e.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Aa.test(this.source):this.hasBackReferences=!1}clone(){return new Vr(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>e.substring(s.start,s.end));return On.lastIndex=0,this.source.replace(On,(s,o)=>Br(r[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=[],n=[],r=[],s=[],o,a,i,l;for(o=0,a=this.source.length;o<a;o++)i=this.source.charAt(o),e[o]=i,n[o]=i,r[o]=i,s[o]=i,i==="\\"&&o+1<a&&(l=this.source.charAt(o+1),l==="A"?(e[o+1]="",n[o+1]="",r[o+1]="A",s[o+1]="A"):l==="G"?(e[o+1]="",n[o+1]="G",r[o+1]="",s[o+1]="G"):(e[o+1]=l,n[o+1]=l,r[o+1]=l,s[o+1]=l),o++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Ne=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){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(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new Dn(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(s=>s.resolveAnchors(e,n));return new Dn(t,r,this._items.map(s=>s.ruleId))}},Dn=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
|
|
142
|
+
`)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},kt=class{constructor(t,e){this.languageId=t,this.tokenType=e}},$a=class jt{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new kt(e,8),this._embeddedLanguagesMatcher=new Pa(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?jt._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new kt(0,0);_getBasicScopeAttributes=new Fr(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new kt(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(jt.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[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!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Pa=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,r])=>Br(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},Bn=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Xr(t,e,n,r,s,o,a,i){const l=e.content.length;let c=!1,u=-1;if(a){const d=La(t,e,n,r,s,o);s=d.stack,r=d.linePos,n=d.isFirstLine,u=d.anchorPosition}const h=Date.now();for(;!c;){if(i!==0&&Date.now()-h>i)return new Bn(s,!0);f()}return new Bn(s,!1);function f(){const d=Ta(t,e,n,r,s,u);if(!d){o.produce(s,l),c=!0;return}const p=d.captureIndices,w=d.matchedRuleId,C=p&&p.length>0?p[0].end>r:!1;if(w===Ia){const g=s.getRule(t);o.produce(s,p[0].start),s=s.withContentNameScopesList(s.nameScopesList),ve(t,e,n,s,o,g.endCaptures,p),o.produce(s,p[0].end);const y=s;if(s=s.parent,u=y.getAnchorPos(),!C&&y.getEnterPos()===r){s=y,o.produce(s,l),c=!0;return}}else{const g=t.getRule(w);o.produce(s,p[0].start);const y=s,m=g.getName(e.content,p),_=s.contentNameScopesList.pushAttributed(m,t);if(s=s.push(w,r,u,p[0].end===l,null,_,_),g instanceof Ft){const S=g;ve(t,e,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const E=S.getContentName(e.content,p),L=_.pushAttributed(E,t);if(s=s.withContentNameScopesList(L),S.endHasBackReferences&&(s=s.withEndRule(S.getEndWithResolvedBackReferences(e.content,p))),!C&&y.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(g instanceof Ye){const S=g;ve(t,e,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const E=S.getContentName(e.content,p),L=_.pushAttributed(E,t);if(s=s.withContentNameScopesList(L),S.whileHasBackReferences&&(s=s.withEndRule(S.getWhileWithResolvedBackReferences(e.content,p))),!C&&y.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(ve(t,e,n,s,o,g.captures,p),o.produce(s,p[0].end),s=s.pop(),!C){s=s.safePop(),o.produce(s,l),c=!0;return}}p[0].end>r&&(r=p[0].end,n=!1)}}function La(t,e,n,r,s,o){let a=s.beginRuleCapturedEOL?0:-1;const i=[];for(let l=s;l;l=l.pop()){const c=l.getRule(t);c instanceof Ye&&i.push({rule:c,stack:l})}for(let l=i.pop();l;l=i.pop()){const{ruleScanner:c,findOptions:u}=Ga(l.rule,t,l.stack.endRule,n,r===a),h=c.findNextMatchSync(e,r,u);if(h){if(h.ruleId!==qr){s=l.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(o.produce(l.stack,h.captureIndices[0].start),ve(t,e,n,l.stack,o,l.rule.whileCaptures,h.captureIndices),o.produce(l.stack,h.captureIndices[0].end),a=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=l.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:a,isFirstLine:n}}function Ta(t,e,n,r,s,o){const a=Ma(t,e,n,r,s,o),i=t.getInjections();if(i.length===0)return a;const l=Oa(i,t,e,n,r,s,o);if(!l)return a;if(!a)return l;const c=a.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:a}function Ma(t,e,n,r,s,o){const a=s.getRule(t),{ruleScanner:i,findOptions:l}=Kr(a,t,s.endRule,n,r===o),c=i.findNextMatchSync(e,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function Oa(t,e,n,r,s,o,a){let i=Number.MAX_VALUE,l=null,c,u=0;const h=o.contentNameScopesList.getScopeNames();for(let f=0,d=t.length;f<d;f++){const p=t[f];if(!p.matcher(h))continue;const w=e.getRule(p.ruleId),{ruleScanner:C,findOptions:g}=Kr(w,e,null,r,s===a),y=C.findNextMatchSync(n,s,g);if(!y)continue;const m=y.captureIndices[0].start;if(!(m>=i)&&(i=m,l=y.captureIndices,c=y.ruleId,u=p.priority,i===s))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function Kr(t,e,n,r,s){return{ruleScanner:t.compileAG(e,n,r,s),findOptions:0}}function Ga(t,e,n,r,s){return{ruleScanner:t.compileWhileAG(e,n,r,s),findOptions:0}}function ve(t,e,n,r,s,o,a){if(o.length===0)return;const i=e.content,l=Math.min(o.length,a.length),c=[],u=a[0].end;for(let h=0;h<l;h++){const f=o[h];if(f===null)continue;const d=a[h];if(d.length===0)continue;if(d.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=d.start;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?s.produceFromScopes(c[c.length-1].scopes,d.start):s.produce(r,d.start),f.retokenizeCapturedWithRuleId){const w=f.getName(i,a),C=r.contentNameScopesList.pushAttributed(w,t),g=f.getContentName(i,a),y=C.pushAttributed(g,t),m=r.push(f.retokenizeCapturedWithRuleId,d.start,-1,!1,null,C,y),_=t.createOnigString(i.substring(0,d.end));Xr(t,_,n&&d.start===0,d.start,m,s,!1,0),zr(_);continue}const p=f.getName(i,a);if(p!==null){const C=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(p,t);c.push(new Da(C,d.end))}}for(;c.length>0;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var Da=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function Ba(t,e,n,r,s,o,a,i){return new ja(t,e,n,r,s,o,a,i)}function Fn(t,e,n,r,s){const o=Ze(e,Je),a=Hr.getCompiledRuleId(n,r,s.repository);for(const i of o)t.push({debugSelector:e,matcher:i.matcher,ruleId:a,grammar:s,priority:i.priority})}function Je(t,e){if(e.length<t.length)return!1;let n=0;return t.every(r=>{for(let s=n;s<e.length;s++)if(Fa(e[s],r))return n=s+1,!0;return!1})}function Fa(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var ja=class{constructor(t,e,n,r,s,o,a,i){if(this._rootScopeName=t,this.balancedBracketSelectors=o,this._onigLib=i,this._basicScopeAttributesProvider=new $a(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=a,this._grammar=jn(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const l of Object.keys(s)){const c=Ze(l,Je);for(const u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){const s=r.injections;if(s)for(let a in s)Fn(e,a,s[a],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(a=>{const i=this.getExternalGrammar(a);if(i){const l=i.injectionSelector;l&&Fn(e,l,i,this,i)}})}return e.sort((s,o)=>s.priority-o.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=jn(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){const r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){this._rootId===-1&&(this._rootId=Hr.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!e||e===Ut.NULL){s=!0;const c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=ge.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null);let d;f?d=Ee.createRootAndLookUpScopeName(f,h,this):d=Ee.createRoot("unknown",h),e=new Ut(null,this._rootId,-1,-1,!1,null,d,d)}else s=!1,e.reset();t=t+`
|
|
143
|
+
`;const o=this.createOnigString(t),a=o.content.length,i=new za(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Xr(this,o,s,0,e,i,!0,r);return zr(o),{lineLength:a,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function jn(t,e){return t=aa(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Ee=class W{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,s=e?.scopePath??null;for(const o of n)s=St.push(s,o.scopeNames),r=new W(r,s,o.encodedTokenAttributes);return r}static createRoot(e,n){return new W(null,new St(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const s=r.getMetadataForScope(e),o=new St(null,e),a=r.themeProvider.themeMatch(o),i=W.mergeAttributes(n,s,a);return new W(null,o,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return W.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let s=-1,o=0,a=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,a=r.backgroundId),ge.set(e,n.languageId,n.tokenType,null,s,o,a)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return W._pushAttributed(this,e,n);const r=e.split(/ /g);let s=this;for(const o of r)s=W._pushAttributed(s,o,n);return s}static _pushAttributed(e,n,r){const s=r.getMetadataForScope(n),o=e.scopePath.push(n),a=r.themeProvider.themeMatch(o),i=W.mergeAttributes(e.tokenAttributes,s,a);return new W(e,o,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},Ut=class te{constructor(e,n,r,s,o,a,i,l){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=a,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new te(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:te._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Ee.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){te._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,s,o,a,i){return new te(this,e,n,r,s,o,a,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new te(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=Ee.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new te(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Ee.fromExtension(r,n.contentNameScopesList))}},Ua=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Ze(n,Je).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>Ze(n,Je).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},za=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=t?.getScopeNames()??[];for(const a of this._tokenTypeOverrides)a.matcher(o)&&(r=ge.set(r,0,a.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=ge.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},Wa=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,s){if(!this._grammars.has(t)){let o=this._rawGrammars.get(t);if(!o)return null;this._grammars.set(t,Ba(t,o,e,n,r,s,this,this._onigLib))}return this._grammars.get(t)}},qa=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Wa(Ke.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(Ke.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,r){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,n,r){return this._loadGrammar(e,n,r.embeddedLanguages,r.tokenTypes,new Ua(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,s,o){const a=new Ca(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(i=>this._loadSingleGrammar(i.scopeName)),a.processQueue();return this._grammarForScopeName(e,n,r,s,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(e,n=[],r=0,s=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,r,s)}_grammarForScopeName(e,n=0,r=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(e,n,r,s,o)}},zt=Ut.NULL;const Ha=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Me{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}Me.prototype.normal={};Me.prototype.property={};Me.prototype.space=void 0;function Zr(t,e){const n={},r={};for(const s of t)Object.assign(n,s.property),Object.assign(r,s.normal);return new Me(n,r,e)}function Wt(t){return t.toLowerCase()}class O{constructor(e,n){this.attribute=n,this.property=e}}O.prototype.attribute="";O.prototype.booleanish=!1;O.prototype.boolean=!1;O.prototype.commaOrSpaceSeparated=!1;O.prototype.commaSeparated=!1;O.prototype.defined=!1;O.prototype.mustUseProperty=!1;O.prototype.number=!1;O.prototype.overloadedBoolean=!1;O.prototype.property="";O.prototype.spaceSeparated=!1;O.prototype.space=void 0;let Va=0;const v=ae(),I=ae(),qt=ae(),b=ae(),x=ae(),de=ae(),G=ae();function ae(){return 2**++Va}var Ht=Object.freeze({__proto__:null,boolean:v,booleanish:I,commaOrSpaceSeparated:G,commaSeparated:de,number:b,overloadedBoolean:qt,spaceSeparated:x});const vt=Object.keys(Ht);class rn extends O{constructor(e,n,r,s){let o=-1;if(super(e,n),Un(this,"space",s),typeof r=="number")for(;++o<vt.length;){const a=vt[o];Un(this,vt[o],(r&Ht[a])===Ht[a])}}}rn.prototype.defined=!0;function Un(t,e,n){n&&(t[e]=n)}function we(t){const e={},n={};for(const[r,s]of Object.entries(t.properties)){const o=new rn(r,t.transform(t.attributes||{},r),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),e[r]=o,n[Wt(r)]=r,n[Wt(o.attribute)]=r}return new Me(e,n,t.space)}const Qr=we({properties:{ariaActiveDescendant:null,ariaAtomic:I,ariaAutoComplete:null,ariaBusy:I,ariaChecked:I,ariaColCount:b,ariaColIndex:b,ariaColSpan:b,ariaControls:x,ariaCurrent:null,ariaDescribedBy:x,ariaDetails:null,ariaDisabled:I,ariaDropEffect:x,ariaErrorMessage:null,ariaExpanded:I,ariaFlowTo:x,ariaGrabbed:I,ariaHasPopup:null,ariaHidden:I,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:x,ariaLevel:b,ariaLive:null,ariaModal:I,ariaMultiLine:I,ariaMultiSelectable:I,ariaOrientation:null,ariaOwns:x,ariaPlaceholder:null,ariaPosInSet:b,ariaPressed:I,ariaReadOnly:I,ariaRelevant:null,ariaRequired:I,ariaRoleDescription:x,ariaRowCount:b,ariaRowIndex:b,ariaRowSpan:b,ariaSelected:I,ariaSetSize:b,ariaSort:null,ariaValueMax:b,ariaValueMin:b,ariaValueNow:b,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function Yr(t,e){return e in t?t[e]:e}function Jr(t,e){return Yr(t,e.toLowerCase())}const Xa=we({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:de,acceptCharset:x,accessKey:x,action:null,allow:null,allowFullScreen:v,allowPaymentRequest:v,allowUserMedia:v,alt:null,as:null,async:v,autoCapitalize:null,autoComplete:x,autoFocus:v,autoPlay:v,blocking:x,capture:null,charSet:null,checked:v,cite:null,className:x,cols:b,colSpan:null,content:null,contentEditable:I,controls:v,controlsList:x,coords:b|de,crossOrigin:null,data:null,dateTime:null,decoding:null,default:v,defer:v,dir:null,dirName:null,disabled:v,download:qt,draggable:I,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:v,formTarget:null,headers:x,height:b,hidden:qt,high:b,href:null,hrefLang:null,htmlFor:x,httpEquiv:x,id:null,imageSizes:null,imageSrcSet:null,inert:v,inputMode:null,integrity:null,is:null,isMap:v,itemId:null,itemProp:x,itemRef:x,itemScope:v,itemType:x,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:v,low:b,manifest:null,max:null,maxLength:b,media:null,method:null,min:null,minLength:b,multiple:v,muted:v,name:null,nonce:null,noModule:v,noValidate:v,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:v,optimum:b,pattern:null,ping:x,placeholder:null,playsInline:v,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:v,referrerPolicy:null,rel:x,required:v,reversed:v,rows:b,rowSpan:b,sandbox:x,scope:null,scoped:v,seamless:v,selected:v,shadowRootClonable:v,shadowRootDelegatesFocus:v,shadowRootMode:null,shape:null,size:b,sizes:null,slot:null,span:b,spellCheck:I,src:null,srcDoc:null,srcLang:null,srcSet:null,start:b,step:null,style:null,tabIndex:b,target:null,title:null,translate:null,type:null,typeMustMatch:v,useMap:null,value:I,width:b,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:x,axis:null,background:null,bgColor:null,border:b,borderColor:null,bottomMargin:b,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:v,declare:v,event:null,face:null,frame:null,frameBorder:null,hSpace:b,leftMargin:b,link:null,longDesc:null,lowSrc:null,marginHeight:b,marginWidth:b,noResize:v,noHref:v,noShade:v,noWrap:v,object:null,profile:null,prompt:null,rev:null,rightMargin:b,rules:null,scheme:null,scrolling:I,standby:null,summary:null,text:null,topMargin:b,valueType:null,version:null,vAlign:null,vLink:null,vSpace:b,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:v,disableRemotePlayback:v,prefix:null,property:null,results:b,security:null,unselectable:null},space:"html",transform:Jr}),Ka=we({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:G,accentHeight:b,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:b,amplitude:b,arabicForm:null,ascent:b,attributeName:null,attributeType:null,azimuth:b,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:b,by:null,calcMode:null,capHeight:b,className:x,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:b,diffuseConstant:b,direction:null,display:null,dur:null,divisor:b,dominantBaseline:null,download:v,dx:null,dy:null,edgeMode:null,editable:null,elevation:b,enableBackground:null,end:null,event:null,exponent:b,externalResourcesRequired:null,fill:null,fillOpacity:b,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:de,g2:de,glyphName:de,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:b,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:b,horizOriginX:b,horizOriginY:b,id:null,ideographic:b,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:b,k:b,k1:b,k2:b,k3:b,k4:b,kernelMatrix:G,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:b,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:b,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:b,overlineThickness:b,paintOrder:null,panose1:null,path:null,pathLength:b,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:x,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:b,pointsAtY:b,pointsAtZ:b,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:G,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:G,rev:G,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:G,requiredFeatures:G,requiredFonts:G,requiredFormats:G,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:b,specularExponent:b,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:b,strikethroughThickness:b,string:null,stroke:null,strokeDashArray:G,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:b,strokeOpacity:b,strokeWidth:null,style:null,surfaceScale:b,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:G,tabIndex:b,tableValues:null,target:null,targetX:b,targetY:b,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:G,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:b,underlineThickness:b,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:b,values:null,vAlphabetic:b,vMathematical:b,vectorEffect:null,vHanging:b,vIdeographic:b,version:null,vertAdvY:b,vertOriginX:b,vertOriginY:b,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:b,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Yr}),es=we({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),ts=we({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Jr}),ns=we({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),Za=/[A-Z]/g,zn=/-[a-z]/g,Qa=/^data[-\w.:]+$/i;function Ya(t,e){const n=Wt(e);let r=e,s=O;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Qa.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(zn,ei);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!zn.test(o)){let a=o.replace(Za,Ja);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}s=rn}return new s(r,e)}function Ja(t){return"-"+t.toLowerCase()}function ei(t){return t.charAt(1).toUpperCase()}const ti=Zr([Qr,Xa,es,ts,ns],"html"),rs=Zr([Qr,Ka,es,ts,ns],"svg"),Wn={}.hasOwnProperty;function ni(t,e){const n=e||{};function r(s,...o){let a=r.invalid;const i=r.handlers;if(s&&Wn.call(s,t)){const l=String(s[t]);a=Wn.call(i,l)?i[l]:r.unknown}if(a)return a.call(this,s,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const ri=/["&'<>`]/g,si=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,oi=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ai=/[|\\{}()[\]^$+*?.]/g,qn=new WeakMap;function ii(t,e){if(t=t.replace(e.subset?li(e.subset):ri,r),e.subset||e.escapeOnly)return t;return t.replace(si,n).replace(oi,r);function n(s,o,a){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,a.charCodeAt(o+2),e)}function r(s,o,a){return e.format(s.charCodeAt(0),a.charCodeAt(o+1),e)}}function li(t){let e=qn.get(t);return e||(e=ci(t),qn.set(t,e)),e}function ci(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(ai,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const ui=/[\dA-Fa-f]/;function hi(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!ui.test(String.fromCharCode(e))?r:r+";"}const fi=/\d/;function di(t,e,n){const r="&#"+String(t);return n&&e&&!fi.test(String.fromCharCode(e))?r:r+";"}const pi=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],xt={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},gi=["cent","copy","divide","gt","lt","not","para","times"],ss={}.hasOwnProperty,Vt={};let Ue;for(Ue in xt)ss.call(xt,Ue)&&(Vt[xt[Ue]]=Ue);const mi=/[^\dA-Za-z]/;function yi(t,e,n,r){const s=String.fromCharCode(t);if(ss.call(Vt,s)){const o=Vt[s],a="&"+o;return n&&pi.includes(o)&&!gi.includes(o)&&(!r||e&&e!==61&&mi.test(String.fromCharCode(e)))?a:a+";"}return""}function bi(t,e,n){let r=hi(t,e,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=yi(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const o=di(t,e,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function pe(t,e){return ii(t,Object.assign({format:bi},e))}const wi=/^>|^->|<!--|-->|--!>|<!-$/g,Ci=[">"],_i=["<",">"];function Si(t,e,n,r){return r.settings.bogusComments?"<?"+pe(t.value,Object.assign({},r.settings.characterReferences,{subset:Ci}))+">":"<!--"+t.value.replace(wi,s)+"-->";function s(o){return pe(o,Object.assign({},r.settings.characterReferences,{subset:_i}))}}function ki(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function Hn(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(e);for(;s!==-1;)r++,s=n.indexOf(e,s+e.length);return r}function vi(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function xi(t){return t.join(" ").trim()}const Ei=/[ \t\n\f\r]/g;function sn(t){return typeof t=="object"?t.type==="text"?Vn(t.value):!1:Vn(t)}function Vn(t){return t.replace(Ei,"")===""}const N=as(1),os=as(-1),Ai=[];function as(t){return e;function e(n,r,s){const o=n?n.children:Ai;let a=(r||0)+t,i=o[a];if(!s)for(;i&&sn(i);)a+=t,i=o[a];return i}}const Ii={}.hasOwnProperty;function is(t){return e;function e(n,r,s){return Ii.call(t,n.tagName)&&t[n.tagName](n,r,s)}}const on=is({body:Ni,caption:Et,colgroup:Et,dd:Ti,dt:Li,head:Et,html:Ri,li:Pi,optgroup:Mi,option:Oi,p:$i,rp:Xn,rt:Xn,tbody:Di,td:Kn,tfoot:Bi,th:Kn,thead:Gi,tr:Fi});function Et(t,e,n){const r=N(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&sn(r.value.charAt(0)))}function Ri(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function Ni(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function $i(t,e,n){const r=N(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function Pi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="li"}function Li(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Ti(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Xn(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Mi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function Oi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Gi(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Di(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Bi(t,e,n){return!N(n,e)}function Fi(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Kn(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const ji=is({body:Wi,colgroup:qi,head:zi,html:Ui,tbody:Hi});function Ui(t){const e=N(t,-1);return!e||e.type!=="comment"}function zi(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function Wi(t){const e=N(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&sn(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function qi(t,e,n){const r=os(n,e),s=N(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&on(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function Hi(t,e,n){const r=os(n,e),s=N(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&on(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const ze={name:[[`
|
|
144
144
|
\f\r &/=>`.split(""),`
|
|
145
145
|
\f\r "&'/=>\``.split("")],[`\0
|
|
146
146
|
\f\r "&'/<=>`.split(""),`\0
|
|
@@ -148,6 +148,6 @@ XID_Start XIDS`.split(/\s/).map(t=>[Fe(t),t])),vo=new Map([["s",R(383)],[R(383),
|
|
|
148
148
|
\f\r &>`.split(""),`\0
|
|
149
149
|
\f\r "&'<=>\``.split("")],[`\0
|
|
150
150
|
\f\r "&'<=>\``.split(""),`\0
|
|
151
|
-
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Vi(t,e,n,r){const s=r.schema,o=s.space==="svg"?!1:r.settings.omitOptionalTags;let a=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const i=[];let l;s.space==="html"&&t.tagName==="svg"&&(r.schema=Lr);const c=Xi(r,t.properties),u=r.all(s.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=s,u&&(a=!1),(c||!o||!ji(t,e,n))&&(i.push("<",t.tagName,c?" "+c:""),a&&(s.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(u),!a&&(!o||!Ht(t,e,n))&&i.push("</"+t.tagName+">"),i.join("")}function Xi(t,e){const n=[];let r=-1,s;if(e){for(s in e)if(e[s]!==null&&e[s]!==void 0){const o=Ki(t,s,e[s]);o&&n.push(o)}}for(;++r<n.length;){const o=t.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function Ki(t,e,n){const r=Ya(t.schema,e),s=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,o=t.settings.allowDangerousCharacters?0:1;let a=t.quote,i;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const l=me(r.attribute,Object.assign({},t.settings.characterReferences,{subset:Je.name[s][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?vi:xi)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?l:(t.settings.preferUnquoted&&(i=me(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:Je.unquoted[s][o]}))),i!==n&&(t.settings.quoteSmart&&Gr(n,a)>Gr(n,t.alternative)&&(a=t.alternative),i=a+me(n,Object.assign({},t.settings.characterReferences,{subset:(a==="'"?Je.single:Je.double)[s][o],attribute:!0}))+a),l+(i&&"="+i))}const Zi=["<","&"];function Wr(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:me(t.value,Object.assign({},r.settings.characterReferences,{subset:Zi}))}function Qi(t,e,n,r){return r.settings.allowDangerousHtml?t.value:Wr(t,e,n,r)}function Yi(t,e,n,r){return r.all(t)}const Ji=ni("type",{invalid:el,unknown:tl,handlers:{comment:Si,doctype:ki,element:Vi,raw:Qi,root:Yi,text:Wr}});function el(t){throw new Error("Expected node, not `"+t+"`")}function tl(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const nl={},rl={},sl=[];function ol(t,e){const n=e||nl,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:al,all:il,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Ha,characterReferences:n.characterReferences||rl,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Lr:ti,quote:r,alternative:s}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function al(t,e,n){return Ji(t,e,n,this)}function il(t){const e=[],n=t&&t.children||sl;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}function et(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[s,o]of Object.entries(e?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function Y(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function ll(t){return Array.isArray(t)?t:[t]}async function qr(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function Xt(t){return!t||["plaintext","txt","text","plain"].includes(t)}function cl(t){return t==="ansi"||Xt(t)}function Kt(t){return t==="none"}function ul(t){return Kt(t)}function Hr(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function tt(t,e=!1){if(t.length===0)return[["",0]];const n=t.split(/(\r?\n)/g);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const a=e?n[o]+(n[o+1]||""):n[o];s.push([a,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}function hl(t){const e=tt(t,!0).map(([s])=>s);function n(s){if(s===t.length)return{line:e.length-1,character:e[e.length-1].length};let o=s,a=0;for(const i of e){if(o<i.length)break;o-=i.length,a++}return{line:a,character:o}}function r(s,o){let a=0;for(let i=0;i<s;i++)a+=e[i].length;return a+=o,a}return{lines:e,indexToPos:n,posToIndex:r}}const Zt="light-dark()",fl=["color","background-color"];function dl(t,e){let n=0;const r=[];for(const s of e)s>n&&r.push({...t,content:t.content.slice(n,s),offset:t.offset+n}),n=s;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function pl(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,s)=>r-s);return n.length?t.map(r=>r.flatMap(s=>{const o=n.filter(a=>s.offset<a&&a<s.offset+s.content.length).map(a=>a-s.offset).sort((a,i)=>a-i);return o.length?dl(s,o):s})):t}function gl(t,e,n,r,s="css-vars"){const o={content:t.content,explanation:t.explanation,offset:t.offset},a=e.map(u=>nt(t.variants[u])),i=new Set(a.flatMap(u=>Object.keys(u))),l={},c=(u,h)=>{const f=h==="color"?"":h==="background-color"?"-bg":`-${h}`;return n+e[u]+(h==="color"?"":f)};return a.forEach((u,h)=>{for(const f of i){const d=u[f]||"inherit";if(h===0&&r&&fl.includes(f))if(r===Zt&&a.length>1){const p=e.findIndex(y=>y==="light"),w=e.findIndex(y=>y==="dark");if(p===-1||w===-1)throw new P('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const C=a[p][f]||"inherit",g=a[w][f]||"inherit";l[f]=`light-dark(${C}, ${g})`,s==="css-vars"&&(l[c(h,f)]=d)}else l[f]=d;else s==="css-vars"&&(l[c(h,f)]=d)}}),o.htmlStyle=l,o}function nt(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&T.Italic&&(e["font-style"]="italic"),t.fontStyle&T.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&T.Underline&&n.push("underline"),t.fontStyle&T.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function Qt(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const Vr=new WeakMap;function rt(t,e){Vr.set(t,e)}function $e(t){return Vr.get(t)}class ye{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new ye(Object.fromEntries(ll(n).map(r=>[r,Gt])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,s]=e;this.lang=r,this._stacks={[s]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return ml(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function ml(t){const e=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&e.push(o),s.parent&&r(s.parent)}return r(t),e}function yl(t,e){if(!(t instanceof ye))throw new P("Invalid grammar state");return t.getInternalStack(e)}function bl(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new P(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...s.indexToPos(a),offset:a}}else{const i=s.lines[a.line];if(i===void 0)throw new P(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${s.lines.length}`);let l=a.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new P(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${i.length}`);return{...a,character:l,offset:s.posToIndex(a.line,l)}}};const s=hl(n.source),o=(n.options.decorations||[]).map(a=>({...a,start:r(a.start),end:r(a.end)}));wl(o),t.set(n.meta,{decorations:o,converter:s,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const s=e(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]);return pl(n,s)},code(n){if(!this.options.decorations?.length)return;const r=e(this),s=Array.from(n.children).filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new P(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(u,h,f,d){const p=s[u];let w="",C=-1,g=-1;if(h===0&&(C=0),f===0&&(g=0),f===Number.POSITIVE_INFINITY&&(g=p.children.length),C===-1||g===-1)for(let m=0;m<p.children.length;m++)w+=Xr(p.children[m]),C===-1&&w.length===h&&(C=m+1),g===-1&&w.length===f&&(g=m+1);if(C===-1)throw new P(`Failed to find start index for decoration ${JSON.stringify(d.start)}`);if(g===-1)throw new P(`Failed to find end index for decoration ${JSON.stringify(d.end)}`);const y=p.children.slice(C,g);if(!d.alwaysWrap&&y.length===p.children.length)i(p,d,"line");else if(!d.alwaysWrap&&y.length===1&&y[0].type==="element")i(y[0],d,"token");else{const m={type:"element",tagName:"span",properties:{},children:y};i(m,d,"wrapper"),p.children.splice(C,y.length,m)}}function a(u,h){s[u]=i(s[u],h,"line")}function i(u,h,f){const d=h.properties||{},p=h.transform||(w=>w);return u.tagName=h.tagName||"span",u.properties={...u.properties,...d,class:u.properties.class},h.properties?.class&&Hr(u,h.properties.class),u=p(u,f)||u,u}const l=[],c=r.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(const u of c){const{start:h,end:f}=u;if(h.line===f.line)o(h.line,h.character,f.character,u);else if(h.line<f.line){o(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let d=h.line+1;d<f.line;d++)l.unshift(()=>a(d,u));o(f.line,0,f.character,u)}}l.forEach(u=>u())}}}function wl(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new P(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const s=t[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,a=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,i=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,l=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||a||i||l){if(o&&a||i&&l||i&&n.start.offset===n.end.offset||a&&s.start.offset===s.end.offset)continue;throw new P(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function Xr(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(Xr).join(""):""}const Cl=[bl()];function st(t){const e=_l(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...Cl]}function _l(t){const e=[],n=[],r=[];for(const s of t)switch(s.enforce){case"pre":e.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:e,post:n,normal:r}}var oe=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Yt={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Sl(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function Kr(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function kl(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)Yt[r]&&e.push({type:"setDecoration",value:Yt[r]});else if(r<=29){const s=Yt[r-20];s&&(e.push({type:"resetDecoration",value:s}),s==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:oe[r-30]}});else if(r===38){const s=Kr(t);s&&e.push({type:"setForegroundColor",value:s})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:oe[r-40]}});else if(r===48){const s=Kr(t);s&&e.push({type:"setBackgroundColor",value:s})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:oe[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:oe[r-100+8]}})}return e}function vl(){let t=null,e=null,n=new Set;return{parse(r){const s=[];let o=0;do{const a=Sl(r,o),i=a.sequence?r.substring(o,a.startPosition):r.substring(o);if(i.length>0&&s.push({value:i,foreground:t,background:e,decorations:new Set(n)}),a.sequence){const l=kl(a.sequence);for(const c of l)c.type==="resetAll"?(t=null,e=null,n.clear()):c.type==="resetForegroundColor"?t=null:c.type==="resetBackgroundColor"?e=null:c.type==="resetDecoration"&&n.delete(c.value);for(const c of l)c.type==="setForegroundColor"?t=c.value:c.type==="setBackgroundColor"?e=c.value:c.type==="setDecoration"&&n.add(c.value)}o=a.position}while(o<r.length);return s}}}var xl={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function El(t=xl){function e(i){return t[i]}function n(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let c=0;c<oe.length;c++)r.push(e(oe[c]));let i=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([i[c],i[u],i[h]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function o(i){return s()[i]}function a(i){switch(i.type){case"named":return e(i.name);case"rgb":return n(i.rgb);case"table":return o(i.index)}}return{value:a}}const Al={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Il(t,e,n){const r=et(t,n),s=tt(e),o=Object.fromEntries(oe.map(l=>{const c=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,u=t.colors?.[c];return[l,u||Al[l]]})),a=El(o),i=vl();return s.map(l=>i.parse(l[0]).map(c=>{let u,h;c.decorations.has("reverse")?(u=c.background?a.value(c.background):t.bg,h=c.foreground?a.value(c.foreground):t.fg):(u=c.foreground?a.value(c.foreground):t.fg,h=c.background?a.value(c.background):void 0),u=Y(u,r),h=Y(h,r),c.decorations.has("dim")&&(u=Rl(u));let f=T.None;return c.decorations.has("bold")&&(f|=T.Bold),c.decorations.has("italic")&&(f|=T.Italic),c.decorations.has("underline")&&(f|=T.Underline),c.decorations.has("strikethrough")&&(f|=T.Strikethrough),{content:c.value,offset:l[1],color:u,bgColor:h,fontStyle:f}}))}function Rl(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const r=e[1];if(r.length===8){const s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const s=r[0],o=r[1],a=r[2],i=r[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${s}${s}${o}${o}${a}${a}${l}`}else if(r.length===3){const s=r[0],o=r[1],a=r[2];return`#${s}${s}${o}${o}${a}${a}80`}}}const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function Jt(t,e,n={}){const{theme:r=t.getLoadedThemes()[0]}=n,s=t.resolveLangAlias(n.lang||"text");if(Xt(s)||Kt(r))return tt(e).map(l=>[{content:l[0],offset:l[1]}]);const{theme:o,colorMap:a}=t.setTheme(r);if(s==="ansi")return Il(o,e,n);const i=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new P(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new P(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return $l(e,i,o,a,n)}function Nl(...t){if(t.length===2)return $e(t[1]);const[e,n,r={}]=t,{lang:s="text",theme:o=e.getLoadedThemes()[0]}=r;if(Xt(s)||Kt(o))throw new P("Plain language does not have grammar state");if(s==="ansi")throw new P("ANSI language does not have grammar state");const{theme:a,colorMap:i}=e.setTheme(o),l=e.getLanguage(s);return new ye(ot(n,l,a,i,r).stateStack,l.name,a.name)}function $l(t,e,n,r,s){const o=ot(t,e,n,r,s),a=new ye(ot(t,e,n,r,s).stateStack,e.name,n.name);return rt(o.tokens,a),o.tokens}function ot(t,e,n,r,s){const o=et(n,s),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:i=500}=s,l=tt(t);let c=s.grammarState?yl(s.grammarState,n.name)??Gt:s.grammarContextCode!=null?ot(s.grammarContextCode,e,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:Gt,u=[];const h=[];for(let f=0,d=l.length;f<d;f++){const[p,w]=l[f];if(p===""){u=[],h.push([]);continue}if(a>0&&p.length>=a){u=[],h.push([{content:p,offset:w,color:"",fontStyle:0}]);continue}let C,g,y;s.includeExplanation&&(C=e.tokenizeLine(p,c,i),g=C.tokens,y=0);const m=e.tokenizeLine2(p,c,i),_=m.tokens.length/2;for(let S=0;S<_;S++){const E=m.tokens[2*S],L=S+1<_?m.tokens[2*S+2]:p.length;if(E===L)continue;const j=m.tokens[2*S+1],ut=Y(r[de.getForeground(j)],o),ln=de.getFontStyle(j),Oe={content:p.substring(E,L),offset:w+E,color:ut,fontStyle:ln};if(s.includeExplanation){const J=[];if(s.includeExplanation!=="scopeName")for(const K of n.settings){let Ce;switch(typeof K.scope){case"string":Ce=K.scope.split(/,/).map(cn=>cn.trim());break;case"object":Ce=K.scope;break;default:continue}J.push({settings:K,selectors:Ce.map(cn=>cn.split(/ /))})}Oe.explanation=[];let ms=0;for(;E+ms<L;){const K=g[y],Ce=p.substring(K.startIndex,K.endIndex);ms+=Ce.length,Oe.explanation.push({content:Ce,scopes:s.includeExplanation==="scopeName"?Pl(K.scopes):Ll(J,K.scopes)}),y+=1}}u.push(Oe)}h.push(u),u=[],c=m.ruleStack}return{tokens:h,stateStack:c}}function Pl(t){return t.map(e=>({scopeName:e}))}function Ll(t,e){const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];n[r]={scopeName:o,themeMatches:Ml(t,o,e.slice(0,r))}}return n}function Zr(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function Tl(t,e,n){if(!Zr(t[t.length-1],e))return!1;let r=t.length-2,s=n.length-1;for(;r>=0&&s>=0;)Zr(t[r],n[s])&&(r-=1),s-=1;return r===-1}function Ml(t,e,n){const r=[];for(const{selectors:s,settings:o}of t)for(const a of s)if(Tl(a,e,n)){r.push(o);break}return r}function Qr(t,e,n){const r=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),s=r.map(l=>{const c=Jt(t,e,{...n,theme:l.theme}),u=$e(c),h=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:c,state:u,theme:h}}),o=Ol(...s.map(l=>l.tokens)),a=o[0].map((l,c)=>l.map((u,h)=>{const f={content:u.content,variants:{},offset:u.offset};return"includeExplanation"in n&&n.includeExplanation&&(f.explanation=u.explanation),o.forEach((d,p)=>{const{content:w,explanation:C,offset:g,...y}=d[c][h];f.variants[r[p].color]=y}),f})),i=s[0].state?new ye(Object.fromEntries(s.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),s[0].state.lang):void 0;return i&&rt(a,i),a}function Ol(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const s=t.map(l=>l[r]),o=e.map(()=>[]);e.forEach((l,c)=>l.push(o[c]));const a=s.map(()=>0),i=s.map(l=>l[0]);for(;i.every(l=>l);){const l=Math.min(...i.map(c=>c.content.length));for(let c=0;c<n;c++){const u=i[c];u.content.length===l?(o[c].push(u),a[c]+=1,i[c]=s[c][a[c]]):(o[c].push({...u,content:u.content.slice(0,l)}),i[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return e}function at(t,e,n){let r,s,o,a,i,l;if("themes"in n){const{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:h="css-vars"}=n,f=Object.entries(n.themes).filter(g=>g[1]).map(g=>({color:g[0],theme:g[1]})).sort((g,y)=>g.color===c?-1:y.color===c?1:0);if(f.length===0)throw new P("`themes` option must not be empty");const d=Qr(t,e,n);if(l=$e(d),c&&Zt!==c&&!f.find(g=>g.color===c))throw new P(`\`themes\` option must contain the defaultColor key \`${c}\``);const p=f.map(g=>t.getTheme(g.theme)),w=f.map(g=>g.color);o=d.map(g=>g.map(y=>gl(y,w,u,c,h))),l&&rt(o,l);const C=f.map(g=>et(g.theme,n));s=Yr(f,p,C,u,c,"fg",h),r=Yr(f,p,C,u,c,"bg",h),a=`shiki-themes ${p.map(g=>g.name).join(" ")}`,i=c?void 0:[s,r].join(";")}else if("theme"in n){const c=et(n.theme,n);o=Jt(t,e,n);const u=t.getTheme(n.theme);r=Y(u.bg,c),s=Y(u.fg,c),a=u.name,l=$e(o)}else throw new P("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:a,rootStyle:i,grammarState:l}}function Yr(t,e,n,r,s,o,a){return t.map((i,l)=>{const c=Y(e[l][o],n[l])||"inherit",u=`${r+i.color}${o==="bg"?"-bg":""}:${c}`;if(l===0&&s){if(s===Zt&&t.length>1){const h=t.findIndex(w=>w.color==="light"),f=t.findIndex(w=>w.color==="dark");if(h===-1||f===-1)throw new P('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const d=Y(e[h][o],n[h])||"inherit",p=Y(e[f][o],n[f])||"inherit";return`light-dark(${d}, ${p});${u}`}return c}return a==="css-vars"?u:null}).filter(i=>!!i).join(";")}function it(t,e,n,r={meta:{},options:n,codeToHast:(s,o)=>it(t,s,o),codeToTokens:(s,o)=>at(t,s,o)}){let s=e;for(const p of st(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:o,fg:a,bg:i,themeName:l,rootStyle:c,grammarState:u}=at(t,s,n);const{mergeWhitespaces:h=!0,mergeSameStyleTokens:f=!1}=n;h===!0?o=Dl(o):h==="never"&&(o=Bl(o)),f&&(o=Fl(o));const d={...r,get source(){return s}};for(const p of st(n))o=p.tokens?.call(d,o)||o;return Gl(o,{...n,fg:a,bg:i,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},d,u)}function Gl(t,e,n,r=$e(t)){const s=st(e),o=[],a={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=e,c={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?c.style=e.rootStyle:c.style=`background-color:${e.bg};color:${e.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(const[w,C]of Object.entries(e.meta||{}))w.startsWith("_")||(c[w]=C);let u={type:"element",tagName:"pre",properties:c,children:[]},h={type:"element",tagName:"code",properties:{},children:o};const f=[],d={...n,structure:i,addClassToHast:Hr,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return a},get pre(){return u},get code(){return h},get lines(){return f}};if(t.forEach((w,C)=>{C&&(i==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&o.push({type:"text",value:`
|
|
152
|
-
`}));let g={type:"element",tagName:"span",properties:{class:"line"},children:[]},y=0;for(const m of w){let _={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]};const S=Qt(m.htmlStyle||nt(m));S&&(_.properties.style=S);for(const E of s)_=E?.span?.call(d,_,C+1,y,g,m)||_;i==="inline"?a.children.push(_):i==="classic"&&g.children.push(_),y+=m.content.length}if(i==="classic"){for(const m of s)g=m?.line?.call(d,g,C+1)||g;f.push(g),o.push(g)}else i==="inline"&&f.push(g)}),i==="classic"){for(const w of s)h=w?.code?.call(d,h)||h;u.children.push(h);for(const w of s)u=w?.pre?.call(d,u)||u;a.children.push(u)}else if(i==="inline"){const w=[];let C={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const m of a.children)m.type==="element"&&m.tagName==="br"?(w.push(C),C={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&C.children.push(m);w.push(C);let y={type:"element",tagName:"code",properties:{},children:w};for(const m of s)y=m?.code?.call(d,y)||y;a.children=[];for(let m=0;m<y.children.length;m++){m>0&&a.children.push({type:"element",tagName:"br",properties:{},children:[]});const _=y.children[m];_.type==="element"&&a.children.push(..._.children)}}let p=a;for(const w of s)p=w?.root?.call(d,p)||p;return r&&rt(p,r),p}function Dl(t){return t.map(e=>{const n=[];let r="",s;return e.forEach((o,a)=>{const l=!(o.fontStyle&&(o.fontStyle&T.Underline||o.fontStyle&T.Strikethrough));l&&o.content.match(/^\s+$/)&&e[a+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(l?n.push({...o,offset:s,content:r+o.content}):n.push({content:r,offset:s},o),s=void 0,r=""):n.push(o)}),n})}function Bl(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,s,o,a]=r;if(!s&&!a)return n;const i=[{...n,offset:n.offset+s.length,content:o}];return s&&i.unshift({content:s,offset:n.offset}),a&&i.push({content:a,offset:n.offset+s.length+o.length}),i}))}function Fl(t){return t.map(e=>{const n=[];for(const r of e){if(n.length===0){n.push({...r});continue}const s=n[n.length-1],o=Qt(s.htmlStyle||nt(s)),a=Qt(r.htmlStyle||nt(r)),i=s.fontStyle&&(s.fontStyle&T.Underline||s.fontStyle&T.Strikethrough),l=r.fontStyle&&(r.fontStyle&T.Underline||r.fontStyle&T.Strikethrough);!i&&!l&&o===a?s.content+=r.content:n.push({...r})}return n})}const jl=ol;function Ul(t,e,n){const r={meta:{},options:n,codeToHast:(o,a)=>it(t,o,a),codeToTokens:(o,a)=>at(t,o,a)};let s=jl(it(t,e,n,r));for(const o of st(n))s=o.postprocess?.call(r,s,n)||s;return s}const Jr={light:"#333333",dark:"#bbbbbb"},es={light:"#fffffe",dark:"#1e1e1e"},ts="__shiki_resolved";function en(t){if(t?.[ts])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const i=e.settings?e.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(r=i.settings.foreground),i?.settings?.background&&(n=i.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?Jr.light:Jr.dark),n||(n=e.type==="light"?es.light:es.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0;const o=new Map;function a(i){if(o.has(i))return o.get(i);s+=1;const l=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${l}`]?a(i):(o.set(i,l),l)}e.settings=e.settings.map(i=>{const l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),c=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!c)return i;const u={...i,settings:{...i.settings}};if(l){const h=a(i.settings.foreground);e.colorReplacements[h]=i.settings.foreground,u.settings.foreground=h}if(c){const h=a(i.settings.background);e.colorReplacements[h]=i.settings.background,u.settings.background=h}return u});for(const i of Object.keys(e.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!e.colors[i]?.startsWith("#")){const l=a(e.colors[i]);e.colorReplacements[l]=e.colors[i],e.colors[i]=l}return Object.defineProperty(e,ts,{enumerable:!1,writable:!1,value:!0}),e}async function zl(t){return Array.from(new Set((await Promise.all(t.filter(e=>!cl(e)).map(async e=>await qr(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function Wl(t){return(await Promise.all(t.map(async n=>ul(n)?null:en(await qr(n))))).filter(n=>!!n)}class be extends Error{constructor(e){super(e),this.name="ShikiError"}}function ns(t,e){if(!e)return t;if(e[t]){const n=new Set([t]);for(;e[t];){if(t=e[t],n.has(t))throw new be(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return t}class ql extends qa{constructor(e,n,r,s={}){super(e),this._resolver=e,this._themes=n,this._langs=r,this._alias=s,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const n=en(e);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let n=this._textmateThemeCache.get(e);n||(n=He.createFromRawTheme(e),this._textmateThemeCache.set(e,n)),this._syncRegistry.setTheme(n)}getGrammar(e){return e=ns(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const n=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const s=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(s.name=e.name,this._resolvedGrammars.set(e.name,s),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,n.size)for(const o of n)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const s of e)this.resolveEmbeddedLanguages(s);const n=Array.from(this._langGraph.entries()),r=n.filter(([s,o])=>!o);if(r.length){const s=n.filter(([o,a])=>a?(a.embeddedLanguages||a.embeddedLangs)?.some(l=>r.map(([c])=>c).includes(l)):!1).filter(o=>!r.includes(o));throw new be(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${s.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[s,o]of n)this._resolver.addLanguage(o);for(const[s,o]of n)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const n=e.embeddedLanguages??e.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}}class Hl{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,n){this._onigLib={createOnigScanner:r=>e.createScanner(r),createOnigString:r=>e.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let r=[];for(let s=1;s<=n.length;s++){const o=n.slice(0,s).join(".");r=[...r,...this._injections.get(o)||[]]}return r}}let Pe=0;function Vl(t){Pe+=1,t.warnings!==!1&&Pe>=10&&Pe%10===0&&console.warn(`[Shiki] ${Pe} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new be("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(en),s=new Hl(t.engine,n),o=new ql(s,r,n,t.langAlias);let a;function i(m){return ns(m,t.langAlias)}function l(m){g();const _=o.getGrammar(typeof m=="string"?m:m.name);if(!_)throw new be(`Language \`${m}\` not found, you may need to load it first`);return _}function c(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};g();const _=o.getTheme(m);if(!_)throw new be(`Theme \`${m}\` not found, you may need to load it first`);return _}function u(m){g();const _=c(m);a!==m&&(o.setTheme(_),a=m);const S=o.getColorMap();return{theme:_,colorMap:S}}function h(){return g(),o.getLoadedThemes()}function f(){return g(),o.getLoadedLanguages()}function d(...m){g(),o.loadLanguages(m.flat(1))}async function p(...m){return d(await zl(m))}function w(...m){g();for(const _ of m.flat(1))o.loadTheme(_)}async function C(...m){return g(),w(await Wl(m))}function g(){if(e)throw new be("Shiki instance has been disposed")}function y(){e||(e=!0,o.dispose(),Pe-=1)}return{setTheme:u,getTheme:c,getLanguage:l,getLoadedThemes:h,getLoadedLanguages:f,resolveLangAlias:i,loadLanguage:p,loadLanguageSync:d,loadTheme:C,loadThemeSync:w,dispose:y,[Symbol.dispose]:y}}function Xl(t){const e=Vl(t);return{getLastGrammarState:(...n)=>Nl(e,...n),codeToTokensBase:(n,r)=>Jt(e,n,r),codeToTokensWithThemes:(n,r)=>Qr(e,n,r),codeToTokens:(n,r)=>at(e,n,r),codeToHast:(n,r)=>it(e,n,r),codeToHtml:(n,r)=>Ul(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}class rs{diff(e,n,r={}){let s;typeof r=="function"?(s=r,r={}):"callback"in r&&(s=r.callback);const o=this.castInput(e,r),a=this.castInput(n,r),i=this.removeEmpty(this.tokenize(o,r)),l=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(i,l,r,s)}diffWithOptionsObj(e,n,r,s){var o;const a=y=>{if(y=this.postProcess(y,r),s){setTimeout(function(){s(y)},0);return}else return y},i=n.length,l=e.length;let c=1,u=i+l;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));const h=(o=r.timeout)!==null&&o!==void 0?o:1/0,f=Date.now()+h,d=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(d[0],n,e,0,r);if(d[0].oldPos+1>=l&&p+1>=i)return a(this.buildValues(d[0].lastComponent,n,e));let w=-1/0,C=1/0;const g=()=>{for(let y=Math.max(w,-c);y<=Math.min(C,c);y+=2){let m;const _=d[y-1],S=d[y+1];_&&(d[y-1]=void 0);let E=!1;if(S){const j=S.oldPos-y;E=S&&0<=j&&j<i}const L=_&&_.oldPos+1<l;if(!E&&!L){d[y]=void 0;continue}if(!L||E&&_.oldPos<S.oldPos?m=this.addToPath(S,!0,!1,0,r):m=this.addToPath(_,!1,!0,1,r),p=this.extractCommon(m,n,e,y,r),m.oldPos+1>=l&&p+1>=i)return a(this.buildValues(m.lastComponent,n,e))||!0;d[y]=m,m.oldPos+1>=l&&(C=Math.min(C,y-1)),p+1>=i&&(w=Math.max(w,y+1))}c++};if(s)(function y(){setTimeout(function(){if(c>u||Date.now()>f)return s(void 0);g()||y()},0)})();else for(;c<=u&&Date.now()<=f;){const y=g();if(y)return y}}addToPath(e,n,r,s,o){const a=e.lastComponent;return a&&!o.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:e.oldPos+s,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(e,n,r,s,o){const a=n.length,i=r.length;let l=e.oldPos,c=l-s,u=0;for(;c+1<a&&l+1<i&&this.equals(r[l+1],n[c+1],o);)c++,l++,u++,o.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return u&&!o.oneChangePerToken&&(e.lastComponent={count:u,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=l,c}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const s=[];let o;for(;e;)s.push(e),o=e.previousComponent,delete e.previousComponent,e=o;s.reverse();const a=s.length;let i=0,l=0,c=0;for(;i<a;i++){const u=s[i];if(u.removed)u.value=this.join(r.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let h=n.slice(l,l+u.count);h=h.map(function(f,d){const p=r[c+d];return p.length>f.length?p:f}),u.value=this.join(h)}else u.value=this.join(n.slice(l,l+u.count));l+=u.count,u.added||(c+=u.count)}}return s}}class Kl extends rs{}const Zl=new Kl;function Ql(t,e,n){return Zl.diff(t,e,n)}const ss="a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class Yl extends rs{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${ss}]+|[^\\S\\n\\r]+|[^${ss}]`,"ug");return e.match(n)||[]}}const Jl=new Yl;function ec(t,e,n){return Jl.diff(t,e,n)}function tc(t={}){const{classPrefix:e="__shiki_",classSuffix:n="",classReplacer:r=i=>i}=t,s=new Map;function o(i){return Object.entries(i).map(([l,c])=>`${l}:${c}`).join(";")}function a(i){const l=typeof i=="string"?i:o(i);let c=e+nc(l)+n;return c=r(c),s.has(c)||s.set(c,typeof i=="string"?i:{...i}),c}return{name:"@shikijs/transformers:style-to-class",pre(i){if(!i.properties.style)return;const l=a(i.properties.style);delete i.properties.style,this.addClassToHast(i,l)},tokens(i){for(const l of i)for(const c of l){if(!c.htmlStyle)continue;const u=a(c.htmlStyle);c.htmlStyle={},c.htmlAttrs||={},c.htmlAttrs.class?c.htmlAttrs.class+=` ${u}`:c.htmlAttrs.class=u}},getClassRegistry(){return s},getCSS(){let i="";for(const[l,c]of s.entries())i+=`.${l}{${typeof c=="string"?c:o(c)}}`;return i},clearRegistry(){s.clear()}}}function nc(t,e=0){let n=3735928559^e,r=1103547991^e;for(let s=0,o;s<t.length;s++)o=t.charCodeAt(s),n=Math.imul(n^o,2654435761),r=Math.imul(r^o,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}const Le={dark:"pierre-dark",light:"pierre-light"},os=new Map,as=new Set;function tn(t,e){t=Array.isArray(t)?t:[t];for(const n of t){if(as.has(n.name))continue;let r=os.get(n.name);r==null&&(r=n,os.set(n.name,r)),as.add(r.name),e.loadLanguageSync(r.data)}}const nn=new Map,is=new Set;function ls(t,e){t=Array.isArray(t)?t:[t];for(let n of t){let r;if(typeof n=="string"){if(r=nn.get(n),r==null)throw new Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else r=n,n=n.name,nn.has(n)||nn.set(n,r);is.has(n)||(is.add(n),e.loadThemeSync(r))}}function Te(t){return t.replace(/\n$|\r\n$/,"")}function rc(t){return{type:"text",value:t}}function rn({tagName:t,children:e=[],properties:n={}}){return{type:"element",tagName:t,properties:n,children:e}}function sc(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e;"children"in e?e=e.children[0]:e=null}}function oc(t,e,n){const r=typeof n.lineInfo=="function"?n.lineInfo(e):n.lineInfo[e];if(r==null)throw console.error({node:t,line:e,state:n}),new Error(`processLine: line ${e}, contains no state.lineInfo`);return t.tagName="span",t.properties["data-column-content"]="",t.children.length===0&&t.children.push(rc(`
|
|
153
|
-
`)),rn({tagName:"div",children:[rn({tagName:"span",children:[rn({tagName:"span",children:[{type:"text",value:`${r.lineNumber}`}],properties:{"data-line-number-content":""}})],properties:{"data-column-number":""}}),t],properties:{"data-line":r.lineNumber,"data-alt-line":r.altLineNumber,"data-line-type":r.type,"data-line-index":r.lineIndex}})}function cs(t=!1){const e={lineInfo:{}},n=[{line(r){return delete r.properties.class,r},pre(r){const s=sc(r),o=[];if(s!=null){let a=1;for(const i of s.children)i.type==="element"&&(o.push(oc(i,a,e)),a++);s.children=o}return r}}];return t&&n.push(ac,us),{state:e,transformers:n,toClass:us}}const us=tc({classPrefix:"hl-"}),ac={name:"token-style-normalizer",tokens(t){for(const e of t)for(const n of e){if(n.htmlStyle!=null)continue;const r={};n.color!=null&&(r.color=n.color),n.bgColor!=null&&(r["background-color"]=n.bgColor),n.fontStyle!=null&&n.fontStyle!==0&&((n.fontStyle&1)!==0&&(r["font-style"]="italic"),(n.fontStyle&2)!==0&&(r["font-weight"]="bold"),(n.fontStyle&4)!==0&&(r["text-decoration"]="underline")),Object.keys(r).length>0&&(n.htmlStyle=r)}}};function D(t="diffs"){return`--${t}-`}const Me={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function sn(t){if(Me[t]!=null)return Me[t];const e=t.match(/\.([^/\\]+\.[^/\\]+)$/);return e!=null&&Me[e[1]]!=null?Me[e[1]]??"text":Me[t.match(/\.([^.]+)$/)?.[1]??""]??"text"}function hs({theme:t=Le,highlighter:e,prefix:n}){let r="";if(typeof t=="string"){const s=e.getTheme(t);r+=`color:${s.fg};`,r+=`background-color:${s.bg};`,r+=`${D(n)}fg:${s.fg};`,r+=`${D(n)}bg:${s.bg};`,r+=on(s,n)}else{let s=e.getTheme(t.dark);r+=`${D(n)}dark:${s.fg};`,r+=`${D(n)}dark-bg:${s.bg};`,r+=on(s,n,"dark"),s=e.getTheme(t.light),r+=`${D(n)}light:${s.fg};`,r+=`${D(n)}light-bg:${s.bg};`,r+=on(s,n,"light")}return r}function on(t,e,n){n=n!=null?`${n}-`:"";let r="";const s=t.colors?.["gitDecoration.addedResourceForeground"]??t.colors?.["terminal.ansiGreen"];s!=null&&(r+=`${D(e)}${n}addition-color:${s};`);const o=t.colors?.["gitDecoration.deletedResourceForeground"]??t.colors?.["terminal.ansiRed"];o!=null&&(r+=`${D(e)}${n}deletion-color:${o};`);const a=t.colors?.["gitDecoration.modifiedResourceForeground"]??t.colors?.["terminal.ansiBlue"];return a!=null&&(r+=`${D(e)}${n}modified-color:${a};`),r}function an(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e.children;"children"in e?e=e.children[0]:e=null}throw console.error(t),new Error("getLineNodes: Unable to find children")}function fs({line:t,spanStart:e,spanLength:n}){return{start:{line:t,character:e},end:{line:t,character:e+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function lt({item:t,arr:e,enableJoin:n,isNeutral:r=!1,isLastItem:s=!1}){const o=e[e.length-1];if(o==null||s||!n){e.push([r?0:1,t.value]);return}const a=o[0]===0;if(r===a||r&&t.value.length===1&&!a){o[1]+=t.value;return}e.push([r?0:1,t.value])}function ic(t,e,n,r=!1){const s=(()=>{const c=n.theme??Le;if(typeof c=="string")return e.getTheme(c).type})(),o=hs({theme:n.theme,highlighter:e});if(t.newLines!=null&&t.oldLines!=null){const{oldContent:c,newContent:u,oldInfo:h,newInfo:f,oldDecorations:d,newDecorations:p}=ds({hunks:t.hunks,oldLines:t.oldLines,newLines:t.newLines,lineDiffType:n.lineDiffType});return{code:ps({oldFile:{name:t.prevName??t.name,contents:c},oldInfo:h,oldDecorations:d,newFile:{name:t.name,contents:u},newInfo:f,newDecorations:p,highlighter:e,options:n,languageOverride:r?"text":t.lang}),themeStyles:o,baseThemeType:s}}const a=[];let i=0,l=0;for(const c of t.hunks){const{oldContent:u,newContent:h,oldInfo:f,newInfo:d,oldDecorations:p,newDecorations:w,splitLineIndex:C,unifiedLineIndex:g}=ds({hunks:[c],splitLineIndex:i,unifiedLineIndex:l,lineDiffType:n.lineDiffType}),y={name:t.prevName??t.name,contents:u},m={name:t.name,contents:h};a.push(ps({oldFile:y,oldInfo:f,oldDecorations:p,newFile:m,newInfo:d,newDecorations:w,highlighter:e,options:n,languageOverride:r?"text":t.lang})),i=C,l=g}return{code:(()=>{if(a.length<=1){const c=a[0]??{oldLines:[],newLines:[]};if(c.newLines.length===0||c.oldLines.length===0)return c}return{hunks:a}})(),themeStyles:o,baseThemeType:s}}function lc({oldLine:t,newLine:e,oldLineIndex:n,newLineIndex:r,oldDecorations:s,newDecorations:o,lineDiffType:a}){if(t==null||e==null||a==="none")return;t=Te(t),e=Te(e);const i=a==="char"?Ql(t,e):ec(t,e),l=[],c=[],u=a==="word-alt";for(const f of i){const d=f===i[i.length-1];!f.added&&!f.removed?(lt({item:f,arr:l,enableJoin:u,isNeutral:!0,isLastItem:d}),lt({item:f,arr:c,enableJoin:u,isNeutral:!0,isLastItem:d})):f.removed?lt({item:f,arr:l,enableJoin:u,isLastItem:d}):lt({item:f,arr:c,enableJoin:u,isLastItem:d})}let h=0;for(const f of l)f[0]===1&&s.push(fs({line:n-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length;h=0;for(const f of c)f[0]===1&&o.push(fs({line:r-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length}function ds({hunks:t,oldLines:e,newLines:n,splitLineIndex:r=0,unifiedLineIndex:s=0,lineDiffType:o}){const a={},i={},l=[],c=[];let u=1,h=1,f=1,d=1,p="",w="";for(const C of t){for(;e!=null&&n!=null&&u<C.additionStart&&h<C.deletionStart;)a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=e[h-1],w+=n[u-1],h++,u++,d++,f++,r++,s++;d=C.deletionStart,f=C.additionStart;for(const g of C.hunkContent)if(g.type==="context")for(const y of g.lines)a[h]={type:"context",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=y,w+=y,h++,u++,f++,d++,r++,s++;else{const y=Math.max(g.additions.length,g.deletions.length);let m=0,_=s;for(;m<y;){const S=g.deletions[m],E=g.additions[m];lc({newLine:E,oldLine:S,oldLineIndex:h,newLineIndex:u,oldDecorations:l,newDecorations:c,lineDiffType:o}),S!=null&&(a[h]={type:"change-deletion",lineNumber:d,lineIndex:`${_},${r}`},p+=S,h++,d++),E!=null&&(i[u]={type:"change-addition",lineNumber:f,lineIndex:`${_+g.deletions.length},${r}`},w+=E,u++,f++),r++,_++,m++}s+=g.additions.length+g.deletions.length}if(!(e==null||n==null||C!==t[t.length-1]))for(;h<=e.length||u<=e.length;){const g=e[h-1],y=n[u-1];if(g==null&&y==null)break;g!=null&&(a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},p+=g,h++,d++),y!=null&&(i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},w+=y,u++,f++),r++,s++}}return{oldContent:Te(p),newContent:Te(w),oldInfo:a,newInfo:i,oldDecorations:l,newDecorations:c,splitLineIndex:r,unifiedLineIndex:s}}function ps({oldFile:t,newFile:e,oldInfo:n,newInfo:r,highlighter:s,oldDecorations:o,newDecorations:a,languageOverride:i,options:{theme:l=Le,...c}}){const u=i??sn(t.name),h=i??sn(e.name),{state:f,transformers:d}=cs(),p=typeof l=="string"?{...c,lang:"text",theme:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()}:{...c,lang:"text",themes:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()};return{oldLines:t.contents===""?[]:(p.lang=u,f.lineInfo=n,p.decorations=o,an(s.codeToHast(t.contents,p))),newLines:e.contents===""?[]:(p.lang=h,p.decorations=a,f.lineInfo=r,an(s.codeToHast(e.contents,p)))}}function cc(t,e,{theme:n=Le,tokenizeMaxLineLength:r},s=!1){const{state:o,transformers:a}=cs(),i=s?"text":t.lang??sn(t.name),l=(()=>{if(typeof n=="string")return e.getTheme(n).type})(),c=hs({theme:n,highlighter:e});o.lineInfo=h=>({type:"context",lineIndex:h-1,lineNumber:h});const u=typeof n=="string"?{lang:i,theme:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r}:{lang:i,themes:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r};return{code:an(e.codeToHast(Te(t.contents),u)),themeStyles:c,baseThemeType:l}}let gs,we={theme:Le,tokenizeMaxLineLength:1e3,lineDiffType:"word-alt"};self.addEventListener("error",t=>{console.error("[Shiki Worker] Unhandled error:",t.error)}),self.addEventListener("message",t=>{const e=t.data;try{switch(e.type){case"initialize":uc(e);break;case"set-render-options":hc(e);break;case"file":fc(e);break;case"diff":dc(e);break;default:throw new Error(`Unknown request type: ${e.type}`)}}catch(n){console.error("Worker error:",n),mc(e.id,n)}});function uc({id:t,renderOptions:e,resolvedThemes:n,resolvedLanguages:r}){const s=ct();ls(n,s),r!=null&&tn(r,s),we=e,postMessage({type:"success",id:t,requestType:"initialize",sentAt:Date.now()})}function hc({id:t,renderOptions:e,resolvedThemes:n}){ls(n,ct()),we=e,postMessage({type:"success",id:t,requestType:"set-render-options",sentAt:Date.now()})}function fc({id:t,file:e,resolvedLanguages:n}){const r=ct();n!=null&&tn(n,r);const s={theme:we.theme,tokenizeMaxLineLength:we.tokenizeMaxLineLength};pc(t,cc(e,r,s),s)}function dc({id:t,diff:e,resolvedLanguages:n}){const r=ct();n!=null&&tn(n,r),gc(t,ic(e,r,we),we)}function ct(){return gs??=Xl({themes:[],langs:[],engine:oa()}),gs}function pc(t,e,n){postMessage({type:"success",requestType:"file",id:t,result:e,options:n,sentAt:Date.now()})}function gc(t,e,n){postMessage({type:"success",requestType:"diff",id:t,result:e,options:n,sentAt:Date.now()})}function mc(t,e){const n={type:"error",id:t,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0};postMessage(n)}})();
|
|
151
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Vi(t,e,n,r){const s=r.schema,o=s.space==="svg"?!1:r.settings.omitOptionalTags;let a=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const i=[];let l;s.space==="html"&&t.tagName==="svg"&&(r.schema=rs);const c=Xi(r,t.properties),u=r.all(s.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=s,u&&(a=!1),(c||!o||!ji(t,e,n))&&(i.push("<",t.tagName,c?" "+c:""),a&&(s.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(u),!a&&(!o||!on(t,e,n))&&i.push("</"+t.tagName+">"),i.join("")}function Xi(t,e){const n=[];let r=-1,s;if(e){for(s in e)if(e[s]!==null&&e[s]!==void 0){const o=Ki(t,s,e[s]);o&&n.push(o)}}for(;++r<n.length;){const o=t.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function Ki(t,e,n){const r=Ya(t.schema,e),s=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,o=t.settings.allowDangerousCharacters?0:1;let a=t.quote,i;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const l=pe(r.attribute,Object.assign({},t.settings.characterReferences,{subset:ze.name[s][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?vi:xi)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?l:(t.settings.preferUnquoted&&(i=pe(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:ze.unquoted[s][o]}))),i!==n&&(t.settings.quoteSmart&&Hn(n,a)>Hn(n,t.alternative)&&(a=t.alternative),i=a+pe(n,Object.assign({},t.settings.characterReferences,{subset:(a==="'"?ze.single:ze.double)[s][o],attribute:!0}))+a),l+(i&&"="+i))}const Zi=["<","&"];function ls(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:pe(t.value,Object.assign({},r.settings.characterReferences,{subset:Zi}))}function Qi(t,e,n,r){return r.settings.allowDangerousHtml?t.value:ls(t,e,n,r)}function Yi(t,e,n,r){return r.all(t)}const Ji=ni("type",{invalid:el,unknown:tl,handlers:{comment:Si,doctype:ki,element:Vi,raw:Qi,root:Yi,text:ls}});function el(t){throw new Error("Expected node, not `"+t+"`")}function tl(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const nl={},rl={},sl=[];function ol(t,e){const n=e||nl,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:al,all:il,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Ha,characterReferences:n.characterReferences||rl,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?rs:ti,quote:r,alternative:s}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function al(t,e,n){return Ji(t,e,n,this)}function il(t){const e=[],n=t&&t.children||sl;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}function et(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[s,o]of Object.entries(e?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function J(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function ll(t){return Array.isArray(t)?t:[t]}async function cs(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function an(t){return!t||["plaintext","txt","text","plain"].includes(t)}function cl(t){return t==="ansi"||an(t)}function ln(t){return t==="none"}function ul(t){return ln(t)}function us(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function ct(t,e=!1){if(t.length===0)return[["",0]];const n=t.split(/(\r?\n)/g);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const a=e?n[o]+(n[o+1]||""):n[o];s.push([a,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}function hl(t){const e=ct(t,!0).map(([s])=>s);function n(s){if(s===t.length)return{line:e.length-1,character:e[e.length-1].length};let o=s,a=0;for(const i of e){if(o<i.length)break;o-=i.length,a++}return{line:a,character:o}}function r(s,o){let a=0;for(let i=0;i<s;i++)a+=e[i].length;return a+=o,a}return{lines:e,indexToPos:n,posToIndex:r}}const cn="light-dark()",fl=["color","background-color"];function dl(t,e){let n=0;const r=[];for(const s of e)s>n&&r.push({...t,content:t.content.slice(n,s),offset:t.offset+n}),n=s;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function pl(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,s)=>r-s);return n.length?t.map(r=>r.flatMap(s=>{const o=n.filter(a=>s.offset<a&&a<s.offset+s.content.length).map(a=>a-s.offset).sort((a,i)=>a-i);return o.length?dl(s,o):s})):t}function gl(t,e,n,r,s="css-vars"){const o={content:t.content,explanation:t.explanation,offset:t.offset},a=e.map(u=>tt(t.variants[u])),i=new Set(a.flatMap(u=>Object.keys(u))),l={},c=(u,h)=>{const f=h==="color"?"":h==="background-color"?"-bg":`-${h}`;return n+e[u]+(h==="color"?"":f)};return a.forEach((u,h)=>{for(const f of i){const d=u[f]||"inherit";if(h===0&&r&&fl.includes(f))if(r===cn&&a.length>1){const p=e.findIndex(y=>y==="light"),w=e.findIndex(y=>y==="dark");if(p===-1||w===-1)throw new $('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const C=a[p][f]||"inherit",g=a[w][f]||"inherit";l[f]=`light-dark(${C}, ${g})`,s==="css-vars"&&(l[c(h,f)]=d)}else l[f]=d;else s==="css-vars"&&(l[c(h,f)]=d)}}),o.htmlStyle=l,o}function tt(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&M.Italic&&(e["font-style"]="italic"),t.fontStyle&M.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&M.Underline&&n.push("underline"),t.fontStyle&M.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function Xt(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const hs=new WeakMap;function ut(t,e){hs.set(t,e)}function $e(t){return hs.get(t)}class Ce{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new Ce(Object.fromEntries(ll(n).map(r=>[r,zt])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,s]=e;this.lang=r,this._stacks={[s]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return ml(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function ml(t){const e=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&e.push(o),s.parent&&r(s.parent)}return r(t),e}function yl(t,e){if(!(t instanceof Ce))throw new $("Invalid grammar state");return t.getInternalStack(e)}function bl(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new $(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...s.indexToPos(a),offset:a}}else{const i=s.lines[a.line];if(i===void 0)throw new $(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${s.lines.length}`);let l=a.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new $(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${i.length}`);return{...a,character:l,offset:s.posToIndex(a.line,l)}}};const s=hl(n.source),o=(n.options.decorations||[]).map(a=>({...a,start:r(a.start),end:r(a.end)}));wl(o),t.set(n.meta,{decorations:o,converter:s,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const s=e(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]);return pl(n,s)},code(n){if(!this.options.decorations?.length)return;const r=e(this),s=Array.from(n.children).filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new $(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(u,h,f,d){const p=s[u];let w="",C=-1,g=-1;if(h===0&&(C=0),f===0&&(g=0),f===Number.POSITIVE_INFINITY&&(g=p.children.length),C===-1||g===-1)for(let m=0;m<p.children.length;m++)w+=fs(p.children[m]),C===-1&&w.length===h&&(C=m+1),g===-1&&w.length===f&&(g=m+1);if(C===-1)throw new $(`Failed to find start index for decoration ${JSON.stringify(d.start)}`);if(g===-1)throw new $(`Failed to find end index for decoration ${JSON.stringify(d.end)}`);const y=p.children.slice(C,g);if(!d.alwaysWrap&&y.length===p.children.length)i(p,d,"line");else if(!d.alwaysWrap&&y.length===1&&y[0].type==="element")i(y[0],d,"token");else{const m={type:"element",tagName:"span",properties:{},children:y};i(m,d,"wrapper"),p.children.splice(C,y.length,m)}}function a(u,h){s[u]=i(s[u],h,"line")}function i(u,h,f){const d=h.properties||{},p=h.transform||(w=>w);return u.tagName=h.tagName||"span",u.properties={...u.properties,...d,class:u.properties.class},h.properties?.class&&us(u,h.properties.class),u=p(u,f)||u,u}const l=[],c=r.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(const u of c){const{start:h,end:f}=u;if(h.line===f.line)o(h.line,h.character,f.character,u);else if(h.line<f.line){o(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let d=h.line+1;d<f.line;d++)l.unshift(()=>a(d,u));o(f.line,0,f.character,u)}}l.forEach(u=>u())}}}function wl(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new $(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const s=t[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,a=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,i=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,l=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||a||i||l){if(o&&a||i&&l||i&&n.start.offset===n.end.offset||a&&s.start.offset===s.end.offset)continue;throw new $(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function fs(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(fs).join(""):""}const Cl=[bl()];function nt(t){const e=_l(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...Cl]}function _l(t){const e=[],n=[],r=[];for(const s of t)switch(s.enforce){case"pre":e.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:e,post:n,normal:r}}var se=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],At={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Sl(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function Zn(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function kl(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)At[r]&&e.push({type:"setDecoration",value:At[r]});else if(r<=29){const s=At[r-20];s&&(e.push({type:"resetDecoration",value:s}),s==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:se[r-30]}});else if(r===38){const s=Zn(t);s&&e.push({type:"setForegroundColor",value:s})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:se[r-40]}});else if(r===48){const s=Zn(t);s&&e.push({type:"setBackgroundColor",value:s})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:se[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:se[r-100+8]}})}return e}function vl(){let t=null,e=null,n=new Set;return{parse(r){const s=[];let o=0;do{const a=Sl(r,o),i=a.sequence?r.substring(o,a.startPosition):r.substring(o);if(i.length>0&&s.push({value:i,foreground:t,background:e,decorations:new Set(n)}),a.sequence){const l=kl(a.sequence);for(const c of l)c.type==="resetAll"?(t=null,e=null,n.clear()):c.type==="resetForegroundColor"?t=null:c.type==="resetBackgroundColor"?e=null:c.type==="resetDecoration"&&n.delete(c.value);for(const c of l)c.type==="setForegroundColor"?t=c.value:c.type==="setBackgroundColor"?e=c.value:c.type==="setDecoration"&&n.add(c.value)}o=a.position}while(o<r.length);return s}}}var xl={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function El(t=xl){function e(i){return t[i]}function n(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let c=0;c<se.length;c++)r.push(e(se[c]));let i=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([i[c],i[u],i[h]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function o(i){return s()[i]}function a(i){switch(i.type){case"named":return e(i.name);case"rgb":return n(i.rgb);case"table":return o(i.index)}}return{value:a}}const Al={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Il(t,e,n){const r=et(t,n),s=ct(e),o=Object.fromEntries(se.map(l=>{const c=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,u=t.colors?.[c];return[l,u||Al[l]]})),a=El(o),i=vl();return s.map(l=>i.parse(l[0]).map(c=>{let u,h;c.decorations.has("reverse")?(u=c.background?a.value(c.background):t.bg,h=c.foreground?a.value(c.foreground):t.fg):(u=c.foreground?a.value(c.foreground):t.fg,h=c.background?a.value(c.background):void 0),u=J(u,r),h=J(h,r),c.decorations.has("dim")&&(u=Rl(u));let f=M.None;return c.decorations.has("bold")&&(f|=M.Bold),c.decorations.has("italic")&&(f|=M.Italic),c.decorations.has("underline")&&(f|=M.Underline),c.decorations.has("strikethrough")&&(f|=M.Strikethrough),{content:c.value,offset:l[1],color:u,bgColor:h,fontStyle:f}}))}function Rl(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const r=e[1];if(r.length===8){const s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const s=r[0],o=r[1],a=r[2],i=r[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${s}${s}${o}${o}${a}${a}${l}`}else if(r.length===3){const s=r[0],o=r[1],a=r[2];return`#${s}${s}${o}${o}${a}${a}80`}}}const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function un(t,e,n={}){const{theme:r=t.getLoadedThemes()[0]}=n,s=t.resolveLangAlias(n.lang||"text");if(an(s)||ln(r))return ct(e).map(l=>[{content:l[0],offset:l[1]}]);const{theme:o,colorMap:a}=t.setTheme(r);if(s==="ansi")return Il(o,e,n);const i=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new $(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new $(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return $l(e,i,o,a,n)}function Nl(...t){if(t.length===2)return $e(t[1]);const[e,n,r={}]=t,{lang:s="text",theme:o=e.getLoadedThemes()[0]}=r;if(an(s)||ln(o))throw new $("Plain language does not have grammar state");if(s==="ansi")throw new $("ANSI language does not have grammar state");const{theme:a,colorMap:i}=e.setTheme(o),l=e.getLanguage(s);return new Ce(rt(n,l,a,i,r).stateStack,l.name,a.name)}function $l(t,e,n,r,s){const o=rt(t,e,n,r,s),a=new Ce(rt(t,e,n,r,s).stateStack,e.name,n.name);return ut(o.tokens,a),o.tokens}function rt(t,e,n,r,s){const o=et(n,s),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:i=500}=s,l=ct(t);let c=s.grammarState?yl(s.grammarState,n.name)??zt:s.grammarContextCode!=null?rt(s.grammarContextCode,e,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:zt,u=[];const h=[];for(let f=0,d=l.length;f<d;f++){const[p,w]=l[f];if(p===""){u=[],h.push([]);continue}if(a>0&&p.length>=a){u=[],h.push([{content:p,offset:w,color:"",fontStyle:0}]);continue}let C,g,y;s.includeExplanation&&(C=e.tokenizeLine(p,c,i),g=C.tokens,y=0);const m=e.tokenizeLine2(p,c,i),_=m.tokens.length/2;for(let S=0;S<_;S++){const E=m.tokens[2*S],L=S+1<_?m.tokens[2*S+2]:p.length;if(E===L)continue;const B=m.tokens[2*S+1],Ge=J(r[ge.getForeground(B)],o),ft=ge.getFontStyle(B),_e={content:p.substring(E,L),offset:w+E,color:Ge,fontStyle:ft};if(s.includeExplanation){const Z=[];if(s.includeExplanation!=="scopeName")for(const q of n.settings){let ie;switch(typeof q.scope){case"string":ie=q.scope.split(/,/).map(dt=>dt.trim());break;case"object":ie=q.scope;break;default:continue}Z.push({settings:q,selectors:ie.map(dt=>dt.split(/ /))})}_e.explanation=[];let dn=0;for(;E+dn<L;){const q=g[y],ie=p.substring(q.startIndex,q.endIndex);dn+=ie.length,_e.explanation.push({content:ie,scopes:s.includeExplanation==="scopeName"?Pl(q.scopes):Ll(Z,q.scopes)}),y+=1}}u.push(_e)}h.push(u),u=[],c=m.ruleStack}return{tokens:h,stateStack:c}}function Pl(t){return t.map(e=>({scopeName:e}))}function Ll(t,e){const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];n[r]={scopeName:o,themeMatches:Ml(t,o,e.slice(0,r))}}return n}function Qn(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function Tl(t,e,n){if(!Qn(t[t.length-1],e))return!1;let r=t.length-2,s=n.length-1;for(;r>=0&&s>=0;)Qn(t[r],n[s])&&(r-=1),s-=1;return r===-1}function Ml(t,e,n){const r=[];for(const{selectors:s,settings:o}of t)for(const a of s)if(Tl(a,e,n)){r.push(o);break}return r}function ds(t,e,n){const r=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),s=r.map(l=>{const c=un(t,e,{...n,theme:l.theme}),u=$e(c),h=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:c,state:u,theme:h}}),o=Ol(...s.map(l=>l.tokens)),a=o[0].map((l,c)=>l.map((u,h)=>{const f={content:u.content,variants:{},offset:u.offset};return"includeExplanation"in n&&n.includeExplanation&&(f.explanation=u.explanation),o.forEach((d,p)=>{const{content:w,explanation:C,offset:g,...y}=d[c][h];f.variants[r[p].color]=y}),f})),i=s[0].state?new Ce(Object.fromEntries(s.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),s[0].state.lang):void 0;return i&&ut(a,i),a}function Ol(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const s=t.map(l=>l[r]),o=e.map(()=>[]);e.forEach((l,c)=>l.push(o[c]));const a=s.map(()=>0),i=s.map(l=>l[0]);for(;i.every(l=>l);){const l=Math.min(...i.map(c=>c.content.length));for(let c=0;c<n;c++){const u=i[c];u.content.length===l?(o[c].push(u),a[c]+=1,i[c]=s[c][a[c]]):(o[c].push({...u,content:u.content.slice(0,l)}),i[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return e}function st(t,e,n){let r,s,o,a,i,l;if("themes"in n){const{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:h="css-vars"}=n,f=Object.entries(n.themes).filter(g=>g[1]).map(g=>({color:g[0],theme:g[1]})).sort((g,y)=>g.color===c?-1:y.color===c?1:0);if(f.length===0)throw new $("`themes` option must not be empty");const d=ds(t,e,n);if(l=$e(d),c&&cn!==c&&!f.find(g=>g.color===c))throw new $(`\`themes\` option must contain the defaultColor key \`${c}\``);const p=f.map(g=>t.getTheme(g.theme)),w=f.map(g=>g.color);o=d.map(g=>g.map(y=>gl(y,w,u,c,h))),l&&ut(o,l);const C=f.map(g=>et(g.theme,n));s=Yn(f,p,C,u,c,"fg",h),r=Yn(f,p,C,u,c,"bg",h),a=`shiki-themes ${p.map(g=>g.name).join(" ")}`,i=c?void 0:[s,r].join(";")}else if("theme"in n){const c=et(n.theme,n);o=un(t,e,n);const u=t.getTheme(n.theme);r=J(u.bg,c),s=J(u.fg,c),a=u.name,l=$e(o)}else throw new $("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:a,rootStyle:i,grammarState:l}}function Yn(t,e,n,r,s,o,a){return t.map((i,l)=>{const c=J(e[l][o],n[l])||"inherit",u=`${r+i.color}${o==="bg"?"-bg":""}:${c}`;if(l===0&&s){if(s===cn&&t.length>1){const h=t.findIndex(w=>w.color==="light"),f=t.findIndex(w=>w.color==="dark");if(h===-1||f===-1)throw new $('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const d=J(e[h][o],n[h])||"inherit",p=J(e[f][o],n[f])||"inherit";return`light-dark(${d}, ${p});${u}`}return c}return a==="css-vars"?u:null}).filter(i=>!!i).join(";")}function ot(t,e,n,r={meta:{},options:n,codeToHast:(s,o)=>ot(t,s,o),codeToTokens:(s,o)=>st(t,s,o)}){let s=e;for(const p of nt(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:o,fg:a,bg:i,themeName:l,rootStyle:c,grammarState:u}=st(t,s,n);const{mergeWhitespaces:h=!0,mergeSameStyleTokens:f=!1}=n;h===!0?o=Dl(o):h==="never"&&(o=Bl(o)),f&&(o=Fl(o));const d={...r,get source(){return s}};for(const p of nt(n))o=p.tokens?.call(d,o)||o;return Gl(o,{...n,fg:a,bg:i,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},d,u)}function Gl(t,e,n,r=$e(t)){const s=nt(e),o=[],a={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=e,c={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?c.style=e.rootStyle:c.style=`background-color:${e.bg};color:${e.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(const[w,C]of Object.entries(e.meta||{}))w.startsWith("_")||(c[w]=C);let u={type:"element",tagName:"pre",properties:c,children:[]},h={type:"element",tagName:"code",properties:{},children:o};const f=[],d={...n,structure:i,addClassToHast:us,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return a},get pre(){return u},get code(){return h},get lines(){return f}};if(t.forEach((w,C)=>{C&&(i==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&o.push({type:"text",value:`
|
|
152
|
+
`}));let g={type:"element",tagName:"span",properties:{class:"line"},children:[]},y=0;for(const m of w){let _={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]};const S=Xt(m.htmlStyle||tt(m));S&&(_.properties.style=S);for(const E of s)_=E?.span?.call(d,_,C+1,y,g,m)||_;i==="inline"?a.children.push(_):i==="classic"&&g.children.push(_),y+=m.content.length}if(i==="classic"){for(const m of s)g=m?.line?.call(d,g,C+1)||g;f.push(g),o.push(g)}else i==="inline"&&f.push(g)}),i==="classic"){for(const w of s)h=w?.code?.call(d,h)||h;u.children.push(h);for(const w of s)u=w?.pre?.call(d,u)||u;a.children.push(u)}else if(i==="inline"){const w=[];let C={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const m of a.children)m.type==="element"&&m.tagName==="br"?(w.push(C),C={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&C.children.push(m);w.push(C);let y={type:"element",tagName:"code",properties:{},children:w};for(const m of s)y=m?.code?.call(d,y)||y;a.children=[];for(let m=0;m<y.children.length;m++){m>0&&a.children.push({type:"element",tagName:"br",properties:{},children:[]});const _=y.children[m];_.type==="element"&&a.children.push(..._.children)}}let p=a;for(const w of s)p=w?.root?.call(d,p)||p;return r&&ut(p,r),p}function Dl(t){return t.map(e=>{const n=[];let r="",s;return e.forEach((o,a)=>{const l=!(o.fontStyle&&(o.fontStyle&M.Underline||o.fontStyle&M.Strikethrough));l&&o.content.match(/^\s+$/)&&e[a+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(l?n.push({...o,offset:s,content:r+o.content}):n.push({content:r,offset:s},o),s=void 0,r=""):n.push(o)}),n})}function Bl(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,s,o,a]=r;if(!s&&!a)return n;const i=[{...n,offset:n.offset+s.length,content:o}];return s&&i.unshift({content:s,offset:n.offset}),a&&i.push({content:a,offset:n.offset+s.length+o.length}),i}))}function Fl(t){return t.map(e=>{const n=[];for(const r of e){if(n.length===0){n.push({...r});continue}const s=n[n.length-1],o=Xt(s.htmlStyle||tt(s)),a=Xt(r.htmlStyle||tt(r)),i=s.fontStyle&&(s.fontStyle&M.Underline||s.fontStyle&M.Strikethrough),l=r.fontStyle&&(r.fontStyle&M.Underline||r.fontStyle&M.Strikethrough);!i&&!l&&o===a?s.content+=r.content:n.push({...r})}return n})}const jl=ol;function Ul(t,e,n){const r={meta:{},options:n,codeToHast:(o,a)=>ot(t,o,a),codeToTokens:(o,a)=>st(t,o,a)};let s=jl(ot(t,e,n,r));for(const o of nt(n))s=o.postprocess?.call(r,s,n)||s;return s}const Jn={light:"#333333",dark:"#bbbbbb"},er={light:"#fffffe",dark:"#1e1e1e"},tr="__shiki_resolved";function hn(t){if(t?.[tr])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const i=e.settings?e.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(r=i.settings.foreground),i?.settings?.background&&(n=i.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?Jn.light:Jn.dark),n||(n=e.type==="light"?er.light:er.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0;const o=new Map;function a(i){if(o.has(i))return o.get(i);s+=1;const l=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${l}`]?a(i):(o.set(i,l),l)}e.settings=e.settings.map(i=>{const l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),c=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!c)return i;const u={...i,settings:{...i.settings}};if(l){const h=a(i.settings.foreground);e.colorReplacements[h]=i.settings.foreground,u.settings.foreground=h}if(c){const h=a(i.settings.background);e.colorReplacements[h]=i.settings.background,u.settings.background=h}return u});for(const i of Object.keys(e.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!e.colors[i]?.startsWith("#")){const l=a(e.colors[i]);e.colorReplacements[l]=e.colors[i],e.colors[i]=l}return Object.defineProperty(e,tr,{enumerable:!1,writable:!1,value:!0}),e}async function zl(t){return Array.from(new Set((await Promise.all(t.filter(e=>!cl(e)).map(async e=>await cs(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function Wl(t){return(await Promise.all(t.map(async n=>ul(n)?null:hn(await cs(n))))).filter(n=>!!n)}class fe extends Error{constructor(e){super(e),this.name="ShikiError"}}function ps(t,e){if(!e)return t;if(e[t]){const n=new Set([t]);for(;e[t];){if(t=e[t],n.has(t))throw new fe(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return t}class ql extends qa{constructor(e,n,r,s={}){super(e),this._resolver=e,this._themes=n,this._langs=r,this._alias=s,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const n=hn(e);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let n=this._textmateThemeCache.get(e);n||(n=Ke.createFromRawTheme(e),this._textmateThemeCache.set(e,n)),this._syncRegistry.setTheme(n)}getGrammar(e){return e=ps(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const n=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const s=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(s.name=e.name,this._resolvedGrammars.set(e.name,s),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,n.size)for(const o of n)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const s of e)this.resolveEmbeddedLanguages(s);const n=Array.from(this._langGraph.entries()),r=n.filter(([s,o])=>!o);if(r.length){const s=n.filter(([o,a])=>a?(a.embeddedLanguages||a.embeddedLangs)?.some(l=>r.map(([c])=>c).includes(l)):!1).filter(o=>!r.includes(o));throw new fe(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${s.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[s,o]of n)this._resolver.addLanguage(o);for(const[s,o]of n)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const n=e.embeddedLanguages??e.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}}class Hl{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,n){this._onigLib={createOnigScanner:r=>e.createScanner(r),createOnigString:r=>e.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let r=[];for(let s=1;s<=n.length;s++){const o=n.slice(0,s).join(".");r=[...r,...this._injections.get(o)||[]]}return r}}let Se=0;function Vl(t){Se+=1,t.warnings!==!1&&Se>=10&&Se%10===0&&console.warn(`[Shiki] ${Se} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new fe("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(hn),s=new Hl(t.engine,n),o=new ql(s,r,n,t.langAlias);let a;function i(m){return ps(m,t.langAlias)}function l(m){g();const _=o.getGrammar(typeof m=="string"?m:m.name);if(!_)throw new fe(`Language \`${m}\` not found, you may need to load it first`);return _}function c(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};g();const _=o.getTheme(m);if(!_)throw new fe(`Theme \`${m}\` not found, you may need to load it first`);return _}function u(m){g();const _=c(m);a!==m&&(o.setTheme(_),a=m);const S=o.getColorMap();return{theme:_,colorMap:S}}function h(){return g(),o.getLoadedThemes()}function f(){return g(),o.getLoadedLanguages()}function d(...m){g(),o.loadLanguages(m.flat(1))}async function p(...m){return d(await zl(m))}function w(...m){g();for(const _ of m.flat(1))o.loadTheme(_)}async function C(...m){return g(),w(await Wl(m))}function g(){if(e)throw new fe("Shiki instance has been disposed")}function y(){e||(e=!0,o.dispose(),Se-=1)}return{setTheme:u,getTheme:c,getLanguage:l,getLoadedThemes:h,getLoadedLanguages:f,resolveLangAlias:i,loadLanguage:p,loadLanguageSync:d,loadTheme:C,loadThemeSync:w,dispose:y,[Symbol.dispose]:y}}function Xl(t){const e=Vl(t);return{getLastGrammarState:(...n)=>Nl(e,...n),codeToTokensBase:(n,r)=>un(e,n,r),codeToTokensWithThemes:(n,r)=>ds(e,n,r),codeToTokens:(n,r)=>st(e,n,r),codeToHast:(n,r)=>ot(e,n,r),codeToHtml:(n,r)=>Ul(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}class gs{diff(e,n,r={}){let s;typeof r=="function"?(s=r,r={}):"callback"in r&&(s=r.callback);const o=this.castInput(e,r),a=this.castInput(n,r),i=this.removeEmpty(this.tokenize(o,r)),l=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(i,l,r,s)}diffWithOptionsObj(e,n,r,s){var o;const a=y=>{if(y=this.postProcess(y,r),s){setTimeout(function(){s(y)},0);return}else return y},i=n.length,l=e.length;let c=1,u=i+l;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));const h=(o=r.timeout)!==null&&o!==void 0?o:1/0,f=Date.now()+h,d=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(d[0],n,e,0,r);if(d[0].oldPos+1>=l&&p+1>=i)return a(this.buildValues(d[0].lastComponent,n,e));let w=-1/0,C=1/0;const g=()=>{for(let y=Math.max(w,-c);y<=Math.min(C,c);y+=2){let m;const _=d[y-1],S=d[y+1];_&&(d[y-1]=void 0);let E=!1;if(S){const B=S.oldPos-y;E=S&&0<=B&&B<i}const L=_&&_.oldPos+1<l;if(!E&&!L){d[y]=void 0;continue}if(!L||E&&_.oldPos<S.oldPos?m=this.addToPath(S,!0,!1,0,r):m=this.addToPath(_,!1,!0,1,r),p=this.extractCommon(m,n,e,y,r),m.oldPos+1>=l&&p+1>=i)return a(this.buildValues(m.lastComponent,n,e))||!0;d[y]=m,m.oldPos+1>=l&&(C=Math.min(C,y-1)),p+1>=i&&(w=Math.max(w,y+1))}c++};if(s)(function y(){setTimeout(function(){if(c>u||Date.now()>f)return s(void 0);g()||y()},0)})();else for(;c<=u&&Date.now()<=f;){const y=g();if(y)return y}}addToPath(e,n,r,s,o){const a=e.lastComponent;return a&&!o.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:e.oldPos+s,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(e,n,r,s,o){const a=n.length,i=r.length;let l=e.oldPos,c=l-s,u=0;for(;c+1<a&&l+1<i&&this.equals(r[l+1],n[c+1],o);)c++,l++,u++,o.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return u&&!o.oneChangePerToken&&(e.lastComponent={count:u,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=l,c}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const s=[];let o;for(;e;)s.push(e),o=e.previousComponent,delete e.previousComponent,e=o;s.reverse();const a=s.length;let i=0,l=0,c=0;for(;i<a;i++){const u=s[i];if(u.removed)u.value=this.join(r.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let h=n.slice(l,l+u.count);h=h.map(function(f,d){const p=r[c+d];return p.length>f.length?p:f}),u.value=this.join(h)}else u.value=this.join(n.slice(l,l+u.count));l+=u.count,u.added||(c+=u.count)}}return s}}class Kl extends gs{}const Zl=new Kl;function Ql(t,e,n){return Zl.diff(t,e,n)}const nr="a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class Yl extends gs{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${nr}]+|[^\\S\\n\\r]+|[^${nr}]`,"ug");return e.match(n)||[]}}const Jl=new Yl;function ec(t,e,n){return Jl.diff(t,e,n)}function tc(t={}){const{classPrefix:e="__shiki_",classSuffix:n="",classReplacer:r=i=>i}=t,s=new Map;function o(i){return Object.entries(i).map(([l,c])=>`${l}:${c}`).join(";")}function a(i){const l=typeof i=="string"?i:o(i);let c=e+nc(l)+n;return c=r(c),s.has(c)||s.set(c,typeof i=="string"?i:{...i}),c}return{name:"@shikijs/transformers:style-to-class",pre(i){if(!i.properties.style)return;const l=a(i.properties.style);delete i.properties.style,this.addClassToHast(i,l)},tokens(i){for(const l of i)for(const c of l){if(!c.htmlStyle)continue;const u=a(c.htmlStyle);c.htmlStyle={},c.htmlAttrs||={},c.htmlAttrs.class?c.htmlAttrs.class+=` ${u}`:c.htmlAttrs.class=u}},getClassRegistry(){return s},getCSS(){let i="";for(const[l,c]of s.entries())i+=`.${l}{${typeof c=="string"?c:o(c)}}`;return i},clearRegistry(){s.clear()}}}function nc(t,e=0){let n=3735928559^e,r=1103547991^e;for(let s=0,o;s<t.length;s++)o=t.charCodeAt(s),n=Math.imul(n^o,2654435761),r=Math.imul(r^o,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}const Oe={dark:"pierre-dark",light:"pierre-light"},rr=new Map,sr=new Set;function fn(t,e){t=Array.isArray(t)?t:[t];for(const n of t){if(sr.has(n.name))continue;let r=rr.get(n.name);r==null&&(r=n,rr.set(n.name,r)),sr.add(r.name),e.loadLanguageSync(r.data)}}const It=new Map,or=new Set;function ms(t,e){t=Array.isArray(t)?t:[t];for(let n of t){let r;if(typeof n=="string"){if(r=It.get(n),r==null)throw new Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else r=n,n=n.name,It.has(n)||It.set(n,r);or.has(n)||(or.add(n),e.loadThemeSync(r))}}function Pe(t){return t.replace(/\n$|\r\n$/,"")}function rc(t){return{type:"text",value:t}}function Rt({tagName:t,children:e=[],properties:n={}}){return{type:"element",tagName:t,properties:n,children:e}}function sc(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e;"children"in e?e=e.children[0]:e=null}}function oc(t,e,n){const r=typeof n.lineInfo=="function"?n.lineInfo(e):n.lineInfo[e];if(r==null)throw console.error({node:t,line:e,state:n}),new Error(`processLine: line ${e}, contains no state.lineInfo`);return t.tagName="span",t.properties["data-column-content"]="",t.children.length===0&&t.children.push(rc(`
|
|
153
|
+
`)),Rt({tagName:"div",children:[Rt({tagName:"span",children:[Rt({tagName:"span",children:[{type:"text",value:`${r.lineNumber}`}],properties:{"data-line-number-content":""}})],properties:{"data-column-number":""}}),t],properties:{"data-line":r.lineNumber,"data-alt-line":r.altLineNumber,"data-line-type":r.type,"data-line-index":r.lineIndex}})}function ys(t=!1){const e={lineInfo:{}},n=[{line(r){return delete r.properties.class,r},pre(r){const s=sc(r),o=[];if(s!=null){let a=1;for(const i of s.children)i.type==="element"&&(o.push(oc(i,a,e)),a++);s.children=o}return r}}];return t&&n.push(ac,ar),{state:e,transformers:n,toClass:ar}}const ar=tc({classPrefix:"hl-"}),ac={name:"token-style-normalizer",tokens(t){for(const e of t)for(const n of e){if(n.htmlStyle!=null)continue;const r={};n.color!=null&&(r.color=n.color),n.bgColor!=null&&(r["background-color"]=n.bgColor),n.fontStyle!=null&&n.fontStyle!==0&&((n.fontStyle&1)!==0&&(r["font-style"]="italic"),(n.fontStyle&2)!==0&&(r["font-weight"]="bold"),(n.fontStyle&4)!==0&&(r["text-decoration"]="underline")),Object.keys(r).length>0&&(n.htmlStyle=r)}}};function D(t="diffs"){return`--${t}-`}const ke={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function Kt(t){if(ke[t]!=null)return ke[t];const e=t.match(/\.([^/\\]+\.[^/\\]+)$/);return e!=null&&ke[e[1]]!=null?ke[e[1]]??"text":ke[t.match(/\.([^.]+)$/)?.[1]??""]??"text"}function bs({theme:t=Oe,highlighter:e,prefix:n}){let r="";if(typeof t=="string"){const s=e.getTheme(t);r+=`color:${s.fg};`,r+=`background-color:${s.bg};`,r+=`${D(n)}fg:${s.fg};`,r+=`${D(n)}bg:${s.bg};`,r+=Nt(s,n)}else{let s=e.getTheme(t.dark);r+=`${D(n)}dark:${s.fg};`,r+=`${D(n)}dark-bg:${s.bg};`,r+=Nt(s,n,"dark"),s=e.getTheme(t.light),r+=`${D(n)}light:${s.fg};`,r+=`${D(n)}light-bg:${s.bg};`,r+=Nt(s,n,"light")}return r}function Nt(t,e,n){n=n!=null?`${n}-`:"";let r="";const s=t.colors?.["gitDecoration.addedResourceForeground"]??t.colors?.["terminal.ansiGreen"];s!=null&&(r+=`${D(e)}${n}addition-color:${s};`);const o=t.colors?.["gitDecoration.deletedResourceForeground"]??t.colors?.["terminal.ansiRed"];o!=null&&(r+=`${D(e)}${n}deletion-color:${o};`);const a=t.colors?.["gitDecoration.modifiedResourceForeground"]??t.colors?.["terminal.ansiBlue"];return a!=null&&(r+=`${D(e)}${n}modified-color:${a};`),r}function Zt(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e.children;"children"in e?e=e.children[0]:e=null}throw console.error(t),new Error("getLineNodes: Unable to find children")}function ir({line:t,spanStart:e,spanLength:n}){return{start:{line:t,character:e},end:{line:t,character:e+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function We({item:t,arr:e,enableJoin:n,isNeutral:r=!1,isLastItem:s=!1}){const o=e[e.length-1];if(o==null||s||!n){e.push([r?0:1,t.value]);return}const a=o[0]===0;if(r===a||r&&t.value.length===1&&!a){o[1]+=t.value;return}e.push([r?0:1,t.value])}function ic(t,e,n,r=!1){const s=(()=>{const c=n.theme??Oe;if(typeof c=="string")return e.getTheme(c).type})(),o=bs({theme:n.theme,highlighter:e});if(t.newLines!=null&&t.oldLines!=null){const{oldContent:c,newContent:u,oldInfo:h,newInfo:f,oldDecorations:d,newDecorations:p}=lr({hunks:t.hunks,oldLines:t.oldLines,newLines:t.newLines,lineDiffType:n.lineDiffType});return{code:cr({oldFile:{name:t.prevName??t.name,contents:c},oldInfo:h,oldDecorations:d,newFile:{name:t.name,contents:u},newInfo:f,newDecorations:p,highlighter:e,options:n,languageOverride:r?"text":t.lang}),themeStyles:o,baseThemeType:s}}const a=[];let i=0,l=0;for(const c of t.hunks){const{oldContent:u,newContent:h,oldInfo:f,newInfo:d,oldDecorations:p,newDecorations:w,splitLineIndex:C,unifiedLineIndex:g}=lr({hunks:[c],splitLineIndex:i,unifiedLineIndex:l,lineDiffType:n.lineDiffType}),y={name:t.prevName??t.name,contents:u},m={name:t.name,contents:h};a.push(cr({oldFile:y,oldInfo:f,oldDecorations:p,newFile:m,newInfo:d,newDecorations:w,highlighter:e,options:n,languageOverride:r?"text":t.lang})),i=C,l=g}return{code:(()=>{if(a.length<=1){const c=a[0]??{oldLines:[],newLines:[]};if(c.newLines.length===0||c.oldLines.length===0)return c}return{hunks:a}})(),themeStyles:o,baseThemeType:s}}function lc({oldLine:t,newLine:e,oldLineIndex:n,newLineIndex:r,oldDecorations:s,newDecorations:o,lineDiffType:a}){if(t==null||e==null||a==="none")return;t=Pe(t),e=Pe(e);const i=a==="char"?Ql(t,e):ec(t,e),l=[],c=[],u=a==="word-alt";for(const f of i){const d=f===i[i.length-1];!f.added&&!f.removed?(We({item:f,arr:l,enableJoin:u,isNeutral:!0,isLastItem:d}),We({item:f,arr:c,enableJoin:u,isNeutral:!0,isLastItem:d})):f.removed?We({item:f,arr:l,enableJoin:u,isLastItem:d}):We({item:f,arr:c,enableJoin:u,isLastItem:d})}let h=0;for(const f of l)f[0]===1&&s.push(ir({line:n-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length;h=0;for(const f of c)f[0]===1&&o.push(ir({line:r-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length}function lr({hunks:t,oldLines:e,newLines:n,splitLineIndex:r=0,unifiedLineIndex:s=0,lineDiffType:o}){const a={},i={},l=[],c=[];let u=1,h=1,f=1,d=1,p="",w="";for(const C of t){for(;e!=null&&n!=null&&u<C.additionStart&&h<C.deletionStart;)a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=e[h-1],w+=n[u-1],h++,u++,d++,f++,r++,s++;d=C.deletionStart,f=C.additionStart;for(const g of C.hunkContent)if(g.type==="context")for(const y of g.lines)a[h]={type:"context",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=y,w+=y,h++,u++,f++,d++,r++,s++;else{const y=Math.max(g.additions.length,g.deletions.length);let m=0,_=s;for(;m<y;){const S=g.deletions[m],E=g.additions[m];lc({newLine:E,oldLine:S,oldLineIndex:h,newLineIndex:u,oldDecorations:l,newDecorations:c,lineDiffType:o}),S!=null&&(a[h]={type:"change-deletion",lineNumber:d,lineIndex:`${_},${r}`},p+=S,h++,d++),E!=null&&(i[u]={type:"change-addition",lineNumber:f,lineIndex:`${_+g.deletions.length},${r}`},w+=E,u++,f++),r++,_++,m++}s+=g.additions.length+g.deletions.length}if(!(e==null||n==null||C!==t[t.length-1]))for(;h<=e.length||u<=e.length;){const g=e[h-1],y=n[u-1];if(g==null&&y==null)break;g!=null&&(a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},p+=g,h++,d++),y!=null&&(i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},w+=y,u++,f++),r++,s++}}return{oldContent:Pe(p),newContent:Pe(w),oldInfo:a,newInfo:i,oldDecorations:l,newDecorations:c,splitLineIndex:r,unifiedLineIndex:s}}function cr({oldFile:t,newFile:e,oldInfo:n,newInfo:r,highlighter:s,oldDecorations:o,newDecorations:a,languageOverride:i,options:{theme:l=Oe,...c}}){const u=i??Kt(t.name),h=i??Kt(e.name),{state:f,transformers:d}=ys(),p=typeof l=="string"?{...c,lang:"text",theme:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()}:{...c,lang:"text",themes:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()};return{oldLines:t.contents===""?[]:(p.lang=u,f.lineInfo=n,p.decorations=o,Zt(s.codeToHast(t.contents,p))),newLines:e.contents===""?[]:(p.lang=h,p.decorations=a,f.lineInfo=r,Zt(s.codeToHast(e.contents,p)))}}function cc(t,e,{theme:n=Oe,tokenizeMaxLineLength:r},s=!1){const{state:o,transformers:a}=ys(),i=s?"text":t.lang??Kt(t.name),l=(()=>{if(typeof n=="string")return e.getTheme(n).type})(),c=bs({theme:n,highlighter:e});o.lineInfo=h=>({type:"context",lineIndex:h-1,lineNumber:h});const u=typeof n=="string"?{lang:i,theme:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r}:{lang:i,themes:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r};return{code:Zt(e.codeToHast(Pe(t.contents),u)),themeStyles:c,baseThemeType:l}}let ur,me={theme:Oe,tokenizeMaxLineLength:1e3,lineDiffType:"word-alt"};self.addEventListener("error",t=>{console.error("[Shiki Worker] Unhandled error:",t.error)});self.addEventListener("message",t=>{const e=t.data;try{switch(e.type){case"initialize":uc(e);break;case"set-render-options":hc(e);break;case"file":fc(e);break;case"diff":dc(e);break;default:throw new Error(`Unknown request type: ${e.type}`)}}catch(n){console.error("Worker error:",n),mc(e.id,n)}});function uc({id:t,renderOptions:e,resolvedThemes:n,resolvedLanguages:r}){const s=ht();ms(n,s),r!=null&&fn(r,s),me=e,postMessage({type:"success",id:t,requestType:"initialize",sentAt:Date.now()})}function hc({id:t,renderOptions:e,resolvedThemes:n}){ms(n,ht()),me=e,postMessage({type:"success",id:t,requestType:"set-render-options",sentAt:Date.now()})}function fc({id:t,file:e,resolvedLanguages:n}){const r=ht();n!=null&&fn(n,r);const s={theme:me.theme,tokenizeMaxLineLength:me.tokenizeMaxLineLength};pc(t,cc(e,r,s),s)}function dc({id:t,diff:e,resolvedLanguages:n}){const r=ht();n!=null&&fn(n,r),gc(t,ic(e,r,me),me)}function ht(){return ur??=Xl({themes:[],langs:[],engine:oa()}),ur}function pc(t,e,n){postMessage({type:"success",requestType:"file",id:t,result:e,options:n,sentAt:Date.now()})}function gc(t,e,n){postMessage({type:"success",requestType:"diff",id:t,result:e,options:n,sentAt:Date.now()})}function mc(t,e){const n={type:"error",id:t,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0};postMessage(n)}
|