@linkshell/gateway 0.6.38 → 0.6.40

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.
Files changed (98) hide show
  1. package/dist/gateway/src/relay.d.ts +1 -1
  2. package/dist/gateway/src/relay.js +8 -1
  3. package/dist/gateway/src/relay.js.map +1 -1
  4. package/dist/gateway/tsconfig.tsbuildinfo +1 -1
  5. package/dist/wire/src/envelopes.d.ts +53 -0
  6. package/dist/wire/src/envelopes.js +251 -0
  7. package/dist/wire/src/envelopes.js.map +1 -0
  8. package/dist/wire/src/index.d.ts +3 -0
  9. package/dist/wire/src/index.js +3 -0
  10. package/dist/wire/src/index.js.map +1 -1
  11. package/dist/wire/src/model.d.ts +54 -0
  12. package/dist/wire/src/model.js +28 -0
  13. package/dist/wire/src/model.js.map +1 -1
  14. package/dist/wire/src/rpc-mcp.d.ts +199 -0
  15. package/dist/wire/src/rpc-mcp.js +78 -0
  16. package/dist/wire/src/rpc-mcp.js.map +1 -0
  17. package/dist/wire/src/rpc.d.ts +823 -6
  18. package/dist/wire/src/rpc.js +64 -1
  19. package/dist/wire/src/rpc.js.map +1 -1
  20. package/dist/wire/src/side.d.ts +83 -0
  21. package/dist/wire/src/side.js +26 -0
  22. package/dist/wire/src/side.js.map +1 -0
  23. package/dist/wire/src/updates.d.ts +211 -0
  24. package/dist/wire/src/updates.js +14 -1
  25. package/dist/wire/src/updates.js.map +1 -1
  26. package/package.json +2 -2
  27. package/src/relay.ts +4 -1
  28. package/web-client/assets/astro-DOly5024.js +1 -0
  29. package/web-client/assets/bash-Yzrsuije.js +1 -0
  30. package/web-client/assets/bat-CickPsom.js +1 -0
  31. package/web-client/assets/c-BIGW1oBm.js +1 -0
  32. package/web-client/assets/clojure-P80f7IUj.js +1 -0
  33. package/web-client/assets/cpp-DddhVWhK.js +1 -0
  34. package/web-client/assets/csharp-B_TYUkTI.js +1 -0
  35. package/web-client/assets/css-Z72CF80r.js +1 -0
  36. package/web-client/assets/dart-CtKP3W-j.js +1 -0
  37. package/web-client/assets/diff-D97Zzqfu.js +1 -0
  38. package/web-client/assets/dockerfile-BcOcwvcX.js +1 -0
  39. package/web-client/assets/elixir-DkJLSxtU.js +1 -0
  40. package/web-client/assets/go-C27-OAKa.js +1 -0
  41. package/web-client/assets/graphql-ChdNCCLP.js +1 -0
  42. package/web-client/assets/haskell-Df6bDoY_.js +1 -0
  43. package/web-client/assets/hcl-BWvSN4gD.js +1 -0
  44. package/web-client/assets/highlight-engine-8FCPMBLW.js +145 -0
  45. package/web-client/assets/html-BlS82ilI.js +1 -0
  46. package/web-client/assets/index-D_DkC1qC.css +1 -0
  47. package/web-client/assets/index-e11uQw2o.js +2 -0
  48. package/web-client/assets/ini-BEwlwnbL.js +1 -0
  49. package/web-client/assets/java-CylS5w8V.js +1 -0
  50. package/web-client/assets/javascript-wDzz0qaB.js +1 -0
  51. package/web-client/assets/json-Cp-IABpG.js +1 -0
  52. package/web-client/assets/jsonc-Des-eS-w.js +1 -0
  53. package/web-client/assets/jsx-g9-lgVsj.js +1 -0
  54. package/web-client/assets/kotlin-BdnUsdx6.js +1 -0
  55. package/web-client/assets/latex-BK3a6r9z.js +1 -0
  56. package/web-client/assets/less-B1dDrJ26.js +1 -0
  57. package/web-client/assets/lua-BaeVxFsk.js +1 -0
  58. package/web-client/assets/makefile-CHLpvVh8.js +1 -0
  59. package/web-client/assets/mark-glyph-D_OhbJdd.png +0 -0
  60. package/web-client/assets/markdown-Cvjx9yec.js +1 -0
  61. package/web-client/assets/markdown-gsWh3zpl.js +53 -0
  62. package/web-client/assets/nginx-BpAMiNFr.js +1 -0
  63. package/web-client/assets/nix-CwoSXNpI.js +1 -0
  64. package/web-client/assets/objective-c-DXmwc3jG.js +1 -0
  65. package/web-client/assets/perl-5klg-GXX.js +1 -0
  66. package/web-client/assets/php-DoruYMF0.js +1 -0
  67. package/web-client/assets/postcss-DnzrXTVv.js +1 -0
  68. package/web-client/assets/powershell-Dd0kTxKP.js +1 -0
  69. package/web-client/assets/prisma-Vru482bI.js +1 -0
  70. package/web-client/assets/proto-C7zT0LnQ.js +1 -0
  71. package/web-client/assets/python-B6aJPvgy.js +1 -0
  72. package/web-client/assets/{qr-scanner.min-D-mj1Slb.js → qr-scanner.min-5hxUn9oI.js} +1 -1
  73. package/web-client/assets/r-Cf5RLm7j.js +1 -0
  74. package/web-client/assets/render-CugEn_RJ.css +1 -0
  75. package/web-client/assets/render-D_iGMdQB.js +757 -0
  76. package/web-client/assets/ruby-KQScI-mG.js +1 -0
  77. package/web-client/assets/rust-DPvrY3IQ.js +1 -0
  78. package/web-client/assets/sass-Cj5Yp3dK.js +1 -0
  79. package/web-client/assets/scala-CqE71os6.js +1 -0
  80. package/web-client/assets/scss-Cw6XMfVs.js +1 -0
  81. package/web-client/assets/sql-DkvoVjww.js +1 -0
  82. package/web-client/assets/svelte-DoIXUgJc.js +1 -0
  83. package/web-client/assets/swift-C2oV4EkX.js +1 -0
  84. package/web-client/assets/terraform-BETggiCN.js +1 -0
  85. package/web-client/assets/toml-vGWfd6FD.js +1 -0
  86. package/web-client/assets/tsx-COt5Ahok.js +1 -0
  87. package/web-client/assets/typescript-BPQ3VLAy.js +1 -0
  88. package/web-client/assets/vim-CJc9bBzg.js +1 -0
  89. package/web-client/assets/vue-CwSeJimo.js +1 -0
  90. package/web-client/assets/xml-sdJ4AIDG.js +1 -0
  91. package/web-client/assets/yaml-Buea-lGh.js +1 -0
  92. package/web-client/assets/zig-VOosw3JB.js +1 -0
  93. package/web-client/index.html +2 -2
  94. package/web-client/assets/index-Byw7jIME.css +0 -1
  95. package/web-client/assets/index-CI0n455B.js +0 -2
  96. package/web-client/assets/markdown-SZOrMO_3.js +0 -45
  97. package/web-client/assets/render-DbAsu5wu.js +0 -642
  98. package/web-client/assets/render-thZKmerw.css +0 -1
@@ -0,0 +1,145 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/astro-DOly5024.js","assets/json-Cp-IABpG.js","assets/javascript-wDzz0qaB.js","assets/typescript-BPQ3VLAy.js","assets/css-Z72CF80r.js","assets/postcss-DnzrXTVv.js","assets/tsx-COt5Ahok.js","assets/cpp-DddhVWhK.js","assets/c-BIGW1oBm.js","assets/elixir-DkJLSxtU.js","assets/html-BlS82ilI.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/latex-BK3a6r9z.js","assets/r-Cf5RLm7j.js","assets/lua-BaeVxFsk.js","assets/nginx-BpAMiNFr.js","assets/perl-5klg-GXX.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/sql-DkvoVjww.js","assets/php-DoruYMF0.js","assets/ruby-KQScI-mG.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/scss-Cw6XMfVs.js","assets/svelte-DoIXUgJc.js","assets/vue-CwSeJimo.js"])))=>i.map(i=>d[i]);
2
+ import{_ as b}from"./index-e11uQw2o.js";import{t as dr}from"./markdown-gsWh3zpl.js";var E=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function pr(e){return kt(e)}function kt(e){return Array.isArray(e)?gr(e):e instanceof RegExp?e:typeof e=="object"?mr(e):e}function gr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=kt(e[n]);return t}function mr(e){let t={};for(let n in e)t[n]=kt(e[n]);return t}function mn(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function _n(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?_n(e.substring(0,e.length-1)):e.substr(~t+1)}var Qe=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(e){return e===null?!1:(Qe.lastIndex=0,Qe.test(e))}static replaceCaptures(e,t,n){return e.replace(Qe,(r,s,o,i)=>{let a=n[parseInt(s||o,10)];if(a){let c=t.substring(a.start,a.end);for(;c[0]===".";)c=c.substring(1);switch(i){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function yn(e,t){return e<t?-1:e>t?1:0}function wn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let s=0;s<n;s++){let o=yn(e[s],t[s]);if(o!==0)return o}return 0}return n-r}function Nt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function bn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Cn=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},ve=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(wr(e),t)}static createFromParsedTheme(e,t){return Cr(e,t)}_cachedMatchRoot=new Cn(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(s=>_r(e.parent,s.parentScopes));return r?new kn(r.fontStyle,r.foreground,r.background):null}},Ke=class Se{constructor(t,n){this.parent=t,this.scopeName=n}parent;scopeName;static push(t,n){for(const r of n)t=new Se(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Se(n,t[r]);return n}push(t){return new Se(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function _r(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!yr(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function yr(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var kn=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function wr(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let s=0,o=t.length;s<o;s++){let i=t[s];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let h=i.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let c=-1;if(typeof i.settings.fontStyle=="string"){c=0;let h=i.settings.fontStyle.split(" ");for(let f=0,d=h.length;f<d;f++)switch(h[f]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof i.settings.foreground=="string"&&Nt(i.settings.foreground)&&(l=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Nt(i.settings.background)&&(u=i.settings.background);for(let h=0,f=a.length;h<f;h++){let p=a[h].trim().split(" "),_=p[p.length-1],y=null;p.length>1&&(y=p.slice(0,p.length-1),y.reverse()),n[r++]=new br(_,y,s,c,l,u)}}return n}var br=class{constructor(e,t,n,r,s,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}scope;parentScopes;index;fontStyle;foreground;background},$=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))($||{});function Cr(e,t){e.sort((c,l)=>{let u=yn(c.scope,l.scope);return u!==0||(u=wn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&e[0].scope==="";){let c=e.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let o=new kr(t),i=new kn(n,o.getId(r),o.getId(s)),a=new Er(new at(0,null,-1,0,0),[]);for(let c=0,l=e.length;c<l;c++){let u=e[c];a.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new ve(o,i,a)}var kr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Sr=Object.freeze([]),at=class Sn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,s,o){this.scopeDepth=t,this.parentScopes=n||Sr,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new Sn(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,s=t.length;r<s;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,s){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Er=class ct{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,s=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=t.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-t.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),s,o;if(r===-1?(s=t,o=""):(s=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(ct._cmpBySpecificity),n}insert(t,n,r,s,o,i){if(n===""){this._doInsertHere(t,r,s,o,i);return}let a=n.indexOf("."),c,l;a===-1?(c=n,l=""):(c=n.substring(0,a),l=n.substring(a+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new ct(this._mainRule.clone(),at.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,s,o,i)}_doInsertHere(t,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(t,r,s,o);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let c=this._rulesWithParentScopes[i];if(wn(c.parentScopes,n)===0){c.acceptOverwrite(t,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 at(t,n,r,s,o))}},J=class N{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=N.getLanguageId(t),r=N.getTokenType(t),s=N.getFontStyle(t),o=N.getForeground(t),i=N.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,s,o,i,a){let c=N.getLanguageId(t),l=N.getTokenType(t),u=N.containsBalancedBrackets(t)?1:0,h=N.getFontStyle(t),f=N.getForeground(t),d=N.getBackground(t);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),i!==0&&(f=i),a!==0&&(d=a),(c<<0|l<<8|u<<10|h<<11|f<<15|d<<24)>>>0}};function Ae(e,t){const n=[],r=Ir(e);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=i();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const c=o();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=a();return s===")"&&(s=r.next()),c}if(Pt(s)){const c=[];do c.push(s),s=r.next();while(Pt(s));return l=>t(c,l)}return null}function i(){const c=[];let l=o();for(;l;)c.push(l),l=o();return u=>c.every(h=>h(u))}function a(){const c=[];let l=i();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=i()}return u=>c.some(h=>h(u))}}function Pt(e){return!!e&&!!e.match(/[\w\.:]+/)}function Ir(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function En(e){typeof e.dispose=="function"&&e.dispose()}var fe=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},vr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Ar=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},xr=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new fe(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new Ar;for(const n of e)Rr(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof fe){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 Rr(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const o=n.lookup(t);e instanceof fe?Ee({baseGrammar:o,selfGrammar:s},r):lt(e.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const i=n.injections(e.scopeName);if(i)for(const a of i)r.add(new fe(a))}function lt(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];xe([r],t,n)}}function Ee(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&xe(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&xe(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function xe(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?mn({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&xe(r.patterns,{...t,repository:s},n);const o=r.include;if(!o)continue;const i=In(o);switch(i.kind){case 0:Ee({...t,selfGrammar:t.baseGrammar},n);break;case 1:Ee(t,n);break;case 2:lt(i.ruleName,{...t,repository:s},n);break;case 3:case 4:const a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){const c={baseGrammar:t.baseGrammar,selfGrammar:a,repository:s};i.kind===4?lt(i.ruleName,c,n):Ee(c,n)}else i.kind===4?n.add(new vr(i.scopeName,i.ruleName)):n.add(new fe(i.scopeName));break}}}var $r=class{kind=0},Lr=class{kind=1},Nr=class{constructor(e){this.ruleName=e}ruleName;kind=2},Pr=class{constructor(e){this.scopeName=e}scopeName;kind=3},Tr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function In(e){if(e==="$base")return new $r;if(e==="$self")return new Lr;const t=e.indexOf("#");if(t===-1)return new Pr(e);if(t===0)return new Nr(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new Tr(n,r)}}var Gr=/\\(\d+)/,Tt=/\\(\d+)/g,Mr=-1,vn=-2;var _e=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${_n(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:we.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,e,t)}},Or=class extends _e{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},Br=class extends _e{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new de(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(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new pe,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Gt=class extends _e{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new pe,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ut=class extends _e{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,o,i,a,c,l){super(e,t,n,r),this._begin=new de(s,this.id),this.beginCaptures=o,this._end=new de(i||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new pe;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Re=class extends _e{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,o,i,a,c){super(e,t,n,r),this._begin=new de(s,this.id),this.beginCaptures=o,this.whileCaptures=a,this._while=new de(i,vn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new pe;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new pe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"￿"),this._cachedCompiledWhilePatterns}},An=class R{static createCaptureRule(t,n,r,s,o){return t.registerRule(i=>new Or(n,i,r,s,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new Br(t.$vscodeTextmateLocation,t.id,t.name,t.match,R._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=mn({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new Gt(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,R._compilePatterns(o,n,r))}return t.while?new Re(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,R._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,R._compileCaptures(t.whileCaptures||t.captures,n,r),R._compilePatterns(t.patterns,n,r)):new ut(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,R._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,R._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,R._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let o=0;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);a>o&&(o=a)}for(let i=0;i<=o;i++)s[i]=null;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);let c=0;t[i].patterns&&(c=R.getCompiledRuleId(t[i],n,r)),s[a]=R.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,c)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let o=0,i=t.length;o<i;o++){const a=t[o];let c=-1;if(a.include){const l=In(a.include);switch(l.kind){case 0:case 1:c=R.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=R.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,f=l.kind===4?l.ruleName:null,d=n.getExternalGrammar(h,r);if(d)if(f){let p=d.repository[f];p&&(c=R.getCompiledRuleId(p,n,d.repository))}else c=R.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else c=R.getCompiledRuleId(a,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof Gt||l instanceof ut||l instanceof Re)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},de=class xn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){const r=t.length;let s=0,o=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){const l=t.charAt(a+1);l==="z"?(o.push(t.substring(s,a)),o.push("$(?!\\n)(?<!\\n)"),s=a+2):(l==="A"||l==="G")&&(i=!0),a++}this.hasAnchor=i,s===0?this.source=t:(o.push(t.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Gr.test(this.source):this.hasBackReferences=!1}clone(){return new xn(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,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=>t.substring(s.start,s.end));return Tt.lastIndex=0,this.source.replace(Tt,(s,o)=>bn(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 t=[],n=[],r=[],s=[],o,i,a,c;for(o=0,i=this.source.length;o<i;o++)a=this.source.charAt(o),t[o]=a,n[o]=a,r[o]=a,s[o]=a,a==="\\"&&o+1<i&&(c=this.source.charAt(o+1),c==="A"?(t[o+1]="￿",n[o+1]="￿",r[o+1]="A",s[o+1]="A"):c==="G"?(t[o+1]="￿",n[o+1]="G",r[o+1]="￿",s[o+1]="G"):(t[o+1]=c,n[o+1]=c,r[o+1]=c,s[o+1]=c),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},pe=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(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Mt(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(s=>s.resolveAnchors(t,n));return new Mt(e,r,this._items.map(s=>s.ruleId))}},Mt=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
3
+ `)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Ze=class{constructor(e,t){this.languageId=e,this.tokenType=t}languageId;tokenType},Dr=class ht{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Ze(t,8),this._embeddedLanguagesMatcher=new Fr(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?ht._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Ze(0,0);_getBasicScopeAttributes=new Cn(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Ze(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(ht.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/},Fr=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>bn(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Ot=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}stack;stoppedEarly};function Rn(e,t,n,r,s,o,i,a){const c=t.content.length;let l=!1,u=-1;if(i){const d=jr(e,t,n,r,s,o);s=d.stack,r=d.linePos,n=d.isFirstLine,u=d.anchorPosition}const h=Date.now();for(;!l;){if(a!==0&&Date.now()-h>a)return new Ot(s,!0);f()}return new Ot(s,!1);function f(){const d=Ur(e,t,n,r,s,u);if(!d){o.produce(s,c),l=!0;return}const p=d.captureIndices,_=d.matchedRuleId,y=p&&p.length>0?p[0].end>r:!1;if(_===Mr){const g=s.getRule(e);o.produce(s,p[0].start),s=s.withContentNameScopesList(s.nameScopesList),le(e,t,n,s,o,g.endCaptures,p),o.produce(s,p[0].end);const m=s;if(s=s.parent,u=m.getAnchorPos(),!y&&m.getEnterPos()===r){s=m,o.produce(s,c),l=!0;return}}else{const g=e.getRule(_);o.produce(s,p[0].start);const m=s,w=g.getName(t.content,p),k=s.contentNameScopesList.pushAttributed(w,e);if(s=s.push(_,r,u,p[0].end===c,null,k,k),g instanceof ut){const S=g;le(e,t,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const x=S.getContentName(t.content,p),L=k.pushAttributed(x,e);if(s=s.withContentNameScopesList(L),S.endHasBackReferences&&(s=s.withEndRule(S.getEndWithResolvedBackReferences(t.content,p))),!y&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,c),l=!0;return}}else if(g instanceof Re){const S=g;le(e,t,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const x=S.getContentName(t.content,p),L=k.pushAttributed(x,e);if(s=s.withContentNameScopesList(L),S.whileHasBackReferences&&(s=s.withEndRule(S.getWhileWithResolvedBackReferences(t.content,p))),!y&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,c),l=!0;return}}else if(le(e,t,n,s,o,g.captures,p),o.produce(s,p[0].end),s=s.pop(),!y){s=s.safePop(),o.produce(s,c),l=!0;return}}p[0].end>r&&(r=p[0].end,n=!1)}}function jr(e,t,n,r,s,o){let i=s.beginRuleCapturedEOL?0:-1;const a=[];for(let c=s;c;c=c.pop()){const l=c.getRule(e);l instanceof Re&&a.push({rule:l,stack:c})}for(let c=a.pop();c;c=a.pop()){const{ruleScanner:l,findOptions:u}=zr(c.rule,e,c.stack.endRule,n,r===i),h=l.findNextMatchSync(t,r,u);if(h){if(h.ruleId!==vn){s=c.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(o.produce(c.stack,h.captureIndices[0].start),le(e,t,n,c.stack,o,c.rule.whileCaptures,h.captureIndices),o.produce(c.stack,h.captureIndices[0].end),i=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=c.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:i,isFirstLine:n}}function Ur(e,t,n,r,s,o){const i=Vr(e,t,n,r,s,o),a=e.getInjections();if(a.length===0)return i;const c=Wr(a,e,t,n,r,s,o);if(!c)return i;if(!i)return c;const l=i.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:i}function Vr(e,t,n,r,s,o){const i=s.getRule(e),{ruleScanner:a,findOptions:c}=$n(i,e,s.endRule,n,r===o),l=a.findNextMatchSync(t,r,c);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}function Wr(e,t,n,r,s,o,i){let a=Number.MAX_VALUE,c=null,l,u=0;const h=o.contentNameScopesList.getScopeNames();for(let f=0,d=e.length;f<d;f++){const p=e[f];if(!p.matcher(h))continue;const _=t.getRule(p.ruleId),{ruleScanner:y,findOptions:g}=$n(_,t,null,r,s===i),m=y.findNextMatchSync(n,s,g);if(!m)continue;const w=m.captureIndices[0].start;if(!(w>=a)&&(a=w,c=m.captureIndices,l=m.ruleId,u=p.priority,a===s))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function $n(e,t,n,r,s){return{ruleScanner:e.compileAG(t,n,r,s),findOptions:0}}function zr(e,t,n,r,s){return{ruleScanner:e.compileWhileAG(t,n,r,s),findOptions:0}}function le(e,t,n,r,s,o,i){if(o.length===0)return;const a=t.content,c=Math.min(o.length,i.length),l=[],u=i[0].end;for(let h=0;h<c;h++){const f=o[h];if(f===null)continue;const d=i[h];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?s.produceFromScopes(l[l.length-1].scopes,d.start):s.produce(r,d.start),f.retokenizeCapturedWithRuleId){const _=f.getName(a,i),y=r.contentNameScopesList.pushAttributed(_,e),g=f.getContentName(a,i),m=y.pushAttributed(g,e),w=r.push(f.retokenizeCapturedWithRuleId,d.start,-1,!1,null,y,m),k=e.createOnigString(a.substring(0,d.end));Rn(e,k,n&&d.start===0,d.start,w,s,!1,0),En(k);continue}const p=f.getName(a,i);if(p!==null){const y=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(p,e);l.push(new Hr(y,d.end))}}for(;l.length>0;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Hr=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function qr(e,t,n,r,s,o,i,a){return new Qr(e,t,n,r,s,o,i,a)}function Bt(e,t,n,r,s){const o=Ae(t,$e),i=An.getCompiledRuleId(n,r,s.repository);for(const a of o)e.push({debugSelector:t,matcher:a.matcher,ruleId:i,grammar:s,priority:a.priority})}function $e(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let s=n;s<t.length;s++)if(Xr(t[s],r))return n=s+1,!0;return!1})}function Xr(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var Qr=class{constructor(e,t,n,r,s,o,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=a,this._basicScopeAttributesProvider=new Dr(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Dt(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const c of Object.keys(s)){const l=Ae(c,$e);for(const u of l)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[c]})}}_rootScopeName;balancedBracketSelectors;_onigLib;_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const s=r.injections;if(s)for(let i in s)Bt(t,i,s[i],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(i=>{const a=this.getExternalGrammar(i);if(a){const c=a.injectionSelector;c&&Bt(t,c,a,this,a)}})}return t.sort((s,o)=>s.priority-o.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Dt(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=An.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!t||t===ft.NULL){s=!0;const l=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=J.set(0,l.languageId,l.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null);let d;f?d=ue.createRootAndLookUpScopeName(f,h,this):d=ue.createRoot("unknown",h),t=new ft(null,this._rootId,-1,-1,!1,null,d,d)}else s=!1,t.reset();e=e+`
4
+ `;const o=this.createOnigString(e),i=o.content.length,a=new Zr(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Rn(this,o,s,0,t,a,!0,r);return En(o),{lineLength:i,lineTokens:a,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Dt(e,t){return e=pr(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var ue=class D{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,s=t?.scopePath??null;for(const o of n)s=Ke.push(s,o.scopeNames),r=new D(r,s,o.encodedTokenAttributes);return r}static createRoot(t,n){return new D(null,new Ke(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const s=r.getMetadataForScope(t),o=new Ke(null,t),i=r.themeProvider.themeMatch(o),a=D.mergeAttributes(n,s,i);return new D(null,o,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return D.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let s=-1,o=0,i=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,i=r.backgroundId),J.set(t,n.languageId,n.tokenType,null,s,o,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return D._pushAttributed(this,t,n);const r=t.split(/ /g);let s=this;for(const o of r)s=D._pushAttributed(s,o,n);return s}static _pushAttributed(t,n,r){const s=r.getMetadataForScope(n),o=t.scopePath.push(n),i=r.themeProvider.themeMatch(o),a=D.mergeAttributes(t.tokenAttributes,s,i);return new D(t,o,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?n.reverse():void 0}},ft=class X{constructor(t,n,r,s,o,i,a,c){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new X(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:X._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?ue.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){X._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,s,o,i,a){return new X(this,t,n,r,s,o,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new X(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.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(t,n){const r=ue.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new X(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,ue.fromExtension(r,n.contentNameScopesList))}},Kr=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Ae(n,$e).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Ae(n,$e).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Zr=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=e?.getScopeNames()??[];for(const i of this._tokenTypeOverrides)i.matcher(o)&&(r=J.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=J.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}const n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),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}},Jr=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,s){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,qr(e,o,t,n,r,s,this,this._onigLib))}return this._grammars.get(e)}},Yr=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new Jr(ve.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(ve.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,r){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(t,n,r){return this._loadGrammar(t,n,r.embeddedLanguages,r.tokenTypes,new Kr(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,s,o){const i=new xr(this._syncRegistry,t);for(;i.Q.length>0;)i.Q.map(a=>this._loadSingleGrammar(a.scopeName)),i.processQueue();return this._grammarForScopeName(t,n,r,s,o)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,s=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,s)}_grammarForScopeName(t,n=0,r=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(t,n,r,s,o)}},dt=ft.NULL;function Le(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[s,o]of Object.entries(t?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function H(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function es(e){return Array.isArray(e)?e:[e]}async function Ln(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Oe(e){return!e||["plaintext","txt","text","plain"].includes(e)}function ts(e){return e==="ansi"||Oe(e)}function Be(e){return e==="none"}function ns(e){return Be(e)}const rs=/(\r?\n)/g;function De(e,t=!1){if(e.length===0)return[["",0]];const n=e.split(rs);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const i=t?n[o]+(n[o+1]||""):n[o];s.push([i,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}const Ft={light:"#333333",dark:"#bbbbbb"},jt={light:"#fffffe",dark:"#1e1e1e"},Ut="__shiki_resolved";function St(e){if(e?.[Ut])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){const a=t.settings?t.settings.find(c=>!c.name&&!c.scope):void 0;a?.settings?.foreground&&(r=a.settings.foreground),a?.settings?.background&&(n=a.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Ft.light:Ft.dark),n||(n=t.type==="light"?jt.light:jt.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let s=0;const o=new Map;function i(a){if(o.has(a))return o.get(a);s+=1;const c=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${c}`]?i(a):(o.set(a,c),c)}t.settings=t.settings.map(a=>{const c=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),l=a.settings?.background&&!a.settings.background.startsWith("#");if(!c&&!l)return a;const u={...a,settings:{...a.settings}};if(c){const h=i(a.settings.foreground);t.colorReplacements[h]=a.settings.foreground,u.settings.foreground=h}if(l){const h=i(a.settings.background);t.colorReplacements[h]=a.settings.background,u.settings.background=h}return u});for(const a of Object.keys(t.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!t.colors[a]?.startsWith("#")){const c=i(t.colors[a]);t.colorReplacements[c]=t.colors[a],t.colors[a]=c}return Object.defineProperty(t,Ut,{enumerable:!1,writable:!1,value:!0}),t}async function Nn(e){return[...new Set((await Promise.all(e.filter(t=>!ts(t)).map(async t=>await Ln(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Pn(e){return(await Promise.all(e.map(async t=>ns(t)?null:St(await Ln(t))))).filter(t=>!!t)}function Tn(e,t){if(!t)return e;if(t[e]){const n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new E(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var ss=class extends Yr{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const t=St(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=ve.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Tn(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const t=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(s=>{this._alias[s]=e.name}),this._loadedLanguagesCache=null,t.size)for(const s of t)this._syncRegistry?._grammars?.get(s.scopeName)?.dispose(),this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const r of e)this.resolveEmbeddedLanguages(r);const t=[...this._langGraph.entries()],n=t.filter(([r,s])=>!s);if(n.length){const r=t.filter(([s,o])=>o?(o.embeddedLanguages||o.embeddedLangs)?.some(i=>n.map(([a])=>a).includes(i)):!1).filter(s=>!n.includes(s));throw new E(`Missing languages ${n.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(const[r,s]of t)this._resolver.addLanguage(s);for(const[r,s]of t)this.loadLanguage(s)}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 t=e.embeddedLanguages??e.embeddedLangs;if(t)for(const n of t)this._langGraph.set(n,this._langMap.get(n))}},os=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}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(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const s=t.slice(0,r).join(".");n=[...n,...this._injections.get(s)||[]]}return n}};let ce=0;function is(e){ce+=1,e.warnings!==!1&&ce>=10&&ce%10===0&&console.warn(`[Shiki] ${ce} 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 t=!1;if(!e.engine)throw new E("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(St),s=new ss(new os(e.engine,n),r,n,e.langAlias);let o;function i(m){return Tn(m,e.langAlias)}function a(m){y();const w=s.getGrammar(typeof m=="string"?m:m.name);if(!w)throw new E(`Language \`${m}\` not found, you may need to load it first`);return w}function c(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};y();const w=s.getTheme(m);if(!w)throw new E(`Theme \`${m}\` not found, you may need to load it first`);return w}function l(m){y();const w=c(m);return o!==m&&(s.setTheme(w),o=m),{theme:w,colorMap:s.getColorMap()}}function u(){return y(),s.getLoadedThemes()}function h(){return y(),s.getLoadedLanguages()}function f(...m){y(),s.loadLanguages(m.flat(1))}async function d(...m){return f(await Nn(m))}function p(...m){y();for(const w of m.flat(1))s.loadTheme(w)}async function _(...m){return y(),p(await Pn(m))}function y(){if(t)throw new E("Shiki instance has been disposed")}function g(){t||(t=!0,s.dispose(),ce-=1)}return{setTheme:l,getTheme:c,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:h,resolveLangAlias:i,loadLanguage:d,loadLanguageSync:f,loadTheme:_,loadThemeSync:p,dispose:g,[Symbol.dispose]:g}}async function as(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([Pn(e.themes||[]),Nn(e.langs||[]),e.engine]);return is({...e,themes:t,langs:n,engine:r})}const Gn=new WeakMap;function Fe(e,t){Gn.set(e,t)}function ge(e){return Gn.get(e)}var je=class Mn{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new Mn(Object.fromEntries(es(n).map(r=>[r,dt])),t)}constructor(...t){if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,s]=t;this.lang=r,this._stacks={[s]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return cs(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function cs(e){const t=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&t.push(o),s.parent&&r(s.parent)}return r(e),t}function ls(e,t){if(!(e instanceof je))throw new E("Invalid grammar state");return e.getInternalStack(t)}const us=/,/,hs=/ /;function On(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Oe(e.resolveLangAlias(n.lang||"text"))||Be(r))return De(t).map(a=>[{content:a[0],offset:a[1]}]);const{theme:s,colorMap:o}=e.setTheme(r),i=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new E(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(s.name))throw new E(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return ds(t,i,s,o,n)}function fs(...e){if(e.length===2)return ge(e[1]);const[t,n,r={}]=e,{lang:s="text",theme:o=t.getLoadedThemes()[0]}=r;if(Oe(s)||Be(o))throw new E("Plain language does not have grammar state");if(s==="ansi")throw new E("ANSI language does not have grammar state");const{theme:i,colorMap:a}=t.setTheme(o),c=t.getLanguage(s);return new je(Et(n,c,i,a,r).stateStack,c.name,i.name)}function ds(e,t,n,r,s){const o=Et(e,t,n,r,s),i=new je(o.stateStack,t.name,n.name);return Fe(o.tokens,i),o.tokens}function Et(e,t,n,r,s){const o=Le(n,s),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:c=!1}=s,l=De(e);let u=s.grammarState?ls(s.grammarState,n.name)??dt:s.grammarContextCode!=null?Et(s.grammarContextCode,t,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:dt,h=[];const f=[];for(let d=0,p=l.length;d<p;d++){const[_,y]=l[d];if(_===""){h=[],f.push([]);continue}if(i>0&&_.length>=i){h=[],f.push([{content:_,offset:y,color:"",fontStyle:0}]);continue}let g,m,w;c&&c!=="tokenType"&&(g=t.tokenizeLine(_,u,a),m=g.tokens,w=0);const k=t.tokenizeLine2(_,u,a),S=k.tokens.length/2;for(let x=0;x<S;x++){const L=k.tokens[2*x],O=x+1<S?k.tokens[2*x+2]:_.length;if(L===O)continue;const ee=k.tokens[2*x+1],He=H(r[J.getForeground(ee)],o),qe=J.getFontStyle(ee),B={content:_.substring(L,O),offset:y+L,color:He,fontStyle:qe};if(c==="tokenType")B.type=J.getTokenType(ee);else if(c){const $t=[];if(c!=="scopeName")for(const F of n.settings){let te;switch(typeof F.scope){case"string":te=F.scope.split(us).map(Xe=>Xe.trim());break;case"object":te=F.scope;break;default:continue}$t.push({settings:F,selectors:te.map(Xe=>Xe.split(hs))})}B.explanation=[];let Lt=0;for(;L+Lt<O;){const F=m[w],te=_.substring(F.startIndex,F.endIndex);Lt+=te.length,B.explanation.push({content:te,scopes:c==="scopeName"?ps(F.scopes):gs($t,F.scopes)}),w+=1}}h.push(B)}f.push(h),h=[],u=k.ruleStack}return{tokens:f,stateStack:u}}function ps(e){return e.map(t=>({scopeName:t}))}function gs(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const o=t[r];n[r]={scopeName:o,themeMatches:_s(e,o,t.slice(0,r))}}return n}function Vt(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function ms(e,t,n){if(!Vt(e.at(-1),t))return!1;let r=e.length-2,s=n.length-1;for(;r>=0&&s>=0;)Vt(e[r],n[s])&&(r-=1),s-=1;return r===-1}function _s(e,t,n){const r=[];for(const{selectors:s,settings:o}of e)for(const i of s)if(ms(i,t,n)){r.push(o);break}return r}function Bn(e,t,n,r=On){const s=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),o=s.map(l=>{const u=r(e,t,{...n,theme:l.theme});return{tokens:u,state:ge(u),theme:typeof l.theme=="string"?l.theme:l.theme.name}}),i=ys(...o.map(l=>l.tokens)),a=i[0].map((l,u)=>l.map((h,f)=>{const d={content:h.content,variants:{},offset:h.offset};return"includeExplanation"in n&&n.includeExplanation&&(d.explanation=h.explanation),i.forEach((p,_)=>{const{content:y,explanation:g,offset:m,...w}=p[u][f];d.variants[s[_].color]=w}),d})),c=o[0].state?new je(Object.fromEntries(o.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),o[0].state.lang):void 0;return c&&Fe(a,c),a}function ys(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const s=e.map(c=>c[r]),o=t.map(()=>[]);t.forEach((c,l)=>c.push(o[l]));const i=s.map(()=>0),a=s.map(c=>c[0]);for(;a.every(c=>c);){const c=Math.min(...a.map(l=>l.content.length));for(let l=0;l<n;l++){const u=a[l];u.content.length===c?(o[l].push(u),i[l]+=1,a[l]=s[l][i[l]]):(o[l].push({...u,content:u.content.slice(0,c)}),a[l]={...u,content:u.content.slice(c),offset:u.offset+c})}}}return t}const Wt=/\s+/g;function Dn(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Wt)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(Wt);for(const r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}function ws(e){const t=De(e,!0).map(([s])=>s);function n(s){if(s===e.length)return{line:t.length-1,character:t.at(-1).length};let o=s,i=0;for(const a of t){if(o<a.length)break;o-=a.length,i++}return{line:i,character:o}}function r(s,o){let i=0;for(let a=0;a<s;a++)i+=t[a].length;return i+=o,i}return{lines:t,indexToPos:n,posToIndex:r}}const bs=["color","background-color"];function Cs(e,t){let n=0;const r=[];for(const s of t)s>n&&r.push({...e,content:e.content.slice(n,s),offset:e.offset+n}),n=s;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function ks(e,t){let n=0,r=e.length;for(;n<r;){const s=n+(r-n>>1);e[s]<=t?n=s+1:r=s}return n}function Ss(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,s)=>r-s);return n.length?e.map(r=>r.flatMap(s=>{const o=s.offset+s.content.length,i=ks(n,s.offset);let a=i;for(;a<n.length&&n[a]<o;)a++;if(i===a)return s;const c=n.slice(i,a);for(let l=0;l<c.length;l++)c[l]-=s.offset;return Cs(s,c)})):e}function Es(e,t,n,r,s="css-vars"){const o={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>Ne(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),c={},l=(u,h)=>{const f=h==="color"?"":h==="background-color"?"-bg":`-${h}`;return n+t[u]+(h==="color"?"":f)};return i.forEach((u,h)=>{for(const f of a){const d=u[f]||"inherit";if(h===0&&r&&bs.includes(f))if(r==="light-dark()"&&i.length>1){const p=t.findIndex(m=>m==="light"),_=t.findIndex(m=>m==="dark");if(p===-1||_===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const y=i[p][f]||"inherit",g=i[_][f]||"inherit";c[f]=`light-dark(${y}, ${g})`,s==="css-vars"&&(c[l(h,f)]=d)}else c[f]=d;else s==="css-vars"&&(c[l(h,f)]=d)}}),o.htmlStyle=c,o}function Ne(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&$.Italic&&(t["font-style"]="italic"),e.fontStyle&$.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&$.Underline&&n.push("underline"),e.fontStyle&$.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function pt(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function Is(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let s=function(i){if(typeof i=="number"){if(i<0||i>n.source.length)throw new E(`Invalid decoration offset: ${i}. Code length: ${n.source.length}`);return{...r.indexToPos(i),offset:i}}else{const a=r.lines[i.line];if(a===void 0)throw new E(`Invalid decoration position ${JSON.stringify(i)}. Lines length: ${r.lines.length}`);let c=i.character;if(c<0&&(c=a.length+c),c<0||c>a.length)throw new E(`Invalid decoration position ${JSON.stringify(i)}. Line ${i.line} length: ${a.length}`);return{...i,character:c,offset:r.posToIndex(i.line,c)}}};const r=ws(n.source),o=(n.options.decorations||[]).map(i=>({...i,start:s(i.start),end:s(i.end)}));vs(o),e.set(n.meta,{decorations:o,converter:r,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return Ss(n,t(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;const r=t(this),s=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new E(`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 _="",y=-1,g=-1;if(h===0&&(y=0),f===0&&(g=0),f===Number.POSITIVE_INFINITY&&(g=p.children.length),y===-1||g===-1)for(let w=0;w<p.children.length;w++)_+=Fn(p.children[w]),y===-1&&_.length===h&&(y=w+1),g===-1&&_.length===f&&(g=w+1);if(y===-1)throw new E(`Failed to find start index for decoration ${JSON.stringify(d.start)}`);if(g===-1)throw new E(`Failed to find end index for decoration ${JSON.stringify(d.end)}`);const m=p.children.slice(y,g);if(!d.alwaysWrap&&m.length===p.children.length)a(p,d,"line");else if(!d.alwaysWrap&&m.length===1&&m[0].type==="element")a(m[0],d,"token");else{const w={type:"element",tagName:"span",properties:{},children:m};a(w,d,"wrapper"),p.children.splice(y,m.length,w)}}function i(u,h){s[u]=a(s[u],h,"line")}function a(u,h,f){const d=h.properties||{},p=h.transform||(_=>_);return u.tagName=h.tagName||"span",u.properties={...u.properties,...d,class:u.properties.class},h.properties?.class&&Dn(u,h.properties.class),u=p(u,f)||u,u}const c=[],l=r.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(const u of l){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++)c.unshift(()=>i(d,u));o(f.line,0,f.character,u)}}c.forEach(u=>u())}}}function vs(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new E(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const s=e[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,i=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,a=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,c=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||i||a||c){if(o&&i||a&&c||a&&n.start.offset===n.end.offset||i&&s.start.offset===s.end.offset)continue;throw new E(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function Fn(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Fn).join(""):""}const As=[Is()];function Pe(e){const t=xs(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...As]}function xs(e){const t=[],n=[],r=[];for(const s of e)switch(s.enforce){case"pre":t.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:t,post:n,normal:r}}var K=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Je={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Rs(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function zt(e){const t=e.shift();if(t==="2"){const n=e.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(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function $s(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)Je[r]&&t.push({type:"setDecoration",value:Je[r]});else if(r<=29){const s=Je[r-20];s&&(t.push({type:"resetDecoration",value:s}),s==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:K[r-30]}});else if(r===38){const s=zt(e);s&&t.push({type:"setForegroundColor",value:s})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:K[r-40]}});else if(r===48){const s=zt(e);s&&t.push({type:"setBackgroundColor",value:s})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:K[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:K[r-100+8]}})}return t}function Ls(){let e=null,t=null,n=new Set;return{parse(r){const s=[];let o=0;do{const i=Rs(r,o),a=i.sequence?r.substring(o,i.startPosition):r.substring(o);if(a.length>0&&s.push({value:a,foreground:e,background:t,decorations:new Set(n)}),i.sequence){const c=$s(i.sequence);for(const l of c)l.type==="resetAll"?(e=null,t=null,n.clear()):l.type==="resetForegroundColor"?e=null:l.type==="resetBackgroundColor"?t=null:l.type==="resetDecoration"&&n.delete(l.value);for(const l of c)l.type==="setForegroundColor"?e=l.value:l.type==="setBackgroundColor"?t=l.value:l.type==="setDecoration"&&n.add(l.value)}o=i.position}while(o<r.length);return s}}}var Ns={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 Ps(e=Ns){function t(a){return e[a]}function n(a){return`#${a.map(c=>Math.max(0,Math.min(c,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let l=0;l<K.length;l++)r.push(t(K[l]));let a=[0,95,135,175,215,255];for(let l=0;l<6;l++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([a[l],a[u],a[h]]));let c=8;for(let l=0;l<24;l++,c+=10)r.push(n([c,c,c]));return r}function o(a){return s()[a]}function i(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return o(a.index)}}return{value:i}}const Ts=/#([0-9a-f]{3,8})/i,Gs=/var\((--[\w-]+-ansi-[\w-]+)\)/,Ms={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 Os(e,t,n){const r=Le(e,n),s=De(t),o=Ps(Object.fromEntries(K.map(a=>{const c=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[c]||Ms[a]]}))),i=Ls();return s.map(a=>i.parse(a[0]).map(c=>{let l,u;c.decorations.has("reverse")?(l=c.background?o.value(c.background):e.bg,u=c.foreground?o.value(c.foreground):e.fg):(l=c.foreground?o.value(c.foreground):e.fg,u=c.background?o.value(c.background):void 0),l=H(l,r),u=H(u,r),c.decorations.has("dim")&&(l=Bs(l));let h=$.None;return c.decorations.has("bold")&&(h|=$.Bold),c.decorations.has("italic")&&(h|=$.Italic),c.decorations.has("underline")&&(h|=$.Underline),c.decorations.has("strikethrough")&&(h|=$.Strikethrough),{content:c.value,offset:a[1],color:l,bgColor:u,fontStyle:h}}))}function Bs(e){const t=e.match(Ts);if(t){const r=t[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],i=r[2],a=r[3];return`#${s}${s}${o}${o}${i}${i}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const s=r[0],o=r[1],i=r[2];return`#${s}${s}${o}${o}${i}${i}80`}}}const n=e.match(Gs);return n?`var(${n[1]}-dim)`:e}function gt(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:s=e.getLoadedThemes()[0]}=n;if(!Oe(r)&&!Be(s)&&r==="ansi"){const{theme:o}=e.setTheme(s);return Os(o,t,n)}return On(e,t,n)}function Te(e,t,n){let r,s,o,i,a,c;if("themes"in n){const{defaultColor:l="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,m)=>g.color===l?-1:m.color===l?1:0);if(f.length===0)throw new E("`themes` option must not be empty");const d=Bn(e,t,n,gt);if(c=ge(d),l&&l!=="light-dark()"&&!f.some(g=>g.color===l))throw new E(`\`themes\` option must contain the defaultColor key \`${l}\``);const p=f.map(g=>e.getTheme(g.theme)),_=f.map(g=>g.color);o=d.map(g=>g.map(m=>Es(m,_,u,l,h))),c&&Fe(o,c);const y=f.map(g=>Le(g.theme,n));s=Ht(f,p,y,u,l,"fg",h),r=Ht(f,p,y,u,l,"bg",h),i=`shiki-themes ${p.map(g=>g.name).join(" ")}`,a=l?void 0:[s,r].join(";")}else if("theme"in n){const l=Le(n.theme,n);o=gt(e,t,n);const u=e.getTheme(n.theme);r=H(u.bg,l),s=H(u.fg,l),i=u.name,c=ge(o)}else throw new E("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:i,rootStyle:a,grammarState:c}}function Ht(e,t,n,r,s,o,i){return e.map((a,c)=>{const l=H(t[c][o],n[c])||"inherit",u=`${r+a.color}${o==="bg"?"-bg":""}:${l}`;if(c===0&&s){if(s==="light-dark()"&&e.length>1){const h=e.findIndex(d=>d.color==="light"),f=e.findIndex(d=>d.color==="dark");if(h===-1||f===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${H(t[h][o],n[h])||"inherit"}, ${H(t[f][o],n[f])||"inherit"});${u}`}return l}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}const jn=/^\s+$/,Ds=/^(\s*)(.*?)(\s*)$/;function Ge(e,t,n,r={meta:{},options:n,codeToHast:(s,o)=>Ge(e,s,o),codeToTokens:(s,o)=>Te(e,s,o)}){let s=t;for(const p of Pe(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:o,fg:i,bg:a,themeName:c,rootStyle:l,grammarState:u}=Te(e,s,n);const{mergeWhitespaces:h=!0,mergeSameStyleTokens:f=!1}=n;h===!0?o=js(o):h==="never"&&(o=Us(o)),f&&(o=Vs(o));const d={...r,get source(){return s}};for(const p of Pe(n))o=p.tokens?.call(d,o)||o;return Fs(o,{...n,fg:i,bg:a,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},d,u)}function Fs(e,t,n,r=ge(e)){const s=Pe(t),o=[],i={type:"root",children:[]},{structure:a="classic",tabindex:c="0"}=t,l={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?l.style=t.rootStyle:l.style=`background-color:${t.bg};color:${t.fg}`),c!==!1&&c!=null&&(l.tabindex=c.toString());for(const[_,y]of Object.entries(t.meta||{}))_.startsWith("_")||(l[_]=y);let u={type:"element",tagName:"pre",properties:l,children:[],data:t.data},h={type:"element",tagName:"code",properties:{},children:o};const f=[],d={...n,structure:a,addClassToHast:Dn,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return i},get pre(){return u},get code(){return h},get lines(){return f}};if(e.forEach((_,y)=>{y&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&o.push({type:"text",value:`
5
+ `}));let g={type:"element",tagName:"span",properties:{class:"line"},children:[]},m=0;for(const w of _){let k={type:"element",tagName:"span",properties:{...w.htmlAttrs},children:[{type:"text",value:w.content}]};const S=pt(w.htmlStyle||Ne(w));S&&(k.properties.style=S);for(const x of s)k=x?.span?.call(d,k,y+1,m,g,w)||k;a==="inline"?i.children.push(k):a==="classic"&&g.children.push(k),m+=w.content.length}if(a==="classic"){for(const w of s)g=w?.line?.call(d,g,y+1)||g;f.push(g),o.push(g)}else a==="inline"&&f.push(g)}),a==="classic"){for(const _ of s)h=_?.code?.call(d,h)||h;u.children.push(h);for(const _ of s)u=_?.pre?.call(d,u)||u;i.children.push(u)}else if(a==="inline"){const _=[];let y={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const m of i.children)m.type==="element"&&m.tagName==="br"?(_.push(y),y={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&y.children.push(m);_.push(y);let g={type:"element",tagName:"code",properties:{},children:_};for(const m of s)g=m?.code?.call(d,g)||g;i.children=[];for(let m=0;m<g.children.length;m++){m>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});const w=g.children[m];w.type==="element"&&i.children.push(...w.children)}}let p=i;for(const _ of s)p=_?.root?.call(d,p)||p;return r&&Fe(p,r),p}function js(e){return e.map(t=>{const n=[];let r="",s;return t.forEach((o,i)=>{const a=!(o.fontStyle&&(o.fontStyle&$.Underline||o.fontStyle&$.Strikethrough));a&&jn.test(o.content)&&t[i+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(a?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 Us(e){return e.map(t=>t.flatMap(n=>{if(jn.test(n.content))return n;const r=n.content.match(Ds);if(!r)return n;const[,s,o,i]=r;if(!s&&!i)return n;const a=[{...n,offset:n.offset+s.length,content:o}];return s&&a.unshift({content:s,offset:n.offset}),i&&a.push({content:i,offset:n.offset+s.length+o.length}),a}))}function Vs(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const s=n.at(-1),o=pt(s.htmlStyle||Ne(s)),i=pt(r.htmlStyle||Ne(r)),a=s.fontStyle&&(s.fontStyle&$.Underline||s.fontStyle&$.Strikethrough),c=r.fontStyle&&(r.fontStyle&$.Underline||r.fontStyle&$.Strikethrough);!a&&!c&&o===i?s.content+=r.content:n.push({...r})}return n})}const Ws=dr;function zs(e,t,n){const r={meta:{},options:n,codeToHast:(o,i)=>Ge(e,o,i),codeToTokens:(o,i)=>Te(e,o,i)};let s=Ws(Ge(e,t,n,r));for(const o of Pe(n))s=o.postprocess?.call(r,s,n)||s;return s}async function Hs(e){const t=await as(e);return{getLastGrammarState:(...n)=>fs(t,...n),codeToTokensBase:(n,r)=>gt(t,n,r),codeToTokensWithThemes:(n,r)=>Bn(t,n,r),codeToTokens:(n,r)=>Te(t,n,r),codeToHast:(n,r)=>Ge(t,n,r),codeToHtml:(n,r)=>zs(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function qs(e={}){const{name:t="css-variables",variablePrefix:n="--shiki-",fontStyle:r=!0}=e,s=i=>e.variableDefaults?.[i]?`var(${n}${i}, ${e.variableDefaults[i]})`:`var(${n}${i})`,o={name:t,type:"dark",colors:{"editor.foreground":s("foreground"),"editor.background":s("background"),"terminal.ansiBlack":s("ansi-black"),"terminal.ansiRed":s("ansi-red"),"terminal.ansiGreen":s("ansi-green"),"terminal.ansiYellow":s("ansi-yellow"),"terminal.ansiBlue":s("ansi-blue"),"terminal.ansiMagenta":s("ansi-magenta"),"terminal.ansiCyan":s("ansi-cyan"),"terminal.ansiWhite":s("ansi-white"),"terminal.ansiBrightBlack":s("ansi-bright-black"),"terminal.ansiBrightRed":s("ansi-bright-red"),"terminal.ansiBrightGreen":s("ansi-bright-green"),"terminal.ansiBrightYellow":s("ansi-bright-yellow"),"terminal.ansiBrightBlue":s("ansi-bright-blue"),"terminal.ansiBrightMagenta":s("ansi-bright-magenta"),"terminal.ansiBrightCyan":s("ansi-bright-cyan"),"terminal.ansiBrightWhite":s("ansi-bright-white")},tokenColors:[{scope:["keyword.operator.accessor","meta.group.braces.round.function.arguments","meta.template.expression","markup.fenced_code meta.embedded.block"],settings:{foreground:s("foreground")}},{scope:"emphasis",settings:{fontStyle:"italic"}},{scope:["strong","markup.heading.markdown","markup.bold.markdown"],settings:{fontStyle:"bold"}},{scope:["markup.italic.markdown"],settings:{fontStyle:"italic"}},{scope:"meta.link.inline.markdown",settings:{fontStyle:"underline",foreground:s("token-link")}},{scope:["string","markup.fenced_code","markup.inline"],settings:{foreground:s("token-string")}},{scope:["comment","string.quoted.docstring.multi"],settings:{foreground:s("token-comment")}},{scope:["constant.numeric","constant.language","constant.other.placeholder","constant.character.format.placeholder","variable.language.this","variable.other.object","variable.other.class","variable.other.constant","meta.property-name","meta.property-value","support"],settings:{foreground:s("token-constant")}},{scope:["keyword","storage.modifier","storage.type","storage.control.clojure","entity.name.function.clojure","entity.name.tag.yaml","support.function.node","support.type.property-name.json","punctuation.separator.key-value","punctuation.definition.template-expression"],settings:{foreground:s("token-keyword")}},{scope:"variable.parameter.function",settings:{foreground:s("token-parameter")}},{scope:["support.function","entity.name.type","entity.other.inherited-class","meta.function-call","meta.instance.constructor","entity.other.attribute-name","entity.name.function","constant.keyword.clojure"],settings:{foreground:s("token-function")}},{scope:["entity.name.tag","string.quoted","string.regexp","string.interpolated","string.template","string.unquoted.plain.out.yaml","keyword.other.template"],settings:{foreground:s("token-string-expression")}},{scope:["punctuation.definition.arguments","punctuation.definition.dict","punctuation.separator","meta.function-call.arguments"],settings:{foreground:s("token-punctuation")}},{scope:["markup.underline.link","punctuation.definition.metadata.markdown"],settings:{foreground:s("token-link")}},{scope:["beginning.punctuation.definition.list.markdown"],settings:{foreground:s("token-string")}},{scope:["punctuation.definition.string.begin.markdown","punctuation.definition.string.end.markdown","string.other.link.title.markdown","string.other.link.description.markdown"],settings:{foreground:s("token-keyword")}},{scope:["markup.inserted","meta.diff.header.to-file","punctuation.definition.inserted"],settings:{foreground:s("token-inserted")}},{scope:["markup.deleted","meta.diff.header.from-file","punctuation.definition.deleted"],settings:{foreground:s("token-deleted")}},{scope:["markup.changed","punctuation.definition.changed"],settings:{foreground:s("token-changed")}}]};return r||(o.tokenColors=o.tokenColors?.map(i=>(i.settings?.fontStyle&&delete i.settings.fontStyle,i))),o}const qt=4294967295;function Xs(e){return!e.sticky&&!e.rawOptions?.strategy}function Xt(e,t){return{index:e,captureIndices:t.map(n=>n==null?{start:qt,end:qt,length:0}:{start:n[0],end:n[1],length:n[1]-n[0]})}}var Qs=class{patterns;options;regexps;lastSearches;constructor(e,t={}){this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:s}=t;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(o=>{if(typeof o!="string")return o;const i=r?.get(o);if(i){if(i instanceof RegExp)return i;if(n)return null;throw i}try{const a=s(o);return r?.set(o,a),a}catch(a){if(r?.set(o,a),n)return null;throw a}}),this.lastSearches=this.regexps.map(o=>o&&Xs(o)?{strId:0,searchedFrom:0,matchIndex:-1,indices:null}:null)}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,s=typeof e=="string"?0:e.id||0;let o=-1,i=0,a=null;for(let c=0;c<this.regexps.length;c++){const l=this.regexps[c];if(l)try{const u=s?this.lastSearches[c]:null;let h,f;if(u&&u.strId===s&&u.searchedFrom<=t&&(u.matchIndex===-1||u.matchIndex>=t))h=u.matchIndex,f=u.indices;else{l.lastIndex=t;const d=l.exec(r);h=d?d.index:-1,f=d?d.indices:null,u&&(u.strId=s,u.searchedFrom=t,u.matchIndex=h,u.indices=f)}if(h===-1)continue;if(h===t)return Xt(c,f);(o===-1||h<i)&&(o=c,i=h,a=f)}catch(u){if(this.options.forgiving)continue;throw u}}return o===-1?null:Xt(o,a)}};let Ks=0;function Zs(e){return{content:e,id:++Ks}}function ie(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Js(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const It=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),A=String.raw;function ae(e,t){if(e==null)throw new Error(t??"Value expected");return e}const Un=A`\[\^?`,Vn=`c.? | C(?:-.?)?|${A`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${A`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${A`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${A`o\{[^\}]*\}?`}|${A`\d{1,3}`}`,vt=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,be=new RegExp(A`
6
+ \\ (?:
7
+ ${Vn}
8
+ | [gk]<[^>]*>?
9
+ | [gk]'[^']*'?
10
+ | .
11
+ )
12
+ | \( (?:
13
+ \? (?:
14
+ [:=!>({]
15
+ | <[=!]
16
+ | <[^>]*>
17
+ | '[^']*'
18
+ | ~\|?
19
+ | #(?:[^)\\]|\\.?)*
20
+ | [^:)]*[:)]
21
+ )?
22
+ | \*[^\)]*\)?
23
+ )?
24
+ | (?:${vt.source})+
25
+ | ${Un}
26
+ | .
27
+ `.replace(/\s+/g,""),"gsu"),Ye=new RegExp(A`
28
+ \\ (?:
29
+ ${Vn}
30
+ | .
31
+ )
32
+ | \[:(?:\^?\p{Alpha}+|\^):\]
33
+ | ${Un}
34
+ | &&
35
+ | .
36
+ `.replace(/\s+/g,""),"gsu");function Ys(e,t={}){const n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const r=wo(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 i=[],a;for(be.lastIndex=0;a=be.exec(e);){const h=eo(o,e,a[0],be.lastIndex);h.tokens?i.push(...h.tokens):h.token&&i.push(h.token),h.lastIndex!==void 0&&(be.lastIndex=h.lastIndex)}const c=[];let l=0;i.filter(h=>h.type==="GroupOpen").forEach(h=>{h.kind==="capturing"?h.number=++l:h.raw==="("&&c.push(h)}),l||c.forEach((h,f)=>{h.kind="capturing",h.number=f+1});const u=l||c.length;return{tokens:i.map(h=>h.type==="EscapedNumber"?Co(h,u):h).flat(),flags:r}}function eo(e,t,n,r){const[s,o]=n;if(n==="["||n==="[^"){const i=to(t,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(o))return{token:Qt(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:ho(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:zn(n)}}if(o==="K")return{token:Hn("keep",n)};if(o==="N"||o==="R")return{token:Z("newline",n,{negate:o==="N"})};if(o==="O")return{token:Z("any",n)};if(o==="X")return{token:Z("text_segment",n)};const i=Wn(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(s==="("){if(o==="*")return{token:mo(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:go(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:se("group",n)};if(n==="(?>")return{token:se("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:se(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:se("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:se("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:co(n)}}if(e.getCurrentModX()){if(n==="#"){const i=t.indexOf(`
37
+ `,r);return{lastIndex:i===-1?t.length:i}}if(/^\s$/.test(n)){const i=/\s+/y;return i.lastIndex=r,{lastIndex:i.exec(t)?i.lastIndex:r}}}if(n===".")return{token:Z("dot",n)};if(n==="^"||n==="$"){const i=e.singleline?{"^":A`\A`,$:A`\Z`}[n]:n;return{token:Qt(i,n)}}return n==="|"?{token:ro(n)}:vt.test(n)?{tokens:ko(n)}:{token:V(ie(n),n)}}function to(e,t,n){const r=[Kt(t[1]==="^",t)];let s=1,o;for(Ye.lastIndex=n;o=Ye.exec(e);){const i=o[0];if(i[0]==="["&&i[1]!==":")s++,r.push(Kt(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(V(93,i));else if(s--,r.push(so(i)),!s)break}else{const a=no(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:Ye.lastIndex||e.length}}function no(e){if(e[0]==="\\")return Wn(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!It.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Z("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?oo(e):e==="&&"?io(e):V(ie(e),e)}function Wn(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return po(e);if("dDhHsSwW".includes(n))return _o(e);if(e.startsWith(A`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return yo(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const r=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...s].map(i=>{const a=[...o.encode(i)].map(c=>`\\x${c.toString(16)}`).join("");return V(ie(i),a)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return V(bo(e),e);if(Zt.has(n))return V(Zt.get(n),e);if(/\d/.test(n))return ao(t,e);if(e==="\\")throw new Error(A`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return V(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function ro(e){return{type:"Alternator",raw:e}}function Qt(e,t){return{type:"Assertion",kind:e,raw:t}}function zn(e){return{type:"Backreference",raw:e}}function V(e,t){return{type:"Character",value:e,raw:t}}function so(e){return{type:"CharacterClassClose",raw:e}}function oo(e){return{type:"CharacterClassHyphen",raw:e}}function io(e){return{type:"CharacterClassIntersector",raw:e}}function Kt(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Z(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function Hn(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:ae(n.flags),raw:t}}function ao(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function co(e){return{type:"GroupClose",raw:e}}function se(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function lo(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function uo(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function ho(e){return{type:"Subroutine",raw:e}}const fo=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Zt=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function po(e){const t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return V(ie(t.toUpperCase())-64,e)}function go(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";const s=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),o=Yt(n),i=Yt(r),a={};if(o&&(a.enable=o),i&&(a.disable=i),e.endsWith(")"))return t.replaceCurrentModX(s),Hn("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(s),t.numOpenGroups++,se("group",e,{...(o||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function mo(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:s}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const o=s?s.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[i,a,c]=o,l=fo.has(n)?n.toLowerCase():"custom";switch(l){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 i=="string")throw new Error(`Named callout argument must be a number "${i}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(o.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);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 i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${i}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof c=="string"&&!/^[A-Za-z_]\w*$/.test(c))throw new Error(`Named callout argument three must be a tag or number "${c}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${l}"`)}return lo(l,r??null,s?.split(",")??null,e)}function Jt(e){let t=null,n,r;if(e[0]==="{"){const{minStr:s,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,i=1e5;if(+s>i||o&&+o>i)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+s,r=o===void 0?+s:o===""?1/0:+o,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return uo(t,n,r,e)}function _o(e){const t=e[1].toLowerCase();return Z({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function yo(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Z("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function Yt(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function wo(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){const r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function bo(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Co(e,t){const{raw:n,inCharClass:r}=e,s=n.slice(1);if(!r&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=t))return[zn(n)];const o=[],i=s.match(/^[0-7]+|\d/g);for(let a=0;a<i.length;a++){const c=i[a];let l;if(a===0&&c!=="8"&&c!=="9"){if(l=parseInt(c,8),l>127)throw new Error(A`Octal encoded byte above 177 unsupported "${n}"`)}else l=ie(c);o.push(V(l,(a===0?"\\":"")+c))}return o}function ko(e){const t=[],n=new RegExp(vt,"gy");let r;for(;r=n.exec(e);){const s=r[0];if(s[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(o){const{min:i,max:a}=o.groups;if(+i>+a&&s.endsWith("?")){n.lastIndex--,t.push(Jt(s.slice(0,-1)));continue}}}t.push(Jt(s))}return t}function qn(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function So(e){return Eo.has(e.type)}const Eo=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Xn(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Ys(e,{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 Y();case"Assertion":return Io(p);case"Backreference":return vo(p,o);case"Character":return Ue(p.value,{useLastValid:!!d.isCheckingRangeEnd});case"CharacterClassHyphen":return Ao(p,o,d);case"CharacterClassOpen":return xo(p,o,d);case"CharacterSet":return Ro(p,o);case"Directive":return Go(p.kind,{flags:p.flags});case"GroupOpen":return $o(p,o,d);case"NamedCallout":return Oo(p.kind,p.tag,p.arguments);case"Quantifier":return Lo(p,o);case"Subroutine":return No(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},i=Do(Mo(r.flags));let a=i.body[0];for(;o.nextIndex<r.tokens.length;){const f=s(a,{});f.type==="Alternative"?(i.body.push(f),a=f):a.body.push(f)}const{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:h}=o;if(l&&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>c.length)throw new Error("Subroutine uses a group number that's not defined");f&&(c[f-1].isSubroutined=!0)}else if(u.has(f)){if(u.get(f).length>1)throw new Error(A`Subroutine uses a duplicate group name "\g<${f}>"`);u.get(f)[0].isSubroutined=!0}else throw new Error(A`Subroutine uses a group name that's not defined "\g<${f}>"`);return i}function Io({kind:e}){return mt(ae({"^":"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"}[e],`Unexpected assertion kind "${e}"`),{negate:e===A`\B`||e===A`\Y`})}function vo({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),s=(o,i=!1)=>{const a=t.capturingGroups.length;let c=!1;if(o>a)if(t.skipBackrefValidation)c=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,_t(i?a+1-o:o,{orphan:c})};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 "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return _t(r)}return s(+r)}function Ao(e,t,n){const{tokens:r,walk:s}=t,o=t.parent,i=o.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){const c=s(o,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&c.type==="Character")return o.body.pop(),To(i,c);throw new Error("Invalid character class range")}return Ue(ie("-"))}function xo({negate:e},t,n){const{tokens:r,walk:s}=t,o=[Ie()],i=r[t.nextIndex];let a=nn(i);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")o.push(Ie()),t.nextIndex++;else{const l=o.at(-1);l.body.push(s(l,n))}a=nn(r[t.nextIndex],i)}const c=Ie({negate:e});return o.length===1?c.body=o[0].body:(c.kind="intersection",c.body=o.map(l=>l.body.length===1?l.body[0]:l)),t.nextIndex++,c}function Ro({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i}=r;if(e==="property"){const a=Ve(n);if(It.has(a)&&!i?.has(a))e="posix",n=a;else return oe(n,{negate:t,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i})}return e==="posix"?Bo(n,{negate:t}):yt(e,{negate:t})}function $o(e,t,n){const{tokens:r,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:i,walk:a}=t,c=Fo(e),l=c.type==="AbsenceFunction",u=tn(c),h=u&&c.negate;if(c.type==="CapturingGroup"&&(s.push(c),c.name&&Js(o,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=rn(r[t.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")c.body.push(Y()),t.nextIndex++;else{const d=c.body.at(-1),p=a(d,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||h});if(d.body.push(p),(u||n.isInLookbehind)&&!i){const _="Lookbehind includes a pattern not allowed by Oniguruma";if(h||n.isInNegLookbehind){if(en(p)||p.type==="CapturingGroup")throw new Error(_)}else if(en(p)||tn(p)&&p.negate)throw new Error(_)}}f=rn(r[t.nextIndex])}return t.nextIndex++,c}function Lo({kind:e,min:t,max:n},r){const s=r.parent,o=s.body.at(-1);if(!o||!So(o))throw new Error("Quantifier requires a repeatable token");const i=Kn(e,t,n,o);return s.body.pop(),i}function No({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let s=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const a=+o.groups.num,c=n.length;if(t.hasNumberedRef=!0,s={"":a,"+":c+a,"-":c+1-a}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const i=Zn(s);return r.push(i),i}function Po(e,t){return{type:"AbsenceFunction",kind:e,body:ye(t?.body)}}function Y(e){return{type:"Alternative",body:Jn(e?.body)}}function mt(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function _t(e,t){const n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function Qn(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!jo(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:ye(t?.body)}}function Ue(e,t){const n={useLastValid:!1,...t};if(e>1114111){const r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>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:e}}function Ie(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Jn(e?.body)}}function To(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function yt(e,t){const n=!!t?.negate,r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function Go(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:ae(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function Mo(e){return{type:"Flags",...e}}function G(e){const t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:ye(e?.body)}}function Q(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:ye(e?.body)}}function Oo(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function Bo(e,t){const n=!!t?.negate;if(!It.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function Kn(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function Do(e,t){return{type:"Regex",body:ye(t?.body),flags:e}}function Zn(e){return{type:"Subroutine",ref:e}}function oe(e,t){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=n.unicodePropertyMap?.get(Ve(e));if(!r){if(n.normalizeUnknownPropertyNames)r=Uo(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(A`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function Fo({flags:e,kind:t,name:n,negate:r,number:s}){switch(t){case"absence_repeater":return Po("repeater");case"atomic":return G({atomic:!0});case"capturing":return Qn(s,{name:n});case"group":return G({flags:e});case"lookahead":case"lookbehind":return Q({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function ye(e){if(e===void 0)e=[Y()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Jn(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function en(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function tn(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function jo(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function Uo(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function Ve(e){return e.replace(/[- _]+/g,"").toLowerCase()}function nn(e,t){const n=t;return ae(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function rn(e){return ae(e,"Unclosed group")}function he(e,t,n=null){function r(o,i){for(let a=0;a<o.length;a++){const c=s(o[a],i,a,o);a=Math.max(-1,a+c)}}function s(o,i=null,a=null,c=null){let l=0,u=!1;const h={node:o,parent:i,key:a,container:c,root:e,remove(){Ce(c).splice(Math.max(0,ne(a)+l),1),l--,u=!0},removeAllNextSiblings(){return Ce(c).splice(ne(a)+1)},removeAllPrevSiblings(){const g=ne(a)+l;return l-=g,Ce(c).splice(0,Math.max(0,g))},replaceWith(g,m={}){const w=!!m.traverse;c?c[Math.max(0,ne(a)+l)]=g:ae(i,"Can't replace root node")[a]=g,w&&s(g,i,a,c),u=!0},replaceWithMultiple(g,m={}){const w=!!m.traverse;if(Ce(c).splice(Math.max(0,ne(a)+l),1,...g),l+=g.length-1,w){let k=0;for(let S=0;S<g.length;S++)k+=s(g[S],i,ne(a)+S+k,c)}u=!0},skip(){u=!0}},{type:f}=o,d=t["*"],p=t[f],_=typeof d=="function"?d:d?.enter,y=typeof p=="function"?p:p?.enter;if(_?.(h,n),y?.(h,n),!u)switch(f){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":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"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),l}return s(e),e}function Ce(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function ne(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const Vo=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Wo(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function zo(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const T=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function At(e,t,n,r){const s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let i=0,a="";for(const c of e.matchAll(s)){const{0:l,groups:{$skip:u}}=c;if(!u&&(!r||r===T.DEFAULT==!i)){n instanceof Function?a+=n(c,{context:i?T.CHAR_CLASS:T.DEFAULT,negated:o[o.length-1]}):a+=n;continue}l[0]==="["?(i++,o.push(l[1]==="^")):l==="]"&&i&&(i--,o.pop()),a+=l}return a}function Yn(e,t,n,r){At(e,t,n,r)}function Ho(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let o=0,i;for(;i=s.exec(e);){const{0:a,groups:{$skip:c}}=i;if(!c&&(!r||r===T.DEFAULT==!o))return i;a==="["?o++:a==="]"&&o&&o--,s.lastIndex==i.index&&s.lastIndex++}return null}function ke(e,t,n){return!!Ho(e,t,0,n)}function qo(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,s=0,o=1,i;for(;i=n.exec(e);){const[a]=i;if(a==="[")s++;else if(s)a==="]"&&s--;else if(a==="(")o++;else if(a===")"&&(o--,!o)){r=i.index;break}}return e.slice(t,r)}const sn=new RegExp(String.raw`(?<noncapturingStart>${Vo})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Xo(e,t){const n=t?.hiddenCaptures??[];let r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const s="(?>",o="(?:(?=(",i=[0],a=[];let c=0,l=0,u=NaN,h;do{h=!1;let f=0,d=0,p=!1,_;for(sn.lastIndex=Number.isNaN(u)?0:u+o.length;_=sn.exec(e);){const{0:y,index:g,groups:{capturingStart:m,noncapturingStart:w}}=_;if(y==="[")f++;else if(f)y==="]"&&f--;else if(y===s&&!p)u=g,p=!0;else if(p&&w)d++;else if(m)p?d++:(c++,i.push(c+l));else if(y===")"&&p){if(!d){l++;const k=c+l;if(e=`${e.slice(0,u)}${o}${e.slice(u+s.length,g)}))<$$${k}>)${e.slice(g+1)}`,h=!0,a.push(k),Wo(n,k),r.size){const S=new Map;r.forEach((x,L)=>{S.set(L>=k?L+1:L,x.map(O=>O>=k?O+1:O))}),r=S}break}d--}}}while(h);return n.push(...a),e=At(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:d,wrappedBackrefNum:p}})=>{if(d){const _=+d;if(_>i.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${i[_]}`}return`\\${p}`},T.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const er=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,et=new RegExp(String.raw`
38
+ \\(?: \d+
39
+ | c[A-Za-z]
40
+ | [gk]<[^>]+>
41
+ | [pPu]\{[^\}]+\}
42
+ | u[A-Fa-f\d]{4}
43
+ | x[A-Fa-f\d]{2}
44
+ )
45
+ | \((?: \? (?: [:=!>]
46
+ | <(?:[=!]|[^>]+>)
47
+ | [A-Za-z\-]+:
48
+ | \(DEFINE\)
49
+ ))?
50
+ | (?<qBase>${er})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
51
+ | \\?.
52
+ `.replace(/\s+/g,""),"gsu");function Qo(e){if(!new RegExp(`${er}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,s="",o=0,i;for(et.lastIndex=0;i=et.exec(e);){const{0:a,index:c,groups:{qBase:l,qMod:u,invalidQ:h}}=i;if(a==="[")o||(r=c),o++;else if(a==="]")o?o--:r=null;else if(!o)if(u==="+"&&s&&!s.startsWith("(")){if(h)throw new Error(`Invalid quantifier "${a}"`);let f=-1;if(/^\{\d+\}$/.test(l))e=zo(e,c+l.length,u,"");else{if(s===")"||s==="]"){const d=s===")"?n:r;if(d===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,d)}(?>${e.slice(d,c)}${l})${e.slice(c+a.length)}`}else e=`${e.slice(0,c-s.length)}(?>${s}${l})${e.slice(c+a.length)}`;f+=4}et.lastIndex+=f}else a[0]==="("?t.push(c):a===")"&&(n=t.length?t.pop():null);s=a}return{pattern:e}}const P=String.raw,Ko=P`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,wt=P`\(\?R=(?<rDepth>[^\)]+)\)|${Ko}`,We=P`\(\?<(?![=!])(?<captureName>[^>]+)>`,tr=P`${We}|(?<unnamed>\()(?!\?)`,q=new RegExp(P`${We}|${wt}|\(\?|\\?.`,"gsu"),tt="Cannot use multiple overlapping recursions";function Zo(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let s=t?.captureTransfers??new Map;if(!new RegExp(wt,"su").test(e))return{pattern:e,captureTransfers:s,hiddenCaptures:n};if(r==="plugin"&&ke(e,P`\(\?\(DEFINE\)`,T.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],i=ke(e,P`\\[1-9]`,T.DEFAULT),a=new Map,c=[];let l=!1,u=0,h=0,f;for(q.lastIndex=0;f=q.exec(e);){const{0:d,groups:{captureName:p,rDepth:_,gRNameOrNum:y,gRDepth:g}}=f;if(d==="[")u++;else if(u)d==="]"&&u--;else if(_){if(on(_),l)throw new Error(tt);if(i)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const m=e.slice(0,f.index),w=e.slice(q.lastIndex);if(ke(w,wt,T.DEFAULT))throw new Error(tt);const k=+_-1;e=an(m,w,k,!1,n,o,h),s=ln(s,m,k,o.length,0,h);break}else if(y){on(g);let m=!1;for(const B of c)if(B.name===y||B.num===+y){if(m=!0,B.hasRecursedWithin)throw new Error(tt);break}if(!m)throw new Error(P`Recursive \g cannot be used outside the referenced group "${r==="external"?y:P`\g<${y}&R=${g}>`}"`);const w=a.get(y),k=qo(e,w);if(i&&ke(k,P`${We}|\((?!\?)`,T.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const S=e.slice(w,f.index),x=k.slice(S.length+d.length),L=o.length,O=+g-1,ee=an(S,x,O,!0,n,o,h);s=ln(s,S,O,o.length-L,L,h);const He=e.slice(0,w),qe=e.slice(w+k.length);e=`${He}${ee}${qe}`,q.lastIndex+=ee.length-d.length-S.length-x.length,c.forEach(B=>B.hasRecursedWithin=!0),l=!0}else if(p)h++,a.set(String(h),q.lastIndex),a.set(p,q.lastIndex),c.push({num:h,name:p});else if(d[0]==="("){const m=d==="(";m&&(h++,a.set(String(h),q.lastIndex)),c.push(m?{num:h}:{})}else d===")"&&c.pop()}return n.push(...o),{pattern:e,captureTransfers:s,hiddenCaptures:n}}function on(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function an(e,t,n,r,s,o,i){const a=new Set;r&&Yn(e+t,We,({groups:{captureName:l}})=>{a.add(l)},T.DEFAULT);const c=[n,r?a:null,s,o,i];return`${e}${cn(`(?:${e}`,"forward",...c)}(?:)${cn(`${t})`,"backward",...c)}${t}`}function cn(e,t,n,r,s,o,i){const c=u=>t==="forward"?u+2:n-u+2-1;let l="";for(let u=0;u<n;u++){const h=c(u);l+=At(e,P`${tr}|\\k<(?<backref>[^>]+)>`,({0:f,groups:{captureName:d,unnamed:p,backref:_}})=>{if(_&&r&&!r.has(_))return f;const y=`_$${h}`;if(p||d){const g=i+o.length+1;return o.push(g),Jo(s,g),p?f:`(?<${d}${y}>`}return P`\k<${_}${y}>`},T.DEFAULT)}return l}function Jo(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function ln(e,t,n,r,s,o){if(e.size&&r){let i=0;Yn(t,tr,()=>i++,T.DEFAULT);const a=o-i+s,c=new Map;return e.forEach((l,u)=>{const h=(r-i*n)/n,f=i*n,d=u>a+i?u+r:u,p=[];for(const _ of l)if(_<=a)p.push(_);else if(_>a+i+h)p.push(_+r);else if(_<=a+i)for(let y=0;y<=n;y++)p.push(_+i*y);else for(let y=0;y<=n;y++)p.push(_+f+h*y);c.set(d,p)}),c}return e}var v=String.fromCodePoint,C=String.raw,M={},ze=globalThis.RegExp;M.flagGroups=(()=>{try{new ze("(?i:)")}catch{return!1}return!0})();M.unicodeSets=(()=>{try{new ze("[[]]","v")}catch{return!1}return!0})();M.bugFlagVLiteralHyphenIsRange=M.unicodeSets?(()=>{try{new ze(C`[\d\-a]`,"v")}catch{return!0}return!1})():!1;M.bugNestedClassIgnoresNegation=M.unicodeSets&&new ze("[[^a]]","v").test("a");function Me(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function me(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function bt(e,t){return un[e]>=un[t]}function Yo(e,t){if(e==null)throw new Error(t??"Value expected");return e}var un={ES2025:2025,ES2024:2024,ES2018:2018},ei={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function nr(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!ei[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=M.flagGroups?"ES2025":M.unicodeSets?"ES2024":"ES2018"),t}var ti="[ -\r ]",ni=new Set([v(304),v(305)]),j=C`[\p{L}\p{M}\p{N}\p{Pc}]`;function rr(e){if(ni.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),s=oi.get(n),o=ri.get(n),i=si.get(n);return[...r].length===1&&t.add(r),i&&t.add(i),s&&t.add(s),t.add(n),o&&t.add(o),[...t]}var xt=new Map(`C Other
53
+ Cc Control cntrl
54
+ Cf Format
55
+ Cn Unassigned
56
+ Co Private_Use
57
+ Cs Surrogate
58
+ L Letter
59
+ LC Cased_Letter
60
+ Ll Lowercase_Letter
61
+ Lm Modifier_Letter
62
+ Lo Other_Letter
63
+ Lt Titlecase_Letter
64
+ Lu Uppercase_Letter
65
+ M Mark Combining_Mark
66
+ Mc Spacing_Mark
67
+ Me Enclosing_Mark
68
+ Mn Nonspacing_Mark
69
+ N Number
70
+ Nd Decimal_Number digit
71
+ Nl Letter_Number
72
+ No Other_Number
73
+ P Punctuation punct
74
+ Pc Connector_Punctuation
75
+ Pd Dash_Punctuation
76
+ Pe Close_Punctuation
77
+ Pf Final_Punctuation
78
+ Pi Initial_Punctuation
79
+ Po Other_Punctuation
80
+ Ps Open_Punctuation
81
+ S Symbol
82
+ Sc Currency_Symbol
83
+ Sk Modifier_Symbol
84
+ Sm Math_Symbol
85
+ So Other_Symbol
86
+ Z Separator
87
+ Zl Line_Separator
88
+ Zp Paragraph_Separator
89
+ Zs Space_Separator
90
+ ASCII
91
+ ASCII_Hex_Digit AHex
92
+ Alphabetic Alpha
93
+ Any
94
+ Assigned
95
+ Bidi_Control Bidi_C
96
+ Bidi_Mirrored Bidi_M
97
+ Case_Ignorable CI
98
+ Cased
99
+ Changes_When_Casefolded CWCF
100
+ Changes_When_Casemapped CWCM
101
+ Changes_When_Lowercased CWL
102
+ Changes_When_NFKC_Casefolded CWKCF
103
+ Changes_When_Titlecased CWT
104
+ Changes_When_Uppercased CWU
105
+ Dash
106
+ Default_Ignorable_Code_Point DI
107
+ Deprecated Dep
108
+ Diacritic Dia
109
+ Emoji
110
+ Emoji_Component EComp
111
+ Emoji_Modifier EMod
112
+ Emoji_Modifier_Base EBase
113
+ Emoji_Presentation EPres
114
+ Extended_Pictographic ExtPict
115
+ Extender Ext
116
+ Grapheme_Base Gr_Base
117
+ Grapheme_Extend Gr_Ext
118
+ Hex_Digit Hex
119
+ IDS_Binary_Operator IDSB
120
+ IDS_Trinary_Operator IDST
121
+ ID_Continue IDC
122
+ ID_Start IDS
123
+ Ideographic Ideo
124
+ Join_Control Join_C
125
+ Logical_Order_Exception LOE
126
+ Lowercase Lower
127
+ Math
128
+ Noncharacter_Code_Point NChar
129
+ Pattern_Syntax Pat_Syn
130
+ Pattern_White_Space Pat_WS
131
+ Quotation_Mark QMark
132
+ Radical
133
+ Regional_Indicator RI
134
+ Sentence_Terminal STerm
135
+ Soft_Dotted SD
136
+ Terminal_Punctuation Term
137
+ Unified_Ideograph UIdeo
138
+ Uppercase Upper
139
+ Variation_Selector VS
140
+ White_Space space
141
+ XID_Continue XIDC
142
+ XID_Start XIDS`.split(/\s/).map(e=>[Ve(e),e])),ri=new Map([["s",v(383)],[v(383),"s"]]),si=new Map([[v(223),v(7838)],[v(107),v(8490)],[v(229),v(8491)],[v(969),v(8486)]]),oi=new Map([W(453),W(456),W(459),W(498),...nt(8072,8079),...nt(8088,8095),...nt(8104,8111),W(8124),W(8140),W(8188)]),ii=new Map([["alnum",C`[\p{Alpha}\p{Nd}]`],["alpha",C`\p{Alpha}`],["ascii",C`\p{ASCII}`],["blank",C`[\p{Zs}\t]`],["cntrl",C`\p{Cc}`],["digit",C`\p{Nd}`],["graph",C`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",C`\p{Lower}`],["print",C`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",C`[\p{P}\p{S}]`],["space",C`\p{space}`],["upper",C`\p{Upper}`],["word",C`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",C`\p{AHex}`]]);function ai(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function W(e){const t=v(e);return[t.toLowerCase(),t]}function nt(e,t){return ai(e,t).map(n=>W(n))}var sr=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function ci(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};or(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:bt(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};he(e,li,r);const s={dotAll:e.flags.dotAll,ignoreCase:e.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};he(e,ui,o);const i={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return he(e,hi,i),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var li={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:s}=e;if(s==="repeater"){const o=G();o.body[0].body.push(Q({negate:!0,body:r}),oe("Any"));const i=G();i.body[0].body.push(Kn("greedy",0,1/0,o)),n(I(i,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const s=e.body.filter(o=>o.kind==="flags");for(let o=n+1;o<t.body.length;o++){const i=t.body[o];me(r,i,[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){const n=ar(t.get(e));if(n){const r=G({flags:n});r.body[0].body=e.body,e.body=[I(r,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:s,remove:o,replaceWith:i},a){const{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:h,supportedGNodes:f,wordIsAscii:d}=a;if(c==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${l?"Y":"y"}"`);if(c==="line_end")i(I(Q({body:[Y({body:[mt("string_end")]}),Y({body:[Ue(10)]})]}),t));else if(c==="line_start")i(I(U(C`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c==="search_start")if(f.has(e))s.flags.sticky=!0,o();else{const p=r[n-1];if(p&&_i(p))i(I(Q({negate:!0}),t));else{if(h)throw new Error(C`Uses "\G" in a way that requires a subclass`);i(z(mt("string_start"),t)),a.strategy="clip_search"}}else if(!(c==="string_end"||c==="string_start"))if(c==="string_end_newline")i(I(U(C`(?=\n?\z)`),t));else if(c==="word_boundary"){if(!d&&!u){const p=`(?:(?<=${j})(?!${j})|(?<!${j})(?=${j}))`,_=`(?:(?<=${j})(?=${j})|(?<!${j})(?!${j}))`;i(I(U(l?_:p),t))}}else throw new Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!st(n)&&(n=rt(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!st(r)&&(r=rt(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){const r=Ie({body:[e]});n(I(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:o,spaceIsAscii:i,wordIsAscii:a}){const{kind:c,negate:l,value:u}=e;if(o&&(c==="digit"||u==="digit")){n(z(yt("digit",{negate:l}),t));return}if(i&&(c==="space"||u==="space")){n(I(ot(U(ti),l),t));return}if(a&&(c==="word"||u==="word")){n(z(yt("word",{negate:l}),t));return}if(c==="any")n(z(oe("Any"),t));else if(c==="digit")n(z(oe("Nd",{negate:l}),t));else if(c!=="dot")if(c==="text_segment"){if(r==="strict")throw new Error(C`Use of "\X" requires non-strict accuracy`);const h="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=C`\p{RI}{2}|${h}(?:\u200D${h})*`;n(I(U(C`(?>\r\n|${s?C`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c==="hex")n(z(oe("AHex",{negate:l}),t));else if(c==="newline")n(I(U(l?`[^
143
+ ]`:`(?>\r
144
+ ?|[
145
+ \v\f…\u2028\u2029])`),t));else if(c==="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];l&&(h=`\0-${v(h.codePointAt(0)-1)}${v(h.codePointAt(2)+1)}-􏿿`),n(I(U(`[${h}]`),t))}else n(I(ot(U(ii.get(u)),l),t));else if(c==="property")xt.has(Ve(u))||(e.key="sc");else if(c==="space")n(z(oe("space",{negate:l}),t));else if(c==="word")n(I(ot(U(j),l),t));else throw new Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:i}){const{kind:a,flags:c}=e;if(a==="flags")if(!c.enable&&!c.disable)r();else{const l=G({flags:c});l.body[0].body=i(),s(I(l,t),{traverse:!0})}else if(a==="keep"){const l=n.body[0],h=n.body.length===1&&qn(l,{type:"Group"})&&l.body[0].body.length===1?l.body[0]:n;if(t.parent!==h||h.body.length>1)throw new Error(C`Uses "\K" in a way that's unsupported`);const f=Q({behind:!0});f.body[0].body=o(),s(I(f,t))}else throw new Error(`Unexpected directive kind "${a}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(I(Q({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=G();t.body[0].body.push(e.body),e.body=I(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,s=!1;for(const o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const i=lr(o.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):s=!0}r&&!s&&n.forEach(o=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(C`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!st(n)&&(n=rt(n,t),e.ref=n)}},ui={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=e;r||n.set(e,[...t.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:i,openRefs:a,reffedNodesByReferencer:c}){const l=s.get(e);if(l&&a.has(e.number)){const h=z(hn(e.number),t);c.set(h,a.get(e.number)),n(h);return}a.set(e.number,e),i.set(e.number,[]),e.name&&me(i,e.name,[]);const u=i.get(e.name??e.number);for(let h=0;h<u.length;h++){const f=u[h];if(l===f.node||l&&l===f.origin||e===f.origin){u.splice(h,1);break}}if(i.get(e.number).push({node:e,origin:l}),e.name&&i.get(e.name).push({node:e,origin:l}),e.name){const h=me(o,e.name,new Map);let f=!1;if(l)f=!0;else for(const d of h.values())if(!d.hasDuplicateNameToRemove){f=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Me(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:s,ref:o}=e;if(s){let u=t;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===o||u.number===o)););r.reffedNodesByReferencer.set(e,u);return}const i=r.subroutineRefMap.get(o),a=o===0,c=a?hn(0):ir(i,r.groupOriginByCopy,null);let l=c;if(!a){const u=ar(pi(i,f=>f.type==="Group"&&!!f.flags)),h=u?Me(r.globalFlags,u):r.globalFlags;fi(h,r.currentFlags)||(l=G({flags:gi(h)}),l.body[0].body.push(c))}n(I(l,t),{traverse:!a})}},hi={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const o=r.reffedNodesByReferencer.get(e).filter(i=>di(i,e));if(!o.length)n(I(Q({negate:!0}),t));else if(o.length>1){const i=G({atomic:!0,body:o.reverse().map(a=>Y({body:[_t(a.number)]}))});n(I(i,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=Qn();e.body.at(-1).body.push(s)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function or(e){he(e,{"*"({node:t,parent:n}){t.parent=n}})}function fi(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function di(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=cr(n.parent);for(const s of r){if(s===n)break;if(s===e||ur(s,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function ir(e,t,n,r){const s=Array.isArray(e)?[]:{};for(const[o,i]of Object.entries(e))o==="parent"?s.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?s[o]=ir(i,t,s,n):(o==="type"&&i==="CapturingGroup"&&t.set(s,t.get(e)??e),s[o]=i);return s}function hn(e){const t=Zn(e);return t.isRecursive=!0,t}function pi(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function rt(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function ar(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.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 gi({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function cr(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function lr(e){const t=e.find(n=>n.kind==="search_start"||yi(n,{negate:!1})||!mi(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const s=lr(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function ur(e,t){const n=cr(e)??[];for(const r of n)if(r===t||ur(r,t))return!0;return!1}function mi({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function _i(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function yi(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&qn(e.body[0],{type:"Assertion",kind:"search_start"})}function st(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function U(e,t){const r=Xn(e,{...t,unicodePropertyMap:xt}).body;return r.length>1||r[0].body.length>1?G({body:r}):r[0].body[0]}function ot(e,t){return e.negate=t,e}function z(e,t){return e.parent=t,e}function I(e,t){return or(e),e.parent=t,e}function wi(e,t){const n=nr(t),r=bt(n.target,"ES2024"),s=bt(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,a=null;if(!s){const d=[e.flags.ignoreCase];he(e,bi,{getCurrentModI:()=>d.at(-1),popModI(){d.pop()},pushModI(p){d.push(p)},setHasCasedChar(){d.at(-1)?i=!0:a=!0}})}const c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!a)};let l=e;const u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&i&&a),useFlagMods:s,useFlagV:r,verbose:n.verbose};function h(d){return u.lastNode=l,l=d,Yo(Ci[d.type],`Unexpected node type "${d.type}"`)(d,u,h)}const f={pattern:e.body.map(h).join("|"),flags:h(e.flags),options:{...e.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&&me(f._captureTransfers,d.transferTo,[]).push(p)}),f}var bi={"*":{enter({node:e},t){if(dn(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Me({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){dn(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Rt(v(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),hr(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&sr.has(e.value)&&t.setHasCasedChar()}},Ci={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?C`\B`:C`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:s,number:o}=e,i={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(i.hidden=!0,o>a.number&&(i.transferTo=a.number)),t.captureMap.set(o,i),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=v(e),r=re(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Rt(n)){const s=rr(n);return t.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:s,parent:o}=e;let{body:i}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");M.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(pn)&&(i=[Ue(45),...i.filter(l=>!pn(l))]);const a=()=>`[${s?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||M.bugNestedClassIgnoresNegation)&&!s){const u=i.filter(h=>h.type==="CharacterClass"&&h.kind==="union"&&h.negate);if(u.length){const h=G(),f=h.body[0];return h.parent=o,f.parent=h,i=i.filter(d=>!u.includes(d)),e.body=i,i.length?(e.parent=f,f.body.push(e)):h.body.pop(),u.forEach(d=>{const p=Y({body:[d]});d.parent=p,p.parent=h,h.body.push(p)}),n(h)}}t.inCharClass=!0;const l=a();return t.inCharClass=!1,l}const c=i[0];if(r==="union"&&!s&&c&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(M.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&i.length===1&&c.type!=="CharacterClassRange"))return i.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=re(n,s),i=re(r,s),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const c=hr(e);vi(c).forEach(u=>{a.add(Array.isArray(u)?`${re(u[0],s)}-${re(u[1],s)}`:re(u,s))})}return`${o}-${i}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},s){if(e==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":C`[^\n]`;if(e==="digit")return t?C`\D`:C`\d`;if(e==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&sr.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?C`\P`:C`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?C`\W`:C`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},s,o){const i=s.currentFlags;n&&(s.currentFlags=Me(i,n));const a=t.map(o).join("|"),c=!s.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!s.useFlagMods||!n)?a:`(?${Ai(e,n,s.useFlagMods)}${a})`;return s.currentFlags=i,c},LookaroundAssertion({body:e,kind:t,negate:n},r,s){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(s).join("|")})`},Quantifier(e,t,n){return n(e.body)+xi(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return t===0?`(?R=${r})`:C`\g<${t}&R=${r}>`}},ki=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Si=new Set(["-","\\","]","^","["]),Ei=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),fn=new Map([[9,C`\t`],[10,C`\n`],[11,C`\v`],[12,C`\f`],[13,C`\r`],[8232,C`\u2028`],[8233,C`\u2029`],[65279,C`\uFEFF`]]),Ii=/^\p{Cased}$/u;function Rt(e){return Ii.test(e)}function hr(e,t){const n=!!t?.firstOnly,r=e.min.value,s=e.max.value,o=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return o;for(let i=r;i<=s;i++){const a=v(i);if(!Rt(a))continue;const c=rr(a).filter(l=>{const u=l.codePointAt(0);return u<r||u>s});if(c.length&&(o.push(...c),n))break}return o}function re(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(fn.has(e))return fn.get(e);if(e<32||e>126&&e<160||e>262143||t&&Ri(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?Ei:Si:ki,o=v(e);return(s.has(o)?"\\":"")+o}function vi(e){const t=e.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),n=[];let r=null;for(let s=0;s<t.length;s++)t[s+1]===t[s]+1?r??=t[s]:r===null?n.push(t[s]):(n.push([r,t[s]]),r=null);return n}function Ai(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:s,disable:o}=t;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function xi({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function dn({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function Ri(e){return e>47&&e<58}function pn({type:e,value:t}){return e==="Character"&&t===45}var $i=class Ct extends RegExp{#t=new Map;#e=null;#r;#n=null;#s=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){const s=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const o=t;super(o,n),this.#r=o.source,o instanceof Ct&&(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?"":t,n),this.#r=t,this.#t=Ni(o.hiddenCaptures,o.transfers),this.#s=o.strategy,this.rawOptions=r??{}}s||(this.#e=this)}exec(t){if(!this.#e){const{lazyCompile:s,...o}=this.rawOptions;this.#e=new Ct(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(t.slice(r));return s&&(Li(s,r,t,this.hasIndices),this.lastIndex+=r),s}return this.#o(t)}#o(t){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,t);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 i=1;i<r.length;i++){const{hidden:a,transferTo:c}=this.#t.get(i)??{};if(a?o.push(null):(o.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(s[i])),c&&r[i]!==void 0){const l=o[c];if(!l)throw new Error(`Invalid capture transfer to "${l}"`);if(n[l]=r[i],this.hasIndices&&(n.indices[l]=s[i]),n.groups){this.#n||(this.#n=Pi(this.source));const u=this.#n.get(c);u&&(n.groups[u]=r[i],this.hasIndices&&(n.indices.groups[u]=s[i]))}}}return n}};function Li(e,t,n,r){if(e.index+=t,e.input=n,r){const s=e.indices;for(let i=0;i<s.length;i++){const a=s[i];a&&(s[i]=[a[0]+t,a[1]+t])}const o=s.groups;o&&Object.keys(o).forEach(i=>{const a=o[i];a&&(o[i]=[a[0]+t,a[1]+t])})}}function Ni(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,s]of t)for(const o of s)me(n,o,{}).transferTo=r;return n}function Pi(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,s=0,o;for(;o=t.exec(e);){const{0:i,groups:{capture:a,name:c}}=o;i==="["?r++:r?i==="]"&&r--:a&&(s++,c&&n.set(s,c))}return n}function Ti(e,t){const n=Gi(e,t);return n.options?new $i(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Gi(e,t){const n=nr(t),r=Xn(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:xt}),s=ci(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=wi(s,n),i=Zo(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),a=Qo(i.pattern),c=Xo(a.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),l={pattern:c.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=c.hiddenCaptures.sort((p,_)=>p-_),h=Array.from(c.captureTransfers),f=s._strategy,d=l.pattern.length>=n.lazyCompileLength;(u.length||h.length||f||d)&&(l.options={...u.length&&{hiddenCaptures:u},...h.length&&{transfers:h},...f&&{strategy:f},...d&&{lazyCompile:d}})}return l}function Mi(e,t){return Ti(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Oi(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>Mi(n,{target:t.target}),{createScanner(n){return new Qs(n,t)},createString:Zs}}const fr={astro:()=>b(()=>import("./astro-DOly5024.js"),__vite__mapDeps([0,1,2,3,4,5,6])),bash:()=>b(()=>import("./bash-Yzrsuije.js"),[]),bat:()=>b(()=>import("./bat-CickPsom.js"),[]),c:()=>b(()=>import("./c-BIGW1oBm.js"),[]),clojure:()=>b(()=>import("./clojure-P80f7IUj.js"),[]),cpp:()=>b(()=>import("./cpp-DddhVWhK.js"),__vite__mapDeps([7,8])),csharp:()=>b(()=>import("./csharp-B_TYUkTI.js"),[]),css:()=>b(()=>import("./css-Z72CF80r.js"),[]),dart:()=>b(()=>import("./dart-CtKP3W-j.js"),[]),diff:()=>b(()=>import("./diff-D97Zzqfu.js"),[]),dockerfile:()=>b(()=>import("./dockerfile-BcOcwvcX.js"),[]),elixir:()=>b(()=>import("./elixir-DkJLSxtU.js"),__vite__mapDeps([9,10,2,4])),go:()=>b(()=>import("./go-C27-OAKa.js"),[]),graphql:()=>b(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([11,2,3,12,6])),haskell:()=>b(()=>import("./haskell-Df6bDoY_.js"),[]),hcl:()=>b(()=>import("./hcl-BWvSN4gD.js"),[]),html:()=>b(()=>import("./html-BlS82ilI.js"),__vite__mapDeps([10,2,4])),ini:()=>b(()=>import("./ini-BEwlwnbL.js"),[]),java:()=>b(()=>import("./java-CylS5w8V.js"),[]),javascript:()=>b(()=>import("./javascript-wDzz0qaB.js"),[]),json:()=>b(()=>import("./json-Cp-IABpG.js"),[]),jsonc:()=>b(()=>import("./jsonc-Des-eS-w.js"),[]),jsx:()=>b(()=>import("./jsx-g9-lgVsj.js"),[]),kotlin:()=>b(()=>import("./kotlin-BdnUsdx6.js"),[]),latex:()=>b(()=>import("./latex-BK3a6r9z.js"),__vite__mapDeps([13,14])),less:()=>b(()=>import("./less-B1dDrJ26.js"),[]),lua:()=>b(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([15,8])),makefile:()=>b(()=>import("./makefile-CHLpvVh8.js"),[]),markdown:()=>b(()=>import("./markdown-Cvjx9yec.js"),[]),nginx:()=>b(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([16,15,8])),nix:()=>b(()=>import("./nix-CwoSXNpI.js"),[]),"objective-c":()=>b(()=>import("./objective-c-DXmwc3jG.js"),[]),perl:()=>b(()=>import("./perl-5klg-GXX.js"),__vite__mapDeps([17,10,2,4,18,19,20])),php:()=>b(()=>import("./php-DoruYMF0.js"),__vite__mapDeps([21,10,2,4,18,19,20,1])),powershell:()=>b(()=>import("./powershell-Dd0kTxKP.js"),[]),prisma:()=>b(()=>import("./prisma-Vru482bI.js"),[]),proto:()=>b(()=>import("./proto-C7zT0LnQ.js"),[]),python:()=>b(()=>import("./python-B6aJPvgy.js"),[]),r:()=>b(()=>import("./r-Cf5RLm7j.js"),[]),ruby:()=>b(()=>import("./ruby-KQScI-mG.js"),__vite__mapDeps([22,10,2,4,18,19,20,11,3,12,6,7,8,23,15,24])),rust:()=>b(()=>import("./rust-DPvrY3IQ.js"),[]),sass:()=>b(()=>import("./sass-Cj5Yp3dK.js"),[]),scala:()=>b(()=>import("./scala-CqE71os6.js"),[]),scss:()=>b(()=>import("./scss-Cw6XMfVs.js"),__vite__mapDeps([25,4])),sql:()=>b(()=>import("./sql-DkvoVjww.js"),[]),svelte:()=>b(()=>import("./svelte-DoIXUgJc.js"),__vite__mapDeps([26,2,3,4,5])),swift:()=>b(()=>import("./swift-C2oV4EkX.js"),[]),terraform:()=>b(()=>import("./terraform-BETggiCN.js"),[]),toml:()=>b(()=>import("./toml-vGWfd6FD.js"),[]),tsx:()=>b(()=>import("./tsx-COt5Ahok.js"),[]),typescript:()=>b(()=>import("./typescript-BPQ3VLAy.js"),[]),vim:()=>b(()=>import("./vim-CJc9bBzg.js"),[]),vue:()=>b(()=>import("./vue-CwSeJimo.js"),__vite__mapDeps([27,4,2,3,1,10])),xml:()=>b(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([18,19])),yaml:()=>b(()=>import("./yaml-Buea-lGh.js"),[]),zig:()=>b(()=>import("./zig-VOosw3JB.js"),[])},Wi=Object.keys(fr),Bi=qs({name:"linkshell",variablePrefix:"--code-",fontStyle:!1}),Di="var(--code-foreground)";let gn;const it=new Map;async function Fi(e){gn??=Hs({themes:[Bi],langs:[],engine:Oi({forgiving:!0})});const t=await gn;if(!t.getLoadedLanguages().includes(e)){let n=it.get(e);n||(n=fr[e]().then(r=>t.loadLanguage(...r.default)),it.set(e,n),n.catch(()=>it.delete(e))),await n}return t}async function zi(e,t){return(await Fi(t)).codeToTokensBase(e,{lang:t,theme:"linkshell"}).map(r=>r.map(s=>s.color&&s.color!==Di?{content:s.content,color:s.color}:{content:s.content}))}export{Wi as loadableGrammars,zi as tokenize};