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