@lexical/code-shiki 0.37.1-nightly.20251021.0 → 0.37.1-nightly.20251023.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.
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{$isCodeNode as e,$createCodeHighlightNode as t,CodeExtension as n,DEFAULT_CODE_LANGUAGE as r,CodeNode as s,CodeHighlightNode as i,$isCodeHighlightNode as o,$getFirstCodeNodeOfLine as a,$getLastCodeNodeOfLine as l,$getCodeLineDirection as c,$getStartOfCodeInLine as u,$getEndOfCodeInLine as p}from"@lexical/code";import{mergeRegister as h}from"@lexical/utils";import{$getNodeByKey as d,$createLineBreakNode as m,$createTabNode as g,defineExtension as f,TextNode as y,KEY_TAB_COMMAND as k,COMMAND_PRIORITY_LOW as b,INSERT_TAB_COMMAND as w,$getSelection as C,$insertNodes as _,INDENT_CONTENT_COMMAND as S,OUTDENT_CONTENT_COMMAND as v,KEY_ARROW_UP_COMMAND as x,$isRangeSelection as N,KEY_ARROW_DOWN_COMMAND as A,MOVE_TO_START as j,MOVE_TO_END as E,$isLineBreakNode as L,$createTextNode as I,$createPoint as P,$setSelectionFromCaretRange as R,$getCaretRangeInDirection as T,$getCaretRange as M,$getTextPointCaret as $,$normalizeCaret as O,$getSiblingCaret as G,$isTabNode as D,$isTextNode as B}from"lexical";function F(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let U=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function z(e){return Array.isArray(e)?function(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=z(e[n]);return t}(e):e instanceof RegExp?e:"object"==typeof e?function(e){let t={};for(let n in e)t[n]=z(e[n]);return t}(e):e}function W(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function H(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return 0===t?e:~t===e.length-1?H(e.substring(0,e.length-1)):e.substr(1+~t)}var q=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,V=class{static hasCaptures(e){return null!==e&&(q.lastIndex=0,q.test(e))}static replaceCaptures(e,t,n){return e.replace(q,(e,r,s,i)=>{let o=n[parseInt(r||s,10)];if(!o)return e;{let e=t.substring(o.start,o.end);for(;"."===e[0];)e=e.substring(1);switch(i){case"downcase":return e.toLowerCase();case"upcase":return e.toUpperCase();default:return e}}})}};function X(e,t){return e<t?-1:e>t?1:0}function K(e,t){if(null===e&&null===t)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=X(e[r],t[r]);if(0!==n)return n}return 0}return n-r}function Q(e){return!!/^#[0-9a-f]{6}$/i.test(e)||(!!/^#[0-9a-f]{8}$/i.test(e)||(!!/^#[0-9a-f]{3}$/i.test(e)||!!/^#[0-9a-f]{4}$/i.test(e)))}function Z(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var J=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},Y=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(function(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,s=t.length;e<s;e++){let s,i=t[e];if(!i.settings)continue;if("string"==typeof i.scope){let e=i.scope;e=e.replace(/^[,]+/,""),e=e.replace(/[,]+$/,""),s=e.split(",")}else s=Array.isArray(i.scope)?i.scope:[""];let o=-1;if("string"==typeof i.settings.fontStyle){o=0;let e=i.settings.fontStyle.split(" ");for(let t=0,n=e.length;t<n;t++){switch(e[t]){case"italic":o|=1;break;case"bold":o|=2;break;case"underline":o|=4;break;case"strikethrough":o|=8}}}let a=null;"string"==typeof i.settings.foreground&&Q(i.settings.foreground)&&(a=i.settings.foreground);let l=null;"string"==typeof i.settings.background&&Q(i.settings.background)&&(l=i.settings.background);for(let t=0,i=s.length;t<i;t++){let i=s[t].trim().split(" "),c=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new re(c,u,e,o,a,l)}}return n}(e),t)}static createFromParsedTheme(e,t){return function(e,t){e.sort((e,t)=>{let n=X(e.scope,t.scope);return 0!==n?n:(n=K(e.parentScopes,t.parentScopes),0!==n?n:e.index-t.index)});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&""===e[0].scope;){let t=e.shift();-1!==t.fontStyle&&(n=t.fontStyle),null!==t.foreground&&(r=t.foreground),null!==t.background&&(s=t.background)}let i=new ie(t),o=new ne(n,i.getId(r),i.getId(s)),a=new le(new ae(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];a.insert(0,n.scope,n.parentScopes,n.fontStyle,i.getId(n.foreground),i.getId(n.background))}return new Y(i,o,a)}(e,t)}_cachedMatchRoot=new J(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(null===e)return this._defaults;const t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>function(e,t){if(0===t.length)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(">"===r){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!te(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}(e.parent,t.parentScopes));return n?new ne(n.fontStyle,n.foreground,n.background):null}},ee=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(const r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e||null!==this.parent&&this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function te(e,t){return t===e||e.startsWith(t)&&"."===e[t.length]}var ne=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};var re=class{constructor(e,t,n,r,s,i){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=i}},se=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(se||{});var ie=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(null===e)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},oe=Object.freeze([]),ae=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,s){this.scopeDepth=e,this.parentScopes=t||oe,this.fontStyle=n,this.foreground=r,this.background=s}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,-1!==t&&(this.fontStyle=t),0!==n&&(this.foreground=n),0!==r&&(this.background=r)}},le=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;">"===e.parentScopes[n]&&n++,">"===t.parentScopes[r]&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){const s=t.parentScopes[r].length-e.parentScopes[n].length;if(0!==s)return s;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(""!==t){let e,n,r=t.indexOf(".");if(-1===r?(e=t,n=""):(e=t.substring(0,r),n=t.substring(r+1)),this._children.hasOwnProperty(e))return this._children[e].match(n)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,s,i,o){if(""===n)return void this._doInsertHere(t,r,s,i,o);let a,l,c,u=n.indexOf(".");-1===u?(a=n,l=""):(a=n.substring(0,u),l=n.substring(u+1)),this._children.hasOwnProperty(a)?c=this._children[a]:(c=new e(this._mainRule.clone(),ae.cloneArr(this._rulesWithParentScopes)),this._children[a]=c),c.insert(t+1,l,r,s,i,o)}_doInsertHere(e,t,n,r,s){if(null!==t){for(let i=0,o=this._rulesWithParentScopes.length;i<o;i++){let o=this._rulesWithParentScopes[i];if(0===K(o.parentScopes,t))return void o.acceptOverwrite(e,n,r,s)}-1===n&&(n=this._mainRule.fontStyle),0===r&&(r=this._mainRule.foreground),0===s&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new ae(e,t,n,r,s))}else this._mainRule.acceptOverwrite(e,n,r,s)}},ce=class e{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(t){const n=e.getLanguageId(t),r=e.getTokenType(t),s=e.getFontStyle(t),i=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:i,background:o})}static getLanguageId(e){return(255&e)>>>0}static getTokenType(e){return(768&e)>>>8}static containsBalancedBrackets(e){return!!(1024&e)}static getFontStyle(e){return(30720&e)>>>11}static getForeground(e){return(16744448&e)>>>15}static getBackground(e){return(4278190080&e)>>>24}static set(t,n,r,s,i,o,a){let l=e.getLanguageId(t),c=e.getTokenType(t),u=e.containsBalancedBrackets(t)?1:0,p=e.getFontStyle(t),h=e.getForeground(t),d=e.getBackground(t);return 0!==n&&(l=n),8!==r&&(c=r),null!==s&&(u=s?1:0),-1!==i&&(p=i),0!==o&&(h=o),0!==a&&(d=a),(l|c<<8|u<<10|p<<11|h<<15|d<<24)>>>0}};function ue(e){return e}function pe(e,t){const n=[],r=function(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}(e);let s=r.next();for(;null!==s;){let e=0;if(2===s.length&&":"===s.charAt(1)){switch(s.charAt(0)){case"R":e=1;break;case"L":e=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let t=o();if(n.push({matcher:t,priority:e}),","!==s)break;s=r.next()}return n;function i(){if("-"===s){s=r.next();const e=i();return t=>!!e&&!e(t)}if("("===s){s=r.next();const e=function(){const e=[];let t=o();for(;t&&(e.push(t),"|"===s||","===s);){do{s=r.next()}while("|"===s||","===s);t=o()}return t=>e.some(e=>e(t))}();return")"===s&&(s=r.next()),e}if(he(s)){const e=[];do{e.push(s),s=r.next()}while(he(s));return n=>t(e,n)}return null}function o(){const e=[];let t=i();for(;t;)e.push(t),t=i();return t=>e.every(e=>e(t))}}function he(e){return!!e&&!!e.match(/[\w\.:]+/)}function de(e){"function"==typeof e.dispose&&e.dispose()}var me=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},ge=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},fe=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},ye=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new me(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new fe;for(const n of e)ke(n,this.initialScopeName,this.repo,t);for(const e of t.references)if(e instanceof me){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName))continue;if(this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function ke(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const i=n.lookup(t);e instanceof me?we({baseGrammar:i,selfGrammar:s},r):be(e.ruleName,{baseGrammar:i,selfGrammar:s,repository:s.repository},r);const o=n.injections(e.scopeName);if(o)for(const e of o)r.add(new me(e))}function be(e,t,n){if(t.repository&&t.repository[e]){Ce([t.repository[e]],t,n)}}function we(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ce(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ce(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ce(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const e=r.repository?W({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Ce(r.patterns,{...t,repository:e},n);const s=r.include;if(!s)continue;const i=Ae(s);switch(i.kind){case 0:we({...t,selfGrammar:t.baseGrammar},n);break;case 1:we(t,n);break;case 2:be(i.ruleName,{...t,repository:e},n);break;case 3:case 4:const r=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){const s={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};4===i.kind?be(i.ruleName,s,n):we(s,n)}else 4===i.kind?n.add(new ge(i.scopeName,i.ruleName)):n.add(new me(i.scopeName))}}}var _e=class{kind=0},Se=class{kind=1},ve=class{constructor(e){this.ruleName=e}kind=2},xe=class{constructor(e){this.scopeName=e}kind=3},Ne=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Ae(e){if("$base"===e)return new _e;if("$self"===e)return new Se;const t=e.indexOf("#");if(-1===t)return new xe(e);if(0===t)return new ve(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new Ne(n,r)}}var je=/\\(\d+)/,Ee=/\\(\d+)/g;var Le=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=V.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=V.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${H(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return this._nameIsCapturing&&null!==this._name&&null!==e&&null!==t?V.replaceCaptures(this._name,e,t):this._name}getContentName(e,t){return this._contentNameIsCapturing&&null!==this._contentName?V.replaceCaptures(this._contentName,e,t):this._contentName}},Ie=class extends Le{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},Pe=class extends Le{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new Oe(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ge,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Re=class extends Le{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns){e.getRule(n).collectPatterns(e,t)}}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ge,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Te=class extends Le{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,i,o,a,l,c){super(e,t,n,r),this._begin=new Oe(s,this.id),this.beginCaptures=i,this._end=new Oe(o||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ge;for(const t of this.patterns){e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Me=class extends Le{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,i,o,a,l){super(e,t,n,r),this._begin=new Oe(s,this.id),this.beginCaptures=i,this.whileCaptures=a,this._while=new Oe(o,-2),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,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ge;for(const t of this.patterns){e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Ge,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},$e=class e{static createCaptureRule(e,t,n,r,s){return e.registerRule(e=>new Ie(t,e,n,r,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new Pe(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(void 0===t.begin){t.repository&&(r=W({},r,t.repository));let s=t.patterns;return void 0===s&&t.include&&(s=[{include:t.include}]),new Re(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(s,n,r))}return t.while?new Me(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Te(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let i=0;for(const e in t){if("$vscodeTextmateLocation"===e)continue;const t=parseInt(e,10);t>i&&(i=t)}for(let e=0;e<=i;e++)s[e]=null;for(const i in t){if("$vscodeTextmateLocation"===i)continue;const o=parseInt(i,10);let a=0;t[i].patterns&&(a=e.getCompiledRuleId(t[i],n,r)),s[o]=e.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,a)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let i=0,o=t.length;i<o;i++){const o=t[i];let a=-1;if(o.include){const t=Ae(o.include);switch(t.kind){case 0:case 1:a=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let s=r[t.ruleName];s&&(a=e.getCompiledRuleId(s,n,r));break;case 3:case 4:const i=t.scopeName,l=4===t.kind?t.ruleName:null,c=n.getExternalGrammar(i,r);if(c)if(l){let t=c.repository[l];t&&(a=e.getCompiledRuleId(t,n,c.repository))}else a=e.getCompiledRuleId(c.repository.$self,n,c.repository)}}else a=e.getCompiledRuleId(o,n,r);if(-1!==a){const e=n.getRule(a);let t=!1;if((e instanceof Re||e instanceof Te||e instanceof Me)&&e.hasMissingPatterns&&0===e.patterns.length&&(t=!0),t)continue;s.push(a)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},Oe=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&"string"==typeof e){const t=e.length;let n=0,r=[],s=!1;for(let i=0;i<t;i++){if("\\"===e.charAt(i)&&i+1<t){const t=e.charAt(i+1);"z"===t?(r.push(e.substring(n,i)),r.push("$(?!\\n)(?<!\\n)"),n=i+2):"A"!==t&&"G"!==t||(s=!0),i++}}this.hasAnchor=s,0===n?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,"string"==typeof this.source?this.hasBackReferences=je.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if("string"!=typeof this.source)throw new Error("This method should only be called if the source is a string");let n=t.map(t=>e.substring(t.start,t.end));return Ee.lastIndex=0,this.source.replace(Ee,(e,t)=>Z(n[parseInt(t,10)]||""))}_buildAnchorCache(){if("string"!=typeof this.source)throw new Error("This method should only be called if the source is a string");let e,t,n,r,s=[],i=[],o=[],a=[];for(e=0,t=this.source.length;e<t;e++)n=this.source.charAt(e),s[e]=n,i[e]=n,o[e]=n,a[e]=n,"\\"===n&&e+1<t&&(r=this.source.charAt(e+1),"A"===r?(s[e+1]="",i[e+1]="",o[e+1]="A",a[e+1]="A"):"G"===r?(s[e+1]="",i[e+1]="G",o[e+1]="",a[e+1]="G"):(s[e+1]=r,i[e+1]=r,o[e+1]=r,a[e+1]=r),e++);return{A0_G0:s.join(""),A0_G1:i.join(""),A1_G0:o.join(""),A1_G1:a.join("")}}resolveAnchors(e,t){return this.hasAnchor&&this._anchorCache&&"string"==typeof this.source?e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0:this.source}},Ge=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new De(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(e=>e.resolveAnchors(t,n));return new De(e,r,this._items.map(e=>e.ruleId))}},De=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){"function"==typeof this.scanner.dispose&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join("\n")}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Be=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Fe=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Be(e,8),this._embeddedLanguagesMatcher=new Ue(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return null===t?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Be(0,0);_getBasicScopeAttributes=new J(e=>{const t=this._scopeToLanguage(e),n=this._toStandardTokenType(e);return new Be(t,n)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){const n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Ue=class{values;scopesRegExp;constructor(e){if(0===e.length)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([e,t])=>Z(e));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);return t?this.values.get(t[1]):void 0}};"undefined"!=typeof process&&process.env.VSCODE_TEXTMATE_DEBUG;var ze=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function We(e,t,n,r,s,i,o,a){const l=t.content.length;let c=!1,u=-1;if(o){const o=function(e,t,n,r,s,i){let o=s.beginRuleCapturedEOL?0:-1;const a=[];for(let t=s;t;t=t.pop()){const n=t.getRule(e);n instanceof Me&&a.push({rule:n,stack:t})}for(let l=a.pop();l;l=a.pop()){const{ruleScanner:a,findOptions:c}=qe(l.rule,e,l.stack.endRule,n,r===o),u=a.findNextMatchSync(t,r,c);if(!u){s=l.stack.pop();break}if(-2!==u.ruleId){s=l.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(i.produce(l.stack,u.captureIndices[0].start),Ve(e,t,n,l.stack,i,l.rule.whileCaptures,u.captureIndices),i.produce(l.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}return{stack:s,linePos:r,anchorPosition:o,isFirstLine:n}}(e,t,n,r,s,i);s=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}const p=Date.now();for(;!c;){if(0!==a){if(Date.now()-p>a)return new ze(s,!0)}h()}return new ze(s,!1);function h(){const o=function(e,t,n,r,s,i){const o=function(e,t,n,r,s,i){const o=s.getRule(e),{ruleScanner:a,findOptions:l}=He(o,e,s.endRule,n,r===i),c=a.findNextMatchSync(t,r,l);if(c)return{captureIndices:c.captureIndices,matchedRuleId:c.ruleId};return null}(e,t,n,r,s,i),a=e.getInjections();if(0===a.length)return o;const l=function(e,t,n,r,s,i,o){let a,l=Number.MAX_VALUE,c=null,u=0;const p=i.contentNameScopesList.getScopeNames();for(let i=0,h=e.length;i<h;i++){const h=e[i];if(!h.matcher(p))continue;const d=t.getRule(h.ruleId),{ruleScanner:m,findOptions:g}=He(d,t,null,r,s===o),f=m.findNextMatchSync(n,s,g);if(!f)continue;const y=f.captureIndices[0].start;if(!(y>=l)&&(l=y,c=f.captureIndices,a=f.ruleId,u=h.priority,l===s))break}if(c)return{priorityMatch:-1===u,captureIndices:c,matchedRuleId:a};return null}(a,e,t,n,r,s,i);if(!l)return o;if(!o)return l;const c=o.captureIndices[0].start,u=l.captureIndices[0].start;if(u<c||l.priorityMatch&&u===c)return l;return o}(e,t,n,r,s,u);if(!o)return i.produce(s,l),void(c=!0);const a=o.captureIndices,p=o.matchedRuleId,h=!!(a&&a.length>0)&&a[0].end>r;if(-1===p){const o=s.getRule(e);i.produce(s,a[0].start),s=s.withContentNameScopesList(s.nameScopesList),Ve(e,t,n,s,i,o.endCaptures,a),i.produce(s,a[0].end);const p=s;if(s=s.parent,u=p.getAnchorPos(),!h&&p.getEnterPos()===r)return s=p,i.produce(s,l),void(c=!0)}else{const o=e.getRule(p);i.produce(s,a[0].start);const d=s,m=o.getName(t.content,a),g=s.contentNameScopesList.pushAttributed(m,e);if(s=s.push(p,r,u,a[0].end===l,null,g,g),o instanceof Te){const r=o;Ve(e,t,n,s,i,r.beginCaptures,a),i.produce(s,a[0].end),u=a[0].end;const p=r.getContentName(t.content,a),m=g.pushAttributed(p,e);if(s=s.withContentNameScopesList(m),r.endHasBackReferences&&(s=s.withEndRule(r.getEndWithResolvedBackReferences(t.content,a))),!h&&d.hasSameRuleAs(s))return s=s.pop(),i.produce(s,l),void(c=!0)}else if(o instanceof Me){const r=o;Ve(e,t,n,s,i,r.beginCaptures,a),i.produce(s,a[0].end),u=a[0].end;const p=r.getContentName(t.content,a),m=g.pushAttributed(p,e);if(s=s.withContentNameScopesList(m),r.whileHasBackReferences&&(s=s.withEndRule(r.getWhileWithResolvedBackReferences(t.content,a))),!h&&d.hasSameRuleAs(s))return s=s.pop(),i.produce(s,l),void(c=!0)}else{if(Ve(e,t,n,s,i,o.captures,a),i.produce(s,a[0].end),s=s.pop(),!h)return s=s.safePop(),i.produce(s,l),void(c=!0)}}a[0].end>r&&(r=a[0].end,n=!1)}}function He(e,t,n,r,s){return{ruleScanner:e.compileAG(t,n,r,s),findOptions:0}}function qe(e,t,n,r,s){return{ruleScanner:e.compileWhileAG(t,n,r,s),findOptions:0}}function Ve(e,t,n,r,s,i,o){if(0===i.length)return;const a=t.content,l=Math.min(i.length,o.length),c=[],u=o[0].end;for(let t=0;t<l;t++){const l=i[t];if(null===l)continue;const p=o[t];if(0===p.length)continue;if(p.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=p.start;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?s.produceFromScopes(c[c.length-1].scopes,p.start):s.produce(r,p.start),l.retokenizeCapturedWithRuleId){const t=l.getName(a,o),i=r.contentNameScopesList.pushAttributed(t,e),c=l.getContentName(a,o),u=i.pushAttributed(c,e),h=r.push(l.retokenizeCapturedWithRuleId,p.start,-1,!1,null,i,u),d=e.createOnigString(a.substring(0,p.end));We(e,d,n&&0===p.start,p.start,h,s,!1,0),de(d);continue}const h=l.getName(a,o);if(null!==h){const t=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(h,e);c.push(new Xe(t,p.end))}}for(;c.length>0;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var Xe=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Ke(e,t,n,r,s){const i=pe(t,Qe),o=$e.getCompiledRuleId(n,r,s.repository);for(const n of i)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:s,priority:n.priority})}function Qe(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(Ze(t[r],e))return n=r+1,!0;return!1})}function Ze(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&"."===e[n]}var Je=class{constructor(e,t,n,r,s,i,o,a){if(this._rootScopeName=e,this.balancedBracketSelectors=i,this._onigLib=a,this._basicScopeAttributesProvider=new Fe(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=Ye(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const e of Object.keys(s)){const t=pe(e,Qe);for(const n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:s[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e=e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),t=[],n=this._rootScopeName,r=e(n);if(r){const e=r.injections;if(e)for(let n in e)Ke(t,n,e[n],this,r);const s=this._grammarRepository.injections(n);s&&s.forEach(e=>{const n=this.getExternalGrammar(e);if(n){const e=n.injectionSelector;e&&Ke(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return null===this._injections&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Ye(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){let s;if(-1===this._rootId&&(this._rootId=$e.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections()),t&&t!==tt.NULL)s=!1,t.reset();else{s=!0;const e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=ce.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),i=this.getRule(this._rootId).getName(null,null);let o;o=i?et.createRootAndLookUpScopeName(i,r,this):et.createRoot("unknown",r),t=new tt(null,this._rootId,-1,-1,!1,null,o,o)}e+="\n";const i=this.createOnigString(e),o=i.content.length,a=new rt(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=We(this,i,s,0,t,a,!0,r);return de(i),{lineLength:o,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Ye(e,t){return(e=z(e)).repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var et=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,s=t?.scopePath??null;for(const t of n)s=ee.push(s,t.scopeNames),r=new e(r,s,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new ee(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const s=r.getMetadataForScope(t),i=new ee(null,t),o=r.themeProvider.themeMatch(i),a=e.mergeAttributes(n,s,o);return new e(null,i,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return e.equals(this,t)}static equals(e,t){for(;;){if(e===t)return!0;if(!e&&!t)return!0;if(!e||!t)return!1;if(e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}}static mergeAttributes(e,t,n){let r=-1,s=0,i=0;return null!==n&&(r=n.fontStyle,s=n.foregroundId,i=n.backgroundId),ce.set(e,t.languageId,t.tokenType,null,r,s,i)}pushAttributed(t,n){if(null===t)return this;if(-1===t.indexOf(" "))return e._pushAttributed(this,t,n);const r=t.split(/ /g);let s=this;for(const t of r)s=e._pushAttributed(s,t,n);return s}static _pushAttributed(t,n,r){const s=r.getMetadataForScope(n),i=t.scopePath.push(n),o=r.themeProvider.themeMatch(i),a=e.mergeAttributes(t.tokenAttributes,s,o);return new e(t,i,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const t=[];let n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},tt=class e{constructor(e,t,n,r,s,i,o,a){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=s,this.endRule=i,this.nameScopesList=o,this.contentNameScopesList=a,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return null!==t&&e._equals(this,t)}static _equals(e,t){return e===t||!!this._structuralEquals(e,t)&&et.equals(e.contentNameScopesList,t.contentNameScopesList)}static _structuralEquals(e,t){for(;;){if(e===t)return!0;if(!e&&!t)return!0;if(!e||!t)return!1;if(e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,s,i,o,a){return new e(this,t,n,r,s,i,o,a)}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,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){const r=et.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,et.fromExtension(r,n.contentNameScopesList))}},nt=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>"*"===e?(this.allowAny=!0,[]):pe(e,Qe).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>pe(e,Qe).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&0===this.unbalancedBracketScopes.length}get matchesNever(){return 0===this.balancedBracketScopes.length&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},rt=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const t=e?.getScopeNames()??[];for(const e of this._tokenTypeOverrides)e.matcher(t)&&(n=ce.set(n,0,ue(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}return r&&(n=ce.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n?void(this._lastTokenEndIndex=t):(this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),void(this._lastTokenEndIndex=t))}const n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),0===this._tokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),0===this._binaryTokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},st=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,s){if(!this._grammars.has(e)){let i=this._rawGrammars.get(e);if(!i)return null;this._grammars.set(e,function(e,t,n,r,s,i,o,a){return new Je(e,t,n,r,s,i,o,a)}(e,i,t,n,r,s,this,this._onigLib))}return this._grammars.get(e)}},it=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new st(Y.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Y.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new nt(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,s){const i=new ye(this._syncRegistry,e);for(;i.Q.length>0;)i.Q.map(e=>this._loadSingleGrammar(e.scopeName)),i.processQueue();return this._grammarForScopeName(e,t,n,r,s)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const t=this._options.loadGrammar(e);if(t){const n="function"==typeof this._options.getInjections?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,s)}},ot=tt.NULL;const at=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class lt{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function ct(e,t){const n={},r={};for(const t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new lt(n,r,t)}function ut(e){return e.toLowerCase()}lt.prototype.normal={},lt.prototype.property={},lt.prototype.space=void 0;class pt{constructor(e,t){this.attribute=t,this.property=e}}pt.prototype.attribute="",pt.prototype.booleanish=!1,pt.prototype.boolean=!1,pt.prototype.commaOrSpaceSeparated=!1,pt.prototype.commaSeparated=!1,pt.prototype.defined=!1,pt.prototype.mustUseProperty=!1,pt.prototype.number=!1,pt.prototype.overloadedBoolean=!1,pt.prototype.property="",pt.prototype.spaceSeparated=!1,pt.prototype.space=void 0;let ht=0;const dt=wt(),mt=wt(),gt=wt(),ft=wt(),yt=wt(),kt=wt(),bt=wt();function wt(){return 2**++ht}var Ct={__proto__:null,boolean:dt,booleanish:mt,commaOrSpaceSeparated:bt,commaSeparated:kt,number:ft,overloadedBoolean:gt,spaceSeparated:yt};const _t=Object.keys(Ct);class St extends pt{constructor(e,t,n,r){let s=-1;if(super(e,t),vt(this,"space",r),"number"==typeof n)for(;++s<_t.length;){const e=_t[s];vt(this,_t[s],(n&Ct[e])===Ct[e])}}}function vt(e,t,n){n&&(e[t]=n)}function xt(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new St(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ut(r)]=r,n[ut(i.attribute)]=r}return new lt(t,n,e.space)}St.prototype.defined=!0;const Nt=xt({properties:{ariaActiveDescendant:null,ariaAtomic:mt,ariaAutoComplete:null,ariaBusy:mt,ariaChecked:mt,ariaColCount:ft,ariaColIndex:ft,ariaColSpan:ft,ariaControls:yt,ariaCurrent:null,ariaDescribedBy:yt,ariaDetails:null,ariaDisabled:mt,ariaDropEffect:yt,ariaErrorMessage:null,ariaExpanded:mt,ariaFlowTo:yt,ariaGrabbed:mt,ariaHasPopup:null,ariaHidden:mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:yt,ariaLevel:ft,ariaLive:null,ariaModal:mt,ariaMultiLine:mt,ariaMultiSelectable:mt,ariaOrientation:null,ariaOwns:yt,ariaPlaceholder:null,ariaPosInSet:ft,ariaPressed:mt,ariaReadOnly:mt,ariaRelevant:null,ariaRequired:mt,ariaRoleDescription:yt,ariaRowCount:ft,ariaRowIndex:ft,ariaRowSpan:ft,ariaSelected:mt,ariaSetSize:ft,ariaSort:null,ariaValueMax:ft,ariaValueMin:ft,ariaValueNow:ft,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function At(e,t){return t in e?e[t]:t}function jt(e,t){return At(e,t.toLowerCase())}const Et=xt({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:kt,acceptCharset:yt,accessKey:yt,action:null,allow:null,allowFullScreen:dt,allowPaymentRequest:dt,allowUserMedia:dt,alt:null,as:null,async:dt,autoCapitalize:null,autoComplete:yt,autoFocus:dt,autoPlay:dt,blocking:yt,capture:null,charSet:null,checked:dt,cite:null,className:yt,cols:ft,colSpan:null,content:null,contentEditable:mt,controls:dt,controlsList:yt,coords:ft|kt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dt,defer:dt,dir:null,dirName:null,disabled:dt,download:gt,draggable:mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dt,formTarget:null,headers:yt,height:ft,hidden:gt,high:ft,href:null,hrefLang:null,htmlFor:yt,httpEquiv:yt,id:null,imageSizes:null,imageSrcSet:null,inert:dt,inputMode:null,integrity:null,is:null,isMap:dt,itemId:null,itemProp:yt,itemRef:yt,itemScope:dt,itemType:yt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dt,low:ft,manifest:null,max:null,maxLength:ft,media:null,method:null,min:null,minLength:ft,multiple:dt,muted:dt,name:null,nonce:null,noModule:dt,noValidate:dt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:dt,optimum:ft,pattern:null,ping:yt,placeholder:null,playsInline:dt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dt,referrerPolicy:null,rel:yt,required:dt,reversed:dt,rows:ft,rowSpan:ft,sandbox:yt,scope:null,scoped:dt,seamless:dt,selected:dt,shadowRootClonable:dt,shadowRootDelegatesFocus:dt,shadowRootMode:null,shape:null,size:ft,sizes:null,slot:null,span:ft,spellCheck:mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ft,step:null,style:null,tabIndex:ft,target:null,title:null,translate:null,type:null,typeMustMatch:dt,useMap:null,value:mt,width:ft,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:yt,axis:null,background:null,bgColor:null,border:ft,borderColor:null,bottomMargin:ft,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dt,declare:dt,event:null,face:null,frame:null,frameBorder:null,hSpace:ft,leftMargin:ft,link:null,longDesc:null,lowSrc:null,marginHeight:ft,marginWidth:ft,noResize:dt,noHref:dt,noShade:dt,noWrap:dt,object:null,profile:null,prompt:null,rev:null,rightMargin:ft,rules:null,scheme:null,scrolling:mt,standby:null,summary:null,text:null,topMargin:ft,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ft,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dt,disableRemotePlayback:dt,prefix:null,property:null,results:ft,security:null,unselectable:null},space:"html",transform:jt}),Lt=xt({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:bt,accentHeight:ft,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ft,amplitude:ft,arabicForm:null,ascent:ft,attributeName:null,attributeType:null,azimuth:ft,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ft,by:null,calcMode:null,capHeight:ft,className:yt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ft,diffuseConstant:ft,direction:null,display:null,dur:null,divisor:ft,dominantBaseline:null,download:dt,dx:null,dy:null,edgeMode:null,editable:null,elevation:ft,enableBackground:null,end:null,event:null,exponent:ft,externalResourcesRequired:null,fill:null,fillOpacity:ft,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:kt,g2:kt,glyphName:kt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ft,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ft,horizOriginX:ft,horizOriginY:ft,id:null,ideographic:ft,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ft,k:ft,k1:ft,k2:ft,k3:ft,k4:ft,kernelMatrix:bt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ft,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ft,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ft,overlineThickness:ft,paintOrder:null,panose1:null,path:null,pathLength:ft,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:yt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ft,pointsAtY:ft,pointsAtZ:ft,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bt,rev:bt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bt,requiredFeatures:bt,requiredFonts:bt,requiredFormats:bt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ft,specularExponent:ft,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ft,strikethroughThickness:ft,string:null,stroke:null,strokeDashArray:bt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ft,strokeOpacity:ft,strokeWidth:null,style:null,surfaceScale:ft,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bt,tabIndex:ft,tableValues:null,target:null,targetX:ft,targetY:ft,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ft,underlineThickness:ft,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ft,values:null,vAlphabetic:ft,vMathematical:ft,vectorEffect:null,vHanging:ft,vIdeographic:ft,version:null,vertAdvY:ft,vertOriginX:ft,vertOriginY:ft,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ft,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:At}),It=xt({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),Pt=xt({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:jt}),Rt=xt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Tt=/[A-Z]/g,Mt=/-[a-z]/g,$t=/^data[-\w.:]+$/i;function Ot(e){return"-"+e.toLowerCase()}function Gt(e){return e.charAt(1).toUpperCase()}const Dt=ct([Nt,Et,It,Pt,Rt],"html"),Bt=ct([Nt,Lt,It,Pt,Rt],"svg"),Ft={}.hasOwnProperty;const Ut=/["&'<>`]/g,zt=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Wt=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Ht=/[|\\{}()[\]^$+*?.]/g,qt=new WeakMap;function Vt(e,t){return e=e.replace(t.subset?function(e){let t=qt.get(e);t||(t=function(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(Ht,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}(e),qt.set(e,t));return t}(t.subset):Ut,n),t.subset||t.escapeOnly?e:e.replace(zt,function(e,n,r){return t.format(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}).replace(Wt,n);function n(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}const Xt=/[\dA-Fa-f]/;const Kt=/\d/;const Qt=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],Zt={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},Jt=["cent","copy","divide","gt","lt","not","para","times"],Yt={}.hasOwnProperty,en={};let tn;for(tn in Zt)Yt.call(Zt,tn)&&(en[Zt[tn]]=tn);const nn=/[^\dA-Za-z]/;function rn(e,t,n){let r,s=function(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!Xt.test(String.fromCharCode(t))?r:r+";"}(e,t,n.omitOptionalSemicolons);if((n.useNamedReferences||n.useShortestReferences)&&(r=function(e,t,n,r){const s=String.fromCharCode(e);if(Yt.call(en,s)){const e=en[s],i="&"+e;return n&&Qt.includes(e)&&!Jt.includes(e)&&(!r||t&&61!==t&&nn.test(String.fromCharCode(t)))?i:i+";"}return""}(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!r)&&n.useShortestReferences){const r=function(e,t,n){const r="&#"+String(e);return n&&t&&!Kt.test(String.fromCharCode(t))?r:r+";"}(e,t,n.omitOptionalSemicolons);r.length<s.length&&(s=r)}return r&&(!n.useShortestReferences||r.length<s.length)?r:s}function sn(e,t){return Vt(e,Object.assign({format:rn},t))}const on=/^>|^->|<!--|-->|--!>|<!-$/g,an=[">"],ln=["<",">"];function cn(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;-1!==s;)r++,s=n.indexOf(t,s+t.length);return r}function un(e,t){const n=t||{};return(""===e[e.length-1]?[...e,""]:e).join((n.padRight?" ":"")+","+(!1===n.padLeft?"":" ")).trim()}function pn(e){return e.join(" ").trim()}const hn=/[ \t\n\f\r]/g;function dn(e){return"object"==typeof e?"text"===e.type&&mn(e.value):mn(e)}function mn(e){return""===e.replace(hn,"")}const gn=kn(1),fn=kn(-1),yn=[];function kn(e){return function(t,n,r){const s=t?t.children:yn;let i=(n||0)+e,o=s[i];if(!r)for(;o&&dn(o);)i+=e,o=s[i];return o}}const bn={}.hasOwnProperty;function wn(e){return function(t,n,r){return bn.call(e,t.tagName)&&e[t.tagName](t,n,r)}}const Cn=wn({body:function(e,t,n){const r=gn(n,t);return!r||"comment"!==r.type},caption:_n,colgroup:_n,dd:function(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&("dt"===r.tagName||"dd"===r.tagName)},dt:function(e,t,n){const r=gn(n,t);return Boolean(r&&"element"===r.type&&("dt"===r.tagName||"dd"===r.tagName))},head:_n,html:function(e,t,n){const r=gn(n,t);return!r||"comment"!==r.type},li:function(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&"li"===r.tagName},optgroup:function(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&"optgroup"===r.tagName},option:function(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&("option"===r.tagName||"optgroup"===r.tagName)},p:function(e,t,n){const r=gn(n,t);return r?"element"===r.type&&("address"===r.tagName||"article"===r.tagName||"aside"===r.tagName||"blockquote"===r.tagName||"details"===r.tagName||"div"===r.tagName||"dl"===r.tagName||"fieldset"===r.tagName||"figcaption"===r.tagName||"figure"===r.tagName||"footer"===r.tagName||"form"===r.tagName||"h1"===r.tagName||"h2"===r.tagName||"h3"===r.tagName||"h4"===r.tagName||"h5"===r.tagName||"h6"===r.tagName||"header"===r.tagName||"hgroup"===r.tagName||"hr"===r.tagName||"main"===r.tagName||"menu"===r.tagName||"nav"===r.tagName||"ol"===r.tagName||"p"===r.tagName||"pre"===r.tagName||"section"===r.tagName||"table"===r.tagName||"ul"===r.tagName):!n||!("element"===n.type&&("a"===n.tagName||"audio"===n.tagName||"del"===n.tagName||"ins"===n.tagName||"map"===n.tagName||"noscript"===n.tagName||"video"===n.tagName))},rp:Sn,rt:Sn,tbody:function(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&("tbody"===r.tagName||"tfoot"===r.tagName)},td:vn,tfoot:function(e,t,n){return!gn(n,t)},th:vn,thead:function(e,t,n){const r=gn(n,t);return Boolean(r&&"element"===r.type&&("tbody"===r.tagName||"tfoot"===r.tagName))},tr:function(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&"tr"===r.tagName}});function _n(e,t,n){const r=gn(n,t,!0);return!r||"comment"!==r.type&&!("text"===r.type&&dn(r.value.charAt(0)))}function Sn(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&("rp"===r.tagName||"rt"===r.tagName)}function vn(e,t,n){const r=gn(n,t);return!r||"element"===r.type&&("td"===r.tagName||"th"===r.tagName)}const xn=wn({body:function(e){const t=gn(e,-1,!0);return!(t&&("comment"===t.type||"text"===t.type&&dn(t.value.charAt(0))||"element"===t.type&&("meta"===t.tagName||"link"===t.tagName||"script"===t.tagName||"style"===t.tagName||"template"===t.tagName)))},colgroup:function(e,t,n){const r=fn(n,t),s=gn(e,-1,!0);if(n&&r&&"element"===r.type&&"colgroup"===r.tagName&&Cn(r,n.children.indexOf(r),n))return!1;return Boolean(s&&"element"===s.type&&"col"===s.tagName)},head:function(e){const t=new Set;for(const n of e.children)if("element"===n.type&&("base"===n.tagName||"title"===n.tagName)){if(t.has(n.tagName))return!1;t.add(n.tagName)}const n=e.children[0];return!n||"element"===n.type},html:function(e){const t=gn(e,-1);return!t||"comment"!==t.type},tbody:function(e,t,n){const r=fn(n,t),s=gn(e,-1);if(n&&r&&"element"===r.type&&("thead"===r.tagName||"tbody"===r.tagName)&&Cn(r,n.children.indexOf(r),n))return!1;return Boolean(s&&"element"===s.type&&"tr"===s.tagName)}});const Nn={name:[["\t\n\f\r &/=>".split(""),"\t\n\f\r \"&'/=>`".split("")],["\0\t\n\f\r \"&'/<=>".split(""),"\0\t\n\f\r \"&'/<=>`".split("")]],unquoted:[["\t\n\f\r &>".split(""),"\0\t\n\f\r \"&'<=>`".split("")],["\0\t\n\f\r \"&'<=>`".split(""),"\0\t\n\f\r \"&'<=>`".split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function An(e,t,n){const r=function(e,t){const n=ut(t);let r=t,s=pt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&$t.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(Mt,Gt);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!Mt.test(e)){let n=e.replace(Tt,Ot);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}s=St}return new s(r,t)}(e.schema,t),s=e.settings.allowParseErrors&&"html"===e.schema.space?0:1,i=e.settings.allowDangerousCharacters?0:1;let o,a=e.quote;if(!r.overloadedBoolean||n!==r.attribute&&""!==n?!r.boolean&&!r.overloadedBoolean||"string"==typeof n&&n!==r.attribute&&""!==n||(n=Boolean(n)):n=!0,null==n||!1===n||"number"==typeof n&&Number.isNaN(n))return"";const l=sn(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Nn.name[s][i]}));return!0===n?l:(n=Array.isArray(n)?(r.commaSeparated?un:pn)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n?l:(e.settings.preferUnquoted&&(o=sn(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Nn.unquoted[s][i]}))),o!==n&&(e.settings.quoteSmart&&cn(n,a)>cn(n,e.alternative)&&(a=e.alternative),o=a+sn(n,Object.assign({},e.settings.characterReferences,{subset:("'"===a?Nn.single:Nn.double)[s][i],attribute:!0}))+a),l+(o?"="+o:o)))}const jn=["<","&"];function En(e,t,n,r){return!n||"element"!==n.type||"script"!==n.tagName&&"style"!==n.tagName?sn(e.value,Object.assign({},r.settings.characterReferences,{subset:jn})):e.value}const Ln=function(e,t){const n=t||{};function r(t,...n){let s=r.invalid;const i=r.handlers;if(t&&Ft.call(t,e)){const n=String(t[e]);s=Ft.call(i,n)?i[n]:r.unknown}if(s)return s.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}("type",{invalid:function(e){throw new Error("Expected node, not `"+e+"`")},unknown:function(e){throw new Error("Cannot compile unknown node `"+e.type+"`")},handlers:{comment:function(e,t,n,r){return r.settings.bogusComments?"<?"+sn(e.value,Object.assign({},r.settings.characterReferences,{subset:an}))+">":"\x3c!--"+e.value.replace(on,function(e){return sn(e,Object.assign({},r.settings.characterReferences,{subset:ln}))})+"--\x3e"},doctype:function(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"},element:function(e,t,n,r){const s=r.schema,i="svg"!==s.space&&r.settings.omitOptionalTags;let o="svg"===s.space?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const a=[];let l;"html"===s.space&&"svg"===e.tagName&&(r.schema=Bt);const c=function(e,t){const n=[];let r,s=-1;if(t)for(r in t)if(null!==t[r]&&void 0!==t[r]){const s=An(e,r,t[r]);s&&n.push(s)}for(;++s<n.length;){const t=e.settings.tightAttributes?n[s].charAt(n[s].length-1):void 0;s!==n.length-1&&'"'!==t&&"'"!==t&&(n[s]+=" ")}return n.join("")}(r,e.properties),u=r.all("html"===s.space&&"template"===e.tagName?e.content:e);return r.schema=s,u&&(o=!1),!c&&i&&xn(e,t,n)||(a.push("<",e.tagName,c?" "+c:""),o&&("svg"===s.space||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||"/"===l||l&&'"'!==l&&"'"!==l)&&a.push(" "),a.push("/")),a.push(">")),a.push(u),o||i&&Cn(e,t,n)||a.push("</"+e.tagName+">"),a.join("")},raw:function(e,t,n,r){return r.settings.allowDangerousHtml?e.value:En(e,0,n,r)},root:function(e,t,n,r){return r.all(e)},text:En}});const In={},Pn={},Rn=[];function Tn(e,t,n){return Ln(e,t,n,this)}function Mn(e){const t=[],n=e&&e.children||Rn;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}function $n(e,t){const n="string"==typeof e?{}:{...e.colorReplacements},r="string"==typeof e?e:e.name;for(const[e,s]of Object.entries(t?.colorReplacements||{}))"string"==typeof s?n[e]=s:e===r&&Object.assign(n,s);return n}function On(e,t){return e&&t?.[e?.toLowerCase()]||e}async function Gn(e){return Promise.resolve("function"==typeof e?e():e).then(e=>e.default||e)}function Dn(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Bn(e){return"ansi"===e||Dn(e)}function Fn(e){return"none"===e}function Un(e){return Fn(e)}function zn(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],"string"==typeof e.properties.class&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(/\s+/g);for(const t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function Wn(e,t=!1){const n=e.split(/(\r?\n)/g);let r=0;const s=[];for(let e=0;e<n.length;e+=2){const i=t?n[e]+(n[e+1]||""):n[e];s.push([i,r]),r+=n[e].length,r+=n[e+1]?.length||0}return s}const Hn="light-dark()",qn=["color","background-color"];function Vn(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&se.Italic&&(t["font-style"]="italic"),e.fontStyle&se.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&se.Underline&&n.push("underline"),e.fontStyle&se.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Xn(e){return"string"==typeof e?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(";")}const Kn=new WeakMap;function Qn(e,t){Kn.set(e,t)}function Zn(e){return Kn.get(e)}class Jn{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,t){return new Jn(Object.fromEntries(function(e){return Array.isArray(e)?e:[e]}(t).map(e=>[e,ot])),e)}constructor(...e){if(2===e.length){const[t,n]=e;this.lang=n,this._stacks=t}else{const[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return function(e){const t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);const s=e?.nameScopesList?.scopeName;s&&t.push(s),e.parent&&r(e.parent)}return r(e),t}(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function Yn(){const e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=function(e){if("number"==typeof e){if(e<0||e>t.source.length)throw new U(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...r.indexToPos(e),offset:e}}{const t=r.lines[e.line];if(void 0===t)throw new U(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${r.lines.length}`);if(e.character<0||e.character>t.length)throw new U(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,offset:r.posToIndex(e.line,e.character)}}};const r=function(e){const t=Wn(e,!0).map(([e])=>e);return{lines:t,indexToPos:function(n){if(n===e.length)return{line:t.length-1,character:t[t.length-1].length};let r=n,s=0;for(const e of t){if(r<e.length)break;r-=e.length,s++}return{line:s,character:r}},posToIndex:function(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}}}(t.source),s=(t.options.decorations||[]).map(e=>({...e,start:n(e.start),end:n(e.end)}));!function(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new U(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const t=e[r],s=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,i=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,a=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(s||i||o||a){if(s&&i)continue;if(o&&a)continue;throw new U(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}(s),e.set(t.meta,{decorations:s,converter:r,source:t.source})}return e.get(t.meta)}return{name:"shiki:decorations",tokens(e){if(!this.options.decorations?.length)return;const n=t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]),r=function(e,t){const n=Array.from(t instanceof Set?t:new Set(t)).sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{const t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?function(e,t){let n=0;const r=[];for(const s of t)s>n&&r.push({...e,content:e.content.slice(n,s),offset:e.offset+n}),n=s;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}(e,t):e})):e}(e,n);return r},code(e){if(!this.options.decorations?.length)return;const n=t(this),r=Array.from(e.children).filter(e=>"element"===e.type&&"span"===e.tagName);if(r.length!==n.converter.lines.length)throw new U(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function s(e,t,n,s){const i=r[e];let a="",l=-1,c=-1;if(0===t&&(l=0),0===n&&(c=0),n===Number.POSITIVE_INFINITY&&(c=i.children.length),-1===l||-1===c)for(let e=0;e<i.children.length;e++)a+=er(i.children[e]),-1===l&&a.length===t&&(l=e+1),-1===c&&a.length===n&&(c=e+1);if(-1===l)throw new U(`Failed to find start index for decoration ${JSON.stringify(s.start)}`);if(-1===c)throw new U(`Failed to find end index for decoration ${JSON.stringify(s.end)}`);const u=i.children.slice(l,c);if(s.alwaysWrap||u.length!==i.children.length)if(s.alwaysWrap||1!==u.length||"element"!==u[0].type){const e={type:"element",tagName:"span",properties:{},children:u};o(e,s,"wrapper"),i.children.splice(l,u.length,e)}else o(u[0],s,"token");else o(i,s,"line")}function i(e,t){r[e]=o(r[e],t,"line")}function o(e,t,n){const r=t.properties||{},s=t.transform||(e=>e);return e.tagName=t.tagName||"span",e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&zn(e,t.properties.class),e=s(e,n)||e}const a=[],l=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(const e of l){const{start:t,end:n}=e;if(t.line===n.line)s(t.line,t.character,n.character,e);else if(t.line<n.line){s(t.line,t.character,Number.POSITIVE_INFINITY,e);for(let r=t.line+1;r<n.line;r++)a.unshift(()=>i(r,e));s(n.line,0,n.character,e)}}a.forEach(e=>e())}}}function er(e){return"text"===e.type?e.value:"element"===e.type?e.children.map(er).join(""):""}const tr=[Yn()];function nr(e){return[...e.transformers||[],...tr]}var rr=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],sr={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function ir(e,t){const n=e.indexOf("",t);if(-1!==n&&"["===e[n+1]){const t=e.indexOf("m",n);if(-1!==t)return{sequence:e.substring(n+2,t).split(";"),startPosition:n,position:t+1}}return{position:e.length}}function or(e){const t=e.shift();if("2"===t){const t=e.splice(0,3).map(e=>Number.parseInt(e));if(3!==t.length||t.some(e=>Number.isNaN(e)))return;return{type:"rgb",rgb:t}}if("5"===t){const t=e.shift();if(t)return{type:"table",index:Number(t)}}}function ar(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(0===r)t.push({type:"resetAll"});else if(r<=9){sr[r]&&t.push({type:"setDecoration",value:sr[r]})}else if(r<=29){const e=sr[r-20];e&&(t.push({type:"resetDecoration",value:e}),"dim"===e&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:rr[r-30]}});else if(38===r){const n=or(e);n&&t.push({type:"setForegroundColor",value:n})}else if(39===r)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:rr[r-40]}});else if(48===r){const n=or(e);n&&t.push({type:"setBackgroundColor",value:n})}else 49===r?t.push({type:"resetBackgroundColor"}):53===r?t.push({type:"setDecoration",value:"overline"}):55===r?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:rr[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:rr[r-100+8]}})}return t}var lr={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 cr(e=lr){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(e){return function(){if(r)return r;r=[];for(let e=0;e<rr.length;e++)r.push(t(rr[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let s=0;s<6;s++)for(let i=0;i<6;i++)r.push(n([e[t],e[s],e[i]]));let s=8;for(let e=0;e<24;e++,s+=10)r.push(n([s,s,s]));return r}()[e]}return{value:function(e){switch(e.type){case"named":return t(e.name);case"rgb":return n(e.rgb);case"table":return s(e.index)}}}}function ur(e,t,n){const r=$n(e,n),s=Wn(t),i=cr(Object.fromEntries(rr.map(t=>[t,e.colors?.[`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`]]))),o=function(){let e=null,t=null,n=new Set;return{parse(r){const s=[];let i=0;do{const o=ir(r,i),a=o.sequence?r.substring(i,o.startPosition):r.substring(i);if(a.length>0&&s.push({value:a,foreground:e,background:t,decorations:new Set(n)}),o.sequence){const r=ar(o.sequence);for(const s of r)"resetAll"===s.type?(e=null,t=null,n.clear()):"resetForegroundColor"===s.type?e=null:"resetBackgroundColor"===s.type?t=null:"resetDecoration"===s.type&&n.delete(s.value);for(const s of r)"setForegroundColor"===s.type?e=s.value:"setBackgroundColor"===s.type?t=s.value:"setDecoration"===s.type&&n.add(s.value)}i=o.position}while(i<r.length);return s}}}();return s.map(t=>o.parse(t[0]).map(n=>{let s,o;n.decorations.has("reverse")?(s=n.background?i.value(n.background):e.bg,o=n.foreground?i.value(n.foreground):e.fg):(s=n.foreground?i.value(n.foreground):e.fg,o=n.background?i.value(n.background):void 0),s=On(s,r),o=On(o,r),n.decorations.has("dim")&&(s=function(e){const t=e.match(/#([0-9a-f]{3})([0-9a-f]{3})?([0-9a-f]{2})?/);if(t){if(t[3]){const e=Math.round(Number.parseInt(t[3],16)/2).toString(16).padStart(2,"0");return`#${t[1]}${t[2]}${e}`}return t[2]?`#${t[1]}${t[2]}80`:`#${Array.from(t[1]).map(e=>`${e}${e}`).join("")}80`}const n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}(s));let a=se.None;return n.decorations.has("bold")&&(a|=se.Bold),n.decorations.has("italic")&&(a|=se.Italic),n.decorations.has("underline")&&(a|=se.Underline),n.decorations.has("strikethrough")&&(a|=se.Strikethrough),{content:n.value,offset:t[1],color:s,bgColor:o,fontStyle:a}}))}function pr(e,t,n={}){const{lang:r="text",theme:s=e.getLoadedThemes()[0]}=n;if(Dn(r)||Fn(s))return Wn(t).map(e=>[{content:e[0],offset:e[1]}]);const{theme:i,colorMap:o}=e.setTheme(s);if("ansi"===r)return ur(i,t,n);const a=e.getLanguage(r);if(n.grammarState){if(n.grammarState.lang!==a.name)throw new U(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${a.name}"`);if(!n.grammarState.themes.includes(i.name))throw new U(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return function(e,t,n,r,s){const i=hr(e,t,n,r,s),o=new Jn(hr(e,t,n,r,s).stateStack,t.name,n.name);return Qn(i.tokens,o),i.tokens}(t,a,i,o,n)}function hr(e,t,n,r,s){const i=$n(n,s),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:a=500}=s,l=Wn(e);let c=s.grammarState?function(e,t){if(!(e instanceof Jn))throw new U("Invalid grammar state");return e.getInternalStack(t)}(s.grammarState,n.name)??ot:null!=s.grammarContextCode?hr(s.grammarContextCode,t,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:ot,u=[];const p=[];for(let e=0,h=l.length;e<h;e++){const[h,d]=l[e];if(""===h){u=[],p.push([]);continue}if(o>0&&h.length>=o){u=[],p.push([{content:h,offset:d,color:"",fontStyle:0}]);continue}let m,g,f;s.includeExplanation&&(m=t.tokenizeLine(h,c,a),g=m.tokens,f=0);const y=t.tokenizeLine2(h,c,a),k=y.tokens.length/2;for(let e=0;e<k;e++){const t=y.tokens[2*e],o=e+1<k?y.tokens[2*e+2]:h.length;if(t===o)continue;const a=y.tokens[2*e+1],l=On(r[ce.getForeground(a)],i),c=ce.getFontStyle(a),p={content:h.substring(t,o),offset:d+t,color:l,fontStyle:c};if(s.includeExplanation){const e=[];if("scopeName"!==s.includeExplanation)for(const t of n.settings){let n;switch(typeof t.scope){case"string":n=t.scope.split(/,/).map(e=>e.trim());break;case"object":n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(/ /))})}p.explanation=[];let r=0;for(;t+r<o;){const t=g[f],n=h.substring(t.startIndex,t.endIndex);r+=n.length,p.explanation.push({content:n,scopes:"scopeName"===s.includeExplanation?dr(t.scopes):mr(e,t.scopes)}),f+=1}}u.push(p)}p.push(u),u=[],c=y.ruleStack}return{tokens:p,stateStack:c}}function dr(e){return e.map(e=>({scopeName:e}))}function mr(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const s=t[r];n[r]={scopeName:s,themeMatches:yr(e,s,t.slice(0,r))}}return n}function gr(e,t){return e===t||t.substring(0,e.length)===e&&"."===t[e.length]}function fr(e,t,n){if(!gr(e[e.length-1],t))return!1;let r=e.length-2,s=n.length-1;for(;r>=0&&s>=0;)gr(e[r],n[s])&&(r-=1),s-=1;return-1===r}function yr(e,t,n){const r=[];for(const{selectors:s,settings:i}of e)for(const e of s)if(fr(e,t,n)){r.push(i);break}return r}function kr(e,t,n){const r=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),s=r.map(r=>{const s=pr(e,t,{...n,theme:r.theme});return{tokens:s,state:Zn(s),theme:"string"==typeof r.theme?r.theme:r.theme.name}}),i=function(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const s=e.map(e=>e[r]),i=t.map(()=>[]);t.forEach((e,t)=>e.push(i[t]));const o=s.map(()=>0),a=s.map(e=>e[0]);for(;a.every(e=>e);){const e=Math.min(...a.map(e=>e.content.length));for(let t=0;t<n;t++){const n=a[t];n.content.length===e?(i[t].push(n),o[t]+=1,a[t]=s[t][o[t]]):(i[t].push({...n,content:n.content.slice(0,e)}),a[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}(...s.map(e=>e.tokens)),o=i[0].map((e,t)=>e.map((e,s)=>{const o={content:e.content,variants:{},offset:e.offset};return"includeExplanation"in n&&n.includeExplanation&&(o.explanation=e.explanation),i.forEach((e,n)=>{const{content:i,explanation:a,offset:l,...c}=e[t][s];o.variants[r[n].color]=c}),o})),a=s[0].state?new Jn(Object.fromEntries(s.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),s[0].state.lang):void 0;return a&&Qn(o,a),o}function br(e,t,n){let r,s,i,o,a,l;if("themes"in n){const{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:p="css-vars"}=n,h=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===c?-1:t.color===c?1:0);if(0===h.length)throw new U("`themes` option must not be empty");const d=kr(e,t,n);if(l=Zn(d),c&&Hn!==c&&!h.find(e=>e.color===c))throw new U(`\`themes\` option must contain the defaultColor key \`${c}\``);const m=h.map(t=>e.getTheme(t.theme)),g=h.map(e=>e.color);i=d.map(e=>e.map(e=>function(e,t,n,r,s="css-vars"){const i={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Vn(e.variants[t])),a=new Set(o.flatMap(e=>Object.keys(e))),l={},c=(e,r)=>{const s="color"===r?"":"background-color"===r?"-bg":`-${r}`;return n+t[e]+("color"===r?"":s)};return o.forEach((e,n)=>{for(const i of a){const a=e[i]||"inherit";if(0===n&&r&&qn.includes(i))if(r===Hn&&o.length>1){const e=t.findIndex(e=>"light"===e),r=t.findIndex(e=>"dark"===e);if(-1===e||-1===r)throw new U('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const u=o[e][i]||"inherit",p=o[r][i]||"inherit";l[i]=`light-dark(${u}, ${p})`,"css-vars"===s&&(l[c(n,i)]=a)}else l[i]=a;else"css-vars"===s&&(l[c(n,i)]=a)}}),i.htmlStyle=l,i}(e,g,u,c,p))),l&&Qn(i,l);const f=h.map(e=>$n(e.theme,n));s=wr(h,m,f,u,c,"fg",p),r=wr(h,m,f,u,c,"bg",p),o=`shiki-themes ${m.map(e=>e.name).join(" ")}`,a=c?void 0:[s,r].join(";")}else{if(!("theme"in n))throw new U("Invalid options, either `theme` or `themes` must be provided");{const a=$n(n.theme,n);i=pr(e,t,n);const c=e.getTheme(n.theme);r=On(c.bg,a),s=On(c.fg,a),o=c.name,l=Zn(i)}}return{tokens:i,fg:s,bg:r,themeName:o,rootStyle:a,grammarState:l}}function wr(e,t,n,r,s,i,o){return e.map((a,l)=>{const c=On(t[l][i],n[l])||"inherit",u=`${r+a.color}${"bg"===i?"-bg":""}:${c}`;if(0===l&&s){if(s===Hn&&e.length>1){const r=e.findIndex(e=>"light"===e.color),s=e.findIndex(e=>"dark"===e.color);if(-1===r||-1===s)throw new U('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${On(t[r][i],n[r])||"inherit"}, ${On(t[s][i],n[s])||"inherit"});${u}`}return c}return"css-vars"===o?u:null}).filter(e=>!!e).join(";")}function Cr(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>Cr(e,t,n),codeToTokens:(t,n)=>br(e,t,n)}){let s=t;for(const e of nr(n))s=e.preprocess?.call(r,s,n)||s;let{tokens:i,fg:o,bg:a,themeName:l,rootStyle:c,grammarState:u}=br(e,s,n);const{mergeWhitespaces:p=!0,mergeSameStyleTokens:h=!1}=n;!0===p?i=function(e){return e.map(e=>{const t=[];let n="",r=0;return e.forEach((s,i)=>{const o=!(s.fontStyle&&(s.fontStyle&se.Underline||s.fontStyle&se.Strikethrough));o&&s.content.match(/^\s+$/)&&e[i+1]?(r||(r=s.offset),n+=s.content):n?(o?t.push({...s,offset:r,content:n+s.content}):t.push({content:n,offset:r},s),r=0,n=""):t.push(s)}),t})}(i):"never"===p&&(i=function(e){return e.map(e=>e.flatMap(e=>{if(e.content.match(/^\s+$/))return e;const t=e.content.match(/^(\s*)(.*?)(\s*)$/);if(!t)return e;const[,n,r,s]=t;if(!n&&!s)return e;const i=[{...e,offset:e.offset+n.length,content:r}];return n&&i.unshift({content:n,offset:e.offset}),s&&i.push({content:s,offset:e.offset+n.length+r.length}),i}))}(i)),h&&(i=function(e){return e.map(e=>{const t=[];for(const n of e){if(0===t.length){t.push({...n});continue}const e=t[t.length-1],r=Xn(e.htmlStyle||Vn(e)),s=Xn(n.htmlStyle||Vn(n)),i=e.fontStyle&&(e.fontStyle&se.Underline||e.fontStyle&se.Strikethrough),o=n.fontStyle&&(n.fontStyle&se.Underline||n.fontStyle&se.Strikethrough);i||o||r!==s?t.push({...n}):e.content+=n.content}return t})}(i));const d={...r,get source(){return s}};for(const e of nr(n))i=e.tokens?.call(d,i)||i;return function(e,t,n,r=Zn(e)){const s=nr(t),i=[],o={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t;let c={type:"element",tagName:"pre",properties:{class:`shiki ${t.themeName||""}`,style:t.rootStyle||`background-color:${t.bg};color:${t.fg}`,...!1!==l&&null!=l?{tabindex:l.toString()}:{},...Object.fromEntries(Array.from(Object.entries(t.meta||{})).filter(([e])=>!e.startsWith("_")))},children:[]},u={type:"element",tagName:"code",properties:{},children:i};const p=[],h={...n,structure:a,addClassToHast:zn,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return c},get code(){return u},get lines(){return p}};if(e.forEach((e,t)=>{t&&("inline"===a?o.children.push({type:"element",tagName:"br",properties:{},children:[]}):"classic"===a&&i.push({type:"text",value:"\n"}));let n={type:"element",tagName:"span",properties:{class:"line"},children:[]},r=0;for(const i of e){let e={type:"element",tagName:"span",properties:{...i.htmlAttrs},children:[{type:"text",value:i.content}]};const l=Xn(i.htmlStyle||Vn(i));l&&(e.properties.style=l);for(const o of s)e=o?.span?.call(h,e,t+1,r,n,i)||e;"inline"===a?o.children.push(e):"classic"===a&&n.children.push(e),r+=i.content.length}if("classic"===a){for(const e of s)n=e?.line?.call(h,n,t+1)||n;p.push(n),i.push(n)}}),"classic"===a){for(const e of s)u=e?.code?.call(h,u)||u;c.children.push(u);for(const e of s)c=e?.pre?.call(h,c)||c;o.children.push(c)}let d=o;for(const e of s)d=e?.root?.call(h,d)||d;r&&Qn(d,r);return d}(i,{...n,fg:o,bg:a,themeName:l,rootStyle:c},d,u)}const _r=function(e,t){const n=t||In,r=n.quote||'"',s='"'===r?"'":'"';if('"'!==r&&"'"!==r)throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Tn,all:Mn,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||at,characterReferences:n.characterReferences||Pn,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:"svg"===n.space?Bt:Dt,quote:r,alternative:s}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)};const Sr="#333333",vr="#bbbbbb",xr="#fffffe",Nr="#1e1e1e",Ar="__shiki_resolved";function jr(e){if(e?.[Ar])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){const e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r="light"===t.type?Sr:vr),n||(n="light"===t.type?xr:Nr),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let s=0;const i=new Map;function o(e){if(i.has(e))return i.get(e);s+=1;const n=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(i.set(e,n),n)}t.settings=t.settings.map(e=>{const n=e.settings?.foreground&&!e.settings.foreground.startsWith("#"),r=e.settings?.background&&!e.settings.background.startsWith("#");if(!n&&!r)return e;const s={...e,settings:{...e.settings}};if(n){const n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,s.settings.foreground=n}if(r){const n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,s.settings.background=n}return s});for(const e of Object.keys(t.colors||{}))if(("editor.foreground"===e||"editor.background"===e||e.startsWith("terminal.ansi"))&&!t.colors[e]?.startsWith("#")){const n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,Ar,{enumerable:!1,writable:!1,value:!0}),t}class Er extends Error{constructor(e){super(e),this.name="ShikiError"}}class Lr extends it{constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return"string"==typeof e?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const t=jr(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Y.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){if(this._alias[e]){const t=new Set([e]);for(;this._alias[e];){if(e=this._alias[e],t.has(e))throw new Er(`Circular alias \`${Array.from(t).join(" -> ")} -> ${e}\``);t.add(e)}}return this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(const e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const t of e)this.resolveEmbeddedLanguages(t);const t=Array.from(this._langGraph.entries()),n=t.filter(([e,t])=>!t);if(n.length){const e=t.filter(([e,t])=>t&&t.embeddedLangs?.some(e=>n.map(([e])=>e).includes(e))).filter(e=>!n.includes(e));throw new Er(`Missing languages ${n.map(([e])=>`\`${e}\``).join(", ")}, required by ${e.map(([e])=>`\`${e}\``).join(", ")}`)}for(const[e,n]of t)this._resolver.addLanguage(n);for(const[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){if(this._langMap.set(e.name,e),this._langGraph.set(e.name,e),e.embeddedLangs)for(const t of e.embeddedLangs)this._langGraph.set(t,this._langMap.get(t))}}class Ir{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let e=1;e<=t.length;e++){const r=t.slice(0,e).join(".");n=[...n,...this._injections.get(r)||[]]}return n}}let Pr=0;function Rr(e){Pr+=1,!1!==e.warnings&&Pr>=10&&Pr%10==0&&console.warn(`[Shiki] ${Pr} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Er("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(jr),s=new Ir(e.engine,n),i=new Lr(s,r,n,e.langAlias);let o;function a(e){if("none"===e)return{bg:"",fg:"",name:"none",settings:[],type:"dark"};u();const t=i.getTheme(e);if(!t)throw new Er(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(...e){u(),i.loadLanguages(e.flat(1))}function c(...e){u();for(const t of e.flat(1))i.loadTheme(t)}function u(){if(t)throw new Er("Shiki instance has been disposed")}function p(){t||(t=!0,i.dispose(),Pr-=1)}return{setTheme:function(e){u();const t=a(e);return o!==e&&(i.setTheme(t),o=e),{theme:t,colorMap:i.getColorMap()}},getTheme:a,getLanguage:function(e){u();const t=i.getGrammar("string"==typeof e?e:e.name);if(!t)throw new Er(`Language \`${e}\` not found, you may need to load it first`);return t},getLoadedThemes:function(){return u(),i.getLoadedThemes()},getLoadedLanguages:function(){return u(),i.getLoadedLanguages()},loadLanguage:async function(...e){return l(await async function(e){return Array.from(new Set((await Promise.all(e.filter(e=>!Bn(e)).map(async e=>await Gn(e).then(e=>Array.isArray(e)?e:[e])))).flat()))}(e))},loadLanguageSync:l,loadTheme:async function(...e){return u(),c(await async function(e){return(await Promise.all(e.map(async e=>Un(e)?null:jr(await Gn(e))))).filter(e=>!!e)}(e))},loadThemeSync:c,dispose:p,[Symbol.dispose]:p}}function Tr(e){if(1!==[...e].length)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}const Mr=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),$r=String.raw;function Or(e,t){if(null==e)throw new Error(t??"Value expected");return e}const Gr=$r`\[\^?`,Dr=`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}`}`,Br=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Fr=new RegExp($r`
|
|
9
|
+
import{$isCodeNode as e,$createCodeHighlightNode as t,CodeExtension as n,DEFAULT_CODE_LANGUAGE as r,CodeNode as s,CodeHighlightNode as i,$isCodeHighlightNode as o,$getFirstCodeNodeOfLine as a,$getLastCodeNodeOfLine as l,$getCodeLineDirection as c,$getStartOfCodeInLine as u,$getEndOfCodeInLine as p}from"@lexical/code";import{mergeRegister as h}from"@lexical/utils";import{$getNodeByKey as d,$createLineBreakNode as m,$createTabNode as g,defineExtension as f,safeCast as y,TextNode as k,KEY_TAB_COMMAND as b,COMMAND_PRIORITY_LOW as w,INSERT_TAB_COMMAND as C,$getSelection as _,$insertNodes as S,INDENT_CONTENT_COMMAND as v,OUTDENT_CONTENT_COMMAND as x,KEY_ARROW_UP_COMMAND as N,$isRangeSelection as A,KEY_ARROW_DOWN_COMMAND as j,MOVE_TO_START as E,MOVE_TO_END as L,$isLineBreakNode as I,$createTextNode as P,$createPoint as R,$setSelectionFromCaretRange as T,$getCaretRangeInDirection as M,$getCaretRange as $,$getTextPointCaret as O,$normalizeCaret as G,$getSiblingCaret as D,$isTabNode as B,$isTextNode as F}from"lexical";function U(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let W=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function z(e){return Array.isArray(e)?function(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=z(e[n]);return t}(e):e instanceof RegExp?e:"object"==typeof e?function(e){let t={};for(let n in e)t[n]=z(e[n]);return t}(e):e}function H(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function q(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return 0===t?e:~t===e.length-1?q(e.substring(0,e.length-1)):e.substr(1+~t)}var V=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,X=class{static hasCaptures(e){return null!==e&&(V.lastIndex=0,V.test(e))}static replaceCaptures(e,t,n){return e.replace(V,(e,r,s,i)=>{let o=n[parseInt(r||s,10)];if(!o)return e;{let e=t.substring(o.start,o.end);for(;"."===e[0];)e=e.substring(1);switch(i){case"downcase":return e.toLowerCase();case"upcase":return e.toUpperCase();default:return e}}})}};function K(e,t){return e<t?-1:e>t?1:0}function Q(e,t){if(null===e&&null===t)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=K(e[r],t[r]);if(0!==n)return n}return 0}return n-r}function Z(e){return!!/^#[0-9a-f]{6}$/i.test(e)||(!!/^#[0-9a-f]{8}$/i.test(e)||(!!/^#[0-9a-f]{3}$/i.test(e)||!!/^#[0-9a-f]{4}$/i.test(e)))}function J(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Y=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},ee=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(function(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,s=t.length;e<s;e++){let s,i=t[e];if(!i.settings)continue;if("string"==typeof i.scope){let e=i.scope;e=e.replace(/^[,]+/,""),e=e.replace(/[,]+$/,""),s=e.split(",")}else s=Array.isArray(i.scope)?i.scope:[""];let o=-1;if("string"==typeof i.settings.fontStyle){o=0;let e=i.settings.fontStyle.split(" ");for(let t=0,n=e.length;t<n;t++){switch(e[t]){case"italic":o|=1;break;case"bold":o|=2;break;case"underline":o|=4;break;case"strikethrough":o|=8}}}let a=null;"string"==typeof i.settings.foreground&&Z(i.settings.foreground)&&(a=i.settings.foreground);let l=null;"string"==typeof i.settings.background&&Z(i.settings.background)&&(l=i.settings.background);for(let t=0,i=s.length;t<i;t++){let i=s[t].trim().split(" "),c=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new se(c,u,e,o,a,l)}}return n}(e),t)}static createFromParsedTheme(e,t){return function(e,t){e.sort((e,t)=>{let n=K(e.scope,t.scope);return 0!==n?n:(n=Q(e.parentScopes,t.parentScopes),0!==n?n:e.index-t.index)});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&""===e[0].scope;){let t=e.shift();-1!==t.fontStyle&&(n=t.fontStyle),null!==t.foreground&&(r=t.foreground),null!==t.background&&(s=t.background)}let i=new oe(t),o=new re(n,i.getId(r),i.getId(s)),a=new ce(new le(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];a.insert(0,n.scope,n.parentScopes,n.fontStyle,i.getId(n.foreground),i.getId(n.background))}return new ee(i,o,a)}(e,t)}_cachedMatchRoot=new Y(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(null===e)return this._defaults;const t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>function(e,t){if(0===t.length)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(">"===r){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!ne(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}(e.parent,t.parentScopes));return n?new re(n.fontStyle,n.foreground,n.background):null}},te=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(const r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e||null!==this.parent&&this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function ne(e,t){return t===e||e.startsWith(t)&&"."===e[t.length]}var re=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};var se=class{constructor(e,t,n,r,s,i){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=i}},ie=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(ie||{});var oe=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(null===e)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},ae=Object.freeze([]),le=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,s){this.scopeDepth=e,this.parentScopes=t||ae,this.fontStyle=n,this.foreground=r,this.background=s}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,-1!==t&&(this.fontStyle=t),0!==n&&(this.foreground=n),0!==r&&(this.background=r)}},ce=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;">"===e.parentScopes[n]&&n++,">"===t.parentScopes[r]&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){const s=t.parentScopes[r].length-e.parentScopes[n].length;if(0!==s)return s;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(""!==t){let e,n,r=t.indexOf(".");if(-1===r?(e=t,n=""):(e=t.substring(0,r),n=t.substring(r+1)),this._children.hasOwnProperty(e))return this._children[e].match(n)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,s,i,o){if(""===n)return void this._doInsertHere(t,r,s,i,o);let a,l,c,u=n.indexOf(".");-1===u?(a=n,l=""):(a=n.substring(0,u),l=n.substring(u+1)),this._children.hasOwnProperty(a)?c=this._children[a]:(c=new e(this._mainRule.clone(),le.cloneArr(this._rulesWithParentScopes)),this._children[a]=c),c.insert(t+1,l,r,s,i,o)}_doInsertHere(e,t,n,r,s){if(null!==t){for(let i=0,o=this._rulesWithParentScopes.length;i<o;i++){let o=this._rulesWithParentScopes[i];if(0===Q(o.parentScopes,t))return void o.acceptOverwrite(e,n,r,s)}-1===n&&(n=this._mainRule.fontStyle),0===r&&(r=this._mainRule.foreground),0===s&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new le(e,t,n,r,s))}else this._mainRule.acceptOverwrite(e,n,r,s)}},ue=class e{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(t){const n=e.getLanguageId(t),r=e.getTokenType(t),s=e.getFontStyle(t),i=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:i,background:o})}static getLanguageId(e){return(255&e)>>>0}static getTokenType(e){return(768&e)>>>8}static containsBalancedBrackets(e){return!!(1024&e)}static getFontStyle(e){return(30720&e)>>>11}static getForeground(e){return(16744448&e)>>>15}static getBackground(e){return(4278190080&e)>>>24}static set(t,n,r,s,i,o,a){let l=e.getLanguageId(t),c=e.getTokenType(t),u=e.containsBalancedBrackets(t)?1:0,p=e.getFontStyle(t),h=e.getForeground(t),d=e.getBackground(t);return 0!==n&&(l=n),8!==r&&(c=r),null!==s&&(u=s?1:0),-1!==i&&(p=i),0!==o&&(h=o),0!==a&&(d=a),(l|c<<8|u<<10|p<<11|h<<15|d<<24)>>>0}};function pe(e){return e}function he(e,t){const n=[],r=function(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}(e);let s=r.next();for(;null!==s;){let e=0;if(2===s.length&&":"===s.charAt(1)){switch(s.charAt(0)){case"R":e=1;break;case"L":e=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let t=o();if(n.push({matcher:t,priority:e}),","!==s)break;s=r.next()}return n;function i(){if("-"===s){s=r.next();const e=i();return t=>!!e&&!e(t)}if("("===s){s=r.next();const e=function(){const e=[];let t=o();for(;t&&(e.push(t),"|"===s||","===s);){do{s=r.next()}while("|"===s||","===s);t=o()}return t=>e.some(e=>e(t))}();return")"===s&&(s=r.next()),e}if(de(s)){const e=[];do{e.push(s),s=r.next()}while(de(s));return n=>t(e,n)}return null}function o(){const e=[];let t=i();for(;t;)e.push(t),t=i();return t=>e.every(e=>e(t))}}function de(e){return!!e&&!!e.match(/[\w\.:]+/)}function me(e){"function"==typeof e.dispose&&e.dispose()}var ge=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},fe=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},ye=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},ke=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ge(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new ye;for(const n of e)be(n,this.initialScopeName,this.repo,t);for(const e of t.references)if(e instanceof ge){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName))continue;if(this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function be(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const i=n.lookup(t);e instanceof ge?Ce({baseGrammar:i,selfGrammar:s},r):we(e.ruleName,{baseGrammar:i,selfGrammar:s,repository:s.repository},r);const o=n.injections(e.scopeName);if(o)for(const e of o)r.add(new ge(e))}function we(e,t,n){if(t.repository&&t.repository[e]){_e([t.repository[e]],t,n)}}function Ce(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&_e(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&_e(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function _e(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const e=r.repository?H({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&_e(r.patterns,{...t,repository:e},n);const s=r.include;if(!s)continue;const i=je(s);switch(i.kind){case 0:Ce({...t,selfGrammar:t.baseGrammar},n);break;case 1:Ce(t,n);break;case 2:we(i.ruleName,{...t,repository:e},n);break;case 3:case 4:const r=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){const s={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};4===i.kind?we(i.ruleName,s,n):Ce(s,n)}else 4===i.kind?n.add(new fe(i.scopeName,i.ruleName)):n.add(new ge(i.scopeName))}}}var Se=class{kind=0},ve=class{kind=1},xe=class{constructor(e){this.ruleName=e}kind=2},Ne=class{constructor(e){this.scopeName=e}kind=3},Ae=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function je(e){if("$base"===e)return new Se;if("$self"===e)return new ve;const t=e.indexOf("#");if(-1===t)return new Ne(e);if(0===t)return new xe(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new Ae(n,r)}}var Ee=/\\(\d+)/,Le=/\\(\d+)/g;var Ie=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=X.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=X.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${q(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return this._nameIsCapturing&&null!==this._name&&null!==e&&null!==t?X.replaceCaptures(this._name,e,t):this._name}getContentName(e,t){return this._contentNameIsCapturing&&null!==this._contentName?X.replaceCaptures(this._contentName,e,t):this._contentName}},Pe=class extends Ie{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},Re=class extends Ie{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new Ge(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new De,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Te=class extends Ie{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns){e.getRule(n).collectPatterns(e,t)}}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new De,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Me=class extends Ie{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,i,o,a,l,c){super(e,t,n,r),this._begin=new Ge(s,this.id),this.beginCaptures=i,this._end=new Ge(o||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new De;for(const t of this.patterns){e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},$e=class extends Ie{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,i,o,a,l){super(e,t,n,r),this._begin=new Ge(s,this.id),this.beginCaptures=i,this.whileCaptures=a,this._while=new Ge(o,-2),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,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new De;for(const t of this.patterns){e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new De,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},Oe=class e{static createCaptureRule(e,t,n,r,s){return e.registerRule(e=>new Pe(t,e,n,r,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new Re(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(void 0===t.begin){t.repository&&(r=H({},r,t.repository));let s=t.patterns;return void 0===s&&t.include&&(s=[{include:t.include}]),new Te(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(s,n,r))}return t.while?new $e(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Me(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let i=0;for(const e in t){if("$vscodeTextmateLocation"===e)continue;const t=parseInt(e,10);t>i&&(i=t)}for(let e=0;e<=i;e++)s[e]=null;for(const i in t){if("$vscodeTextmateLocation"===i)continue;const o=parseInt(i,10);let a=0;t[i].patterns&&(a=e.getCompiledRuleId(t[i],n,r)),s[o]=e.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,a)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let i=0,o=t.length;i<o;i++){const o=t[i];let a=-1;if(o.include){const t=je(o.include);switch(t.kind){case 0:case 1:a=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let s=r[t.ruleName];s&&(a=e.getCompiledRuleId(s,n,r));break;case 3:case 4:const i=t.scopeName,l=4===t.kind?t.ruleName:null,c=n.getExternalGrammar(i,r);if(c)if(l){let t=c.repository[l];t&&(a=e.getCompiledRuleId(t,n,c.repository))}else a=e.getCompiledRuleId(c.repository.$self,n,c.repository)}}else a=e.getCompiledRuleId(o,n,r);if(-1!==a){const e=n.getRule(a);let t=!1;if((e instanceof Te||e instanceof Me||e instanceof $e)&&e.hasMissingPatterns&&0===e.patterns.length&&(t=!0),t)continue;s.push(a)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},Ge=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&"string"==typeof e){const t=e.length;let n=0,r=[],s=!1;for(let i=0;i<t;i++){if("\\"===e.charAt(i)&&i+1<t){const t=e.charAt(i+1);"z"===t?(r.push(e.substring(n,i)),r.push("$(?!\\n)(?<!\\n)"),n=i+2):"A"!==t&&"G"!==t||(s=!0),i++}}this.hasAnchor=s,0===n?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,"string"==typeof this.source?this.hasBackReferences=Ee.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if("string"!=typeof this.source)throw new Error("This method should only be called if the source is a string");let n=t.map(t=>e.substring(t.start,t.end));return Le.lastIndex=0,this.source.replace(Le,(e,t)=>J(n[parseInt(t,10)]||""))}_buildAnchorCache(){if("string"!=typeof this.source)throw new Error("This method should only be called if the source is a string");let e,t,n,r,s=[],i=[],o=[],a=[];for(e=0,t=this.source.length;e<t;e++)n=this.source.charAt(e),s[e]=n,i[e]=n,o[e]=n,a[e]=n,"\\"===n&&e+1<t&&(r=this.source.charAt(e+1),"A"===r?(s[e+1]="",i[e+1]="",o[e+1]="A",a[e+1]="A"):"G"===r?(s[e+1]="",i[e+1]="G",o[e+1]="",a[e+1]="G"):(s[e+1]=r,i[e+1]=r,o[e+1]=r,a[e+1]=r),e++);return{A0_G0:s.join(""),A0_G1:i.join(""),A1_G0:o.join(""),A1_G1:a.join("")}}resolveAnchors(e,t){return this.hasAnchor&&this._anchorCache&&"string"==typeof this.source?e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0:this.source}},De=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new Be(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(e=>e.resolveAnchors(t,n));return new Be(e,r,this._items.map(e=>e.ruleId))}},Be=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){"function"==typeof this.scanner.dispose&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join("\n")}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Fe=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Ue=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Fe(e,8),this._embeddedLanguagesMatcher=new We(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return null===t?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Fe(0,0);_getBasicScopeAttributes=new Y(e=>{const t=this._scopeToLanguage(e),n=this._toStandardTokenType(e);return new Fe(t,n)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){const n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},We=class{values;scopesRegExp;constructor(e){if(0===e.length)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([e,t])=>J(e));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);return t?this.values.get(t[1]):void 0}};"undefined"!=typeof process&&process.env.VSCODE_TEXTMATE_DEBUG;var ze=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function He(e,t,n,r,s,i,o,a){const l=t.content.length;let c=!1,u=-1;if(o){const o=function(e,t,n,r,s,i){let o=s.beginRuleCapturedEOL?0:-1;const a=[];for(let t=s;t;t=t.pop()){const n=t.getRule(e);n instanceof $e&&a.push({rule:n,stack:t})}for(let l=a.pop();l;l=a.pop()){const{ruleScanner:a,findOptions:c}=Ve(l.rule,e,l.stack.endRule,n,r===o),u=a.findNextMatchSync(t,r,c);if(!u){s=l.stack.pop();break}if(-2!==u.ruleId){s=l.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(i.produce(l.stack,u.captureIndices[0].start),Xe(e,t,n,l.stack,i,l.rule.whileCaptures,u.captureIndices),i.produce(l.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}return{stack:s,linePos:r,anchorPosition:o,isFirstLine:n}}(e,t,n,r,s,i);s=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}const p=Date.now();for(;!c;){if(0!==a){if(Date.now()-p>a)return new ze(s,!0)}h()}return new ze(s,!1);function h(){const o=function(e,t,n,r,s,i){const o=function(e,t,n,r,s,i){const o=s.getRule(e),{ruleScanner:a,findOptions:l}=qe(o,e,s.endRule,n,r===i),c=a.findNextMatchSync(t,r,l);if(c)return{captureIndices:c.captureIndices,matchedRuleId:c.ruleId};return null}(e,t,n,r,s,i),a=e.getInjections();if(0===a.length)return o;const l=function(e,t,n,r,s,i,o){let a,l=Number.MAX_VALUE,c=null,u=0;const p=i.contentNameScopesList.getScopeNames();for(let i=0,h=e.length;i<h;i++){const h=e[i];if(!h.matcher(p))continue;const d=t.getRule(h.ruleId),{ruleScanner:m,findOptions:g}=qe(d,t,null,r,s===o),f=m.findNextMatchSync(n,s,g);if(!f)continue;const y=f.captureIndices[0].start;if(!(y>=l)&&(l=y,c=f.captureIndices,a=f.ruleId,u=h.priority,l===s))break}if(c)return{priorityMatch:-1===u,captureIndices:c,matchedRuleId:a};return null}(a,e,t,n,r,s,i);if(!l)return o;if(!o)return l;const c=o.captureIndices[0].start,u=l.captureIndices[0].start;if(u<c||l.priorityMatch&&u===c)return l;return o}(e,t,n,r,s,u);if(!o)return i.produce(s,l),void(c=!0);const a=o.captureIndices,p=o.matchedRuleId,h=!!(a&&a.length>0)&&a[0].end>r;if(-1===p){const o=s.getRule(e);i.produce(s,a[0].start),s=s.withContentNameScopesList(s.nameScopesList),Xe(e,t,n,s,i,o.endCaptures,a),i.produce(s,a[0].end);const p=s;if(s=s.parent,u=p.getAnchorPos(),!h&&p.getEnterPos()===r)return s=p,i.produce(s,l),void(c=!0)}else{const o=e.getRule(p);i.produce(s,a[0].start);const d=s,m=o.getName(t.content,a),g=s.contentNameScopesList.pushAttributed(m,e);if(s=s.push(p,r,u,a[0].end===l,null,g,g),o instanceof Me){const r=o;Xe(e,t,n,s,i,r.beginCaptures,a),i.produce(s,a[0].end),u=a[0].end;const p=r.getContentName(t.content,a),m=g.pushAttributed(p,e);if(s=s.withContentNameScopesList(m),r.endHasBackReferences&&(s=s.withEndRule(r.getEndWithResolvedBackReferences(t.content,a))),!h&&d.hasSameRuleAs(s))return s=s.pop(),i.produce(s,l),void(c=!0)}else if(o instanceof $e){const r=o;Xe(e,t,n,s,i,r.beginCaptures,a),i.produce(s,a[0].end),u=a[0].end;const p=r.getContentName(t.content,a),m=g.pushAttributed(p,e);if(s=s.withContentNameScopesList(m),r.whileHasBackReferences&&(s=s.withEndRule(r.getWhileWithResolvedBackReferences(t.content,a))),!h&&d.hasSameRuleAs(s))return s=s.pop(),i.produce(s,l),void(c=!0)}else{if(Xe(e,t,n,s,i,o.captures,a),i.produce(s,a[0].end),s=s.pop(),!h)return s=s.safePop(),i.produce(s,l),void(c=!0)}}a[0].end>r&&(r=a[0].end,n=!1)}}function qe(e,t,n,r,s){return{ruleScanner:e.compileAG(t,n,r,s),findOptions:0}}function Ve(e,t,n,r,s){return{ruleScanner:e.compileWhileAG(t,n,r,s),findOptions:0}}function Xe(e,t,n,r,s,i,o){if(0===i.length)return;const a=t.content,l=Math.min(i.length,o.length),c=[],u=o[0].end;for(let t=0;t<l;t++){const l=i[t];if(null===l)continue;const p=o[t];if(0===p.length)continue;if(p.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=p.start;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?s.produceFromScopes(c[c.length-1].scopes,p.start):s.produce(r,p.start),l.retokenizeCapturedWithRuleId){const t=l.getName(a,o),i=r.contentNameScopesList.pushAttributed(t,e),c=l.getContentName(a,o),u=i.pushAttributed(c,e),h=r.push(l.retokenizeCapturedWithRuleId,p.start,-1,!1,null,i,u),d=e.createOnigString(a.substring(0,p.end));He(e,d,n&&0===p.start,p.start,h,s,!1,0),me(d);continue}const h=l.getName(a,o);if(null!==h){const t=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(h,e);c.push(new Ke(t,p.end))}}for(;c.length>0;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var Ke=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Qe(e,t,n,r,s){const i=he(t,Ze),o=Oe.getCompiledRuleId(n,r,s.repository);for(const n of i)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:s,priority:n.priority})}function Ze(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(Je(t[r],e))return n=r+1,!0;return!1})}function Je(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&"."===e[n]}var Ye=class{constructor(e,t,n,r,s,i,o,a){if(this._rootScopeName=e,this.balancedBracketSelectors=i,this._onigLib=a,this._basicScopeAttributesProvider=new Ue(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=et(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const e of Object.keys(s)){const t=he(e,Ze);for(const n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:s[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e=e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),t=[],n=this._rootScopeName,r=e(n);if(r){const e=r.injections;if(e)for(let n in e)Qe(t,n,e[n],this,r);const s=this._grammarRepository.injections(n);s&&s.forEach(e=>{const n=this.getExternalGrammar(e);if(n){const e=n.injectionSelector;e&&Qe(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return null===this._injections&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=et(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){let s;if(-1===this._rootId&&(this._rootId=Oe.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections()),t&&t!==nt.NULL)s=!1,t.reset();else{s=!0;const e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=ue.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),i=this.getRule(this._rootId).getName(null,null);let o;o=i?tt.createRootAndLookUpScopeName(i,r,this):tt.createRoot("unknown",r),t=new nt(null,this._rootId,-1,-1,!1,null,o,o)}e+="\n";const i=this.createOnigString(e),o=i.content.length,a=new st(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=He(this,i,s,0,t,a,!0,r);return me(i),{lineLength:o,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function et(e,t){return(e=z(e)).repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var tt=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,s=t?.scopePath??null;for(const t of n)s=te.push(s,t.scopeNames),r=new e(r,s,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new te(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const s=r.getMetadataForScope(t),i=new te(null,t),o=r.themeProvider.themeMatch(i),a=e.mergeAttributes(n,s,o);return new e(null,i,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return e.equals(this,t)}static equals(e,t){for(;;){if(e===t)return!0;if(!e&&!t)return!0;if(!e||!t)return!1;if(e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}}static mergeAttributes(e,t,n){let r=-1,s=0,i=0;return null!==n&&(r=n.fontStyle,s=n.foregroundId,i=n.backgroundId),ue.set(e,t.languageId,t.tokenType,null,r,s,i)}pushAttributed(t,n){if(null===t)return this;if(-1===t.indexOf(" "))return e._pushAttributed(this,t,n);const r=t.split(/ /g);let s=this;for(const t of r)s=e._pushAttributed(s,t,n);return s}static _pushAttributed(t,n,r){const s=r.getMetadataForScope(n),i=t.scopePath.push(n),o=r.themeProvider.themeMatch(i),a=e.mergeAttributes(t.tokenAttributes,s,o);return new e(t,i,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const t=[];let n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},nt=class e{constructor(e,t,n,r,s,i,o,a){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=s,this.endRule=i,this.nameScopesList=o,this.contentNameScopesList=a,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return null!==t&&e._equals(this,t)}static _equals(e,t){return e===t||!!this._structuralEquals(e,t)&&tt.equals(e.contentNameScopesList,t.contentNameScopesList)}static _structuralEquals(e,t){for(;;){if(e===t)return!0;if(!e&&!t)return!0;if(!e||!t)return!1;if(e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,s,i,o,a){return new e(this,t,n,r,s,i,o,a)}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,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){const r=tt.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,tt.fromExtension(r,n.contentNameScopesList))}},rt=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>"*"===e?(this.allowAny=!0,[]):he(e,Ze).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>he(e,Ze).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&0===this.unbalancedBracketScopes.length}get matchesNever(){return 0===this.balancedBracketScopes.length&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},st=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const t=e?.getScopeNames()??[];for(const e of this._tokenTypeOverrides)e.matcher(t)&&(n=ue.set(n,0,pe(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}return r&&(n=ue.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n?void(this._lastTokenEndIndex=t):(this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),void(this._lastTokenEndIndex=t))}const n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),0===this._tokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),0===this._binaryTokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},it=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,s){if(!this._grammars.has(e)){let i=this._rawGrammars.get(e);if(!i)return null;this._grammars.set(e,function(e,t,n,r,s,i,o,a){return new Ye(e,t,n,r,s,i,o,a)}(e,i,t,n,r,s,this,this._onigLib))}return this._grammars.get(e)}},ot=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new it(ee.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(ee.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new rt(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,s){const i=new ke(this._syncRegistry,e);for(;i.Q.length>0;)i.Q.map(e=>this._loadSingleGrammar(e.scopeName)),i.processQueue();return this._grammarForScopeName(e,t,n,r,s)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const t=this._options.loadGrammar(e);if(t){const n="function"==typeof this._options.getInjections?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,s)}},at=nt.NULL;const lt=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class ct{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function ut(e,t){const n={},r={};for(const t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ct(n,r,t)}function pt(e){return e.toLowerCase()}ct.prototype.normal={},ct.prototype.property={},ct.prototype.space=void 0;class ht{constructor(e,t){this.attribute=t,this.property=e}}ht.prototype.attribute="",ht.prototype.booleanish=!1,ht.prototype.boolean=!1,ht.prototype.commaOrSpaceSeparated=!1,ht.prototype.commaSeparated=!1,ht.prototype.defined=!1,ht.prototype.mustUseProperty=!1,ht.prototype.number=!1,ht.prototype.overloadedBoolean=!1,ht.prototype.property="",ht.prototype.spaceSeparated=!1,ht.prototype.space=void 0;let dt=0;const mt=Ct(),gt=Ct(),ft=Ct(),yt=Ct(),kt=Ct(),bt=Ct(),wt=Ct();function Ct(){return 2**++dt}var _t={__proto__:null,boolean:mt,booleanish:gt,commaOrSpaceSeparated:wt,commaSeparated:bt,number:yt,overloadedBoolean:ft,spaceSeparated:kt};const St=Object.keys(_t);class vt extends ht{constructor(e,t,n,r){let s=-1;if(super(e,t),xt(this,"space",r),"number"==typeof n)for(;++s<St.length;){const e=St[s];xt(this,St[s],(n&_t[e])===_t[e])}}}function xt(e,t,n){n&&(e[t]=n)}function Nt(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new vt(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[pt(r)]=r,n[pt(i.attribute)]=r}return new ct(t,n,e.space)}vt.prototype.defined=!0;const At=Nt({properties:{ariaActiveDescendant:null,ariaAtomic:gt,ariaAutoComplete:null,ariaBusy:gt,ariaChecked:gt,ariaColCount:yt,ariaColIndex:yt,ariaColSpan:yt,ariaControls:kt,ariaCurrent:null,ariaDescribedBy:kt,ariaDetails:null,ariaDisabled:gt,ariaDropEffect:kt,ariaErrorMessage:null,ariaExpanded:gt,ariaFlowTo:kt,ariaGrabbed:gt,ariaHasPopup:null,ariaHidden:gt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kt,ariaLevel:yt,ariaLive:null,ariaModal:gt,ariaMultiLine:gt,ariaMultiSelectable:gt,ariaOrientation:null,ariaOwns:kt,ariaPlaceholder:null,ariaPosInSet:yt,ariaPressed:gt,ariaReadOnly:gt,ariaRelevant:null,ariaRequired:gt,ariaRoleDescription:kt,ariaRowCount:yt,ariaRowIndex:yt,ariaRowSpan:yt,ariaSelected:gt,ariaSetSize:yt,ariaSort:null,ariaValueMax:yt,ariaValueMin:yt,ariaValueNow:yt,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function jt(e,t){return t in e?e[t]:t}function Et(e,t){return jt(e,t.toLowerCase())}const Lt=Nt({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:bt,acceptCharset:kt,accessKey:kt,action:null,allow:null,allowFullScreen:mt,allowPaymentRequest:mt,allowUserMedia:mt,alt:null,as:null,async:mt,autoCapitalize:null,autoComplete:kt,autoFocus:mt,autoPlay:mt,blocking:kt,capture:null,charSet:null,checked:mt,cite:null,className:kt,cols:yt,colSpan:null,content:null,contentEditable:gt,controls:mt,controlsList:kt,coords:yt|bt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:mt,defer:mt,dir:null,dirName:null,disabled:mt,download:ft,draggable:gt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:mt,formTarget:null,headers:kt,height:yt,hidden:ft,high:yt,href:null,hrefLang:null,htmlFor:kt,httpEquiv:kt,id:null,imageSizes:null,imageSrcSet:null,inert:mt,inputMode:null,integrity:null,is:null,isMap:mt,itemId:null,itemProp:kt,itemRef:kt,itemScope:mt,itemType:kt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:mt,low:yt,manifest:null,max:null,maxLength:yt,media:null,method:null,min:null,minLength:yt,multiple:mt,muted:mt,name:null,nonce:null,noModule:mt,noValidate:mt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:mt,optimum:yt,pattern:null,ping:kt,placeholder:null,playsInline:mt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:mt,referrerPolicy:null,rel:kt,required:mt,reversed:mt,rows:yt,rowSpan:yt,sandbox:kt,scope:null,scoped:mt,seamless:mt,selected:mt,shadowRootClonable:mt,shadowRootDelegatesFocus:mt,shadowRootMode:null,shape:null,size:yt,sizes:null,slot:null,span:yt,spellCheck:gt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:yt,step:null,style:null,tabIndex:yt,target:null,title:null,translate:null,type:null,typeMustMatch:mt,useMap:null,value:gt,width:yt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kt,axis:null,background:null,bgColor:null,border:yt,borderColor:null,bottomMargin:yt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:mt,declare:mt,event:null,face:null,frame:null,frameBorder:null,hSpace:yt,leftMargin:yt,link:null,longDesc:null,lowSrc:null,marginHeight:yt,marginWidth:yt,noResize:mt,noHref:mt,noShade:mt,noWrap:mt,object:null,profile:null,prompt:null,rev:null,rightMargin:yt,rules:null,scheme:null,scrolling:gt,standby:null,summary:null,text:null,topMargin:yt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:yt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:mt,disableRemotePlayback:mt,prefix:null,property:null,results:yt,security:null,unselectable:null},space:"html",transform:Et}),It=Nt({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:wt,accentHeight:yt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:yt,amplitude:yt,arabicForm:null,ascent:yt,attributeName:null,attributeType:null,azimuth:yt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:yt,by:null,calcMode:null,capHeight:yt,className:kt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:yt,diffuseConstant:yt,direction:null,display:null,dur:null,divisor:yt,dominantBaseline:null,download:mt,dx:null,dy:null,edgeMode:null,editable:null,elevation:yt,enableBackground:null,end:null,event:null,exponent:yt,externalResourcesRequired:null,fill:null,fillOpacity:yt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:bt,g2:bt,glyphName:bt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:yt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:yt,horizOriginX:yt,horizOriginY:yt,id:null,ideographic:yt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:yt,k:yt,k1:yt,k2:yt,k3:yt,k4:yt,kernelMatrix:wt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:yt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:yt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:yt,overlineThickness:yt,paintOrder:null,panose1:null,path:null,pathLength:yt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:yt,pointsAtY:yt,pointsAtZ:yt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:wt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:wt,rev:wt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:wt,requiredFeatures:wt,requiredFonts:wt,requiredFormats:wt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:yt,specularExponent:yt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:yt,strikethroughThickness:yt,string:null,stroke:null,strokeDashArray:wt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:yt,strokeOpacity:yt,strokeWidth:null,style:null,surfaceScale:yt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:wt,tabIndex:yt,tableValues:null,target:null,targetX:yt,targetY:yt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:wt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:yt,underlineThickness:yt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:yt,values:null,vAlphabetic:yt,vMathematical:yt,vectorEffect:null,vHanging:yt,vIdeographic:yt,version:null,vertAdvY:yt,vertOriginX:yt,vertOriginY:yt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:yt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:jt}),Pt=Nt({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),Rt=Nt({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Et}),Tt=Nt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Mt=/[A-Z]/g,$t=/-[a-z]/g,Ot=/^data[-\w.:]+$/i;function Gt(e){return"-"+e.toLowerCase()}function Dt(e){return e.charAt(1).toUpperCase()}const Bt=ut([At,Lt,Pt,Rt,Tt],"html"),Ft=ut([At,It,Pt,Rt,Tt],"svg"),Ut={}.hasOwnProperty;const Wt=/["&'<>`]/g,zt=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ht=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,qt=/[|\\{}()[\]^$+*?.]/g,Vt=new WeakMap;function Xt(e,t){return e=e.replace(t.subset?function(e){let t=Vt.get(e);t||(t=function(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(qt,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}(e),Vt.set(e,t));return t}(t.subset):Wt,n),t.subset||t.escapeOnly?e:e.replace(zt,function(e,n,r){return t.format(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}).replace(Ht,n);function n(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}const Kt=/[\dA-Fa-f]/;const Qt=/\d/;const Zt=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],Jt={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},Yt=["cent","copy","divide","gt","lt","not","para","times"],en={}.hasOwnProperty,tn={};let nn;for(nn in Jt)en.call(Jt,nn)&&(tn[Jt[nn]]=nn);const rn=/[^\dA-Za-z]/;function sn(e,t,n){let r,s=function(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!Kt.test(String.fromCharCode(t))?r:r+";"}(e,t,n.omitOptionalSemicolons);if((n.useNamedReferences||n.useShortestReferences)&&(r=function(e,t,n,r){const s=String.fromCharCode(e);if(en.call(tn,s)){const e=tn[s],i="&"+e;return n&&Zt.includes(e)&&!Yt.includes(e)&&(!r||t&&61!==t&&rn.test(String.fromCharCode(t)))?i:i+";"}return""}(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!r)&&n.useShortestReferences){const r=function(e,t,n){const r="&#"+String(e);return n&&t&&!Qt.test(String.fromCharCode(t))?r:r+";"}(e,t,n.omitOptionalSemicolons);r.length<s.length&&(s=r)}return r&&(!n.useShortestReferences||r.length<s.length)?r:s}function on(e,t){return Xt(e,Object.assign({format:sn},t))}const an=/^>|^->|<!--|-->|--!>|<!-$/g,ln=[">"],cn=["<",">"];function un(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;-1!==s;)r++,s=n.indexOf(t,s+t.length);return r}function pn(e,t){const n=t||{};return(""===e[e.length-1]?[...e,""]:e).join((n.padRight?" ":"")+","+(!1===n.padLeft?"":" ")).trim()}function hn(e){return e.join(" ").trim()}const dn=/[ \t\n\f\r]/g;function mn(e){return"object"==typeof e?"text"===e.type&&gn(e.value):gn(e)}function gn(e){return""===e.replace(dn,"")}const fn=bn(1),yn=bn(-1),kn=[];function bn(e){return function(t,n,r){const s=t?t.children:kn;let i=(n||0)+e,o=s[i];if(!r)for(;o&&mn(o);)i+=e,o=s[i];return o}}const wn={}.hasOwnProperty;function Cn(e){return function(t,n,r){return wn.call(e,t.tagName)&&e[t.tagName](t,n,r)}}const _n=Cn({body:function(e,t,n){const r=fn(n,t);return!r||"comment"!==r.type},caption:Sn,colgroup:Sn,dd:function(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&("dt"===r.tagName||"dd"===r.tagName)},dt:function(e,t,n){const r=fn(n,t);return Boolean(r&&"element"===r.type&&("dt"===r.tagName||"dd"===r.tagName))},head:Sn,html:function(e,t,n){const r=fn(n,t);return!r||"comment"!==r.type},li:function(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&"li"===r.tagName},optgroup:function(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&"optgroup"===r.tagName},option:function(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&("option"===r.tagName||"optgroup"===r.tagName)},p:function(e,t,n){const r=fn(n,t);return r?"element"===r.type&&("address"===r.tagName||"article"===r.tagName||"aside"===r.tagName||"blockquote"===r.tagName||"details"===r.tagName||"div"===r.tagName||"dl"===r.tagName||"fieldset"===r.tagName||"figcaption"===r.tagName||"figure"===r.tagName||"footer"===r.tagName||"form"===r.tagName||"h1"===r.tagName||"h2"===r.tagName||"h3"===r.tagName||"h4"===r.tagName||"h5"===r.tagName||"h6"===r.tagName||"header"===r.tagName||"hgroup"===r.tagName||"hr"===r.tagName||"main"===r.tagName||"menu"===r.tagName||"nav"===r.tagName||"ol"===r.tagName||"p"===r.tagName||"pre"===r.tagName||"section"===r.tagName||"table"===r.tagName||"ul"===r.tagName):!n||!("element"===n.type&&("a"===n.tagName||"audio"===n.tagName||"del"===n.tagName||"ins"===n.tagName||"map"===n.tagName||"noscript"===n.tagName||"video"===n.tagName))},rp:vn,rt:vn,tbody:function(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&("tbody"===r.tagName||"tfoot"===r.tagName)},td:xn,tfoot:function(e,t,n){return!fn(n,t)},th:xn,thead:function(e,t,n){const r=fn(n,t);return Boolean(r&&"element"===r.type&&("tbody"===r.tagName||"tfoot"===r.tagName))},tr:function(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&"tr"===r.tagName}});function Sn(e,t,n){const r=fn(n,t,!0);return!r||"comment"!==r.type&&!("text"===r.type&&mn(r.value.charAt(0)))}function vn(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&("rp"===r.tagName||"rt"===r.tagName)}function xn(e,t,n){const r=fn(n,t);return!r||"element"===r.type&&("td"===r.tagName||"th"===r.tagName)}const Nn=Cn({body:function(e){const t=fn(e,-1,!0);return!(t&&("comment"===t.type||"text"===t.type&&mn(t.value.charAt(0))||"element"===t.type&&("meta"===t.tagName||"link"===t.tagName||"script"===t.tagName||"style"===t.tagName||"template"===t.tagName)))},colgroup:function(e,t,n){const r=yn(n,t),s=fn(e,-1,!0);if(n&&r&&"element"===r.type&&"colgroup"===r.tagName&&_n(r,n.children.indexOf(r),n))return!1;return Boolean(s&&"element"===s.type&&"col"===s.tagName)},head:function(e){const t=new Set;for(const n of e.children)if("element"===n.type&&("base"===n.tagName||"title"===n.tagName)){if(t.has(n.tagName))return!1;t.add(n.tagName)}const n=e.children[0];return!n||"element"===n.type},html:function(e){const t=fn(e,-1);return!t||"comment"!==t.type},tbody:function(e,t,n){const r=yn(n,t),s=fn(e,-1);if(n&&r&&"element"===r.type&&("thead"===r.tagName||"tbody"===r.tagName)&&_n(r,n.children.indexOf(r),n))return!1;return Boolean(s&&"element"===s.type&&"tr"===s.tagName)}});const An={name:[["\t\n\f\r &/=>".split(""),"\t\n\f\r \"&'/=>`".split("")],["\0\t\n\f\r \"&'/<=>".split(""),"\0\t\n\f\r \"&'/<=>`".split("")]],unquoted:[["\t\n\f\r &>".split(""),"\0\t\n\f\r \"&'<=>`".split("")],["\0\t\n\f\r \"&'<=>`".split(""),"\0\t\n\f\r \"&'<=>`".split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function jn(e,t,n){const r=function(e,t){const n=pt(t);let r=t,s=ht;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Ot.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace($t,Dt);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!$t.test(e)){let n=e.replace(Mt,Gt);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}s=vt}return new s(r,t)}(e.schema,t),s=e.settings.allowParseErrors&&"html"===e.schema.space?0:1,i=e.settings.allowDangerousCharacters?0:1;let o,a=e.quote;if(!r.overloadedBoolean||n!==r.attribute&&""!==n?!r.boolean&&!r.overloadedBoolean||"string"==typeof n&&n!==r.attribute&&""!==n||(n=Boolean(n)):n=!0,null==n||!1===n||"number"==typeof n&&Number.isNaN(n))return"";const l=on(r.attribute,Object.assign({},e.settings.characterReferences,{subset:An.name[s][i]}));return!0===n?l:(n=Array.isArray(n)?(r.commaSeparated?pn:hn)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n?l:(e.settings.preferUnquoted&&(o=on(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:An.unquoted[s][i]}))),o!==n&&(e.settings.quoteSmart&&un(n,a)>un(n,e.alternative)&&(a=e.alternative),o=a+on(n,Object.assign({},e.settings.characterReferences,{subset:("'"===a?An.single:An.double)[s][i],attribute:!0}))+a),l+(o?"="+o:o)))}const En=["<","&"];function Ln(e,t,n,r){return!n||"element"!==n.type||"script"!==n.tagName&&"style"!==n.tagName?on(e.value,Object.assign({},r.settings.characterReferences,{subset:En})):e.value}const In=function(e,t){const n=t||{};function r(t,...n){let s=r.invalid;const i=r.handlers;if(t&&Ut.call(t,e)){const n=String(t[e]);s=Ut.call(i,n)?i[n]:r.unknown}if(s)return s.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}("type",{invalid:function(e){throw new Error("Expected node, not `"+e+"`")},unknown:function(e){throw new Error("Cannot compile unknown node `"+e.type+"`")},handlers:{comment:function(e,t,n,r){return r.settings.bogusComments?"<?"+on(e.value,Object.assign({},r.settings.characterReferences,{subset:ln}))+">":"\x3c!--"+e.value.replace(an,function(e){return on(e,Object.assign({},r.settings.characterReferences,{subset:cn}))})+"--\x3e"},doctype:function(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"},element:function(e,t,n,r){const s=r.schema,i="svg"!==s.space&&r.settings.omitOptionalTags;let o="svg"===s.space?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const a=[];let l;"html"===s.space&&"svg"===e.tagName&&(r.schema=Ft);const c=function(e,t){const n=[];let r,s=-1;if(t)for(r in t)if(null!==t[r]&&void 0!==t[r]){const s=jn(e,r,t[r]);s&&n.push(s)}for(;++s<n.length;){const t=e.settings.tightAttributes?n[s].charAt(n[s].length-1):void 0;s!==n.length-1&&'"'!==t&&"'"!==t&&(n[s]+=" ")}return n.join("")}(r,e.properties),u=r.all("html"===s.space&&"template"===e.tagName?e.content:e);return r.schema=s,u&&(o=!1),!c&&i&&Nn(e,t,n)||(a.push("<",e.tagName,c?" "+c:""),o&&("svg"===s.space||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||"/"===l||l&&'"'!==l&&"'"!==l)&&a.push(" "),a.push("/")),a.push(">")),a.push(u),o||i&&_n(e,t,n)||a.push("</"+e.tagName+">"),a.join("")},raw:function(e,t,n,r){return r.settings.allowDangerousHtml?e.value:Ln(e,0,n,r)},root:function(e,t,n,r){return r.all(e)},text:Ln}});const Pn={},Rn={},Tn=[];function Mn(e,t,n){return In(e,t,n,this)}function $n(e){const t=[],n=e&&e.children||Tn;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}function On(e,t){const n="string"==typeof e?{}:{...e.colorReplacements},r="string"==typeof e?e:e.name;for(const[e,s]of Object.entries(t?.colorReplacements||{}))"string"==typeof s?n[e]=s:e===r&&Object.assign(n,s);return n}function Gn(e,t){return e&&t?.[e?.toLowerCase()]||e}async function Dn(e){return Promise.resolve("function"==typeof e?e():e).then(e=>e.default||e)}function Bn(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Fn(e){return"ansi"===e||Bn(e)}function Un(e){return"none"===e}function Wn(e){return Un(e)}function zn(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],"string"==typeof e.properties.class&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(/\s+/g);for(const t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function Hn(e,t=!1){const n=e.split(/(\r?\n)/g);let r=0;const s=[];for(let e=0;e<n.length;e+=2){const i=t?n[e]+(n[e+1]||""):n[e];s.push([i,r]),r+=n[e].length,r+=n[e+1]?.length||0}return s}const qn="light-dark()",Vn=["color","background-color"];function Xn(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&ie.Italic&&(t["font-style"]="italic"),e.fontStyle&ie.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&ie.Underline&&n.push("underline"),e.fontStyle&ie.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Kn(e){return"string"==typeof e?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(";")}const Qn=new WeakMap;function Zn(e,t){Qn.set(e,t)}function Jn(e){return Qn.get(e)}class Yn{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,t){return new Yn(Object.fromEntries(function(e){return Array.isArray(e)?e:[e]}(t).map(e=>[e,at])),e)}constructor(...e){if(2===e.length){const[t,n]=e;this.lang=n,this._stacks=t}else{const[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return function(e){const t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);const s=e?.nameScopesList?.scopeName;s&&t.push(s),e.parent&&r(e.parent)}return r(e),t}(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function er(){const e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=function(e){if("number"==typeof e){if(e<0||e>t.source.length)throw new W(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...r.indexToPos(e),offset:e}}{const t=r.lines[e.line];if(void 0===t)throw new W(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${r.lines.length}`);if(e.character<0||e.character>t.length)throw new W(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,offset:r.posToIndex(e.line,e.character)}}};const r=function(e){const t=Hn(e,!0).map(([e])=>e);return{lines:t,indexToPos:function(n){if(n===e.length)return{line:t.length-1,character:t[t.length-1].length};let r=n,s=0;for(const e of t){if(r<e.length)break;r-=e.length,s++}return{line:s,character:r}},posToIndex:function(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}}}(t.source),s=(t.options.decorations||[]).map(e=>({...e,start:n(e.start),end:n(e.end)}));!function(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new W(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const t=e[r],s=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,i=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,a=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(s||i||o||a){if(s&&i)continue;if(o&&a)continue;throw new W(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}(s),e.set(t.meta,{decorations:s,converter:r,source:t.source})}return e.get(t.meta)}return{name:"shiki:decorations",tokens(e){if(!this.options.decorations?.length)return;const n=t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]),r=function(e,t){const n=Array.from(t instanceof Set?t:new Set(t)).sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{const t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?function(e,t){let n=0;const r=[];for(const s of t)s>n&&r.push({...e,content:e.content.slice(n,s),offset:e.offset+n}),n=s;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}(e,t):e})):e}(e,n);return r},code(e){if(!this.options.decorations?.length)return;const n=t(this),r=Array.from(e.children).filter(e=>"element"===e.type&&"span"===e.tagName);if(r.length!==n.converter.lines.length)throw new W(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function s(e,t,n,s){const i=r[e];let a="",l=-1,c=-1;if(0===t&&(l=0),0===n&&(c=0),n===Number.POSITIVE_INFINITY&&(c=i.children.length),-1===l||-1===c)for(let e=0;e<i.children.length;e++)a+=tr(i.children[e]),-1===l&&a.length===t&&(l=e+1),-1===c&&a.length===n&&(c=e+1);if(-1===l)throw new W(`Failed to find start index for decoration ${JSON.stringify(s.start)}`);if(-1===c)throw new W(`Failed to find end index for decoration ${JSON.stringify(s.end)}`);const u=i.children.slice(l,c);if(s.alwaysWrap||u.length!==i.children.length)if(s.alwaysWrap||1!==u.length||"element"!==u[0].type){const e={type:"element",tagName:"span",properties:{},children:u};o(e,s,"wrapper"),i.children.splice(l,u.length,e)}else o(u[0],s,"token");else o(i,s,"line")}function i(e,t){r[e]=o(r[e],t,"line")}function o(e,t,n){const r=t.properties||{},s=t.transform||(e=>e);return e.tagName=t.tagName||"span",e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&zn(e,t.properties.class),e=s(e,n)||e}const a=[],l=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(const e of l){const{start:t,end:n}=e;if(t.line===n.line)s(t.line,t.character,n.character,e);else if(t.line<n.line){s(t.line,t.character,Number.POSITIVE_INFINITY,e);for(let r=t.line+1;r<n.line;r++)a.unshift(()=>i(r,e));s(n.line,0,n.character,e)}}a.forEach(e=>e())}}}function tr(e){return"text"===e.type?e.value:"element"===e.type?e.children.map(tr).join(""):""}const nr=[er()];function rr(e){return[...e.transformers||[],...nr]}var sr=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],ir={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function or(e,t){const n=e.indexOf("",t);if(-1!==n&&"["===e[n+1]){const t=e.indexOf("m",n);if(-1!==t)return{sequence:e.substring(n+2,t).split(";"),startPosition:n,position:t+1}}return{position:e.length}}function ar(e){const t=e.shift();if("2"===t){const t=e.splice(0,3).map(e=>Number.parseInt(e));if(3!==t.length||t.some(e=>Number.isNaN(e)))return;return{type:"rgb",rgb:t}}if("5"===t){const t=e.shift();if(t)return{type:"table",index:Number(t)}}}function lr(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(0===r)t.push({type:"resetAll"});else if(r<=9){ir[r]&&t.push({type:"setDecoration",value:ir[r]})}else if(r<=29){const e=ir[r-20];e&&(t.push({type:"resetDecoration",value:e}),"dim"===e&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:sr[r-30]}});else if(38===r){const n=ar(e);n&&t.push({type:"setForegroundColor",value:n})}else if(39===r)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:sr[r-40]}});else if(48===r){const n=ar(e);n&&t.push({type:"setBackgroundColor",value:n})}else 49===r?t.push({type:"resetBackgroundColor"}):53===r?t.push({type:"setDecoration",value:"overline"}):55===r?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:sr[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:sr[r-100+8]}})}return t}var cr={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 ur(e=cr){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(e){return function(){if(r)return r;r=[];for(let e=0;e<sr.length;e++)r.push(t(sr[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let s=0;s<6;s++)for(let i=0;i<6;i++)r.push(n([e[t],e[s],e[i]]));let s=8;for(let e=0;e<24;e++,s+=10)r.push(n([s,s,s]));return r}()[e]}return{value:function(e){switch(e.type){case"named":return t(e.name);case"rgb":return n(e.rgb);case"table":return s(e.index)}}}}function pr(e,t,n){const r=On(e,n),s=Hn(t),i=ur(Object.fromEntries(sr.map(t=>[t,e.colors?.[`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`]]))),o=function(){let e=null,t=null,n=new Set;return{parse(r){const s=[];let i=0;do{const o=or(r,i),a=o.sequence?r.substring(i,o.startPosition):r.substring(i);if(a.length>0&&s.push({value:a,foreground:e,background:t,decorations:new Set(n)}),o.sequence){const r=lr(o.sequence);for(const s of r)"resetAll"===s.type?(e=null,t=null,n.clear()):"resetForegroundColor"===s.type?e=null:"resetBackgroundColor"===s.type?t=null:"resetDecoration"===s.type&&n.delete(s.value);for(const s of r)"setForegroundColor"===s.type?e=s.value:"setBackgroundColor"===s.type?t=s.value:"setDecoration"===s.type&&n.add(s.value)}i=o.position}while(i<r.length);return s}}}();return s.map(t=>o.parse(t[0]).map(n=>{let s,o;n.decorations.has("reverse")?(s=n.background?i.value(n.background):e.bg,o=n.foreground?i.value(n.foreground):e.fg):(s=n.foreground?i.value(n.foreground):e.fg,o=n.background?i.value(n.background):void 0),s=Gn(s,r),o=Gn(o,r),n.decorations.has("dim")&&(s=function(e){const t=e.match(/#([0-9a-f]{3})([0-9a-f]{3})?([0-9a-f]{2})?/);if(t){if(t[3]){const e=Math.round(Number.parseInt(t[3],16)/2).toString(16).padStart(2,"0");return`#${t[1]}${t[2]}${e}`}return t[2]?`#${t[1]}${t[2]}80`:`#${Array.from(t[1]).map(e=>`${e}${e}`).join("")}80`}const n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}(s));let a=ie.None;return n.decorations.has("bold")&&(a|=ie.Bold),n.decorations.has("italic")&&(a|=ie.Italic),n.decorations.has("underline")&&(a|=ie.Underline),n.decorations.has("strikethrough")&&(a|=ie.Strikethrough),{content:n.value,offset:t[1],color:s,bgColor:o,fontStyle:a}}))}function hr(e,t,n={}){const{lang:r="text",theme:s=e.getLoadedThemes()[0]}=n;if(Bn(r)||Un(s))return Hn(t).map(e=>[{content:e[0],offset:e[1]}]);const{theme:i,colorMap:o}=e.setTheme(s);if("ansi"===r)return pr(i,t,n);const a=e.getLanguage(r);if(n.grammarState){if(n.grammarState.lang!==a.name)throw new W(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${a.name}"`);if(!n.grammarState.themes.includes(i.name))throw new W(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return function(e,t,n,r,s){const i=dr(e,t,n,r,s),o=new Yn(dr(e,t,n,r,s).stateStack,t.name,n.name);return Zn(i.tokens,o),i.tokens}(t,a,i,o,n)}function dr(e,t,n,r,s){const i=On(n,s),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:a=500}=s,l=Hn(e);let c=s.grammarState?function(e,t){if(!(e instanceof Yn))throw new W("Invalid grammar state");return e.getInternalStack(t)}(s.grammarState,n.name)??at:null!=s.grammarContextCode?dr(s.grammarContextCode,t,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:at,u=[];const p=[];for(let e=0,h=l.length;e<h;e++){const[h,d]=l[e];if(""===h){u=[],p.push([]);continue}if(o>0&&h.length>=o){u=[],p.push([{content:h,offset:d,color:"",fontStyle:0}]);continue}let m,g,f;s.includeExplanation&&(m=t.tokenizeLine(h,c,a),g=m.tokens,f=0);const y=t.tokenizeLine2(h,c,a),k=y.tokens.length/2;for(let e=0;e<k;e++){const t=y.tokens[2*e],o=e+1<k?y.tokens[2*e+2]:h.length;if(t===o)continue;const a=y.tokens[2*e+1],l=Gn(r[ue.getForeground(a)],i),c=ue.getFontStyle(a),p={content:h.substring(t,o),offset:d+t,color:l,fontStyle:c};if(s.includeExplanation){const e=[];if("scopeName"!==s.includeExplanation)for(const t of n.settings){let n;switch(typeof t.scope){case"string":n=t.scope.split(/,/).map(e=>e.trim());break;case"object":n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(/ /))})}p.explanation=[];let r=0;for(;t+r<o;){const t=g[f],n=h.substring(t.startIndex,t.endIndex);r+=n.length,p.explanation.push({content:n,scopes:"scopeName"===s.includeExplanation?mr(t.scopes):gr(e,t.scopes)}),f+=1}}u.push(p)}p.push(u),u=[],c=y.ruleStack}return{tokens:p,stateStack:c}}function mr(e){return e.map(e=>({scopeName:e}))}function gr(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const s=t[r];n[r]={scopeName:s,themeMatches:kr(e,s,t.slice(0,r))}}return n}function fr(e,t){return e===t||t.substring(0,e.length)===e&&"."===t[e.length]}function yr(e,t,n){if(!fr(e[e.length-1],t))return!1;let r=e.length-2,s=n.length-1;for(;r>=0&&s>=0;)fr(e[r],n[s])&&(r-=1),s-=1;return-1===r}function kr(e,t,n){const r=[];for(const{selectors:s,settings:i}of e)for(const e of s)if(yr(e,t,n)){r.push(i);break}return r}function br(e,t,n){const r=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),s=r.map(r=>{const s=hr(e,t,{...n,theme:r.theme});return{tokens:s,state:Jn(s),theme:"string"==typeof r.theme?r.theme:r.theme.name}}),i=function(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const s=e.map(e=>e[r]),i=t.map(()=>[]);t.forEach((e,t)=>e.push(i[t]));const o=s.map(()=>0),a=s.map(e=>e[0]);for(;a.every(e=>e);){const e=Math.min(...a.map(e=>e.content.length));for(let t=0;t<n;t++){const n=a[t];n.content.length===e?(i[t].push(n),o[t]+=1,a[t]=s[t][o[t]]):(i[t].push({...n,content:n.content.slice(0,e)}),a[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}(...s.map(e=>e.tokens)),o=i[0].map((e,t)=>e.map((e,s)=>{const o={content:e.content,variants:{},offset:e.offset};return"includeExplanation"in n&&n.includeExplanation&&(o.explanation=e.explanation),i.forEach((e,n)=>{const{content:i,explanation:a,offset:l,...c}=e[t][s];o.variants[r[n].color]=c}),o})),a=s[0].state?new Yn(Object.fromEntries(s.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),s[0].state.lang):void 0;return a&&Zn(o,a),o}function wr(e,t,n){let r,s,i,o,a,l;if("themes"in n){const{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:p="css-vars"}=n,h=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===c?-1:t.color===c?1:0);if(0===h.length)throw new W("`themes` option must not be empty");const d=br(e,t,n);if(l=Jn(d),c&&qn!==c&&!h.find(e=>e.color===c))throw new W(`\`themes\` option must contain the defaultColor key \`${c}\``);const m=h.map(t=>e.getTheme(t.theme)),g=h.map(e=>e.color);i=d.map(e=>e.map(e=>function(e,t,n,r,s="css-vars"){const i={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Xn(e.variants[t])),a=new Set(o.flatMap(e=>Object.keys(e))),l={},c=(e,r)=>{const s="color"===r?"":"background-color"===r?"-bg":`-${r}`;return n+t[e]+("color"===r?"":s)};return o.forEach((e,n)=>{for(const i of a){const a=e[i]||"inherit";if(0===n&&r&&Vn.includes(i))if(r===qn&&o.length>1){const e=t.findIndex(e=>"light"===e),r=t.findIndex(e=>"dark"===e);if(-1===e||-1===r)throw new W('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const u=o[e][i]||"inherit",p=o[r][i]||"inherit";l[i]=`light-dark(${u}, ${p})`,"css-vars"===s&&(l[c(n,i)]=a)}else l[i]=a;else"css-vars"===s&&(l[c(n,i)]=a)}}),i.htmlStyle=l,i}(e,g,u,c,p))),l&&Zn(i,l);const f=h.map(e=>On(e.theme,n));s=Cr(h,m,f,u,c,"fg",p),r=Cr(h,m,f,u,c,"bg",p),o=`shiki-themes ${m.map(e=>e.name).join(" ")}`,a=c?void 0:[s,r].join(";")}else{if(!("theme"in n))throw new W("Invalid options, either `theme` or `themes` must be provided");{const a=On(n.theme,n);i=hr(e,t,n);const c=e.getTheme(n.theme);r=Gn(c.bg,a),s=Gn(c.fg,a),o=c.name,l=Jn(i)}}return{tokens:i,fg:s,bg:r,themeName:o,rootStyle:a,grammarState:l}}function Cr(e,t,n,r,s,i,o){return e.map((a,l)=>{const c=Gn(t[l][i],n[l])||"inherit",u=`${r+a.color}${"bg"===i?"-bg":""}:${c}`;if(0===l&&s){if(s===qn&&e.length>1){const r=e.findIndex(e=>"light"===e.color),s=e.findIndex(e=>"dark"===e.color);if(-1===r||-1===s)throw new W('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Gn(t[r][i],n[r])||"inherit"}, ${Gn(t[s][i],n[s])||"inherit"});${u}`}return c}return"css-vars"===o?u:null}).filter(e=>!!e).join(";")}function _r(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>_r(e,t,n),codeToTokens:(t,n)=>wr(e,t,n)}){let s=t;for(const e of rr(n))s=e.preprocess?.call(r,s,n)||s;let{tokens:i,fg:o,bg:a,themeName:l,rootStyle:c,grammarState:u}=wr(e,s,n);const{mergeWhitespaces:p=!0,mergeSameStyleTokens:h=!1}=n;!0===p?i=function(e){return e.map(e=>{const t=[];let n="",r=0;return e.forEach((s,i)=>{const o=!(s.fontStyle&&(s.fontStyle&ie.Underline||s.fontStyle&ie.Strikethrough));o&&s.content.match(/^\s+$/)&&e[i+1]?(r||(r=s.offset),n+=s.content):n?(o?t.push({...s,offset:r,content:n+s.content}):t.push({content:n,offset:r},s),r=0,n=""):t.push(s)}),t})}(i):"never"===p&&(i=function(e){return e.map(e=>e.flatMap(e=>{if(e.content.match(/^\s+$/))return e;const t=e.content.match(/^(\s*)(.*?)(\s*)$/);if(!t)return e;const[,n,r,s]=t;if(!n&&!s)return e;const i=[{...e,offset:e.offset+n.length,content:r}];return n&&i.unshift({content:n,offset:e.offset}),s&&i.push({content:s,offset:e.offset+n.length+r.length}),i}))}(i)),h&&(i=function(e){return e.map(e=>{const t=[];for(const n of e){if(0===t.length){t.push({...n});continue}const e=t[t.length-1],r=Kn(e.htmlStyle||Xn(e)),s=Kn(n.htmlStyle||Xn(n)),i=e.fontStyle&&(e.fontStyle&ie.Underline||e.fontStyle&ie.Strikethrough),o=n.fontStyle&&(n.fontStyle&ie.Underline||n.fontStyle&ie.Strikethrough);i||o||r!==s?t.push({...n}):e.content+=n.content}return t})}(i));const d={...r,get source(){return s}};for(const e of rr(n))i=e.tokens?.call(d,i)||i;return function(e,t,n,r=Jn(e)){const s=rr(t),i=[],o={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t;let c={type:"element",tagName:"pre",properties:{class:`shiki ${t.themeName||""}`,style:t.rootStyle||`background-color:${t.bg};color:${t.fg}`,...!1!==l&&null!=l?{tabindex:l.toString()}:{},...Object.fromEntries(Array.from(Object.entries(t.meta||{})).filter(([e])=>!e.startsWith("_")))},children:[]},u={type:"element",tagName:"code",properties:{},children:i};const p=[],h={...n,structure:a,addClassToHast:zn,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return c},get code(){return u},get lines(){return p}};if(e.forEach((e,t)=>{t&&("inline"===a?o.children.push({type:"element",tagName:"br",properties:{},children:[]}):"classic"===a&&i.push({type:"text",value:"\n"}));let n={type:"element",tagName:"span",properties:{class:"line"},children:[]},r=0;for(const i of e){let e={type:"element",tagName:"span",properties:{...i.htmlAttrs},children:[{type:"text",value:i.content}]};const l=Kn(i.htmlStyle||Xn(i));l&&(e.properties.style=l);for(const o of s)e=o?.span?.call(h,e,t+1,r,n,i)||e;"inline"===a?o.children.push(e):"classic"===a&&n.children.push(e),r+=i.content.length}if("classic"===a){for(const e of s)n=e?.line?.call(h,n,t+1)||n;p.push(n),i.push(n)}}),"classic"===a){for(const e of s)u=e?.code?.call(h,u)||u;c.children.push(u);for(const e of s)c=e?.pre?.call(h,c)||c;o.children.push(c)}let d=o;for(const e of s)d=e?.root?.call(h,d)||d;r&&Zn(d,r);return d}(i,{...n,fg:o,bg:a,themeName:l,rootStyle:c},d,u)}const Sr=function(e,t){const n=t||Pn,r=n.quote||'"',s='"'===r?"'":'"';if('"'!==r&&"'"!==r)throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Mn,all:$n,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||lt,characterReferences:n.characterReferences||Rn,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:"svg"===n.space?Ft:Bt,quote:r,alternative:s}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)};const vr="#333333",xr="#bbbbbb",Nr="#fffffe",Ar="#1e1e1e",jr="__shiki_resolved";function Er(e){if(e?.[jr])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){const e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r="light"===t.type?vr:xr),n||(n="light"===t.type?Nr:Ar),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let s=0;const i=new Map;function o(e){if(i.has(e))return i.get(e);s+=1;const n=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(i.set(e,n),n)}t.settings=t.settings.map(e=>{const n=e.settings?.foreground&&!e.settings.foreground.startsWith("#"),r=e.settings?.background&&!e.settings.background.startsWith("#");if(!n&&!r)return e;const s={...e,settings:{...e.settings}};if(n){const n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,s.settings.foreground=n}if(r){const n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,s.settings.background=n}return s});for(const e of Object.keys(t.colors||{}))if(("editor.foreground"===e||"editor.background"===e||e.startsWith("terminal.ansi"))&&!t.colors[e]?.startsWith("#")){const n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,jr,{enumerable:!1,writable:!1,value:!0}),t}class Lr extends Error{constructor(e){super(e),this.name="ShikiError"}}class Ir extends ot{constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return"string"==typeof e?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const t=Er(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=ee.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){if(this._alias[e]){const t=new Set([e]);for(;this._alias[e];){if(e=this._alias[e],t.has(e))throw new Lr(`Circular alias \`${Array.from(t).join(" -> ")} -> ${e}\``);t.add(e)}}return this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(const e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const t of e)this.resolveEmbeddedLanguages(t);const t=Array.from(this._langGraph.entries()),n=t.filter(([e,t])=>!t);if(n.length){const e=t.filter(([e,t])=>t&&t.embeddedLangs?.some(e=>n.map(([e])=>e).includes(e))).filter(e=>!n.includes(e));throw new Lr(`Missing languages ${n.map(([e])=>`\`${e}\``).join(", ")}, required by ${e.map(([e])=>`\`${e}\``).join(", ")}`)}for(const[e,n]of t)this._resolver.addLanguage(n);for(const[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){if(this._langMap.set(e.name,e),this._langGraph.set(e.name,e),e.embeddedLangs)for(const t of e.embeddedLangs)this._langGraph.set(t,this._langMap.get(t))}}class Pr{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let e=1;e<=t.length;e++){const r=t.slice(0,e).join(".");n=[...n,...this._injections.get(r)||[]]}return n}}let Rr=0;function Tr(e){Rr+=1,!1!==e.warnings&&Rr>=10&&Rr%10==0&&console.warn(`[Shiki] ${Rr} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Lr("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Er),s=new Pr(e.engine,n),i=new Ir(s,r,n,e.langAlias);let o;function a(e){if("none"===e)return{bg:"",fg:"",name:"none",settings:[],type:"dark"};u();const t=i.getTheme(e);if(!t)throw new Lr(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(...e){u(),i.loadLanguages(e.flat(1))}function c(...e){u();for(const t of e.flat(1))i.loadTheme(t)}function u(){if(t)throw new Lr("Shiki instance has been disposed")}function p(){t||(t=!0,i.dispose(),Rr-=1)}return{setTheme:function(e){u();const t=a(e);return o!==e&&(i.setTheme(t),o=e),{theme:t,colorMap:i.getColorMap()}},getTheme:a,getLanguage:function(e){u();const t=i.getGrammar("string"==typeof e?e:e.name);if(!t)throw new Lr(`Language \`${e}\` not found, you may need to load it first`);return t},getLoadedThemes:function(){return u(),i.getLoadedThemes()},getLoadedLanguages:function(){return u(),i.getLoadedLanguages()},loadLanguage:async function(...e){return l(await async function(e){return Array.from(new Set((await Promise.all(e.filter(e=>!Fn(e)).map(async e=>await Dn(e).then(e=>Array.isArray(e)?e:[e])))).flat()))}(e))},loadLanguageSync:l,loadTheme:async function(...e){return u(),c(await async function(e){return(await Promise.all(e.map(async e=>Wn(e)?null:Er(await Dn(e))))).filter(e=>!!e)}(e))},loadThemeSync:c,dispose:p,[Symbol.dispose]:p}}function Mr(e){if(1!==[...e].length)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}const $r=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Or=String.raw;function Gr(e,t){if(null==e)throw new Error(t??"Value expected");return e}const Dr=Or`\[\^?`,Br=`c.? | C(?:-.?)?|${Or`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Or`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Or`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Or`o\{[^\}]*\}?`}|${Or`\d{1,3}`}`,Fr=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Ur=new RegExp(Or`
|
|
10
10
|
\\ (?:
|
|
11
|
-
${
|
|
11
|
+
${Br}
|
|
12
12
|
| [gk]<[^>]*>?
|
|
13
13
|
| [gk]'[^']*'?
|
|
14
14
|
| .
|
|
@@ -25,19 +25,19 @@ import{$isCodeNode as e,$createCodeHighlightNode as t,CodeExtension as n,DEFAULT
|
|
|
25
25
|
)?
|
|
26
26
|
| \*[^\)]*\)?
|
|
27
27
|
)?
|
|
28
|
-
| (?:${
|
|
29
|
-
| ${
|
|
28
|
+
| (?:${Fr.source})+
|
|
29
|
+
| ${Dr}
|
|
30
30
|
| .
|
|
31
|
-
`.replace(/\s+/g,""),"gsu"),
|
|
31
|
+
`.replace(/\s+/g,""),"gsu"),Wr=new RegExp(Or`
|
|
32
32
|
\\ (?:
|
|
33
|
-
${
|
|
33
|
+
${Br}
|
|
34
34
|
| .
|
|
35
35
|
)
|
|
36
36
|
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
37
|
-
| ${
|
|
37
|
+
| ${Dr}
|
|
38
38
|
| &&
|
|
39
39
|
| .
|
|
40
|
-
`.replace(/\s+/g,""),"gsu");function zr(e,t={}){const n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if("string"!=typeof e)throw new Error("String expected as pattern");const r=function(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){const r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if("y"!==r)t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0;else{if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode="g"===e[n+2]?"grapheme":"word",n+=3}}return t}(n.flags),s=[r.extended],i={captureGroup:n.rules.captureGroup,getCurrentModX:()=>s.at(-1),numOpenGroups:0,popModX(){s.pop()},pushModX(e){s.push(e)},replaceCurrentModX(e){s[s.length-1]=e},singleline:n.rules.singleline};let o,a=[];for(Fr.lastIndex=0;o=Fr.exec(e);){const t=Wr(i,e,o[0],Fr.lastIndex);t.tokens?a.push(...t.tokens):t.token&&a.push(t.token),void 0!==t.lastIndex&&(Fr.lastIndex=t.lastIndex)}const l=[];let c=0;a.filter(e=>"GroupOpen"===e.type).forEach(e=>{"capturing"===e.kind?e.number=++c:"("===e.raw&&l.push(e)}),c||l.forEach((e,t)=>{e.kind="capturing",e.number=t+1});const u=c||l.length;return{tokens:a.map(e=>"EscapedNumber"===e.type?function(e,t){const{raw:n,inCharClass:r}=e,s=n.slice(1);if(!r&&("0"!==s&&1===s.length||"0"!==s[0]&&+s<=t))return[Kr(n)];const i=[],o=s.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){const t=o[e];let r;if(0===e&&"8"!==t&&"9"!==t){if(r=parseInt(t,8),r>127)throw new Error($r`Octal encoded byte above 177 unsupported "${n}"`)}else r=Tr(t);i.push(Qr(r,(0===e?"\\":"")+t))}return i}(e,u):e).flat(),flags:r}}function Wr(e,t,n,r){const[s,i]=n;if("["===n||"[^"===n){const e=function(e,t,n){const r=[Jr("^"===t[1],t)];let s,i=1;for(Ur.lastIndex=n;s=Ur.exec(e);){const e=s[0];if("["===e[0]&&":"!==e[1])i++,r.push(Jr("^"===e[1],e));else if("]"===e){if("CharacterClassOpen"===r.at(-1).type)r.push(Qr(93,e));else if(i--,r.push(Zr(e)),!i)break}else{const t=Hr(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:Ur.lastIndex||e.length}}(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if("\\"===s){if("AbBGyYzZ".includes(i))return{token:Xr(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:rs(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Kr(n)}}if("K"===i)return{token:es("keep",n)};if("N"===i||"R"===i)return{token:Yr("newline",n,{negate:"N"===i})};if("O"===i)return{token:Yr("any",n)};if("X"===i)return{token:Yr("text_segment",n)};const e=qr(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if("("===s){if("*"===i)return{token:as(n)};if("(?{"===n)throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(")"!==t[r])throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:os(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,"("===n&&!e.captureGroup||"(?:"===n)return{token:ns("group",n)};if("(?>"===n)return{token:ns("atomic",n)};if("(?="===n||"(?!"===n||"(?<="===n||"(?<!"===n)return{token:ns("<"===n[2]?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if("("===n&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:ns("capturing",n,{..."("!==n&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if("(?~|"===n)throw new Error(`Unsupported absence function kind "${n}"`);return{token:ns("absence_repeater",n)}}throw"(?("===n?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(")"===n){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:ts(n)}}if(e.getCurrentModX()){if("#"===n){const e=t.indexOf("\n",r);return{lastIndex:-1===e?t.length:e}}if(/^\s$/.test(n)){const e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}if("."===n)return{token:Yr("dot",n)};if("^"===n||"$"===n){return{token:Xr(e.singleline?{"^":$r`\A`,$:$r`\Z`}[n]:n,n)}}return"|"===n?{token:Vr(n)}:Br.test(n)?{tokens:us(n)}:{token:Qr(Tr(n),n)}}function Hr(e){if("\\"===e[0])return qr(e,{inCharClass:!0});if("["===e[0]){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Mr.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Yr("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return"-"===e?function(e){return{type:"CharacterClassHyphen",raw:e}}(e):"&&"===e?function(e){return{type:"CharacterClassIntersector",raw:e}}(e):Qr(Tr(e),e)}function qr(e,{inCharClass:t}){const n=e[1];if("c"===n||"C"===n)return function(e){const t="c"===e[1]?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Qr(Tr(t.toUpperCase())-64,e)}(e);if("dDhHsSwW".includes(n))return function(e){const t=e[1].toLowerCase();return Yr({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}(e);if(e.startsWith($r`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(3===e.length)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return function(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Yr("property",e,{value:r,negate:"P"===t&&!n||"p"===t&&!!n})}(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{const t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join("");return Qr(Tr(e),t)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if("u"===n||"x"===n)return Qr(function(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t="{"===e[2]?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}(e),e);if(is.has(n))return Qr(is.get(n),e);if(/\d/.test(n))return function(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}(t,e);if("\\"===e)throw new Error($r`Incomplete escape "\"`);if("M"===n)throw new Error(`Unsupported meta "${e}"`);if(2===[...e].length)return Qr(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Vr(e){return{type:"Alternator",raw:e}}function Xr(e,t){return{type:"Assertion",kind:e,raw:t}}function Kr(e){return{type:"Backreference",raw:e}}function Qr(e,t){return{type:"Character",value:e,raw:t}}function Zr(e){return{type:"CharacterClassClose",raw:e}}function Jr(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Yr(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function es(e,t,n={}){return"keep"===e?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Or(n.flags),raw:t}}function ts(e){return{type:"GroupClose",raw:e}}function ns(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function rs(e){return{type:"Subroutine",raw:e}}const ss=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),is=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function os(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";const s=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),i=cs(n),o=cs(r),a={};if(i&&(a.enable=i),o&&(a.disable=o),e.endsWith(")"))return t.replaceCurrentModX(s),es("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(s),t.numOpenGroups++,ns("group",e,{...(i||o)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function as(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:s}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(""===r)throw new Error(`Named callout tag with empty value not allowed "${e}"`);const i=s?s.split(",").filter(e=>""!==e).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,a,l]=i,c=ss.has(n)?n.toLowerCase():"custom";switch(c){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("string"==typeof o)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("string"==typeof o&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(2===i.length&&("number"==typeof a||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(i.length>1)throw new Error(`Named callout allows only one argument "${i}"`);if(1===i.length&&("number"==typeof o||!/^[<>X]$/.test(o)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case"cmp":if(3!==i.length)throw new Error(`Named callout must have three arguments "${i}"`);if("string"==typeof o&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if("number"==typeof a||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if("string"==typeof l&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return function(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}(c,r??null,s?.split(",")??null,e)}function ls(e){let t,n,r=null;if("{"===e[0]){const{minStr:s,maxStr:i}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+s>o||i&&+i>o)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+s,n=void 0===i?+s:""===i?1/0:+i,t>n&&(r="possessive",[t,n]=[n,t]),e.endsWith("?")){if("possessive"===r)throw new Error('Unsupported possessive interval quantifier chain with "?"');r="lazy"}else r||(r="greedy")}else t="+"===e[0]?1:0,n="?"===e[0]?1:1/0,r="+"===e[1]?"possessive":"?"===e[1]?"lazy":"greedy";return function(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}(r,t,n,e)}function cs(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function us(e){const t=[],n=new RegExp(Br,"gy");let r;for(;r=n.exec(e);){const e=r[0];if("{"===e[0]){const r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){const{min:s,max:i}=r.groups;if(+s>+i&&e.endsWith("?")){n.lastIndex--,t.push(ls(e.slice(0,-1)));continue}}}t.push(ls(e))}return t}function ps(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(1!==e.body.length)return!1;const n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}const hs=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function ds(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=zr(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(e,t)=>{const n=r.tokens[i.nextIndex];switch(i.parent=e,i.nextIndex++,n.type){case"Alternator":return ys();case"Assertion":return ms(n);case"Backreference":return function({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),s=(n,r=!1)=>{const s=t.capturingGroups.length;let i=!1;if(n>s){if(!t.skipBackrefValidation)throw new Error(`Not enough capturing groups defined to the left "${e}"`);i=!0}return t.hasNumberedRef=!0,bs(r?s+1-n:n,{orphan:i})};if(n){const n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return s(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return bs(r)}return s(+r)}(n,i);case"Character":return Cs(n.value,{useLastValid:!!t.isCheckingRangeEnd});case"CharacterClassHyphen":return function(e,t,n){const{tokens:r,walk:s}=t,i=t.parent,o=i.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&"CharacterClass"!==o.type&&"CharacterClassRange"!==o.type&&a&&"CharacterClassOpen"!==a.type&&"CharacterClassClose"!==a.type&&"CharacterClassIntersector"!==a.type){const e=s(i,{...n,isCheckingRangeEnd:!0});if("Character"===o.type&&"Character"===e.type)return i.body.pop(),function(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}(o,e);throw new Error("Invalid character class range")}return Cs(Tr("-"))}(0,i,t);case"CharacterClassOpen":return function({negate:e},t,n){const{tokens:r,walk:s}=t,i=r[t.nextIndex],o=[_s()];let a=Ms(i);for(;"CharacterClassClose"!==a.type;){if("CharacterClassIntersector"===a.type)o.push(_s()),t.nextIndex++;else{const e=o.at(-1);e.body.push(s(e,n))}a=Ms(r[t.nextIndex],i)}const l=_s({negate:e});return 1===o.length?l.body=o[0].body:(l.kind="intersection",l.body=o.map(e=>1===e.body.length?e.body[0]:e)),t.nextIndex++,l}(n,i,t);case"CharacterSet":return gs(n,i);case"Directive":return vs(n.kind,{flags:n.flags});case"GroupOpen":return function(e,t,n){const{tokens:r,capturingGroups:s,namedGroupsByName:i,skipLookbehindValidation:o,walk:a}=t,l=function({flags:e,kind:t,name:n,negate:r,number:s}){switch(t){case"absence_repeater":return function(e,t){return{type:"AbsenceFunction",kind:e,body:Ls(t?.body)}}("repeater");case"atomic":return xs({atomic:!0});case"capturing":return ws(s,{name:n});case"group":return xs({flags:e});case"lookahead":case"lookbehind":return Ns({behind:"lookbehind"===t,negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}(e),c="AbsenceFunction"===l.type,u=Rs(l),p=u&&l.negate;if("CapturingGroup"===l.type&&(s.push(l),l.name&&function(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}(i,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let h=$s(r[t.nextIndex]);for(;"GroupClose"!==h.type;){if("Alternator"===h.type)l.body.push(ys()),t.nextIndex++;else{const e=l.body.at(-1),t=a(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||p});if(e.body.push(t),(u||n.isInLookbehind)&&!o){const e="Lookbehind includes a pattern not allowed by Oniguruma";if(p||n.isInNegLookbehind){if(Ps(t)||"CapturingGroup"===t.type)throw new Error(e)}else if(Ps(t)||Rs(t)&&t.negate)throw new Error(e)}}h=$s(r[t.nextIndex])}return t.nextIndex++,l}(n,i,t);case"NamedCallout":return function(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}(n.kind,n.tag,n.arguments);case"Quantifier":return fs(n,i);case"Subroutine":return function({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let s=e.slice(3,-1);const i=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(i){const e=+i.groups.num,r=n.length;if(t.hasNumberedRef=!0,s={"":e,"+":r+e,"-":r+1-e}[i.groups.sign],s<1)throw new Error("Invalid subroutine number")}else"0"===s&&(s=0);const o=js(s);return r.push(o),o}(n,i);default:throw new Error(`Unexpected token type "${n.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=function(e,t){return{type:"Regex",body:Ls(t?.body),flags:e}}(function(e){return{type:"Flags",...e}}(r.flags));let a=o.body[0];for(;i.nextIndex<r.tokens.length;){const e=s(a,{});"Alternative"===e.type?(o.body.push(e),a=e):a.body.push(e)}const{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:p}=i;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:e}of p)if("number"==typeof e){if(e>l.length)throw new Error("Subroutine uses a group number that's not defined");e&&(l[e-1].isSubroutined=!0)}else{if(!u.has(e))throw new Error($r`Subroutine uses a group name that's not defined "\g<${e}>"`);if(u.get(e).length>1)throw new Error($r`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}return o}function ms({kind:e}){return ks(Or({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===$r`\B`||e===$r`\Y`})}function gs({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:i,unicodePropertyMap:o}=r;if("property"===e){const r=Ts(n);if(!Mr.has(r)||o?.has(r))return Es(n,{negate:t,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:i,unicodePropertyMap:o});e="posix",n=r}return"posix"===e?function(e,t){const n=!!t?.negate;if(!Mr.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}(n,{negate:t}):Ss(e,{negate:t})}function fs({kind:e,min:t,max:n},r){const s=r.parent,i=s.body.at(-1);if(!i||!function(e){return hs.has(e.type)}(i))throw new Error("Quantifier requires a repeatable token");const o=As(e,t,n,i);return s.body.pop(),o}function ys(e){return{type:"Alternative",body:Is(e?.body)}}function ks(e,t){const n={type:"Assertion",kind:e};return("word_boundary"===e||"text_segment_boundary"===e)&&(n.negate=!!t?.negate),n}function bs(e,t){const n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function ws(e,t){const n={name:void 0,isSubroutined:!1,...t};if(void 0!==n.name&&!function(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Ls(t?.body)}}function Cs(e,t){const n={useLastValid:!1,...t};if(e>1114111){const t=e.toString(16);if(!n.useLastValid)throw e>1310719?new Error(`Invalid code point out of range "\\x{${t}}"`):new Error(`Invalid code point out of range in JS "\\x{${t}}"`);e=1114111}return{type:"Character",value:e}}function _s(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Is(e?.body)}}function Ss(e,t){const n=!!t?.negate,r={type:"CharacterSet",kind:e};return("digit"===e||"hex"===e||"newline"===e||"space"===e||"word"===e)&&(r.negate=n),("text_segment"===e||"newline"===e&&!n)&&(r.variableLength=!0),r}function vs(e,t={}){if("keep"===e)return{type:"Directive",kind:e};if("flags"===e)return{type:"Directive",kind:e,flags:Or(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function xs(e){const t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:Ls(e?.body)}}function Ns(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Ls(e?.body)}}function As(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function js(e){return{type:"Subroutine",ref:e}}function Es(e,t){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=n.unicodePropertyMap?.get(Ts(e));if(!r)if(n.normalizeUnknownPropertyNames)r=function(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error($r`Invalid Unicode property "\p{${e}}"`);return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function Ls(e){if(void 0===e)e=[ys()];else if(!Array.isArray(e)||!e.length||!e.every(e=>"Alternative"===e.type))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Is(e){if(void 0===e)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return e}function Ps(e){return"LookaroundAssertion"===e.type&&"lookahead"===e.kind}function Rs(e){return"LookaroundAssertion"===e.type&&"lookbehind"===e.kind}function Ts(e){return e.replace(/[- _]+/g,"").toLowerCase()}function Ms(e,t){return Or(e,("Character"===t?.type&&93===t.value?"Empty":"Unclosed")+" character class")}function $s(e){return Or(e,"Unclosed group")}function Os(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){const r=s(e[n],t,n,e);n=Math.max(-1,n+r)}}function s(i,o=null,a=null,l=null){let c=0,u=!1;const p={node:i,parent:o,key:a,container:l,root:e,remove(){Gs(l).splice(Math.max(0,Ds(a)+c),1),c--,u=!0},removeAllNextSiblings:()=>Gs(l).splice(Ds(a)+1),removeAllPrevSiblings(){const e=Ds(a)+c;return c-=e,Gs(l).splice(0,Math.max(0,e))},replaceWith(e,t={}){const n=!!t.traverse;l?l[Math.max(0,Ds(a)+c)]=e:Or(o,"Can't replace root node")[a]=e,n&&s(e,o,a,l),u=!0},replaceWithMultiple(e,t={}){const n=!!t.traverse;if(Gs(l).splice(Math.max(0,Ds(a)+c),1,...e),c+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=s(e[n],o,Ds(a)+n+t,l)}u=!0},skip(){u=!0}},{type:h}=i,d=t["*"],m=t[h],g="function"==typeof d?d:d?.enter,f="function"==typeof m?m:m?.enter;if(g?.(p,n),f?.(p,n),!u)switch(h){case"AbsenceFunction":case"CapturingGroup":case"Group":case"Alternative":case"CharacterClass":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 "${h}"`)}return m?.exit?.(p,n),d?.exit?.(p,n),c}return s(e),e}function Gs(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Ds(e){if("number"!=typeof e)throw new Error("Numeric key expected");return e}const Bs=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Fs(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Us(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const zs=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Ws(e,t,n,r){const s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),i=[!1];let o=0,a="";for(const t of e.matchAll(s)){const{0:e,groups:{$skip:s}}=t;s||r&&r===zs.DEFAULT!=!o?("["===e[0]?(o++,i.push("^"===e[1])):"]"===e&&o&&(o--,i.pop()),a+=e):a+=n instanceof Function?n(t,{context:o?zs.CHAR_CLASS:zs.DEFAULT,negated:i[i.length-1]}):n}return a}function Hs(e,t,n,r){Ws(e,t,n,r)}function qs(e,t,n){return!!function(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let i,o=0;for(;i=s.exec(e);){const{0:e,groups:{$skip:t}}=i;if(!(t||r&&r===zs.DEFAULT!=!o))return i;"["===e?o++:"]"===e&&o&&o--,s.lastIndex==i.index&&s.lastIndex++}return null}(e,t,0,n)}function Vs(e,t){const n=/\\?./gsu;n.lastIndex=t;let r,s=e.length,i=0,o=1;for(;r=n.exec(e);){const[e]=r;if("["===e)i++;else if(i)"]"===e&&i--;else if("("===e)o++;else if(")"===e&&(o--,!o)){s=r.index;break}}return e.slice(t,s)}const Xs=new RegExp(String.raw`(?<noncapturingStart>${Bs})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");const Ks=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Qs=new RegExp(String.raw`
|
|
40
|
+
`.replace(/\s+/g,""),"gsu");function zr(e,t={}){const n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if("string"!=typeof e)throw new Error("String expected as pattern");const r=function(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){const r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if("y"!==r)t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0;else{if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode="g"===e[n+2]?"grapheme":"word",n+=3}}return t}(n.flags),s=[r.extended],i={captureGroup:n.rules.captureGroup,getCurrentModX:()=>s.at(-1),numOpenGroups:0,popModX(){s.pop()},pushModX(e){s.push(e)},replaceCurrentModX(e){s[s.length-1]=e},singleline:n.rules.singleline};let o,a=[];for(Ur.lastIndex=0;o=Ur.exec(e);){const t=Hr(i,e,o[0],Ur.lastIndex);t.tokens?a.push(...t.tokens):t.token&&a.push(t.token),void 0!==t.lastIndex&&(Ur.lastIndex=t.lastIndex)}const l=[];let c=0;a.filter(e=>"GroupOpen"===e.type).forEach(e=>{"capturing"===e.kind?e.number=++c:"("===e.raw&&l.push(e)}),c||l.forEach((e,t)=>{e.kind="capturing",e.number=t+1});const u=c||l.length;return{tokens:a.map(e=>"EscapedNumber"===e.type?function(e,t){const{raw:n,inCharClass:r}=e,s=n.slice(1);if(!r&&("0"!==s&&1===s.length||"0"!==s[0]&&+s<=t))return[Qr(n)];const i=[],o=s.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){const t=o[e];let r;if(0===e&&"8"!==t&&"9"!==t){if(r=parseInt(t,8),r>127)throw new Error(Or`Octal encoded byte above 177 unsupported "${n}"`)}else r=Mr(t);i.push(Zr(r,(0===e?"\\":"")+t))}return i}(e,u):e).flat(),flags:r}}function Hr(e,t,n,r){const[s,i]=n;if("["===n||"[^"===n){const e=function(e,t,n){const r=[Yr("^"===t[1],t)];let s,i=1;for(Wr.lastIndex=n;s=Wr.exec(e);){const e=s[0];if("["===e[0]&&":"!==e[1])i++,r.push(Yr("^"===e[1],e));else if("]"===e){if("CharacterClassOpen"===r.at(-1).type)r.push(Zr(93,e));else if(i--,r.push(Jr(e)),!i)break}else{const t=qr(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:Wr.lastIndex||e.length}}(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if("\\"===s){if("AbBGyYzZ".includes(i))return{token:Kr(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:ss(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Qr(n)}}if("K"===i)return{token:ts("keep",n)};if("N"===i||"R"===i)return{token:es("newline",n,{negate:"N"===i})};if("O"===i)return{token:es("any",n)};if("X"===i)return{token:es("text_segment",n)};const e=Vr(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if("("===s){if("*"===i)return{token:ls(n)};if("(?{"===n)throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(")"!==t[r])throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:as(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,"("===n&&!e.captureGroup||"(?:"===n)return{token:rs("group",n)};if("(?>"===n)return{token:rs("atomic",n)};if("(?="===n||"(?!"===n||"(?<="===n||"(?<!"===n)return{token:rs("<"===n[2]?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if("("===n&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:rs("capturing",n,{..."("!==n&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if("(?~|"===n)throw new Error(`Unsupported absence function kind "${n}"`);return{token:rs("absence_repeater",n)}}throw"(?("===n?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(")"===n){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:ns(n)}}if(e.getCurrentModX()){if("#"===n){const e=t.indexOf("\n",r);return{lastIndex:-1===e?t.length:e}}if(/^\s$/.test(n)){const e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}if("."===n)return{token:es("dot",n)};if("^"===n||"$"===n){return{token:Kr(e.singleline?{"^":Or`\A`,$:Or`\Z`}[n]:n,n)}}return"|"===n?{token:Xr(n)}:Fr.test(n)?{tokens:ps(n)}:{token:Zr(Mr(n),n)}}function qr(e){if("\\"===e[0])return Vr(e,{inCharClass:!0});if("["===e[0]){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!$r.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return es("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return"-"===e?function(e){return{type:"CharacterClassHyphen",raw:e}}(e):"&&"===e?function(e){return{type:"CharacterClassIntersector",raw:e}}(e):Zr(Mr(e),e)}function Vr(e,{inCharClass:t}){const n=e[1];if("c"===n||"C"===n)return function(e){const t="c"===e[1]?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Zr(Mr(t.toUpperCase())-64,e)}(e);if("dDhHsSwW".includes(n))return function(e){const t=e[1].toLowerCase();return es({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}(e);if(e.startsWith(Or`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(3===e.length)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return function(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return es("property",e,{value:r,negate:"P"===t&&!n||"p"===t&&!!n})}(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{const t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join("");return Zr(Mr(e),t)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if("u"===n||"x"===n)return Zr(function(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t="{"===e[2]?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}(e),e);if(os.has(n))return Zr(os.get(n),e);if(/\d/.test(n))return function(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}(t,e);if("\\"===e)throw new Error(Or`Incomplete escape "\"`);if("M"===n)throw new Error(`Unsupported meta "${e}"`);if(2===[...e].length)return Zr(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Xr(e){return{type:"Alternator",raw:e}}function Kr(e,t){return{type:"Assertion",kind:e,raw:t}}function Qr(e){return{type:"Backreference",raw:e}}function Zr(e,t){return{type:"Character",value:e,raw:t}}function Jr(e){return{type:"CharacterClassClose",raw:e}}function Yr(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function es(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function ts(e,t,n={}){return"keep"===e?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Gr(n.flags),raw:t}}function ns(e){return{type:"GroupClose",raw:e}}function rs(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function ss(e){return{type:"Subroutine",raw:e}}const is=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),os=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function as(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";const s=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),i=us(n),o=us(r),a={};if(i&&(a.enable=i),o&&(a.disable=o),e.endsWith(")"))return t.replaceCurrentModX(s),ts("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(s),t.numOpenGroups++,rs("group",e,{...(i||o)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function ls(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:s}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(""===r)throw new Error(`Named callout tag with empty value not allowed "${e}"`);const i=s?s.split(",").filter(e=>""!==e).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,a,l]=i,c=is.has(n)?n.toLowerCase():"custom";switch(c){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("string"==typeof o)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("string"==typeof o&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(2===i.length&&("number"==typeof a||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(i.length>1)throw new Error(`Named callout allows only one argument "${i}"`);if(1===i.length&&("number"==typeof o||!/^[<>X]$/.test(o)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case"cmp":if(3!==i.length)throw new Error(`Named callout must have three arguments "${i}"`);if("string"==typeof o&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if("number"==typeof a||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if("string"==typeof l&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return function(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}(c,r??null,s?.split(",")??null,e)}function cs(e){let t,n,r=null;if("{"===e[0]){const{minStr:s,maxStr:i}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+s>o||i&&+i>o)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+s,n=void 0===i?+s:""===i?1/0:+i,t>n&&(r="possessive",[t,n]=[n,t]),e.endsWith("?")){if("possessive"===r)throw new Error('Unsupported possessive interval quantifier chain with "?"');r="lazy"}else r||(r="greedy")}else t="+"===e[0]?1:0,n="?"===e[0]?1:1/0,r="+"===e[1]?"possessive":"?"===e[1]?"lazy":"greedy";return function(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}(r,t,n,e)}function us(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function ps(e){const t=[],n=new RegExp(Fr,"gy");let r;for(;r=n.exec(e);){const e=r[0];if("{"===e[0]){const r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){const{min:s,max:i}=r.groups;if(+s>+i&&e.endsWith("?")){n.lastIndex--,t.push(cs(e.slice(0,-1)));continue}}}t.push(cs(e))}return t}function hs(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(1!==e.body.length)return!1;const n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}const ds=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function ms(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=zr(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(e,t)=>{const n=r.tokens[i.nextIndex];switch(i.parent=e,i.nextIndex++,n.type){case"Alternator":return ks();case"Assertion":return gs(n);case"Backreference":return function({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),s=(n,r=!1)=>{const s=t.capturingGroups.length;let i=!1;if(n>s){if(!t.skipBackrefValidation)throw new Error(`Not enough capturing groups defined to the left "${e}"`);i=!0}return t.hasNumberedRef=!0,ws(r?s+1-n:n,{orphan:i})};if(n){const n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return s(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return ws(r)}return s(+r)}(n,i);case"Character":return _s(n.value,{useLastValid:!!t.isCheckingRangeEnd});case"CharacterClassHyphen":return function(e,t,n){const{tokens:r,walk:s}=t,i=t.parent,o=i.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&"CharacterClass"!==o.type&&"CharacterClassRange"!==o.type&&a&&"CharacterClassOpen"!==a.type&&"CharacterClassClose"!==a.type&&"CharacterClassIntersector"!==a.type){const e=s(i,{...n,isCheckingRangeEnd:!0});if("Character"===o.type&&"Character"===e.type)return i.body.pop(),function(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}(o,e);throw new Error("Invalid character class range")}return _s(Mr("-"))}(0,i,t);case"CharacterClassOpen":return function({negate:e},t,n){const{tokens:r,walk:s}=t,i=r[t.nextIndex],o=[Ss()];let a=$s(i);for(;"CharacterClassClose"!==a.type;){if("CharacterClassIntersector"===a.type)o.push(Ss()),t.nextIndex++;else{const e=o.at(-1);e.body.push(s(e,n))}a=$s(r[t.nextIndex],i)}const l=Ss({negate:e});return 1===o.length?l.body=o[0].body:(l.kind="intersection",l.body=o.map(e=>1===e.body.length?e.body[0]:e)),t.nextIndex++,l}(n,i,t);case"CharacterSet":return fs(n,i);case"Directive":return xs(n.kind,{flags:n.flags});case"GroupOpen":return function(e,t,n){const{tokens:r,capturingGroups:s,namedGroupsByName:i,skipLookbehindValidation:o,walk:a}=t,l=function({flags:e,kind:t,name:n,negate:r,number:s}){switch(t){case"absence_repeater":return function(e,t){return{type:"AbsenceFunction",kind:e,body:Is(t?.body)}}("repeater");case"atomic":return Ns({atomic:!0});case"capturing":return Cs(s,{name:n});case"group":return Ns({flags:e});case"lookahead":case"lookbehind":return As({behind:"lookbehind"===t,negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}(e),c="AbsenceFunction"===l.type,u=Ts(l),p=u&&l.negate;if("CapturingGroup"===l.type&&(s.push(l),l.name&&function(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}(i,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let h=Os(r[t.nextIndex]);for(;"GroupClose"!==h.type;){if("Alternator"===h.type)l.body.push(ks()),t.nextIndex++;else{const e=l.body.at(-1),t=a(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||p});if(e.body.push(t),(u||n.isInLookbehind)&&!o){const e="Lookbehind includes a pattern not allowed by Oniguruma";if(p||n.isInNegLookbehind){if(Rs(t)||"CapturingGroup"===t.type)throw new Error(e)}else if(Rs(t)||Ts(t)&&t.negate)throw new Error(e)}}h=Os(r[t.nextIndex])}return t.nextIndex++,l}(n,i,t);case"NamedCallout":return function(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}(n.kind,n.tag,n.arguments);case"Quantifier":return ys(n,i);case"Subroutine":return function({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let s=e.slice(3,-1);const i=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(i){const e=+i.groups.num,r=n.length;if(t.hasNumberedRef=!0,s={"":e,"+":r+e,"-":r+1-e}[i.groups.sign],s<1)throw new Error("Invalid subroutine number")}else"0"===s&&(s=0);const o=Es(s);return r.push(o),o}(n,i);default:throw new Error(`Unexpected token type "${n.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=function(e,t){return{type:"Regex",body:Is(t?.body),flags:e}}(function(e){return{type:"Flags",...e}}(r.flags));let a=o.body[0];for(;i.nextIndex<r.tokens.length;){const e=s(a,{});"Alternative"===e.type?(o.body.push(e),a=e):a.body.push(e)}const{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:p}=i;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:e}of p)if("number"==typeof e){if(e>l.length)throw new Error("Subroutine uses a group number that's not defined");e&&(l[e-1].isSubroutined=!0)}else{if(!u.has(e))throw new Error(Or`Subroutine uses a group name that's not defined "\g<${e}>"`);if(u.get(e).length>1)throw new Error(Or`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}return o}function gs({kind:e}){return bs(Gr({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===Or`\B`||e===Or`\Y`})}function fs({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:i,unicodePropertyMap:o}=r;if("property"===e){const r=Ms(n);if(!$r.has(r)||o?.has(r))return Ls(n,{negate:t,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:i,unicodePropertyMap:o});e="posix",n=r}return"posix"===e?function(e,t){const n=!!t?.negate;if(!$r.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}(n,{negate:t}):vs(e,{negate:t})}function ys({kind:e,min:t,max:n},r){const s=r.parent,i=s.body.at(-1);if(!i||!function(e){return ds.has(e.type)}(i))throw new Error("Quantifier requires a repeatable token");const o=js(e,t,n,i);return s.body.pop(),o}function ks(e){return{type:"Alternative",body:Ps(e?.body)}}function bs(e,t){const n={type:"Assertion",kind:e};return("word_boundary"===e||"text_segment_boundary"===e)&&(n.negate=!!t?.negate),n}function ws(e,t){const n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function Cs(e,t){const n={name:void 0,isSubroutined:!1,...t};if(void 0!==n.name&&!function(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Is(t?.body)}}function _s(e,t){const n={useLastValid:!1,...t};if(e>1114111){const t=e.toString(16);if(!n.useLastValid)throw e>1310719?new Error(`Invalid code point out of range "\\x{${t}}"`):new Error(`Invalid code point out of range in JS "\\x{${t}}"`);e=1114111}return{type:"Character",value:e}}function Ss(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Ps(e?.body)}}function vs(e,t){const n=!!t?.negate,r={type:"CharacterSet",kind:e};return("digit"===e||"hex"===e||"newline"===e||"space"===e||"word"===e)&&(r.negate=n),("text_segment"===e||"newline"===e&&!n)&&(r.variableLength=!0),r}function xs(e,t={}){if("keep"===e)return{type:"Directive",kind:e};if("flags"===e)return{type:"Directive",kind:e,flags:Gr(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function Ns(e){const t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:Is(e?.body)}}function As(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Is(e?.body)}}function js(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function Es(e){return{type:"Subroutine",ref:e}}function Ls(e,t){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=n.unicodePropertyMap?.get(Ms(e));if(!r)if(n.normalizeUnknownPropertyNames)r=function(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Or`Invalid Unicode property "\p{${e}}"`);return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function Is(e){if(void 0===e)e=[ks()];else if(!Array.isArray(e)||!e.length||!e.every(e=>"Alternative"===e.type))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Ps(e){if(void 0===e)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return e}function Rs(e){return"LookaroundAssertion"===e.type&&"lookahead"===e.kind}function Ts(e){return"LookaroundAssertion"===e.type&&"lookbehind"===e.kind}function Ms(e){return e.replace(/[- _]+/g,"").toLowerCase()}function $s(e,t){return Gr(e,("Character"===t?.type&&93===t.value?"Empty":"Unclosed")+" character class")}function Os(e){return Gr(e,"Unclosed group")}function Gs(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){const r=s(e[n],t,n,e);n=Math.max(-1,n+r)}}function s(i,o=null,a=null,l=null){let c=0,u=!1;const p={node:i,parent:o,key:a,container:l,root:e,remove(){Ds(l).splice(Math.max(0,Bs(a)+c),1),c--,u=!0},removeAllNextSiblings:()=>Ds(l).splice(Bs(a)+1),removeAllPrevSiblings(){const e=Bs(a)+c;return c-=e,Ds(l).splice(0,Math.max(0,e))},replaceWith(e,t={}){const n=!!t.traverse;l?l[Math.max(0,Bs(a)+c)]=e:Gr(o,"Can't replace root node")[a]=e,n&&s(e,o,a,l),u=!0},replaceWithMultiple(e,t={}){const n=!!t.traverse;if(Ds(l).splice(Math.max(0,Bs(a)+c),1,...e),c+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=s(e[n],o,Bs(a)+n+t,l)}u=!0},skip(){u=!0}},{type:h}=i,d=t["*"],m=t[h],g="function"==typeof d?d:d?.enter,f="function"==typeof m?m:m?.enter;if(g?.(p,n),f?.(p,n),!u)switch(h){case"AbsenceFunction":case"CapturingGroup":case"Group":case"Alternative":case"CharacterClass":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 "${h}"`)}return m?.exit?.(p,n),d?.exit?.(p,n),c}return s(e),e}function Ds(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Bs(e){if("number"!=typeof e)throw new Error("Numeric key expected");return e}const Fs=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Us(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Ws(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const zs=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Hs(e,t,n,r){const s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),i=[!1];let o=0,a="";for(const t of e.matchAll(s)){const{0:e,groups:{$skip:s}}=t;s||r&&r===zs.DEFAULT!=!o?("["===e[0]?(o++,i.push("^"===e[1])):"]"===e&&o&&(o--,i.pop()),a+=e):a+=n instanceof Function?n(t,{context:o?zs.CHAR_CLASS:zs.DEFAULT,negated:i[i.length-1]}):n}return a}function qs(e,t,n,r){Hs(e,t,n,r)}function Vs(e,t,n){return!!function(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let i,o=0;for(;i=s.exec(e);){const{0:e,groups:{$skip:t}}=i;if(!(t||r&&r===zs.DEFAULT!=!o))return i;"["===e?o++:"]"===e&&o&&o--,s.lastIndex==i.index&&s.lastIndex++}return null}(e,t,0,n)}function Xs(e,t){const n=/\\?./gsu;n.lastIndex=t;let r,s=e.length,i=0,o=1;for(;r=n.exec(e);){const[e]=r;if("["===e)i++;else if(i)"]"===e&&i--;else if("("===e)o++;else if(")"===e&&(o--,!o)){s=r.index;break}}return e.slice(t,s)}const Ks=new RegExp(String.raw`(?<noncapturingStart>${Fs})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");const Qs=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Zs=new RegExp(String.raw`
|
|
41
41
|
\\(?: \d+
|
|
42
42
|
| c[A-Za-z]
|
|
43
43
|
| [gk]<[^>]+>
|
|
@@ -50,6 +50,6 @@ import{$isCodeNode as e,$createCodeHighlightNode as t,CodeExtension as n,DEFAULT
|
|
|
50
50
|
| [A-Za-z\-]+:
|
|
51
51
|
| \(DEFINE\)
|
|
52
52
|
))?
|
|
53
|
-
| (?<qBase>${
|
|
53
|
+
| (?<qBase>${Qs})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
54
54
|
| \\?.
|
|
55
|
-
`.replace(/\s+/g,""),"gsu");const Zs=String.raw,Js=Zs`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Ys=Zs`\(\?R=(?<rDepth>[^\)]+)\)|${Js}`,ei=Zs`\(\?<(?![=!])(?<captureName>[^>]+)>`,ti=Zs`${ei}|(?<unnamed>\()(?!\?)`,ni=new RegExp(Zs`${ei}|${Ys}|\(\?|\\?.`,"gsu"),ri="Cannot use multiple overlapping recursions";function si(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if((e=+e)<2||e>100)throw new Error(t)}function ii(e,t,n,r,s,i,o){const a=new Set;r&&Hs(e+t,ei,({groups:{captureName:e}})=>{a.add(e)},zs.DEFAULT);const l=[n,r?a:null,s,i,o];return`${e}${oi(`(?:${e}`,"forward",...l)}(?:)${oi(`${t})`,"backward",...l)}${t}`}function oi(e,t,n,r,s,i,o){const a=e=>"forward"===t?e+2:n-e+2-1;let l="";for(let t=0;t<n;t++){const n=a(t);l+=Ws(e,Zs`${ti}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:a,backref:l}})=>{if(l&&r&&!r.has(l))return e;const c=`_$${n}`;if(a||t){const n=o+i.length+1;return i.push(n),ai(s,n),a?e:`(?<${t}${c}>`}return Zs`\k<${l}${c}>`},zs.DEFAULT)}return l}function ai(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function li(e,t,n,r,s,i){if(e.size&&r){let o=0;Hs(t,ti,()=>o++,zs.DEFAULT);const a=i-o+s,l=new Map;return e.forEach((e,t)=>{const s=(r-o*n)/n,i=o*n,c=t>a+o?t+r:t,u=[];for(const t of e)if(t<=a)u.push(t);else if(t>a+o+s)u.push(t+r);else if(t<=a+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+i+s*e);l.set(c,u)}),l}return e}var ci=String.fromCodePoint,ui=String.raw,pi={flagGroups:(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),unicodeSets:(()=>{try{new RegExp("","v")}catch{return!1}return!0})()};function hi(e,{enable:t,disable:n}){return{dotAll:!(n?.dotAll||!t?.dotAll&&!e.dotAll),ignoreCase:!(n?.ignoreCase||!t?.ignoreCase&&!e.ignoreCase)}}function di(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function mi(e,t){return gi[e]>=gi[t]}pi.bugFlagVLiteralHyphenIsRange=!!pi.unicodeSets&&(()=>{try{new RegExp(ui`[\d\-a]`,"v")}catch{return!0}return!1})(),pi.bugNestedClassIgnoresNegation=pi.unicodeSets&&new RegExp("[[^a]]","v").test("a");var gi={ES2025:2025,ES2024:2024,ES2018:2018},fi={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function yi(e={}){if("[object Object]"!=={}.toString.call(e))throw new Error("Unexpected options");if(void 0!==e.target&&!fi[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return"auto"===t.target&&(t.target=pi.flagGroups?"ES2025":pi.unicodeSets?"ES2024":"ES2018"),t}var ki=new Set([ci(304),ci(305)]),bi=ui`[\p{L}\p{M}\p{N}\p{Pc}]`;function wi(e){if(ki.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),s=vi.get(n),i=_i.get(n),o=Si.get(n);return 1===[...r].length&&t.add(r),o&&t.add(o),s&&t.add(s),t.add(n),i&&t.add(i),[...t]}var Ci=new Map("C Other\nCc Control cntrl\nCf Format\nCn Unassigned\nCo Private_Use\nCs Surrogate\nL Letter\nLC Cased_Letter\nLl Lowercase_Letter\nLm Modifier_Letter\nLo Other_Letter\nLt Titlecase_Letter\nLu Uppercase_Letter\nM Mark Combining_Mark\nMc Spacing_Mark\nMe Enclosing_Mark\nMn Nonspacing_Mark\nN Number\nNd Decimal_Number digit\nNl Letter_Number\nNo Other_Number\nP Punctuation punct\nPc Connector_Punctuation\nPd Dash_Punctuation\nPe Close_Punctuation\nPf Final_Punctuation\nPi Initial_Punctuation\nPo Other_Punctuation\nPs Open_Punctuation\nS Symbol\nSc Currency_Symbol\nSk Modifier_Symbol\nSm Math_Symbol\nSo Other_Symbol\nZ Separator\nZl Line_Separator\nZp Paragraph_Separator\nZs Space_Separator\nASCII\nASCII_Hex_Digit AHex\nAlphabetic Alpha\nAny\nAssigned\nBidi_Control Bidi_C\nBidi_Mirrored Bidi_M\nCase_Ignorable CI\nCased\nChanges_When_Casefolded CWCF\nChanges_When_Casemapped CWCM\nChanges_When_Lowercased CWL\nChanges_When_NFKC_Casefolded CWKCF\nChanges_When_Titlecased CWT\nChanges_When_Uppercased CWU\nDash\nDefault_Ignorable_Code_Point DI\nDeprecated Dep\nDiacritic Dia\nEmoji\nEmoji_Component EComp\nEmoji_Modifier EMod\nEmoji_Modifier_Base EBase\nEmoji_Presentation EPres\nExtended_Pictographic ExtPict\nExtender Ext\nGrapheme_Base Gr_Base\nGrapheme_Extend Gr_Ext\nHex_Digit Hex\nIDS_Binary_Operator IDSB\nIDS_Trinary_Operator IDST\nID_Continue IDC\nID_Start IDS\nIdeographic Ideo\nJoin_Control Join_C\nLogical_Order_Exception LOE\nLowercase Lower\nMath\nNoncharacter_Code_Point NChar\nPattern_Syntax Pat_Syn\nPattern_White_Space Pat_WS\nQuotation_Mark QMark\nRadical\nRegional_Indicator RI\nSentence_Terminal STerm\nSoft_Dotted SD\nTerminal_Punctuation Term\nUnified_Ideograph UIdeo\nUppercase Upper\nVariation_Selector VS\nWhite_Space space\nXID_Continue XIDC\nXID_Start XIDS".split(/\s/).map(e=>[Ts(e),e])),_i=new Map([["s",ci(383)],[ci(383),"s"]]),Si=new Map([[ci(223),ci(7838)],[ci(107),ci(8490)],[ci(229),ci(8491)],[ci(969),ci(8486)]]),vi=new Map([Ni(453),Ni(456),Ni(459),Ni(498),...Ai(8072,8079),...Ai(8088,8095),...Ai(8104,8111),Ni(8124),Ni(8140),Ni(8188)]),xi=new Map([["alnum",ui`[\p{Alpha}\p{Nd}]`],["alpha",ui`\p{Alpha}`],["ascii",ui`\p{ASCII}`],["blank",ui`[\p{Zs}\t]`],["cntrl",ui`\p{Cc}`],["digit",ui`\p{Nd}`],["graph",ui`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",ui`\p{Lower}`],["print",ui`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",ui`[\p{P}\p{S}]`],["space",ui`\p{space}`],["upper",ui`\p{Upper}`],["word",ui`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",ui`\p{AHex}`]]);function Ni(e){const t=ci(e);return[t.toLowerCase(),t]}function Ai(e,t){return function(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}(e,t).map(e=>Ni(e))}var ji=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var Ei={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:s}=e;if("repeater"!==s)throw new Error('Unsupported absence function "(?~|"');{const e=xs();e.body[0].body.push(Ns({negate:!0,body:r}),Es("Any"));const s=xs();s.body[0].body.push(As("greedy",0,1/0,e)),n(Hi(s,t),{traverse:!0})}},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const s=e.body.filter(e=>"flags"===e.kind);for(let e=n+1;e<t.body.length;e++){di(r,t.body[e],[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){const n=$i(t.get(e));if(n){const t=xs({flags:n});t.body[0].body=e.body,e.body=[Hi(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:s,remove:i,replaceWith:o},a){const{kind:l,negate:c}=e,{asciiWordBoundaries:u,avoidSubclass:p,supportedGNodes:h,wordIsAscii:d}=a;if("text_segment_boundary"===l)throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if("line_end"===l)o(Hi(Ns({body:[ys({body:[ks("string_end")]}),ys({body:[Cs(10)]})]}),t));else if("line_start"===l)o(Hi(Ui(ui`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if("search_start"===l)if(h.has(e))s.flags.sticky=!0,i();else{const e=r[n-1];if(e&&function(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||"Quantifier"===e.type&&e.min&&t.includes(e.body.type)}(e))o(Hi(Ns({negate:!0}),t));else{if(p)throw new Error(ui`Uses "\G" in a way that requires a subclass`);o(Wi(ks("string_start"),t)),a.strategy="clip_search"}}else if("string_end"===l||"string_start"===l);else if("string_end_newline"===l)o(Hi(Ui(ui`(?=\n?\z)`),t));else{if("word_boundary"!==l)throw new Error(`Unexpected assertion kind "${l}"`);if(!d&&!u){o(Hi(Ui(c?`(?:(?<=${bi})(?=${bi})|(?<!${bi})(?!${bi}))`:`(?:(?<=${bi})(?!${bi})|(?<!${bi})(?=${bi}))`),t))}}},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;"string"!=typeof n||Fi(n)||(n=Mi(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Fi(r)&&(r=Mi(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if("intersection"===t.kind){n(Hi(_s({body:[e]}),t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:i,spaceIsAscii:o,wordIsAscii:a}){const{kind:l,negate:c,value:u}=e;if(!i||"digit"!==l&&"digit"!==u)if(!o||"space"!==l&&"space"!==u)if(!a||"word"!==l&&"word"!==u)if("any"===l)n(Wi(Es("Any"),t));else if("digit"===l)n(Wi(Es("Nd",{negate:c}),t));else if("dot"===l);else if("text_segment"===l){if("strict"===r)throw new Error(ui`Use of "\X" requires non-strict accuracy`);const e="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",i=ui`\p{RI}{2}|${e}(?:\u200D${e})*`;n(Hi(Ui(ui`(?>\r\n|${s?ui`\p{RGI_Emoji}`:i}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if("hex"===l)n(Wi(Es("AHex",{negate:c}),t));else if("newline"===l)n(Hi(Ui(c?"[^\n]":"(?>\r\n?|[\n\v\f
\u2028\u2029])"),t));else if("posix"===l)if(s||"graph"!==u&&"print"!==u)n(Hi(zi(Ui(xi.get(u)),c),t));else{if("strict"===r)throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:"!-~",print:" -~"}[u];c&&(e=`\0-${ci(e.codePointAt(0)-1)}${ci(e.codePointAt(2)+1)}-`),n(Hi(Ui(`[${e}]`),t))}else if("property"===l)Ci.has(Ts(u))||(e.key="sc");else if("space"===l)n(Wi(Es("space",{negate:c}),t));else{if("word"!==l)throw new Error(`Unexpected character set kind "${l}"`);n(Hi(zi(Ui(bi),c),t))}else n(Wi(Ss("word",{negate:c}),t));else n(Hi(zi(Ui("[\t-\r ]"),c),t));else n(Wi(Ss("digit",{negate:c}),t))},Directive({node:e,parent:t,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:i,removeAllNextSiblings:o}){const{kind:a,flags:l}=e;if("flags"===a)if(l.enable||l.disable){const e=xs({flags:l});e.body[0].body=o(),s(Hi(e,t),{traverse:!0})}else r();else{if("keep"!==a)throw new Error(`Unexpected directive kind "${a}"`);{const e=n.body[0],r=1===n.body.length&&ps(e,{type:"Group"})&&1===e.body[0].body.length?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw new Error(ui`Uses "\K" in a way that's unsupported`);const o=Ns({behind:!0});o.body[0].body=i(),s(Hi(o,t))}}},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if("word"===e.textSegmentMode)throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;"lookbehind"===n&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if("fail"!==r)throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`);n(Hi(Ns({negate:!0}),t))},Quantifier({node:e}){if("Quantifier"===e.body.type){const t=xs();t.body[0].body.push(e.body),e.body=Hi(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,s=!1;for(const t of e.body)if(1===t.body.length&&"search_start"===t.body[0].kind)t.body.pop();else{const e=Di(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):s=!0}r&&!s&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if("strict"===t&&n&&r)throw new Error(ui`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;"string"!=typeof n||Fi(n)||(n=Mi(n,t),e.ref=n)}},Li={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=e;r||n.set(e,[...t.get(s).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:i,multiplexCapturesToLeftByRef:o,openRefs:a,reffedNodesByReferencer:l}){const c=s.get(e);if(c&&a.has(e.number)){const r=Wi(Ti(e.number),t);return l.set(r,a.get(e.number)),void n(r)}a.set(e.number,e),o.set(e.number,[]),e.name&&di(o,e.name,[]);const u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){const n=u[t];if(c===n.node||c&&c===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:c}),e.name&&o.get(e.name).push({node:e,origin:c}),e.name){const t=di(i,e.name,new Map);let n=!1;if(c)n=!0;else for(const e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}i.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=hi(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:s,ref:i}=e;if(s){let n=t;for(;(n=n.parent)&&("CapturingGroup"!==n.type||n.name!==i&&n.number!==i););return void r.reffedNodesByReferencer.set(e,n)}const o=r.subroutineRefMap.get(i),a=0===i,l=a?Ti(0):Ri(o,r.groupOriginByCopy,null);let c=l;if(!a){const e=$i(function(e,t){const n=[];for(;e=e.parent;)t&&!t(e)||n.push(e);return n}(o,e=>"Group"===e.type&&!!e.flags)),t=e?hi(r.globalFlags,e):r.globalFlags;(function(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase})(t,r.currentFlags)||(c=xs({flags:Oi(t)}),c.body[0].body.push(l))}n(Hi(c,t),{traverse:!a})}},Ii={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan)return void(r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref));const s=r.reffedNodesByReferencer.get(e).filter(t=>function(e,t){let n=t;do{if("Regex"===n.type)return!1;if("Alternative"===n.type)continue;if(n===e)return!1;const t=Gi(n.parent);for(const r of t){if(r===n)break;if(r===e||Bi(r,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}(t,e));if(s.length)if(s.length>1){n(Hi(xs({atomic:!0,body:s.reverse().map(e=>ys({body:[bs(e.number)]}))}),t))}else e.ref=s[0].number;else n(Hi(Ns({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){const t=ws();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){e.isRecursive&&0!==e.ref&&(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Pi(e){Os(e,{"*"({node:e,parent:t}){e.parent=t}})}function Ri(e,t,n,r){const s=Array.isArray(e)?[]:{};for(const[i,o]of Object.entries(e))"parent"===i?s.parent=Array.isArray(n)?r:n:o&&"object"==typeof o?s[i]=Ri(o,t,s,n):("type"===i&&"CapturingGroup"===o&&t.set(s,t.get(e)??e),s[i]=o);return s}function Ti(e){const t=js(e);return t.isRecursive=!0,t}function Mi(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,"_")}`;return t.set(e,n),n}function $i(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Oi({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),e&&t||(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Gi(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Di(e){const t=e.find(e=>"search_start"===e.kind||function(e,t){const n={negate:null,...t};return"LookaroundAssertion"===e.type&&(null===n.negate||e.negate===n.negate)&&1===e.body.length&&ps(e.body[0],{type:"Assertion",kind:"search_start"})}(e,{negate:!1})||!function({type:e}){return"Assertion"===e||"Directive"===e||"LookaroundAssertion"===e}(e));if(!t)return null;if("search_start"===t.kind)return t;if("LookaroundAssertion"===t.type)return t.body[0].body[0];if("CapturingGroup"===t.type||"Group"===t.type){const e=[];for(const n of t.body){const t=Di(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Bi(e,t){const n=Gi(e)??[];for(const e of n)if(e===t||Bi(e,t))return!0;return!1}function Fi(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Ui(e,t){const n=ds(e,{...t,unicodePropertyMap:Ci}).body;return n.length>1||n[0].body.length>1?xs({body:n}):n[0].body[0]}function zi(e,t){return e.negate=t,e}function Wi(e,t){return e.parent=t,e}function Hi(e,t){return Pi(e),e.parent=t,e}function qi(e,t){const n=yi(t),r=mi(n.target,"ES2024"),s=mi(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,a=null;if(!s){const t=[e.flags.ignoreCase];Os(e,Vi,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:a=!0}})}const l={dotAll:e.flags.dotAll,ignoreCase:!(!e.flags.ignoreCase&&!o||a)};let c=e;const u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:i,useAppliedIgnoreCase:!(s||!o||!a),useFlagMods:s,useFlagV:r,verbose:n.verbose};function p(e){u.lastNode=c,c=e;return function(e,t){if(null==e)throw new Error(t??"Value expected");return e}(Xi[e.type],`Unexpected node type "${e.type}"`)(e,u,p)}const h={pattern:e.body.map(p).join("|"),flags:p(e.flags),options:{...e.options}};return r||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&h._hiddenCaptures.push(t),e.transferTo&&di(h._captureTransfers,e.transferTo,[]).push(t)}),h}var Vi={"*":{enter({node:e},t){if(ro(e)){const n=t.getCurrentModI();t.pushModI(e.flags?hi({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){ro(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){eo(ci(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),to(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){"property"===e.kind&&ji.has(e.value)&&t.setHasCasedChar()}},Xi={Alternative:({body:e},t,n)=>e.map(n).join(""),Assertion({kind:e,negate:t}){if("string_end"===e)return"$";if("string_start"===e)return"^";if("word_boundary"===e)return t?ui`\B`:ui`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if("number"!=typeof e)throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&"strict"===t.accuracy&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:s,number:i}=e,o={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(o.hidden=!0,i>a.number&&(o.transferTo=a.number)),t.captureMap.set(i,o),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=ci(e),r=no(e,{escDigit:"Backreference"===t.lastNode.type,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&eo(n)){const e=wi(n);return t.inCharClass?e.join(""):e.length>1?`[${e.join("")}]`:e[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:s,parent:i}=e;let{body:o}=e;if("intersection"===r&&!t.useFlagV)throw new Error("Use of class intersection requires min target ES2024");pi.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(so)&&(o=[Cs(45),...o.filter(e=>!so(e))]);const a=()=>`[${s?"^":""}${o.map(n).join("intersection"===r?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||pi.bugNestedClassIgnoresNegation)&&!s){const t=o.filter(e=>"CharacterClass"===e.type&&"union"===e.kind&&e.negate);if(t.length){const r=xs(),s=r.body[0];return r.parent=i,s.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=s,s.body.push(e)):r.body.pop(),t.forEach(e=>{const t=ys({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;const r=a();return t.inCharClass=!1,r}const l=o[0];if("union"===r&&!s&&l&&((!t.useFlagV||!t.verbose)&&"union"===i.kind&&(!pi.bugFlagVLiteralHyphenIsRange||!t.useFlagV)||!t.verbose&&"intersection"===i.kind&&1===o.length&&"CharacterClassRange"!==l.type))return o.map(n).join("");if(!t.useFlagV&&"CharacterClass"===i.type)throw new Error("Use of nested character class requires min target ES2024");return a()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},i=no(n,s),o=no(r,s),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const t=function(e){const t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[];let r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:null===r?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}(to(e));t.forEach(e=>{a.add(Array.isArray(e)?`${no(e[0],s)}-${no(e[1],s)}`:no(e,s))})}return`${i}-${o}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},s){if("dot"===e)return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":ui`[^\n]`;if("digit"===e)return t?ui`\D`:ui`\d`;if("property"===e){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&ji.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?ui`\P`:ui`\p`}{${r?`${r}=`:""}${n}}`}if("word"===e)return t?ui`\W`:ui`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags:(e,t)=>(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":""),Group({atomic:e,body:t,flags:n,parent:r},s,i){const o=s.currentFlags;n&&(s.currentFlags=hi(o,n));const a=t.map(i).join("|"),l=s.verbose||1!==t.length||"Quantifier"===r.type||e||s.useFlagMods&&n?`(?${function(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:e,disable:n}=t;r=(e?.ignoreCase?"i":"")+(e?.dotAll?"s":"")+(n?"-":"")+(n?.ignoreCase?"i":"")+(n?.dotAll?"s":"")}return`${r}:`}(e,n,s.useFlagMods)}${a})`:a;return s.currentFlags=o,l},LookaroundAssertion:({body:e,kind:t,negate:n},r,s)=>`(?${`${"lookahead"===t?"":"<"}${n?"!":"="}`}${e.map(s).join("|")})`,Quantifier:(e,t,n)=>n(e.body)+function({kind:e,max:t,min:n}){let r;r=n||1!==t?n||t!==1/0?1===n&&t===1/0?"+":n===t?`{${n}}`:`{${n},${t===1/0?"":t}}`:"*":"?";return r+{greedy:"",lazy:"?",possessive:"+"}[e]}(e),Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return 0===t?`(?R=${r})`:ui`\g<${t}&R=${r}>`}},Ki=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Qi=new Set(["-","\\","]","^","["]),Zi=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Ji=new Map([[9,ui`\t`],[10,ui`\n`],[11,ui`\v`],[12,ui`\f`],[13,ui`\r`],[8232,ui`\u2028`],[8233,ui`\u2029`],[65279,ui`\uFEFF`]]),Yi=/^\p{Cased}$/u;function eo(e){return Yi.test(e)}function to(e,t){const n=!!t?.firstOnly,r=e.min.value,s=e.max.value,i=[];if(r<65&&(65535===s||s>=131071)||65536===r&&s>=131071)return i;for(let e=r;e<=s;e++){const t=ci(e);if(!eo(t))continue;const o=wi(t).filter(e=>{const t=e.codePointAt(0);return t<r||t>s});if(o.length&&(i.push(...o),n))break}return i}function no(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Ji.has(e))return Ji.get(e);if(e<32||e>126&&e<160||e>262143||t&&((s=e)>47&&s<58))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;var s;const i=n?r?Zi:Qi:Ki,o=ci(e);return(i.has(o)?"\\":"")+o}function ro({type:e}){return"CapturingGroup"===e||"Group"===e||"LookaroundAssertion"===e}function so({type:e,value:t}){return"Character"===e&&45===t}var io=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#s=null;rawOptions={};get source(){return this.#n||"(?:)"}constructor(t,n,r){const s=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const s=t;super(s,n),this.#n=s.source,s instanceof e&&(this.#e=s.#e,this.#r=s.#r,this.#s=s.#s,this.rawOptions=s.rawOptions)}else{const e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":t,n),this.#n=t,this.#e=function(e,t){const n=new Map;for(const t of e)n.set(t,{hidden:!0});for(const[e,r]of t)for(const t of r)di(n,t,{}).transferTo=e;return n}(e.hiddenCaptures,e.transfers),this.#s=e.strategy,this.rawOptions=r??{}}s||(this.#t=this)}exec(t){if(!this.#t){const{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}const n=this.global||this.sticky,r=this.lastIndex;if("clip_search"===this.#s&&n&&r){this.lastIndex=0;const e=this.#i(t.slice(r));return e&&(!function(e,t,n,r){if(e.index+=t,e.input=n,r){const n=e.indices;for(let e=0;e<n.length;e++){const r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}const r=n.groups;r&&Object.keys(r).forEach(e=>{const n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#i(t)}#i(e){this.#t.lastIndex=this.lastIndex;const t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;const n=[...t];let r;t.length=1,this.hasIndices&&(r=[...t.indices],t.indices.length=1);const s=[0];for(let e=1;e<n.length;e++){const{hidden:i,transferTo:o}=this.#e.get(e)??{};if(i?s.push(null):(s.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&void 0!==n[e]){const i=s[o];if(!i)throw new Error(`Invalid capture transfer to "${i}"`);if(t[i]=n[e],this.hasIndices&&(t.indices[i]=r[e]),t.groups){this.#r||(this.#r=oo(this.source));const s=this.#r.get(o);s&&(t.groups[s]=n[e],this.hasIndices&&(t.indices.groups[s]=r[e]))}}}return t}};function oo(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r,s=0,i=0;for(;r=t.exec(e);){const{0:e,groups:{capture:t,name:o}}=r;"["===e?s++:s?"]"===e&&s--:t&&(i++,o&&n.set(i,o))}return n}function ao(e,t){const n=function(e,t){const n=yi(t),r=ds(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Ci}),s=function(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};Pi(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:mi(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Os(e,Ei,r);const s={dotAll:e.flags.dotAll,ignoreCase:e.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};return Os(e,Li,i),Os(e,Ii,{groupsByName:i.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:i.reffedNodesByReferencer}),e._originMap=i.groupOriginByCopy,e._strategy=r.strategy,e}(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=qi(s,n),o=function(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let s=t?.captureTransfers??new Map;if(!new RegExp(Ys,"su").test(e))return{pattern:e,captureTransfers:s,hiddenCaptures:n};if("plugin"===r&&qs(e,Zs`\(\?\(DEFINE\)`,zs.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const i=[],o=qs(e,Zs`\\[1-9]`,zs.DEFAULT),a=new Map,l=[];let c,u=!1,p=0,h=0;for(ni.lastIndex=0;c=ni.exec(e);){const{0:t,groups:{captureName:d,rDepth:m,gRNameOrNum:g,gRDepth:f}}=c;if("["===t)p++;else if(p)"]"===t&&p--;else{if(m){if(si(m),u)throw new Error(ri);if(o)throw new Error(("external"===r?"Backrefs":"Numbered backrefs")+" cannot be used with global recursion");const t=e.slice(0,c.index),a=e.slice(ni.lastIndex);if(qs(a,Ys,zs.DEFAULT))throw new Error(ri);const l=+m-1;e=ii(t,a,l,!1,n,i,h),s=li(s,t,l,i.length,0,h);break}if(g){si(f);let p=!1;for(const e of l)if(e.name===g||e.num===+g){if(p=!0,e.hasRecursedWithin)throw new Error(ri);break}if(!p)throw new Error(Zs`Recursive \g cannot be used outside the referenced group "${"external"===r?g:Zs`\g<${g}&R=${f}>`}"`);const d=a.get(g),m=Vs(e,d);if(o&&qs(m,Zs`${ei}|\((?!\?)`,zs.DEFAULT))throw new Error(("external"===r?"Backrefs":"Numbered backrefs")+" cannot be used with recursion of capturing groups");const y=e.slice(d,c.index),k=m.slice(y.length+t.length),b=i.length,w=+f-1,C=ii(y,k,w,!0,n,i,h);s=li(s,y,w,i.length-b,b,h);const _=e.slice(0,d),S=e.slice(d+m.length);e=`${_}${C}${S}`,ni.lastIndex+=C.length-t.length-y.length-k.length,l.forEach(e=>e.hasRecursedWithin=!0),u=!0}else if(d)h++,a.set(String(h),ni.lastIndex),a.set(d,ni.lastIndex),l.push({num:h,name:d});else if("("===t[0]){const e="("===t;e&&(h++,a.set(String(h),ni.lastIndex)),l.push(e?{num:h}:{})}else")"===t&&l.pop()}}return n.push(...i),{pattern:e,captureTransfers:s,hiddenCaptures:n}}(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:"external"}),a=function(e,t){const n=t?.hiddenCaptures??[];let r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const s="(?:(?=(",i=[0],o=[];let a,l=0,c=0,u=NaN;do{a=!1;let t,p=0,h=0,d=!1;for(Xs.lastIndex=Number.isNaN(u)?0:u+7;t=Xs.exec(e);){const{0:m,index:g,groups:{capturingStart:f,noncapturingStart:y}}=t;if("["===m)p++;else if(p)"]"===m&&p--;else if("(?>"!==m||d){if(d&&y)h++;else if(f)d?h++:(l++,i.push(l+c));else if(")"===m&&d){if(!h){c++;const t=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+3,g)}))<$$${t}>)${e.slice(g+1)}`,a=!0,o.push(t),Fs(n,t),r.size){const e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}h--}}else u=g,d=!0}}while(a);return n.push(...o),e=Ws(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){const n=+t;if(n>i.length-1)throw new Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},zs.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}(function(e){if(!new RegExp(`${Ks}\\+`).test(e))return{pattern:e};const t=[];let n,r=null,s=null,i="",o=0;for(Qs.lastIndex=0;n=Qs.exec(e);){const{0:a,index:l,groups:{qBase:c,qMod:u,invalidQ:p}}=n;if("["===a)o||(s=l),o++;else if("]"===a)o?o--:s=null;else if(!o)if("+"===u&&i&&!i.startsWith("(")){if(p)throw new Error(`Invalid quantifier "${a}"`);let t=-1;if(/^\{\d+\}$/.test(c))e=Us(e,l+c.length,u,"");else{if(")"===i||"]"===i){const t=")"===i?r:s;if(null===t)throw new Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,l)}${c})${e.slice(l+a.length)}`}else e=`${e.slice(0,l-i.length)}(?>${i}${c})${e.slice(l+a.length)}`;t+=4}Qs.lastIndex+=t}else"("===a[0]?t.push(l):")"===a&&(r=t.length?t.pop():null);i=a}return{pattern:e}}(o.pattern).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 e=a.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(a.captureTransfers),r=s._strategy,i=l.pattern.length>=n.lazyCompileLength;(e.length||t.length||r||i)&&(l.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...r&&{strategy:r},...i&&{lazyCompile:i}})}return l}(e,t);return n.options?new io(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}const lo=4294967295;class co{constructor(e,t={}){this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:s}=t;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if("string"!=typeof e)return e;const t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{const t=s(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}regexps;findNextMatchSync(e,t,n){const r="string"==typeof e?e:e.content,s=[];function i(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>null==e?{start:lo,end:lo,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){const n=this.regexps[e];if(n)try{n.lastIndex=t;const o=n.exec(r);if(!o)continue;if(o.index===t)return i(e,o,0);s.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(s.length){const e=Math.min(...s.map(e=>e[1].index));for(const[t,n,r]of s)if(n.index===e)return i(t,n,r)}return null}}const uo=[{id:"abap",name:"ABAP",import:()=>import("@shikijs/langs/abap")},{id:"actionscript-3",name:"ActionScript",import:()=>import("@shikijs/langs/actionscript-3")},{id:"ada",name:"Ada",import:()=>import("@shikijs/langs/ada")},{id:"angular-html",name:"Angular HTML",import:()=>import("@shikijs/langs/angular-html")},{id:"angular-ts",name:"Angular TypeScript",import:()=>import("@shikijs/langs/angular-ts")},{id:"apache",name:"Apache Conf",import:()=>import("@shikijs/langs/apache")},{id:"apex",name:"Apex",import:()=>import("@shikijs/langs/apex")},{id:"apl",name:"APL",import:()=>import("@shikijs/langs/apl")},{id:"applescript",name:"AppleScript",import:()=>import("@shikijs/langs/applescript")},{id:"ara",name:"Ara",import:()=>import("@shikijs/langs/ara")},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:()=>import("@shikijs/langs/asciidoc")},{id:"asm",name:"Assembly",import:()=>import("@shikijs/langs/asm")},{id:"astro",name:"Astro",import:()=>import("@shikijs/langs/astro")},{id:"awk",name:"AWK",import:()=>import("@shikijs/langs/awk")},{id:"ballerina",name:"Ballerina",import:()=>import("@shikijs/langs/ballerina")},{id:"bat",name:"Batch File",aliases:["batch"],import:()=>import("@shikijs/langs/bat")},{id:"beancount",name:"Beancount",import:()=>import("@shikijs/langs/beancount")},{id:"berry",name:"Berry",aliases:["be"],import:()=>import("@shikijs/langs/berry")},{id:"bibtex",name:"BibTeX",import:()=>import("@shikijs/langs/bibtex")},{id:"bicep",name:"Bicep",import:()=>import("@shikijs/langs/bicep")},{id:"blade",name:"Blade",import:()=>import("@shikijs/langs/blade")},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:()=>import("@shikijs/langs/bsl")},{id:"c",name:"C",import:()=>import("@shikijs/langs/c")},{id:"cadence",name:"Cadence",aliases:["cdc"],import:()=>import("@shikijs/langs/cadence")},{id:"cairo",name:"Cairo",import:()=>import("@shikijs/langs/cairo")},{id:"clarity",name:"Clarity",import:()=>import("@shikijs/langs/clarity")},{id:"clojure",name:"Clojure",aliases:["clj"],import:()=>import("@shikijs/langs/clojure")},{id:"cmake",name:"CMake",import:()=>import("@shikijs/langs/cmake")},{id:"cobol",name:"COBOL",import:()=>import("@shikijs/langs/cobol")},{id:"codeowners",name:"CODEOWNERS",import:()=>import("@shikijs/langs/codeowners")},{id:"codeql",name:"CodeQL",aliases:["ql"],import:()=>import("@shikijs/langs/codeql")},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:()=>import("@shikijs/langs/coffee")},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:()=>import("@shikijs/langs/common-lisp")},{id:"coq",name:"Coq",import:()=>import("@shikijs/langs/coq")},{id:"cpp",name:"C++",aliases:["c++"],import:()=>import("@shikijs/langs/cpp")},{id:"crystal",name:"Crystal",import:()=>import("@shikijs/langs/crystal")},{id:"csharp",name:"C#",aliases:["c#","cs"],import:()=>import("@shikijs/langs/csharp")},{id:"css",name:"CSS",import:()=>import("@shikijs/langs/css")},{id:"csv",name:"CSV",import:()=>import("@shikijs/langs/csv")},{id:"cue",name:"CUE",import:()=>import("@shikijs/langs/cue")},{id:"cypher",name:"Cypher",aliases:["cql"],import:()=>import("@shikijs/langs/cypher")},{id:"d",name:"D",import:()=>import("@shikijs/langs/d")},{id:"dart",name:"Dart",import:()=>import("@shikijs/langs/dart")},{id:"dax",name:"DAX",import:()=>import("@shikijs/langs/dax")},{id:"desktop",name:"Desktop",import:()=>import("@shikijs/langs/desktop")},{id:"diff",name:"Diff",import:()=>import("@shikijs/langs/diff")},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:()=>import("@shikijs/langs/docker")},{id:"dotenv",name:"dotEnv",import:()=>import("@shikijs/langs/dotenv")},{id:"dream-maker",name:"Dream Maker",import:()=>import("@shikijs/langs/dream-maker")},{id:"edge",name:"Edge",import:()=>import("@shikijs/langs/edge")},{id:"elixir",name:"Elixir",import:()=>import("@shikijs/langs/elixir")},{id:"elm",name:"Elm",import:()=>import("@shikijs/langs/elm")},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:()=>import("@shikijs/langs/emacs-lisp")},{id:"erb",name:"ERB",import:()=>import("@shikijs/langs/erb")},{id:"erlang",name:"Erlang",aliases:["erl"],import:()=>import("@shikijs/langs/erlang")},{id:"fennel",name:"Fennel",import:()=>import("@shikijs/langs/fennel")},{id:"fish",name:"Fish",import:()=>import("@shikijs/langs/fish")},{id:"fluent",name:"Fluent",aliases:["ftl"],import:()=>import("@shikijs/langs/fluent")},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:()=>import("@shikijs/langs/fortran-fixed-form")},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:()=>import("@shikijs/langs/fortran-free-form")},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:()=>import("@shikijs/langs/fsharp")},{id:"gdresource",name:"GDResource",import:()=>import("@shikijs/langs/gdresource")},{id:"gdscript",name:"GDScript",import:()=>import("@shikijs/langs/gdscript")},{id:"gdshader",name:"GDShader",import:()=>import("@shikijs/langs/gdshader")},{id:"genie",name:"Genie",import:()=>import("@shikijs/langs/genie")},{id:"gherkin",name:"Gherkin",import:()=>import("@shikijs/langs/gherkin")},{id:"git-commit",name:"Git Commit Message",import:()=>import("@shikijs/langs/git-commit")},{id:"git-rebase",name:"Git Rebase Message",import:()=>import("@shikijs/langs/git-rebase")},{id:"gleam",name:"Gleam",import:()=>import("@shikijs/langs/gleam")},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:()=>import("@shikijs/langs/glimmer-js")},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:()=>import("@shikijs/langs/glimmer-ts")},{id:"glsl",name:"GLSL",import:()=>import("@shikijs/langs/glsl")},{id:"gnuplot",name:"Gnuplot",import:()=>import("@shikijs/langs/gnuplot")},{id:"go",name:"Go",import:()=>import("@shikijs/langs/go")},{id:"graphql",name:"GraphQL",aliases:["gql"],import:()=>import("@shikijs/langs/graphql")},{id:"groovy",name:"Groovy",import:()=>import("@shikijs/langs/groovy")},{id:"hack",name:"Hack",import:()=>import("@shikijs/langs/hack")},{id:"haml",name:"Ruby Haml",import:()=>import("@shikijs/langs/haml")},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:()=>import("@shikijs/langs/handlebars")},{id:"haskell",name:"Haskell",aliases:["hs"],import:()=>import("@shikijs/langs/haskell")},{id:"haxe",name:"Haxe",import:()=>import("@shikijs/langs/haxe")},{id:"hcl",name:"HashiCorp HCL",import:()=>import("@shikijs/langs/hcl")},{id:"hjson",name:"Hjson",import:()=>import("@shikijs/langs/hjson")},{id:"hlsl",name:"HLSL",import:()=>import("@shikijs/langs/hlsl")},{id:"html",name:"HTML",import:()=>import("@shikijs/langs/html")},{id:"html-derivative",name:"HTML (Derivative)",import:()=>import("@shikijs/langs/html-derivative")},{id:"http",name:"HTTP",import:()=>import("@shikijs/langs/http")},{id:"hxml",name:"HXML",import:()=>import("@shikijs/langs/hxml")},{id:"hy",name:"Hy",import:()=>import("@shikijs/langs/hy")},{id:"imba",name:"Imba",import:()=>import("@shikijs/langs/imba")},{id:"ini",name:"INI",aliases:["properties"],import:()=>import("@shikijs/langs/ini")},{id:"java",name:"Java",import:()=>import("@shikijs/langs/java")},{id:"javascript",name:"JavaScript",aliases:["js"],import:()=>import("@shikijs/langs/javascript")},{id:"jinja",name:"Jinja",import:()=>import("@shikijs/langs/jinja")},{id:"jison",name:"Jison",import:()=>import("@shikijs/langs/jison")},{id:"json",name:"JSON",import:()=>import("@shikijs/langs/json")},{id:"json5",name:"JSON5",import:()=>import("@shikijs/langs/json5")},{id:"jsonc",name:"JSON with Comments",import:()=>import("@shikijs/langs/jsonc")},{id:"jsonl",name:"JSON Lines",import:()=>import("@shikijs/langs/jsonl")},{id:"jsonnet",name:"Jsonnet",import:()=>import("@shikijs/langs/jsonnet")},{id:"jssm",name:"JSSM",aliases:["fsl"],import:()=>import("@shikijs/langs/jssm")},{id:"jsx",name:"JSX",import:()=>import("@shikijs/langs/jsx")},{id:"julia",name:"Julia",aliases:["jl"],import:()=>import("@shikijs/langs/julia")},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:()=>import("@shikijs/langs/kotlin")},{id:"kusto",name:"Kusto",aliases:["kql"],import:()=>import("@shikijs/langs/kusto")},{id:"latex",name:"LaTeX",import:()=>import("@shikijs/langs/latex")},{id:"lean",name:"Lean 4",aliases:["lean4"],import:()=>import("@shikijs/langs/lean")},{id:"less",name:"Less",import:()=>import("@shikijs/langs/less")},{id:"liquid",name:"Liquid",import:()=>import("@shikijs/langs/liquid")},{id:"llvm",name:"LLVM IR",import:()=>import("@shikijs/langs/llvm")},{id:"log",name:"Log file",import:()=>import("@shikijs/langs/log")},{id:"logo",name:"Logo",import:()=>import("@shikijs/langs/logo")},{id:"lua",name:"Lua",import:()=>import("@shikijs/langs/lua")},{id:"luau",name:"Luau",import:()=>import("@shikijs/langs/luau")},{id:"make",name:"Makefile",aliases:["makefile"],import:()=>import("@shikijs/langs/make")},{id:"markdown",name:"Markdown",aliases:["md"],import:()=>import("@shikijs/langs/markdown")},{id:"marko",name:"Marko",import:()=>import("@shikijs/langs/marko")},{id:"matlab",name:"MATLAB",import:()=>import("@shikijs/langs/matlab")},{id:"mdc",name:"MDC",import:()=>import("@shikijs/langs/mdc")},{id:"mdx",name:"MDX",import:()=>import("@shikijs/langs/mdx")},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:()=>import("@shikijs/langs/mermaid")},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:()=>import("@shikijs/langs/mipsasm")},{id:"mojo",name:"Mojo",import:()=>import("@shikijs/langs/mojo")},{id:"move",name:"Move",import:()=>import("@shikijs/langs/move")},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:()=>import("@shikijs/langs/narrat")},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:()=>import("@shikijs/langs/nextflow")},{id:"nginx",name:"Nginx",import:()=>import("@shikijs/langs/nginx")},{id:"nim",name:"Nim",import:()=>import("@shikijs/langs/nim")},{id:"nix",name:"Nix",import:()=>import("@shikijs/langs/nix")},{id:"nushell",name:"nushell",aliases:["nu"],import:()=>import("@shikijs/langs/nushell")},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:()=>import("@shikijs/langs/objective-c")},{id:"objective-cpp",name:"Objective-C++",import:()=>import("@shikijs/langs/objective-cpp")},{id:"ocaml",name:"OCaml",import:()=>import("@shikijs/langs/ocaml")},{id:"pascal",name:"Pascal",import:()=>import("@shikijs/langs/pascal")},{id:"perl",name:"Perl",import:()=>import("@shikijs/langs/perl")},{id:"php",name:"PHP",import:()=>import("@shikijs/langs/php")},{id:"plsql",name:"PL/SQL",import:()=>import("@shikijs/langs/plsql")},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:()=>import("@shikijs/langs/po")},{id:"polar",name:"Polar",import:()=>import("@shikijs/langs/polar")},{id:"postcss",name:"PostCSS",import:()=>import("@shikijs/langs/postcss")},{id:"powerquery",name:"PowerQuery",import:()=>import("@shikijs/langs/powerquery")},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:()=>import("@shikijs/langs/powershell")},{id:"prisma",name:"Prisma",import:()=>import("@shikijs/langs/prisma")},{id:"prolog",name:"Prolog",import:()=>import("@shikijs/langs/prolog")},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:()=>import("@shikijs/langs/proto")},{id:"pug",name:"Pug",aliases:["jade"],import:()=>import("@shikijs/langs/pug")},{id:"puppet",name:"Puppet",import:()=>import("@shikijs/langs/puppet")},{id:"purescript",name:"PureScript",import:()=>import("@shikijs/langs/purescript")},{id:"python",name:"Python",aliases:["py"],import:()=>import("@shikijs/langs/python")},{id:"qml",name:"QML",import:()=>import("@shikijs/langs/qml")},{id:"qmldir",name:"QML Directory",import:()=>import("@shikijs/langs/qmldir")},{id:"qss",name:"Qt Style Sheets",import:()=>import("@shikijs/langs/qss")},{id:"r",name:"R",import:()=>import("@shikijs/langs/r")},{id:"racket",name:"Racket",import:()=>import("@shikijs/langs/racket")},{id:"raku",name:"Raku",aliases:["perl6"],import:()=>import("@shikijs/langs/raku")},{id:"razor",name:"ASP.NET Razor",import:()=>import("@shikijs/langs/razor")},{id:"reg",name:"Windows Registry Script",import:()=>import("@shikijs/langs/reg")},{id:"regexp",name:"RegExp",aliases:["regex"],import:()=>import("@shikijs/langs/regexp")},{id:"rel",name:"Rel",import:()=>import("@shikijs/langs/rel")},{id:"riscv",name:"RISC-V",import:()=>import("@shikijs/langs/riscv")},{id:"rst",name:"reStructuredText",import:()=>import("@shikijs/langs/rst")},{id:"ruby",name:"Ruby",aliases:["rb"],import:()=>import("@shikijs/langs/ruby")},{id:"rust",name:"Rust",aliases:["rs"],import:()=>import("@shikijs/langs/rust")},{id:"sas",name:"SAS",import:()=>import("@shikijs/langs/sas")},{id:"sass",name:"Sass",import:()=>import("@shikijs/langs/sass")},{id:"scala",name:"Scala",import:()=>import("@shikijs/langs/scala")},{id:"scheme",name:"Scheme",import:()=>import("@shikijs/langs/scheme")},{id:"scss",name:"SCSS",import:()=>import("@shikijs/langs/scss")},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:()=>import("@shikijs/langs/sdbl")},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:()=>import("@shikijs/langs/shaderlab")},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:()=>import("@shikijs/langs/shellscript")},{id:"shellsession",name:"Shell Session",aliases:["console"],import:()=>import("@shikijs/langs/shellsession")},{id:"smalltalk",name:"Smalltalk",import:()=>import("@shikijs/langs/smalltalk")},{id:"solidity",name:"Solidity",import:()=>import("@shikijs/langs/solidity")},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:()=>import("@shikijs/langs/soy")},{id:"sparql",name:"SPARQL",import:()=>import("@shikijs/langs/sparql")},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:()=>import("@shikijs/langs/splunk")},{id:"sql",name:"SQL",import:()=>import("@shikijs/langs/sql")},{id:"ssh-config",name:"SSH Config",import:()=>import("@shikijs/langs/ssh-config")},{id:"stata",name:"Stata",import:()=>import("@shikijs/langs/stata")},{id:"stylus",name:"Stylus",aliases:["styl"],import:()=>import("@shikijs/langs/stylus")},{id:"svelte",name:"Svelte",import:()=>import("@shikijs/langs/svelte")},{id:"swift",name:"Swift",import:()=>import("@shikijs/langs/swift")},{id:"system-verilog",name:"SystemVerilog",import:()=>import("@shikijs/langs/system-verilog")},{id:"systemd",name:"Systemd Units",import:()=>import("@shikijs/langs/systemd")},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:()=>import("@shikijs/langs/talonscript")},{id:"tasl",name:"Tasl",import:()=>import("@shikijs/langs/tasl")},{id:"tcl",name:"Tcl",import:()=>import("@shikijs/langs/tcl")},{id:"templ",name:"Templ",import:()=>import("@shikijs/langs/templ")},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:()=>import("@shikijs/langs/terraform")},{id:"tex",name:"TeX",import:()=>import("@shikijs/langs/tex")},{id:"toml",name:"TOML",import:()=>import("@shikijs/langs/toml")},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:()=>import("@shikijs/langs/ts-tags")},{id:"tsv",name:"TSV",import:()=>import("@shikijs/langs/tsv")},{id:"tsx",name:"TSX",import:()=>import("@shikijs/langs/tsx")},{id:"turtle",name:"Turtle",import:()=>import("@shikijs/langs/turtle")},{id:"twig",name:"Twig",import:()=>import("@shikijs/langs/twig")},{id:"typescript",name:"TypeScript",aliases:["ts"],import:()=>import("@shikijs/langs/typescript")},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:()=>import("@shikijs/langs/typespec")},{id:"typst",name:"Typst",aliases:["typ"],import:()=>import("@shikijs/langs/typst")},{id:"v",name:"V",import:()=>import("@shikijs/langs/v")},{id:"vala",name:"Vala",import:()=>import("@shikijs/langs/vala")},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:()=>import("@shikijs/langs/vb")},{id:"verilog",name:"Verilog",import:()=>import("@shikijs/langs/verilog")},{id:"vhdl",name:"VHDL",import:()=>import("@shikijs/langs/vhdl")},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:()=>import("@shikijs/langs/viml")},{id:"vue",name:"Vue",import:()=>import("@shikijs/langs/vue")},{id:"vue-html",name:"Vue HTML",import:()=>import("@shikijs/langs/vue-html")},{id:"vyper",name:"Vyper",aliases:["vy"],import:()=>import("@shikijs/langs/vyper")},{id:"wasm",name:"WebAssembly",import:()=>import("@shikijs/langs/wasm")},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:()=>import("@shikijs/langs/wenyan")},{id:"wgsl",name:"WGSL",import:()=>import("@shikijs/langs/wgsl")},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:()=>import("@shikijs/langs/wikitext")},{id:"wit",name:"WebAssembly Interface Types",import:()=>import("@shikijs/langs/wit")},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:()=>import("@shikijs/langs/wolfram")},{id:"xml",name:"XML",import:()=>import("@shikijs/langs/xml")},{id:"xsl",name:"XSL",import:()=>import("@shikijs/langs/xsl")},{id:"yaml",name:"YAML",aliases:["yml"],import:()=>import("@shikijs/langs/yaml")},{id:"zenscript",name:"ZenScript",import:()=>import("@shikijs/langs/zenscript")},{id:"zig",name:"Zig",import:()=>import("@shikijs/langs/zig")}],po=(Object.fromEntries(uo.map(e=>[e.id,e.import])),Object.fromEntries(uo.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:()=>import("@shikijs/themes/andromeeda")},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:()=>import("@shikijs/themes/aurora-x")},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:()=>import("@shikijs/themes/ayu-dark")},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:()=>import("@shikijs/themes/catppuccin-frappe")},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:()=>import("@shikijs/themes/catppuccin-latte")},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:()=>import("@shikijs/themes/catppuccin-macchiato")},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:()=>import("@shikijs/themes/catppuccin-mocha")},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:()=>import("@shikijs/themes/dark-plus")},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:()=>import("@shikijs/themes/dracula")},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:()=>import("@shikijs/themes/dracula-soft")},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:()=>import("@shikijs/themes/everforest-dark")},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:()=>import("@shikijs/themes/everforest-light")},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:()=>import("@shikijs/themes/github-dark")},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:()=>import("@shikijs/themes/github-dark-default")},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:()=>import("@shikijs/themes/github-dark-dimmed")},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:()=>import("@shikijs/themes/github-dark-high-contrast")},{id:"github-light",displayName:"GitHub Light",type:"light",import:()=>import("@shikijs/themes/github-light")},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:()=>import("@shikijs/themes/github-light-default")},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:()=>import("@shikijs/themes/github-light-high-contrast")},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:()=>import("@shikijs/themes/gruvbox-dark-hard")},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:()=>import("@shikijs/themes/gruvbox-dark-medium")},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:()=>import("@shikijs/themes/gruvbox-dark-soft")},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:()=>import("@shikijs/themes/gruvbox-light-hard")},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:()=>import("@shikijs/themes/gruvbox-light-medium")},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:()=>import("@shikijs/themes/gruvbox-light-soft")},{id:"houston",displayName:"Houston",type:"dark",import:()=>import("@shikijs/themes/houston")},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:()=>import("@shikijs/themes/kanagawa-dragon")},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:()=>import("@shikijs/themes/kanagawa-lotus")},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:()=>import("@shikijs/themes/kanagawa-wave")},{id:"laserwave",displayName:"LaserWave",type:"dark",import:()=>import("@shikijs/themes/laserwave")},{id:"light-plus",displayName:"Light Plus",type:"light",import:()=>import("@shikijs/themes/light-plus")},{id:"material-theme",displayName:"Material Theme",type:"dark",import:()=>import("@shikijs/themes/material-theme")},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:()=>import("@shikijs/themes/material-theme-darker")},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:()=>import("@shikijs/themes/material-theme-lighter")},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:()=>import("@shikijs/themes/material-theme-ocean")},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:()=>import("@shikijs/themes/material-theme-palenight")},{id:"min-dark",displayName:"Min Dark",type:"dark",import:()=>import("@shikijs/themes/min-dark")},{id:"min-light",displayName:"Min Light",type:"light",import:()=>import("@shikijs/themes/min-light")},{id:"monokai",displayName:"Monokai",type:"dark",import:()=>import("@shikijs/themes/monokai")},{id:"night-owl",displayName:"Night Owl",type:"dark",import:()=>import("@shikijs/themes/night-owl")},{id:"nord",displayName:"Nord",type:"dark",import:()=>import("@shikijs/themes/nord")},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:()=>import("@shikijs/themes/one-dark-pro")},{id:"one-light",displayName:"One Light",type:"light",import:()=>import("@shikijs/themes/one-light")},{id:"plastic",displayName:"Plastic",type:"dark",import:()=>import("@shikijs/themes/plastic")},{id:"poimandres",displayName:"Poimandres",type:"dark",import:()=>import("@shikijs/themes/poimandres")},{id:"red",displayName:"Red",type:"dark",import:()=>import("@shikijs/themes/red")},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:()=>import("@shikijs/themes/rose-pine")},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:()=>import("@shikijs/themes/rose-pine-dawn")},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:()=>import("@shikijs/themes/rose-pine-moon")},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:()=>import("@shikijs/themes/slack-dark")},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:()=>import("@shikijs/themes/slack-ochin")},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:()=>import("@shikijs/themes/snazzy-light")},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:()=>import("@shikijs/themes/solarized-dark")},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:()=>import("@shikijs/themes/solarized-light")},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:()=>import("@shikijs/themes/synthwave-84")},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:()=>import("@shikijs/themes/tokyo-night")},{id:"vesper",displayName:"Vesper",type:"dark",import:()=>import("@shikijs/themes/vesper")},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:()=>import("@shikijs/themes/vitesse-black")},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:()=>import("@shikijs/themes/vitesse-dark")},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:()=>import("@shikijs/themes/vitesse-light")}]);Object.fromEntries(po.map(e=>[e.id,e.import]));const ho=function(e){const t=Rr(e);return{getLastGrammarState:(...e)=>function(...e){if(2===e.length)return Zn(e[1]);const[t,n,r={}]=e,{lang:s="text",theme:i=t.getLoadedThemes()[0]}=r;if(Dn(s)||Fn(i))throw new U("Plain language does not have grammar state");if("ansi"===s)throw new U("ANSI language does not have grammar state");const{theme:o,colorMap:a}=t.setTheme(i),l=t.getLanguage(s);return new Jn(hr(n,l,o,a,r).stateStack,l.name,o.name)}(t,...e),codeToTokensBase:(e,n)=>pr(t,e,n),codeToTokensWithThemes:(e,n)=>kr(t,e,n),codeToTokens:(e,n)=>br(t,e,n),codeToHast:(e,n)=>Cr(t,e,n),codeToHtml:(e,n)=>function(e,t,n){const r={meta:{},options:n,codeToHast:(t,n)=>Cr(e,t,n),codeToTokens:(t,n)=>br(e,t,n)};let s=_r(Cr(e,t,n,r));for(const e of nr(n))s=e.postprocess?.call(r,s,n)||s;return s}(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}({engine:function(e={}){const t=Object.assign({target:"auto",cache:new Map},e);return t.regexConstructor||=e=>function(e,t){return ao(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}(e,{target:t.target}),{createScanner:e=>new co(e,t),createString:e=>({content:e})}}(),langs:[],themes:[]});function mo(e){const t=/^diff-([\w-]+)/i.exec(e);return t?t[1]:null}function go(e){const t=mo(e)||e;return!!Bn(t)||ho.getLoadedLanguages().includes(t)}function fo(t,n,r){const s=mo(t),i=s||t;if(!go(i)){const s=uo.find(e=>e.id===i||e.aliases&&e.aliases.includes(i));if(s)return ho.loadLanguage(s.import()).then(()=>{n&&r&&n.update(()=>{const n=d(r);e(n)&&n.getLanguage()===t&&!n.getIsSyntaxHighlightSupported()&&n.setIsSyntaxHighlightSupported(!0)})})}}function yo(e){const t=e;return!!Un(t)||ho.getLoadedThemes().includes(t)}function ko(t,n,r){if(!yo(t)){const s=po.find(e=>e.id===t);if(s)return ho.loadTheme(s.import()).then(()=>{n&&r&&n.update(()=>{const t=d(r);e(t)&&t.markDirty()})})}}function bo(){return uo.map(e=>[e.id,e.name])}function wo(){return po.map(e=>[e.id,e.displayName])}function Co(e){const t=e,n=uo.find(e=>e.id===t||e.aliases&&e.aliases.includes(t));return n?n.id:e}function _o(e,n){const r=/^diff-([\w-]+)/i.exec(n),s=e.getTextContent(),i=ho.codeToTokens(s,{lang:r?r[1]:n,theme:e.getTheme()||"poimandres"}),{tokens:o,bg:a,fg:l}=i;let c="";return a&&(c+=`background-color: ${a};`),l&&(c+=`color: ${l};`),e.getStyle()!==c&&e.setStyle(c),function(e,n){const r=[];return e.forEach((e,s)=>{s&&r.push(m()),e.forEach((e,s)=>{let i=e.content;if(n&&0===s&&i.length>0){const e=["+","-",">","<"," "],n=["inserted","deleted","inserted","deleted","unchanged"],s=e.indexOf(i[0]);-1!==s&&(r.push(t(e[s],n[s])),i=i.slice(1))}i.split("\t").forEach((n,s)=>{if(s&&r.push(g()),""!==n){const s=t(n),i=Xn(e.htmlStyle||Vn(e));s.setStyle(i),r.push(s)}})})}),r}(o,!!r)}const So={$tokenize(e,t){return _o(e,t||this.defaultLanguage)},defaultLanguage:r,defaultTheme:"one-light"};function vo(t,n,r){const s=t.getParent();e(s)?Ao(s,n,r):o(t)&&t.replace(I(t.__text))}function xo(e,t){const n=t.getElementByKey(e.getKey());if(null===n)return;const r=e.getChildren(),s=r.length;if(s===n.__cachedChildrenLength)return;n.__cachedChildrenLength=s;let i="1",o=1;for(let e=0;e<s;e++)L(r[e])&&(i+="\n"+ ++o);n.setAttribute("data-gutter",i)}const No=new Set;function Ao(t,n,r){const s=t.getKey();let i=t.getLanguage();i||(i=r.defaultLanguage,t.setLanguage(i));let o=t.getTheme();o||(o=r.defaultTheme,t.setTheme(o));let a=!1;yo(o)||(ko(o,n,s),a=!0),go(i)?t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(!0):(t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(!1),fo(i,n,s),a=!0),a||No.has(s)||(No.add(s),n.update(()=>{!function(t,n){const r=d(t);if(!e(r)||!r.isAttached())return;const s=C();if(!N(s))return void n();const i=s.anchor,o=i.offset,a="element"===i.type&&L(r.getChildAtIndex(i.offset-1));let l=0;if(!a){const e=i.getNode();l=o+e.getPreviousSiblings().reduce((e,t)=>e+t.getTextContentSize(),0)}if(!n())return;if(a)return void i.getNode().select(o,o);r.getChildren().some(e=>{const t=B(e);if(t||L(e)){const n=e.getTextContentSize();if(t&&n>=l)return e.select(l,l),!0;l-=n}return!1})}(s,()=>{const n=d(s);if(!e(n)||!n.isAttached())return!1;const i=n.getLanguage()||r.defaultLanguage,o=r.$tokenize(n,i),a=function(e,t){let n=0;for(;n<e.length&&jo(e[n],t[n]);)n++;const r=e.length,s=t.length,i=Math.min(r,s)-n;let o=0;for(;o<i;)if(o++,!jo(e[r-o],t[s-o])){o--;break}const a=n,l=r-o,c=t.slice(n,s-o);return{from:a,nodesForReplacement:c,to:l}}(n.getChildren(),o),{from:l,to:c,nodesForReplacement:u}=a;return!(l===c&&!u.length)&&(t.splice(l,c-l,u),!0)})},{onUpdate:()=>{No.delete(s)},skipTransforms:!0}))}function jo(e,t){return o(e)&&o(t)&&e.__text===t.__text&&e.__highlightType===t.__highlightType&&e.__style===t.__style||D(e)&&D(t)||L(e)&&L(t)}function Eo(t){if(!N(t))return!1;const n=t.anchor.getNode(),r=e(n)?n:n.getParent(),s=t.focus.getNode(),i=e(s)?s:s.getParent();return e(r)&&r.is(i)}function Lo(t){const n=t.getNodes(),r=[];if(1===n.length&&e(n[0]))return r;let s=[];for(let e=0;e<n.length;e++){const t=n[e];o(t)||D(t)||L(t)||F(169),L(t)?s.length>0&&(r.push(s),s=[]):s.push(t)}if(s.length>0){const e=t.isBackward()?t.anchor:t.focus,n=P(s[0].getKey(),0,"text");e.is(n)||r.push(s)}return r}function Io(e){const t=C();if(!N(t)||!Eo(t))return!1;const n=Lo(t),r=n.length;if(0===r&&t.isCollapsed())return e===S&&t.insertNodes([g()]),!0;if(0===r&&e===S&&"\n"===t.getTextContent()){const e=g(),n=m(),r=t.isBackward()?"previous":"next";return t.insertNodes([e,n]),R(T(M($(e,"next",0),O(G(n,"next"))),r)),!0}for(let s=0;s<r;s++){const r=n[s];if(r.length>0){let n=r[0];if(0===s&&(n=a(n)),e===S){const e=g();if(n.insertBefore(e),0===s){const r=t.isBackward()?"focus":"anchor",s=P(n.getKey(),0,"text");t[r].is(s)&&t[r].set(e.getKey(),0,"text")}}else D(n)&&n.remove()}}return!0}function Po(e,t){const n=C();if(!N(n))return!1;const{anchor:r,focus:s}=n,i=r.offset,c=s.offset,u=r.getNode(),p=s.getNode(),h=e===x;if(!Eo(n)||!o(u)&&!D(u)||!o(p)&&!D(p))return!1;if(!t.altKey){if(n.isCollapsed()){const e=u.getParentOrThrow();if(h&&0===i&&null===u.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!0}else if(!h&&i===u.getTextContentSize()&&null===u.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!0}}return!1}let d,m;if(u.isBefore(p)?(d=a(u),m=l(p)):(d=a(p),m=l(u)),null==d||null==m)return!1;const g=d.getNodesBetween(m);for(let e=0;e<g.length;e++){const t=g[e];if(!o(t)&&!D(t)&&!L(t))return!1}t.preventDefault(),t.stopPropagation();const f=h?d.getPreviousSibling():m.getNextSibling();if(!L(f))return!0;const y=h?f.getPreviousSibling():f.getNextSibling();if(null==y)return!0;const k=o(y)||D(y)||L(y)?h?a(y):l(y):null;let b=null!=k?k:y;return f.remove(),g.forEach(e=>e.remove()),e===x?(g.forEach(e=>b.insertBefore(e)),b.insertBefore(f)):(b.insertAfter(f),b=f,g.forEach(e=>{b.insertAfter(e),b=e})),n.setTextNodeRange(u,i,p,c),!0}function Ro(e,t){const n=C();if(!N(n))return!1;const{anchor:r,focus:s}=n,i=r.getNode(),a=s.getNode(),l=e===j;if(!Eo(n)||!o(i)&&!D(i)||!o(a)&&!D(a))return!1;const h=a;if("rtl"===c(h)?!l:l){const e=u(h,s.offset);if(null!==e){const{node:t,offset:r}=e;L(t)?t.selectNext(0,0):n.setTextNodeRange(t,r,t,r)}else h.getParentOrThrow().selectStart()}else{p(h).select()}return t.preventDefault(),t.stopPropagation(),!0}function To(t,n){if(!t.hasNodes([s,i]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==n&&(n=So);const r=[];return!0!==t._headless&&r.push(t.registerMutationListener(s,e=>{t.getEditorState().read(()=>{for(const[n,r]of e)if("destroyed"!==r){const e=d(n);null!==e&&xo(e,t)}})},{skipInitialization:!1})),r.push(t.registerNodeTransform(s,e=>Ao(e,t,n)),t.registerNodeTransform(y,e=>vo(e,t,n)),t.registerNodeTransform(i,e=>vo(e,t,n)),t.registerCommand(k,e=>{const n=function(e){const t=C();if(!N(t)||!Eo(t))return null;const n=e?v:S,r=e?v:w,s=t.anchor,i=t.focus;if(s.is(i))return r;const o=Lo(t);if(1!==o.length)return n;const c=o[0];let u,p;0===c.length&&F(285),t.isBackward()?(u=i,p=s):(u=s,p=i);const h=a(c[0]),d=l(c[0]),m=P(h.getKey(),0,"text"),g=P(d.getKey(),d.getTextContentSize(),"text");return u.isBefore(m)||g.isBefore(p)?n:m.isBefore(u)||p.isBefore(g)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)},b),t.registerCommand(w,()=>!!Eo(C())&&(_([g()]),!0),b),t.registerCommand(S,e=>Io(S),b),t.registerCommand(v,e=>Io(v),b),t.registerCommand(x,t=>{const n=C();if(!N(n))return!1;const{anchor:r}=n,s=r.getNode();return!!Eo(n)&&(n.isCollapsed()&&0===r.offset&&null===s.getPreviousSibling()&&e(s.getParentOrThrow())?(t.preventDefault(),!0):Po(x,t))},b),t.registerCommand(A,t=>{const n=C();if(!N(n))return!1;const{anchor:r}=n,s=r.getNode();return!!Eo(n)&&(n.isCollapsed()&&r.offset===s.getTextContentSize()&&null===s.getNextSibling()&&e(s.getParentOrThrow())?(t.preventDefault(),!0):Po(A,t))},b),t.registerCommand(j,e=>Ro(j,e),b),t.registerCommand(E,e=>Ro(E,e),b)),h(...r)}const Mo=f({config:{tokenizer:So},dependencies:[n],name:"@lexical/code-shiki",register:(e,{tokenizer:t})=>To(e,t)});export{Mo as CodeHighlighterShikiExtension,So as ShikiTokenizer,bo as getCodeLanguageOptions,wo as getCodeThemeOptions,go as isCodeLanguageLoaded,fo as loadCodeLanguage,ko as loadCodeTheme,Co as normalizeCodeLanguage,To as registerCodeHighlighting};
|
|
55
|
+
`.replace(/\s+/g,""),"gsu");const Js=String.raw,Ys=Js`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,ei=Js`\(\?R=(?<rDepth>[^\)]+)\)|${Ys}`,ti=Js`\(\?<(?![=!])(?<captureName>[^>]+)>`,ni=Js`${ti}|(?<unnamed>\()(?!\?)`,ri=new RegExp(Js`${ti}|${ei}|\(\?|\\?.`,"gsu"),si="Cannot use multiple overlapping recursions";function ii(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if((e=+e)<2||e>100)throw new Error(t)}function oi(e,t,n,r,s,i,o){const a=new Set;r&&qs(e+t,ti,({groups:{captureName:e}})=>{a.add(e)},zs.DEFAULT);const l=[n,r?a:null,s,i,o];return`${e}${ai(`(?:${e}`,"forward",...l)}(?:)${ai(`${t})`,"backward",...l)}${t}`}function ai(e,t,n,r,s,i,o){const a=e=>"forward"===t?e+2:n-e+2-1;let l="";for(let t=0;t<n;t++){const n=a(t);l+=Hs(e,Js`${ni}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:a,backref:l}})=>{if(l&&r&&!r.has(l))return e;const c=`_$${n}`;if(a||t){const n=o+i.length+1;return i.push(n),li(s,n),a?e:`(?<${t}${c}>`}return Js`\k<${l}${c}>`},zs.DEFAULT)}return l}function li(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function ci(e,t,n,r,s,i){if(e.size&&r){let o=0;qs(t,ni,()=>o++,zs.DEFAULT);const a=i-o+s,l=new Map;return e.forEach((e,t)=>{const s=(r-o*n)/n,i=o*n,c=t>a+o?t+r:t,u=[];for(const t of e)if(t<=a)u.push(t);else if(t>a+o+s)u.push(t+r);else if(t<=a+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+i+s*e);l.set(c,u)}),l}return e}var ui=String.fromCodePoint,pi=String.raw,hi={flagGroups:(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),unicodeSets:(()=>{try{new RegExp("","v")}catch{return!1}return!0})()};function di(e,{enable:t,disable:n}){return{dotAll:!(n?.dotAll||!t?.dotAll&&!e.dotAll),ignoreCase:!(n?.ignoreCase||!t?.ignoreCase&&!e.ignoreCase)}}function mi(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function gi(e,t){return fi[e]>=fi[t]}hi.bugFlagVLiteralHyphenIsRange=!!hi.unicodeSets&&(()=>{try{new RegExp(pi`[\d\-a]`,"v")}catch{return!0}return!1})(),hi.bugNestedClassIgnoresNegation=hi.unicodeSets&&new RegExp("[[^a]]","v").test("a");var fi={ES2025:2025,ES2024:2024,ES2018:2018},yi={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function ki(e={}){if("[object Object]"!=={}.toString.call(e))throw new Error("Unexpected options");if(void 0!==e.target&&!yi[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return"auto"===t.target&&(t.target=hi.flagGroups?"ES2025":hi.unicodeSets?"ES2024":"ES2018"),t}var bi=new Set([ui(304),ui(305)]),wi=pi`[\p{L}\p{M}\p{N}\p{Pc}]`;function Ci(e){if(bi.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),s=xi.get(n),i=Si.get(n),o=vi.get(n);return 1===[...r].length&&t.add(r),o&&t.add(o),s&&t.add(s),t.add(n),i&&t.add(i),[...t]}var _i=new Map("C Other\nCc Control cntrl\nCf Format\nCn Unassigned\nCo Private_Use\nCs Surrogate\nL Letter\nLC Cased_Letter\nLl Lowercase_Letter\nLm Modifier_Letter\nLo Other_Letter\nLt Titlecase_Letter\nLu Uppercase_Letter\nM Mark Combining_Mark\nMc Spacing_Mark\nMe Enclosing_Mark\nMn Nonspacing_Mark\nN Number\nNd Decimal_Number digit\nNl Letter_Number\nNo Other_Number\nP Punctuation punct\nPc Connector_Punctuation\nPd Dash_Punctuation\nPe Close_Punctuation\nPf Final_Punctuation\nPi Initial_Punctuation\nPo Other_Punctuation\nPs Open_Punctuation\nS Symbol\nSc Currency_Symbol\nSk Modifier_Symbol\nSm Math_Symbol\nSo Other_Symbol\nZ Separator\nZl Line_Separator\nZp Paragraph_Separator\nZs Space_Separator\nASCII\nASCII_Hex_Digit AHex\nAlphabetic Alpha\nAny\nAssigned\nBidi_Control Bidi_C\nBidi_Mirrored Bidi_M\nCase_Ignorable CI\nCased\nChanges_When_Casefolded CWCF\nChanges_When_Casemapped CWCM\nChanges_When_Lowercased CWL\nChanges_When_NFKC_Casefolded CWKCF\nChanges_When_Titlecased CWT\nChanges_When_Uppercased CWU\nDash\nDefault_Ignorable_Code_Point DI\nDeprecated Dep\nDiacritic Dia\nEmoji\nEmoji_Component EComp\nEmoji_Modifier EMod\nEmoji_Modifier_Base EBase\nEmoji_Presentation EPres\nExtended_Pictographic ExtPict\nExtender Ext\nGrapheme_Base Gr_Base\nGrapheme_Extend Gr_Ext\nHex_Digit Hex\nIDS_Binary_Operator IDSB\nIDS_Trinary_Operator IDST\nID_Continue IDC\nID_Start IDS\nIdeographic Ideo\nJoin_Control Join_C\nLogical_Order_Exception LOE\nLowercase Lower\nMath\nNoncharacter_Code_Point NChar\nPattern_Syntax Pat_Syn\nPattern_White_Space Pat_WS\nQuotation_Mark QMark\nRadical\nRegional_Indicator RI\nSentence_Terminal STerm\nSoft_Dotted SD\nTerminal_Punctuation Term\nUnified_Ideograph UIdeo\nUppercase Upper\nVariation_Selector VS\nWhite_Space space\nXID_Continue XIDC\nXID_Start XIDS".split(/\s/).map(e=>[Ms(e),e])),Si=new Map([["s",ui(383)],[ui(383),"s"]]),vi=new Map([[ui(223),ui(7838)],[ui(107),ui(8490)],[ui(229),ui(8491)],[ui(969),ui(8486)]]),xi=new Map([Ai(453),Ai(456),Ai(459),Ai(498),...ji(8072,8079),...ji(8088,8095),...ji(8104,8111),Ai(8124),Ai(8140),Ai(8188)]),Ni=new Map([["alnum",pi`[\p{Alpha}\p{Nd}]`],["alpha",pi`\p{Alpha}`],["ascii",pi`\p{ASCII}`],["blank",pi`[\p{Zs}\t]`],["cntrl",pi`\p{Cc}`],["digit",pi`\p{Nd}`],["graph",pi`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",pi`\p{Lower}`],["print",pi`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",pi`[\p{P}\p{S}]`],["space",pi`\p{space}`],["upper",pi`\p{Upper}`],["word",pi`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",pi`\p{AHex}`]]);function Ai(e){const t=ui(e);return[t.toLowerCase(),t]}function ji(e,t){return function(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}(e,t).map(e=>Ai(e))}var Ei=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var Li={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:s}=e;if("repeater"!==s)throw new Error('Unsupported absence function "(?~|"');{const e=Ns();e.body[0].body.push(As({negate:!0,body:r}),Ls("Any"));const s=Ns();s.body[0].body.push(js("greedy",0,1/0,e)),n(qi(s,t),{traverse:!0})}},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const s=e.body.filter(e=>"flags"===e.kind);for(let e=n+1;e<t.body.length;e++){mi(r,t.body[e],[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){const n=Oi(t.get(e));if(n){const t=Ns({flags:n});t.body[0].body=e.body,e.body=[qi(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:s,remove:i,replaceWith:o},a){const{kind:l,negate:c}=e,{asciiWordBoundaries:u,avoidSubclass:p,supportedGNodes:h,wordIsAscii:d}=a;if("text_segment_boundary"===l)throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if("line_end"===l)o(qi(As({body:[ks({body:[bs("string_end")]}),ks({body:[_s(10)]})]}),t));else if("line_start"===l)o(qi(Wi(pi`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if("search_start"===l)if(h.has(e))s.flags.sticky=!0,i();else{const e=r[n-1];if(e&&function(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||"Quantifier"===e.type&&e.min&&t.includes(e.body.type)}(e))o(qi(As({negate:!0}),t));else{if(p)throw new Error(pi`Uses "\G" in a way that requires a subclass`);o(Hi(bs("string_start"),t)),a.strategy="clip_search"}}else if("string_end"===l||"string_start"===l);else if("string_end_newline"===l)o(qi(Wi(pi`(?=\n?\z)`),t));else{if("word_boundary"!==l)throw new Error(`Unexpected assertion kind "${l}"`);if(!d&&!u){o(qi(Wi(c?`(?:(?<=${wi})(?=${wi})|(?<!${wi})(?!${wi}))`:`(?:(?<=${wi})(?!${wi})|(?<!${wi})(?=${wi}))`),t))}}},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;"string"!=typeof n||Ui(n)||(n=$i(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Ui(r)&&(r=$i(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if("intersection"===t.kind){n(qi(Ss({body:[e]}),t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:i,spaceIsAscii:o,wordIsAscii:a}){const{kind:l,negate:c,value:u}=e;if(!i||"digit"!==l&&"digit"!==u)if(!o||"space"!==l&&"space"!==u)if(!a||"word"!==l&&"word"!==u)if("any"===l)n(Hi(Ls("Any"),t));else if("digit"===l)n(Hi(Ls("Nd",{negate:c}),t));else if("dot"===l);else if("text_segment"===l){if("strict"===r)throw new Error(pi`Use of "\X" requires non-strict accuracy`);const e="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",i=pi`\p{RI}{2}|${e}(?:\u200D${e})*`;n(qi(Wi(pi`(?>\r\n|${s?pi`\p{RGI_Emoji}`:i}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if("hex"===l)n(Hi(Ls("AHex",{negate:c}),t));else if("newline"===l)n(qi(Wi(c?"[^\n]":"(?>\r\n?|[\n\v\f
\u2028\u2029])"),t));else if("posix"===l)if(s||"graph"!==u&&"print"!==u)n(qi(zi(Wi(Ni.get(u)),c),t));else{if("strict"===r)throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:"!-~",print:" -~"}[u];c&&(e=`\0-${ui(e.codePointAt(0)-1)}${ui(e.codePointAt(2)+1)}-`),n(qi(Wi(`[${e}]`),t))}else if("property"===l)_i.has(Ms(u))||(e.key="sc");else if("space"===l)n(Hi(Ls("space",{negate:c}),t));else{if("word"!==l)throw new Error(`Unexpected character set kind "${l}"`);n(qi(zi(Wi(wi),c),t))}else n(Hi(vs("word",{negate:c}),t));else n(qi(zi(Wi("[\t-\r ]"),c),t));else n(Hi(vs("digit",{negate:c}),t))},Directive({node:e,parent:t,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:i,removeAllNextSiblings:o}){const{kind:a,flags:l}=e;if("flags"===a)if(l.enable||l.disable){const e=Ns({flags:l});e.body[0].body=o(),s(qi(e,t),{traverse:!0})}else r();else{if("keep"!==a)throw new Error(`Unexpected directive kind "${a}"`);{const e=n.body[0],r=1===n.body.length&&hs(e,{type:"Group"})&&1===e.body[0].body.length?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw new Error(pi`Uses "\K" in a way that's unsupported`);const o=As({behind:!0});o.body[0].body=i(),s(qi(o,t))}}},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if("word"===e.textSegmentMode)throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;"lookbehind"===n&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if("fail"!==r)throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`);n(qi(As({negate:!0}),t))},Quantifier({node:e}){if("Quantifier"===e.body.type){const t=Ns();t.body[0].body.push(e.body),e.body=qi(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,s=!1;for(const t of e.body)if(1===t.body.length&&"search_start"===t.body[0].kind)t.body.pop();else{const e=Bi(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):s=!0}r&&!s&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if("strict"===t&&n&&r)throw new Error(pi`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;"string"!=typeof n||Ui(n)||(n=$i(n,t),e.ref=n)}},Ii={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=e;r||n.set(e,[...t.get(s).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:i,multiplexCapturesToLeftByRef:o,openRefs:a,reffedNodesByReferencer:l}){const c=s.get(e);if(c&&a.has(e.number)){const r=Hi(Mi(e.number),t);return l.set(r,a.get(e.number)),void n(r)}a.set(e.number,e),o.set(e.number,[]),e.name&&mi(o,e.name,[]);const u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){const n=u[t];if(c===n.node||c&&c===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:c}),e.name&&o.get(e.name).push({node:e,origin:c}),e.name){const t=mi(i,e.name,new Map);let n=!1;if(c)n=!0;else for(const e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}i.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=di(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:s,ref:i}=e;if(s){let n=t;for(;(n=n.parent)&&("CapturingGroup"!==n.type||n.name!==i&&n.number!==i););return void r.reffedNodesByReferencer.set(e,n)}const o=r.subroutineRefMap.get(i),a=0===i,l=a?Mi(0):Ti(o,r.groupOriginByCopy,null);let c=l;if(!a){const e=Oi(function(e,t){const n=[];for(;e=e.parent;)t&&!t(e)||n.push(e);return n}(o,e=>"Group"===e.type&&!!e.flags)),t=e?di(r.globalFlags,e):r.globalFlags;(function(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase})(t,r.currentFlags)||(c=Ns({flags:Gi(t)}),c.body[0].body.push(l))}n(qi(c,t),{traverse:!a})}},Pi={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan)return void(r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref));const s=r.reffedNodesByReferencer.get(e).filter(t=>function(e,t){let n=t;do{if("Regex"===n.type)return!1;if("Alternative"===n.type)continue;if(n===e)return!1;const t=Di(n.parent);for(const r of t){if(r===n)break;if(r===e||Fi(r,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}(t,e));if(s.length)if(s.length>1){n(qi(Ns({atomic:!0,body:s.reverse().map(e=>ks({body:[ws(e.number)]}))}),t))}else e.ref=s[0].number;else n(qi(As({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){const t=Cs();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){e.isRecursive&&0!==e.ref&&(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Ri(e){Gs(e,{"*"({node:e,parent:t}){e.parent=t}})}function Ti(e,t,n,r){const s=Array.isArray(e)?[]:{};for(const[i,o]of Object.entries(e))"parent"===i?s.parent=Array.isArray(n)?r:n:o&&"object"==typeof o?s[i]=Ti(o,t,s,n):("type"===i&&"CapturingGroup"===o&&t.set(s,t.get(e)??e),s[i]=o);return s}function Mi(e){const t=Es(e);return t.isRecursive=!0,t}function $i(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,"_")}`;return t.set(e,n),n}function Oi(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Gi({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),e&&t||(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Di(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Bi(e){const t=e.find(e=>"search_start"===e.kind||function(e,t){const n={negate:null,...t};return"LookaroundAssertion"===e.type&&(null===n.negate||e.negate===n.negate)&&1===e.body.length&&hs(e.body[0],{type:"Assertion",kind:"search_start"})}(e,{negate:!1})||!function({type:e}){return"Assertion"===e||"Directive"===e||"LookaroundAssertion"===e}(e));if(!t)return null;if("search_start"===t.kind)return t;if("LookaroundAssertion"===t.type)return t.body[0].body[0];if("CapturingGroup"===t.type||"Group"===t.type){const e=[];for(const n of t.body){const t=Bi(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Fi(e,t){const n=Di(e)??[];for(const e of n)if(e===t||Fi(e,t))return!0;return!1}function Ui(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Wi(e,t){const n=ms(e,{...t,unicodePropertyMap:_i}).body;return n.length>1||n[0].body.length>1?Ns({body:n}):n[0].body[0]}function zi(e,t){return e.negate=t,e}function Hi(e,t){return e.parent=t,e}function qi(e,t){return Ri(e),e.parent=t,e}function Vi(e,t){const n=ki(t),r=gi(n.target,"ES2024"),s=gi(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,a=null;if(!s){const t=[e.flags.ignoreCase];Gs(e,Xi,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:a=!0}})}const l={dotAll:e.flags.dotAll,ignoreCase:!(!e.flags.ignoreCase&&!o||a)};let c=e;const u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:i,useAppliedIgnoreCase:!(s||!o||!a),useFlagMods:s,useFlagV:r,verbose:n.verbose};function p(e){u.lastNode=c,c=e;return function(e,t){if(null==e)throw new Error(t??"Value expected");return e}(Ki[e.type],`Unexpected node type "${e.type}"`)(e,u,p)}const h={pattern:e.body.map(p).join("|"),flags:p(e.flags),options:{...e.options}};return r||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&h._hiddenCaptures.push(t),e.transferTo&&mi(h._captureTransfers,e.transferTo,[]).push(t)}),h}var Xi={"*":{enter({node:e},t){if(so(e)){const n=t.getCurrentModI();t.pushModI(e.flags?di({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){so(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){to(ui(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),no(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){"property"===e.kind&&Ei.has(e.value)&&t.setHasCasedChar()}},Ki={Alternative:({body:e},t,n)=>e.map(n).join(""),Assertion({kind:e,negate:t}){if("string_end"===e)return"$";if("string_start"===e)return"^";if("word_boundary"===e)return t?pi`\B`:pi`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if("number"!=typeof e)throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&"strict"===t.accuracy&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:s,number:i}=e,o={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(o.hidden=!0,i>a.number&&(o.transferTo=a.number)),t.captureMap.set(i,o),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=ui(e),r=ro(e,{escDigit:"Backreference"===t.lastNode.type,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&to(n)){const e=Ci(n);return t.inCharClass?e.join(""):e.length>1?`[${e.join("")}]`:e[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:s,parent:i}=e;let{body:o}=e;if("intersection"===r&&!t.useFlagV)throw new Error("Use of class intersection requires min target ES2024");hi.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(io)&&(o=[_s(45),...o.filter(e=>!io(e))]);const a=()=>`[${s?"^":""}${o.map(n).join("intersection"===r?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||hi.bugNestedClassIgnoresNegation)&&!s){const t=o.filter(e=>"CharacterClass"===e.type&&"union"===e.kind&&e.negate);if(t.length){const r=Ns(),s=r.body[0];return r.parent=i,s.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=s,s.body.push(e)):r.body.pop(),t.forEach(e=>{const t=ks({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;const r=a();return t.inCharClass=!1,r}const l=o[0];if("union"===r&&!s&&l&&((!t.useFlagV||!t.verbose)&&"union"===i.kind&&(!hi.bugFlagVLiteralHyphenIsRange||!t.useFlagV)||!t.verbose&&"intersection"===i.kind&&1===o.length&&"CharacterClassRange"!==l.type))return o.map(n).join("");if(!t.useFlagV&&"CharacterClass"===i.type)throw new Error("Use of nested character class requires min target ES2024");return a()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},i=ro(n,s),o=ro(r,s),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const t=function(e){const t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[];let r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:null===r?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}(no(e));t.forEach(e=>{a.add(Array.isArray(e)?`${ro(e[0],s)}-${ro(e[1],s)}`:ro(e,s))})}return`${i}-${o}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},s){if("dot"===e)return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":pi`[^\n]`;if("digit"===e)return t?pi`\D`:pi`\d`;if("property"===e){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&Ei.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?pi`\P`:pi`\p`}{${r?`${r}=`:""}${n}}`}if("word"===e)return t?pi`\W`:pi`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags:(e,t)=>(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":""),Group({atomic:e,body:t,flags:n,parent:r},s,i){const o=s.currentFlags;n&&(s.currentFlags=di(o,n));const a=t.map(i).join("|"),l=s.verbose||1!==t.length||"Quantifier"===r.type||e||s.useFlagMods&&n?`(?${function(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:e,disable:n}=t;r=(e?.ignoreCase?"i":"")+(e?.dotAll?"s":"")+(n?"-":"")+(n?.ignoreCase?"i":"")+(n?.dotAll?"s":"")}return`${r}:`}(e,n,s.useFlagMods)}${a})`:a;return s.currentFlags=o,l},LookaroundAssertion:({body:e,kind:t,negate:n},r,s)=>`(?${`${"lookahead"===t?"":"<"}${n?"!":"="}`}${e.map(s).join("|")})`,Quantifier:(e,t,n)=>n(e.body)+function({kind:e,max:t,min:n}){let r;r=n||1!==t?n||t!==1/0?1===n&&t===1/0?"+":n===t?`{${n}}`:`{${n},${t===1/0?"":t}}`:"*":"?";return r+{greedy:"",lazy:"?",possessive:"+"}[e]}(e),Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return 0===t?`(?R=${r})`:pi`\g<${t}&R=${r}>`}},Qi=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Zi=new Set(["-","\\","]","^","["]),Ji=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Yi=new Map([[9,pi`\t`],[10,pi`\n`],[11,pi`\v`],[12,pi`\f`],[13,pi`\r`],[8232,pi`\u2028`],[8233,pi`\u2029`],[65279,pi`\uFEFF`]]),eo=/^\p{Cased}$/u;function to(e){return eo.test(e)}function no(e,t){const n=!!t?.firstOnly,r=e.min.value,s=e.max.value,i=[];if(r<65&&(65535===s||s>=131071)||65536===r&&s>=131071)return i;for(let e=r;e<=s;e++){const t=ui(e);if(!to(t))continue;const o=Ci(t).filter(e=>{const t=e.codePointAt(0);return t<r||t>s});if(o.length&&(i.push(...o),n))break}return i}function ro(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Yi.has(e))return Yi.get(e);if(e<32||e>126&&e<160||e>262143||t&&((s=e)>47&&s<58))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;var s;const i=n?r?Ji:Zi:Qi,o=ui(e);return(i.has(o)?"\\":"")+o}function so({type:e}){return"CapturingGroup"===e||"Group"===e||"LookaroundAssertion"===e}function io({type:e,value:t}){return"Character"===e&&45===t}var oo=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#s=null;rawOptions={};get source(){return this.#n||"(?:)"}constructor(t,n,r){const s=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const s=t;super(s,n),this.#n=s.source,s instanceof e&&(this.#e=s.#e,this.#r=s.#r,this.#s=s.#s,this.rawOptions=s.rawOptions)}else{const e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":t,n),this.#n=t,this.#e=function(e,t){const n=new Map;for(const t of e)n.set(t,{hidden:!0});for(const[e,r]of t)for(const t of r)mi(n,t,{}).transferTo=e;return n}(e.hiddenCaptures,e.transfers),this.#s=e.strategy,this.rawOptions=r??{}}s||(this.#t=this)}exec(t){if(!this.#t){const{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}const n=this.global||this.sticky,r=this.lastIndex;if("clip_search"===this.#s&&n&&r){this.lastIndex=0;const e=this.#i(t.slice(r));return e&&(!function(e,t,n,r){if(e.index+=t,e.input=n,r){const n=e.indices;for(let e=0;e<n.length;e++){const r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}const r=n.groups;r&&Object.keys(r).forEach(e=>{const n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#i(t)}#i(e){this.#t.lastIndex=this.lastIndex;const t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;const n=[...t];let r;t.length=1,this.hasIndices&&(r=[...t.indices],t.indices.length=1);const s=[0];for(let e=1;e<n.length;e++){const{hidden:i,transferTo:o}=this.#e.get(e)??{};if(i?s.push(null):(s.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&void 0!==n[e]){const i=s[o];if(!i)throw new Error(`Invalid capture transfer to "${i}"`);if(t[i]=n[e],this.hasIndices&&(t.indices[i]=r[e]),t.groups){this.#r||(this.#r=ao(this.source));const s=this.#r.get(o);s&&(t.groups[s]=n[e],this.hasIndices&&(t.indices.groups[s]=r[e]))}}}return t}};function ao(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r,s=0,i=0;for(;r=t.exec(e);){const{0:e,groups:{capture:t,name:o}}=r;"["===e?s++:s?"]"===e&&s--:t&&(i++,o&&n.set(i,o))}return n}function lo(e,t){const n=function(e,t){const n=ki(t),r=ms(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:_i}),s=function(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};Ri(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:gi(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Gs(e,Li,r);const s={dotAll:e.flags.dotAll,ignoreCase:e.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};return Gs(e,Ii,i),Gs(e,Pi,{groupsByName:i.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:i.reffedNodesByReferencer}),e._originMap=i.groupOriginByCopy,e._strategy=r.strategy,e}(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Vi(s,n),o=function(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let s=t?.captureTransfers??new Map;if(!new RegExp(ei,"su").test(e))return{pattern:e,captureTransfers:s,hiddenCaptures:n};if("plugin"===r&&Vs(e,Js`\(\?\(DEFINE\)`,zs.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const i=[],o=Vs(e,Js`\\[1-9]`,zs.DEFAULT),a=new Map,l=[];let c,u=!1,p=0,h=0;for(ri.lastIndex=0;c=ri.exec(e);){const{0:t,groups:{captureName:d,rDepth:m,gRNameOrNum:g,gRDepth:f}}=c;if("["===t)p++;else if(p)"]"===t&&p--;else{if(m){if(ii(m),u)throw new Error(si);if(o)throw new Error(("external"===r?"Backrefs":"Numbered backrefs")+" cannot be used with global recursion");const t=e.slice(0,c.index),a=e.slice(ri.lastIndex);if(Vs(a,ei,zs.DEFAULT))throw new Error(si);const l=+m-1;e=oi(t,a,l,!1,n,i,h),s=ci(s,t,l,i.length,0,h);break}if(g){ii(f);let p=!1;for(const e of l)if(e.name===g||e.num===+g){if(p=!0,e.hasRecursedWithin)throw new Error(si);break}if(!p)throw new Error(Js`Recursive \g cannot be used outside the referenced group "${"external"===r?g:Js`\g<${g}&R=${f}>`}"`);const d=a.get(g),m=Xs(e,d);if(o&&Vs(m,Js`${ti}|\((?!\?)`,zs.DEFAULT))throw new Error(("external"===r?"Backrefs":"Numbered backrefs")+" cannot be used with recursion of capturing groups");const y=e.slice(d,c.index),k=m.slice(y.length+t.length),b=i.length,w=+f-1,C=oi(y,k,w,!0,n,i,h);s=ci(s,y,w,i.length-b,b,h);const _=e.slice(0,d),S=e.slice(d+m.length);e=`${_}${C}${S}`,ri.lastIndex+=C.length-t.length-y.length-k.length,l.forEach(e=>e.hasRecursedWithin=!0),u=!0}else if(d)h++,a.set(String(h),ri.lastIndex),a.set(d,ri.lastIndex),l.push({num:h,name:d});else if("("===t[0]){const e="("===t;e&&(h++,a.set(String(h),ri.lastIndex)),l.push(e?{num:h}:{})}else")"===t&&l.pop()}}return n.push(...i),{pattern:e,captureTransfers:s,hiddenCaptures:n}}(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:"external"}),a=function(e,t){const n=t?.hiddenCaptures??[];let r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const s="(?:(?=(",i=[0],o=[];let a,l=0,c=0,u=NaN;do{a=!1;let t,p=0,h=0,d=!1;for(Ks.lastIndex=Number.isNaN(u)?0:u+7;t=Ks.exec(e);){const{0:m,index:g,groups:{capturingStart:f,noncapturingStart:y}}=t;if("["===m)p++;else if(p)"]"===m&&p--;else if("(?>"!==m||d){if(d&&y)h++;else if(f)d?h++:(l++,i.push(l+c));else if(")"===m&&d){if(!h){c++;const t=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+3,g)}))<$$${t}>)${e.slice(g+1)}`,a=!0,o.push(t),Us(n,t),r.size){const e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}h--}}else u=g,d=!0}}while(a);return n.push(...o),e=Hs(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){const n=+t;if(n>i.length-1)throw new Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},zs.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}(function(e){if(!new RegExp(`${Qs}\\+`).test(e))return{pattern:e};const t=[];let n,r=null,s=null,i="",o=0;for(Zs.lastIndex=0;n=Zs.exec(e);){const{0:a,index:l,groups:{qBase:c,qMod:u,invalidQ:p}}=n;if("["===a)o||(s=l),o++;else if("]"===a)o?o--:s=null;else if(!o)if("+"===u&&i&&!i.startsWith("(")){if(p)throw new Error(`Invalid quantifier "${a}"`);let t=-1;if(/^\{\d+\}$/.test(c))e=Ws(e,l+c.length,u,"");else{if(")"===i||"]"===i){const t=")"===i?r:s;if(null===t)throw new Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,l)}${c})${e.slice(l+a.length)}`}else e=`${e.slice(0,l-i.length)}(?>${i}${c})${e.slice(l+a.length)}`;t+=4}Zs.lastIndex+=t}else"("===a[0]?t.push(l):")"===a&&(r=t.length?t.pop():null);i=a}return{pattern:e}}(o.pattern).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 e=a.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(a.captureTransfers),r=s._strategy,i=l.pattern.length>=n.lazyCompileLength;(e.length||t.length||r||i)&&(l.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...r&&{strategy:r},...i&&{lazyCompile:i}})}return l}(e,t);return n.options?new oo(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}const co=4294967295;class uo{constructor(e,t={}){this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:s}=t;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if("string"!=typeof e)return e;const t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{const t=s(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}regexps;findNextMatchSync(e,t,n){const r="string"==typeof e?e:e.content,s=[];function i(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>null==e?{start:co,end:co,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){const n=this.regexps[e];if(n)try{n.lastIndex=t;const o=n.exec(r);if(!o)continue;if(o.index===t)return i(e,o,0);s.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(s.length){const e=Math.min(...s.map(e=>e[1].index));for(const[t,n,r]of s)if(n.index===e)return i(t,n,r)}return null}}const po=[{id:"abap",name:"ABAP",import:()=>import("@shikijs/langs/abap")},{id:"actionscript-3",name:"ActionScript",import:()=>import("@shikijs/langs/actionscript-3")},{id:"ada",name:"Ada",import:()=>import("@shikijs/langs/ada")},{id:"angular-html",name:"Angular HTML",import:()=>import("@shikijs/langs/angular-html")},{id:"angular-ts",name:"Angular TypeScript",import:()=>import("@shikijs/langs/angular-ts")},{id:"apache",name:"Apache Conf",import:()=>import("@shikijs/langs/apache")},{id:"apex",name:"Apex",import:()=>import("@shikijs/langs/apex")},{id:"apl",name:"APL",import:()=>import("@shikijs/langs/apl")},{id:"applescript",name:"AppleScript",import:()=>import("@shikijs/langs/applescript")},{id:"ara",name:"Ara",import:()=>import("@shikijs/langs/ara")},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:()=>import("@shikijs/langs/asciidoc")},{id:"asm",name:"Assembly",import:()=>import("@shikijs/langs/asm")},{id:"astro",name:"Astro",import:()=>import("@shikijs/langs/astro")},{id:"awk",name:"AWK",import:()=>import("@shikijs/langs/awk")},{id:"ballerina",name:"Ballerina",import:()=>import("@shikijs/langs/ballerina")},{id:"bat",name:"Batch File",aliases:["batch"],import:()=>import("@shikijs/langs/bat")},{id:"beancount",name:"Beancount",import:()=>import("@shikijs/langs/beancount")},{id:"berry",name:"Berry",aliases:["be"],import:()=>import("@shikijs/langs/berry")},{id:"bibtex",name:"BibTeX",import:()=>import("@shikijs/langs/bibtex")},{id:"bicep",name:"Bicep",import:()=>import("@shikijs/langs/bicep")},{id:"blade",name:"Blade",import:()=>import("@shikijs/langs/blade")},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:()=>import("@shikijs/langs/bsl")},{id:"c",name:"C",import:()=>import("@shikijs/langs/c")},{id:"cadence",name:"Cadence",aliases:["cdc"],import:()=>import("@shikijs/langs/cadence")},{id:"cairo",name:"Cairo",import:()=>import("@shikijs/langs/cairo")},{id:"clarity",name:"Clarity",import:()=>import("@shikijs/langs/clarity")},{id:"clojure",name:"Clojure",aliases:["clj"],import:()=>import("@shikijs/langs/clojure")},{id:"cmake",name:"CMake",import:()=>import("@shikijs/langs/cmake")},{id:"cobol",name:"COBOL",import:()=>import("@shikijs/langs/cobol")},{id:"codeowners",name:"CODEOWNERS",import:()=>import("@shikijs/langs/codeowners")},{id:"codeql",name:"CodeQL",aliases:["ql"],import:()=>import("@shikijs/langs/codeql")},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:()=>import("@shikijs/langs/coffee")},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:()=>import("@shikijs/langs/common-lisp")},{id:"coq",name:"Coq",import:()=>import("@shikijs/langs/coq")},{id:"cpp",name:"C++",aliases:["c++"],import:()=>import("@shikijs/langs/cpp")},{id:"crystal",name:"Crystal",import:()=>import("@shikijs/langs/crystal")},{id:"csharp",name:"C#",aliases:["c#","cs"],import:()=>import("@shikijs/langs/csharp")},{id:"css",name:"CSS",import:()=>import("@shikijs/langs/css")},{id:"csv",name:"CSV",import:()=>import("@shikijs/langs/csv")},{id:"cue",name:"CUE",import:()=>import("@shikijs/langs/cue")},{id:"cypher",name:"Cypher",aliases:["cql"],import:()=>import("@shikijs/langs/cypher")},{id:"d",name:"D",import:()=>import("@shikijs/langs/d")},{id:"dart",name:"Dart",import:()=>import("@shikijs/langs/dart")},{id:"dax",name:"DAX",import:()=>import("@shikijs/langs/dax")},{id:"desktop",name:"Desktop",import:()=>import("@shikijs/langs/desktop")},{id:"diff",name:"Diff",import:()=>import("@shikijs/langs/diff")},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:()=>import("@shikijs/langs/docker")},{id:"dotenv",name:"dotEnv",import:()=>import("@shikijs/langs/dotenv")},{id:"dream-maker",name:"Dream Maker",import:()=>import("@shikijs/langs/dream-maker")},{id:"edge",name:"Edge",import:()=>import("@shikijs/langs/edge")},{id:"elixir",name:"Elixir",import:()=>import("@shikijs/langs/elixir")},{id:"elm",name:"Elm",import:()=>import("@shikijs/langs/elm")},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:()=>import("@shikijs/langs/emacs-lisp")},{id:"erb",name:"ERB",import:()=>import("@shikijs/langs/erb")},{id:"erlang",name:"Erlang",aliases:["erl"],import:()=>import("@shikijs/langs/erlang")},{id:"fennel",name:"Fennel",import:()=>import("@shikijs/langs/fennel")},{id:"fish",name:"Fish",import:()=>import("@shikijs/langs/fish")},{id:"fluent",name:"Fluent",aliases:["ftl"],import:()=>import("@shikijs/langs/fluent")},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:()=>import("@shikijs/langs/fortran-fixed-form")},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:()=>import("@shikijs/langs/fortran-free-form")},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:()=>import("@shikijs/langs/fsharp")},{id:"gdresource",name:"GDResource",import:()=>import("@shikijs/langs/gdresource")},{id:"gdscript",name:"GDScript",import:()=>import("@shikijs/langs/gdscript")},{id:"gdshader",name:"GDShader",import:()=>import("@shikijs/langs/gdshader")},{id:"genie",name:"Genie",import:()=>import("@shikijs/langs/genie")},{id:"gherkin",name:"Gherkin",import:()=>import("@shikijs/langs/gherkin")},{id:"git-commit",name:"Git Commit Message",import:()=>import("@shikijs/langs/git-commit")},{id:"git-rebase",name:"Git Rebase Message",import:()=>import("@shikijs/langs/git-rebase")},{id:"gleam",name:"Gleam",import:()=>import("@shikijs/langs/gleam")},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:()=>import("@shikijs/langs/glimmer-js")},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:()=>import("@shikijs/langs/glimmer-ts")},{id:"glsl",name:"GLSL",import:()=>import("@shikijs/langs/glsl")},{id:"gnuplot",name:"Gnuplot",import:()=>import("@shikijs/langs/gnuplot")},{id:"go",name:"Go",import:()=>import("@shikijs/langs/go")},{id:"graphql",name:"GraphQL",aliases:["gql"],import:()=>import("@shikijs/langs/graphql")},{id:"groovy",name:"Groovy",import:()=>import("@shikijs/langs/groovy")},{id:"hack",name:"Hack",import:()=>import("@shikijs/langs/hack")},{id:"haml",name:"Ruby Haml",import:()=>import("@shikijs/langs/haml")},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:()=>import("@shikijs/langs/handlebars")},{id:"haskell",name:"Haskell",aliases:["hs"],import:()=>import("@shikijs/langs/haskell")},{id:"haxe",name:"Haxe",import:()=>import("@shikijs/langs/haxe")},{id:"hcl",name:"HashiCorp HCL",import:()=>import("@shikijs/langs/hcl")},{id:"hjson",name:"Hjson",import:()=>import("@shikijs/langs/hjson")},{id:"hlsl",name:"HLSL",import:()=>import("@shikijs/langs/hlsl")},{id:"html",name:"HTML",import:()=>import("@shikijs/langs/html")},{id:"html-derivative",name:"HTML (Derivative)",import:()=>import("@shikijs/langs/html-derivative")},{id:"http",name:"HTTP",import:()=>import("@shikijs/langs/http")},{id:"hxml",name:"HXML",import:()=>import("@shikijs/langs/hxml")},{id:"hy",name:"Hy",import:()=>import("@shikijs/langs/hy")},{id:"imba",name:"Imba",import:()=>import("@shikijs/langs/imba")},{id:"ini",name:"INI",aliases:["properties"],import:()=>import("@shikijs/langs/ini")},{id:"java",name:"Java",import:()=>import("@shikijs/langs/java")},{id:"javascript",name:"JavaScript",aliases:["js"],import:()=>import("@shikijs/langs/javascript")},{id:"jinja",name:"Jinja",import:()=>import("@shikijs/langs/jinja")},{id:"jison",name:"Jison",import:()=>import("@shikijs/langs/jison")},{id:"json",name:"JSON",import:()=>import("@shikijs/langs/json")},{id:"json5",name:"JSON5",import:()=>import("@shikijs/langs/json5")},{id:"jsonc",name:"JSON with Comments",import:()=>import("@shikijs/langs/jsonc")},{id:"jsonl",name:"JSON Lines",import:()=>import("@shikijs/langs/jsonl")},{id:"jsonnet",name:"Jsonnet",import:()=>import("@shikijs/langs/jsonnet")},{id:"jssm",name:"JSSM",aliases:["fsl"],import:()=>import("@shikijs/langs/jssm")},{id:"jsx",name:"JSX",import:()=>import("@shikijs/langs/jsx")},{id:"julia",name:"Julia",aliases:["jl"],import:()=>import("@shikijs/langs/julia")},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:()=>import("@shikijs/langs/kotlin")},{id:"kusto",name:"Kusto",aliases:["kql"],import:()=>import("@shikijs/langs/kusto")},{id:"latex",name:"LaTeX",import:()=>import("@shikijs/langs/latex")},{id:"lean",name:"Lean 4",aliases:["lean4"],import:()=>import("@shikijs/langs/lean")},{id:"less",name:"Less",import:()=>import("@shikijs/langs/less")},{id:"liquid",name:"Liquid",import:()=>import("@shikijs/langs/liquid")},{id:"llvm",name:"LLVM IR",import:()=>import("@shikijs/langs/llvm")},{id:"log",name:"Log file",import:()=>import("@shikijs/langs/log")},{id:"logo",name:"Logo",import:()=>import("@shikijs/langs/logo")},{id:"lua",name:"Lua",import:()=>import("@shikijs/langs/lua")},{id:"luau",name:"Luau",import:()=>import("@shikijs/langs/luau")},{id:"make",name:"Makefile",aliases:["makefile"],import:()=>import("@shikijs/langs/make")},{id:"markdown",name:"Markdown",aliases:["md"],import:()=>import("@shikijs/langs/markdown")},{id:"marko",name:"Marko",import:()=>import("@shikijs/langs/marko")},{id:"matlab",name:"MATLAB",import:()=>import("@shikijs/langs/matlab")},{id:"mdc",name:"MDC",import:()=>import("@shikijs/langs/mdc")},{id:"mdx",name:"MDX",import:()=>import("@shikijs/langs/mdx")},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:()=>import("@shikijs/langs/mermaid")},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:()=>import("@shikijs/langs/mipsasm")},{id:"mojo",name:"Mojo",import:()=>import("@shikijs/langs/mojo")},{id:"move",name:"Move",import:()=>import("@shikijs/langs/move")},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:()=>import("@shikijs/langs/narrat")},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:()=>import("@shikijs/langs/nextflow")},{id:"nginx",name:"Nginx",import:()=>import("@shikijs/langs/nginx")},{id:"nim",name:"Nim",import:()=>import("@shikijs/langs/nim")},{id:"nix",name:"Nix",import:()=>import("@shikijs/langs/nix")},{id:"nushell",name:"nushell",aliases:["nu"],import:()=>import("@shikijs/langs/nushell")},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:()=>import("@shikijs/langs/objective-c")},{id:"objective-cpp",name:"Objective-C++",import:()=>import("@shikijs/langs/objective-cpp")},{id:"ocaml",name:"OCaml",import:()=>import("@shikijs/langs/ocaml")},{id:"pascal",name:"Pascal",import:()=>import("@shikijs/langs/pascal")},{id:"perl",name:"Perl",import:()=>import("@shikijs/langs/perl")},{id:"php",name:"PHP",import:()=>import("@shikijs/langs/php")},{id:"plsql",name:"PL/SQL",import:()=>import("@shikijs/langs/plsql")},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:()=>import("@shikijs/langs/po")},{id:"polar",name:"Polar",import:()=>import("@shikijs/langs/polar")},{id:"postcss",name:"PostCSS",import:()=>import("@shikijs/langs/postcss")},{id:"powerquery",name:"PowerQuery",import:()=>import("@shikijs/langs/powerquery")},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:()=>import("@shikijs/langs/powershell")},{id:"prisma",name:"Prisma",import:()=>import("@shikijs/langs/prisma")},{id:"prolog",name:"Prolog",import:()=>import("@shikijs/langs/prolog")},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:()=>import("@shikijs/langs/proto")},{id:"pug",name:"Pug",aliases:["jade"],import:()=>import("@shikijs/langs/pug")},{id:"puppet",name:"Puppet",import:()=>import("@shikijs/langs/puppet")},{id:"purescript",name:"PureScript",import:()=>import("@shikijs/langs/purescript")},{id:"python",name:"Python",aliases:["py"],import:()=>import("@shikijs/langs/python")},{id:"qml",name:"QML",import:()=>import("@shikijs/langs/qml")},{id:"qmldir",name:"QML Directory",import:()=>import("@shikijs/langs/qmldir")},{id:"qss",name:"Qt Style Sheets",import:()=>import("@shikijs/langs/qss")},{id:"r",name:"R",import:()=>import("@shikijs/langs/r")},{id:"racket",name:"Racket",import:()=>import("@shikijs/langs/racket")},{id:"raku",name:"Raku",aliases:["perl6"],import:()=>import("@shikijs/langs/raku")},{id:"razor",name:"ASP.NET Razor",import:()=>import("@shikijs/langs/razor")},{id:"reg",name:"Windows Registry Script",import:()=>import("@shikijs/langs/reg")},{id:"regexp",name:"RegExp",aliases:["regex"],import:()=>import("@shikijs/langs/regexp")},{id:"rel",name:"Rel",import:()=>import("@shikijs/langs/rel")},{id:"riscv",name:"RISC-V",import:()=>import("@shikijs/langs/riscv")},{id:"rst",name:"reStructuredText",import:()=>import("@shikijs/langs/rst")},{id:"ruby",name:"Ruby",aliases:["rb"],import:()=>import("@shikijs/langs/ruby")},{id:"rust",name:"Rust",aliases:["rs"],import:()=>import("@shikijs/langs/rust")},{id:"sas",name:"SAS",import:()=>import("@shikijs/langs/sas")},{id:"sass",name:"Sass",import:()=>import("@shikijs/langs/sass")},{id:"scala",name:"Scala",import:()=>import("@shikijs/langs/scala")},{id:"scheme",name:"Scheme",import:()=>import("@shikijs/langs/scheme")},{id:"scss",name:"SCSS",import:()=>import("@shikijs/langs/scss")},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:()=>import("@shikijs/langs/sdbl")},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:()=>import("@shikijs/langs/shaderlab")},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:()=>import("@shikijs/langs/shellscript")},{id:"shellsession",name:"Shell Session",aliases:["console"],import:()=>import("@shikijs/langs/shellsession")},{id:"smalltalk",name:"Smalltalk",import:()=>import("@shikijs/langs/smalltalk")},{id:"solidity",name:"Solidity",import:()=>import("@shikijs/langs/solidity")},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:()=>import("@shikijs/langs/soy")},{id:"sparql",name:"SPARQL",import:()=>import("@shikijs/langs/sparql")},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:()=>import("@shikijs/langs/splunk")},{id:"sql",name:"SQL",import:()=>import("@shikijs/langs/sql")},{id:"ssh-config",name:"SSH Config",import:()=>import("@shikijs/langs/ssh-config")},{id:"stata",name:"Stata",import:()=>import("@shikijs/langs/stata")},{id:"stylus",name:"Stylus",aliases:["styl"],import:()=>import("@shikijs/langs/stylus")},{id:"svelte",name:"Svelte",import:()=>import("@shikijs/langs/svelte")},{id:"swift",name:"Swift",import:()=>import("@shikijs/langs/swift")},{id:"system-verilog",name:"SystemVerilog",import:()=>import("@shikijs/langs/system-verilog")},{id:"systemd",name:"Systemd Units",import:()=>import("@shikijs/langs/systemd")},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:()=>import("@shikijs/langs/talonscript")},{id:"tasl",name:"Tasl",import:()=>import("@shikijs/langs/tasl")},{id:"tcl",name:"Tcl",import:()=>import("@shikijs/langs/tcl")},{id:"templ",name:"Templ",import:()=>import("@shikijs/langs/templ")},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:()=>import("@shikijs/langs/terraform")},{id:"tex",name:"TeX",import:()=>import("@shikijs/langs/tex")},{id:"toml",name:"TOML",import:()=>import("@shikijs/langs/toml")},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:()=>import("@shikijs/langs/ts-tags")},{id:"tsv",name:"TSV",import:()=>import("@shikijs/langs/tsv")},{id:"tsx",name:"TSX",import:()=>import("@shikijs/langs/tsx")},{id:"turtle",name:"Turtle",import:()=>import("@shikijs/langs/turtle")},{id:"twig",name:"Twig",import:()=>import("@shikijs/langs/twig")},{id:"typescript",name:"TypeScript",aliases:["ts"],import:()=>import("@shikijs/langs/typescript")},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:()=>import("@shikijs/langs/typespec")},{id:"typst",name:"Typst",aliases:["typ"],import:()=>import("@shikijs/langs/typst")},{id:"v",name:"V",import:()=>import("@shikijs/langs/v")},{id:"vala",name:"Vala",import:()=>import("@shikijs/langs/vala")},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:()=>import("@shikijs/langs/vb")},{id:"verilog",name:"Verilog",import:()=>import("@shikijs/langs/verilog")},{id:"vhdl",name:"VHDL",import:()=>import("@shikijs/langs/vhdl")},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:()=>import("@shikijs/langs/viml")},{id:"vue",name:"Vue",import:()=>import("@shikijs/langs/vue")},{id:"vue-html",name:"Vue HTML",import:()=>import("@shikijs/langs/vue-html")},{id:"vyper",name:"Vyper",aliases:["vy"],import:()=>import("@shikijs/langs/vyper")},{id:"wasm",name:"WebAssembly",import:()=>import("@shikijs/langs/wasm")},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:()=>import("@shikijs/langs/wenyan")},{id:"wgsl",name:"WGSL",import:()=>import("@shikijs/langs/wgsl")},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:()=>import("@shikijs/langs/wikitext")},{id:"wit",name:"WebAssembly Interface Types",import:()=>import("@shikijs/langs/wit")},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:()=>import("@shikijs/langs/wolfram")},{id:"xml",name:"XML",import:()=>import("@shikijs/langs/xml")},{id:"xsl",name:"XSL",import:()=>import("@shikijs/langs/xsl")},{id:"yaml",name:"YAML",aliases:["yml"],import:()=>import("@shikijs/langs/yaml")},{id:"zenscript",name:"ZenScript",import:()=>import("@shikijs/langs/zenscript")},{id:"zig",name:"Zig",import:()=>import("@shikijs/langs/zig")}],ho=(Object.fromEntries(po.map(e=>[e.id,e.import])),Object.fromEntries(po.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:()=>import("@shikijs/themes/andromeeda")},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:()=>import("@shikijs/themes/aurora-x")},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:()=>import("@shikijs/themes/ayu-dark")},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:()=>import("@shikijs/themes/catppuccin-frappe")},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:()=>import("@shikijs/themes/catppuccin-latte")},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:()=>import("@shikijs/themes/catppuccin-macchiato")},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:()=>import("@shikijs/themes/catppuccin-mocha")},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:()=>import("@shikijs/themes/dark-plus")},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:()=>import("@shikijs/themes/dracula")},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:()=>import("@shikijs/themes/dracula-soft")},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:()=>import("@shikijs/themes/everforest-dark")},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:()=>import("@shikijs/themes/everforest-light")},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:()=>import("@shikijs/themes/github-dark")},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:()=>import("@shikijs/themes/github-dark-default")},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:()=>import("@shikijs/themes/github-dark-dimmed")},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:()=>import("@shikijs/themes/github-dark-high-contrast")},{id:"github-light",displayName:"GitHub Light",type:"light",import:()=>import("@shikijs/themes/github-light")},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:()=>import("@shikijs/themes/github-light-default")},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:()=>import("@shikijs/themes/github-light-high-contrast")},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:()=>import("@shikijs/themes/gruvbox-dark-hard")},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:()=>import("@shikijs/themes/gruvbox-dark-medium")},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:()=>import("@shikijs/themes/gruvbox-dark-soft")},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:()=>import("@shikijs/themes/gruvbox-light-hard")},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:()=>import("@shikijs/themes/gruvbox-light-medium")},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:()=>import("@shikijs/themes/gruvbox-light-soft")},{id:"houston",displayName:"Houston",type:"dark",import:()=>import("@shikijs/themes/houston")},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:()=>import("@shikijs/themes/kanagawa-dragon")},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:()=>import("@shikijs/themes/kanagawa-lotus")},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:()=>import("@shikijs/themes/kanagawa-wave")},{id:"laserwave",displayName:"LaserWave",type:"dark",import:()=>import("@shikijs/themes/laserwave")},{id:"light-plus",displayName:"Light Plus",type:"light",import:()=>import("@shikijs/themes/light-plus")},{id:"material-theme",displayName:"Material Theme",type:"dark",import:()=>import("@shikijs/themes/material-theme")},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:()=>import("@shikijs/themes/material-theme-darker")},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:()=>import("@shikijs/themes/material-theme-lighter")},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:()=>import("@shikijs/themes/material-theme-ocean")},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:()=>import("@shikijs/themes/material-theme-palenight")},{id:"min-dark",displayName:"Min Dark",type:"dark",import:()=>import("@shikijs/themes/min-dark")},{id:"min-light",displayName:"Min Light",type:"light",import:()=>import("@shikijs/themes/min-light")},{id:"monokai",displayName:"Monokai",type:"dark",import:()=>import("@shikijs/themes/monokai")},{id:"night-owl",displayName:"Night Owl",type:"dark",import:()=>import("@shikijs/themes/night-owl")},{id:"nord",displayName:"Nord",type:"dark",import:()=>import("@shikijs/themes/nord")},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:()=>import("@shikijs/themes/one-dark-pro")},{id:"one-light",displayName:"One Light",type:"light",import:()=>import("@shikijs/themes/one-light")},{id:"plastic",displayName:"Plastic",type:"dark",import:()=>import("@shikijs/themes/plastic")},{id:"poimandres",displayName:"Poimandres",type:"dark",import:()=>import("@shikijs/themes/poimandres")},{id:"red",displayName:"Red",type:"dark",import:()=>import("@shikijs/themes/red")},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:()=>import("@shikijs/themes/rose-pine")},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:()=>import("@shikijs/themes/rose-pine-dawn")},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:()=>import("@shikijs/themes/rose-pine-moon")},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:()=>import("@shikijs/themes/slack-dark")},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:()=>import("@shikijs/themes/slack-ochin")},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:()=>import("@shikijs/themes/snazzy-light")},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:()=>import("@shikijs/themes/solarized-dark")},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:()=>import("@shikijs/themes/solarized-light")},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:()=>import("@shikijs/themes/synthwave-84")},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:()=>import("@shikijs/themes/tokyo-night")},{id:"vesper",displayName:"Vesper",type:"dark",import:()=>import("@shikijs/themes/vesper")},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:()=>import("@shikijs/themes/vitesse-black")},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:()=>import("@shikijs/themes/vitesse-dark")},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:()=>import("@shikijs/themes/vitesse-light")}]);Object.fromEntries(ho.map(e=>[e.id,e.import]));const mo=function(e){const t=Tr(e);return{getLastGrammarState:(...e)=>function(...e){if(2===e.length)return Jn(e[1]);const[t,n,r={}]=e,{lang:s="text",theme:i=t.getLoadedThemes()[0]}=r;if(Bn(s)||Un(i))throw new W("Plain language does not have grammar state");if("ansi"===s)throw new W("ANSI language does not have grammar state");const{theme:o,colorMap:a}=t.setTheme(i),l=t.getLanguage(s);return new Yn(dr(n,l,o,a,r).stateStack,l.name,o.name)}(t,...e),codeToTokensBase:(e,n)=>hr(t,e,n),codeToTokensWithThemes:(e,n)=>br(t,e,n),codeToTokens:(e,n)=>wr(t,e,n),codeToHast:(e,n)=>_r(t,e,n),codeToHtml:(e,n)=>function(e,t,n){const r={meta:{},options:n,codeToHast:(t,n)=>_r(e,t,n),codeToTokens:(t,n)=>wr(e,t,n)};let s=Sr(_r(e,t,n,r));for(const e of rr(n))s=e.postprocess?.call(r,s,n)||s;return s}(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}({engine:function(e={}){const t=Object.assign({target:"auto",cache:new Map},e);return t.regexConstructor||=e=>function(e,t){return lo(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}(e,{target:t.target}),{createScanner:e=>new uo(e,t),createString:e=>({content:e})}}(),langs:[],themes:[]});function go(e){const t=/^diff-([\w-]+)/i.exec(e);return t?t[1]:null}function fo(e){const t=go(e)||e;return!!Fn(t)||mo.getLoadedLanguages().includes(t)}function yo(t,n,r){const s=go(t),i=s||t;if(!fo(i)){const s=po.find(e=>e.id===i||e.aliases&&e.aliases.includes(i));if(s)return mo.loadLanguage(s.import()).then(()=>{n&&r&&n.update(()=>{const n=d(r);e(n)&&n.getLanguage()===t&&!n.getIsSyntaxHighlightSupported()&&n.setIsSyntaxHighlightSupported(!0)})})}}function ko(e){const t=e;return!!Wn(t)||mo.getLoadedThemes().includes(t)}function bo(t,n,r){if(!ko(t)){const s=ho.find(e=>e.id===t);if(s)return mo.loadTheme(s.import()).then(()=>{n&&r&&n.update(()=>{const t=d(r);e(t)&&t.markDirty()})})}}function wo(){return po.map(e=>[e.id,e.name])}function Co(){return ho.map(e=>[e.id,e.displayName])}function _o(e){const t=e,n=po.find(e=>e.id===t||e.aliases&&e.aliases.includes(t));return n?n.id:e}function So(e,n){const r=/^diff-([\w-]+)/i.exec(n),s=e.getTextContent(),i=mo.codeToTokens(s,{lang:r?r[1]:n,theme:e.getTheme()||"poimandres"}),{tokens:o,bg:a,fg:l}=i;let c="";return a&&(c+=`background-color: ${a};`),l&&(c+=`color: ${l};`),e.getStyle()!==c&&e.setStyle(c),function(e,n){const r=[];return e.forEach((e,s)=>{s&&r.push(m()),e.forEach((e,s)=>{let i=e.content;if(n&&0===s&&i.length>0){const e=["+","-",">","<"," "],n=["inserted","deleted","inserted","deleted","unchanged"],s=e.indexOf(i[0]);-1!==s&&(r.push(t(e[s],n[s])),i=i.slice(1))}i.split("\t").forEach((n,s)=>{if(s&&r.push(g()),""!==n){const s=t(n),i=Kn(e.htmlStyle||Xn(e));s.setStyle(i),r.push(s)}})})}),r}(o,!!r)}const vo={$tokenize(e,t){return So(e,t||this.defaultLanguage)},defaultLanguage:r,defaultTheme:"one-light"};function xo(t,n,r){const s=t.getParent();e(s)?jo(s,n,r):o(t)&&t.replace(P(t.__text))}function No(e,t){const n=t.getElementByKey(e.getKey());if(null===n)return;const r=e.getChildren(),s=r.length;if(s===n.__cachedChildrenLength)return;n.__cachedChildrenLength=s;let i="1",o=1;for(let e=0;e<s;e++)I(r[e])&&(i+="\n"+ ++o);n.setAttribute("data-gutter",i)}const Ao=new Set;function jo(t,n,r){const s=t.getKey();let i=t.getLanguage();i||(i=r.defaultLanguage,t.setLanguage(i));let o=t.getTheme();o||(o=r.defaultTheme,t.setTheme(o));let a=!1;ko(o)||(bo(o,n,s),a=!0),fo(i)?t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(!0):(t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(!1),yo(i,n,s),a=!0),a||Ao.has(s)||(Ao.add(s),n.update(()=>{!function(t,n){const r=d(t);if(!e(r)||!r.isAttached())return;const s=_();if(!A(s))return void n();const i=s.anchor,o=i.offset,a="element"===i.type&&I(r.getChildAtIndex(i.offset-1));let l=0;if(!a){const e=i.getNode();l=o+e.getPreviousSiblings().reduce((e,t)=>e+t.getTextContentSize(),0)}if(!n())return;if(a)return void i.getNode().select(o,o);r.getChildren().some(e=>{const t=F(e);if(t||I(e)){const n=e.getTextContentSize();if(t&&n>=l)return e.select(l,l),!0;l-=n}return!1})}(s,()=>{const n=d(s);if(!e(n)||!n.isAttached())return!1;const i=n.getLanguage()||r.defaultLanguage,o=r.$tokenize(n,i),a=function(e,t){let n=0;for(;n<e.length&&Eo(e[n],t[n]);)n++;const r=e.length,s=t.length,i=Math.min(r,s)-n;let o=0;for(;o<i;)if(o++,!Eo(e[r-o],t[s-o])){o--;break}const a=n,l=r-o,c=t.slice(n,s-o);return{from:a,nodesForReplacement:c,to:l}}(n.getChildren(),o),{from:l,to:c,nodesForReplacement:u}=a;return!(l===c&&!u.length)&&(t.splice(l,c-l,u),!0)})},{onUpdate:()=>{Ao.delete(s)},skipTransforms:!0}))}function Eo(e,t){return o(e)&&o(t)&&e.__text===t.__text&&e.__highlightType===t.__highlightType&&e.__style===t.__style||B(e)&&B(t)||I(e)&&I(t)}function Lo(t){if(!A(t))return!1;const n=t.anchor.getNode(),r=e(n)?n:n.getParent(),s=t.focus.getNode(),i=e(s)?s:s.getParent();return e(r)&&r.is(i)}function Io(t){const n=t.getNodes(),r=[];if(1===n.length&&e(n[0]))return r;let s=[];for(let e=0;e<n.length;e++){const t=n[e];o(t)||B(t)||I(t)||U(169),I(t)?s.length>0&&(r.push(s),s=[]):s.push(t)}if(s.length>0){const e=t.isBackward()?t.anchor:t.focus,n=R(s[0].getKey(),0,"text");e.is(n)||r.push(s)}return r}function Po(e){const t=_();if(!A(t)||!Lo(t))return!1;const n=Io(t),r=n.length;if(0===r&&t.isCollapsed())return e===v&&t.insertNodes([g()]),!0;if(0===r&&e===v&&"\n"===t.getTextContent()){const e=g(),n=m(),r=t.isBackward()?"previous":"next";return t.insertNodes([e,n]),T(M($(O(e,"next",0),G(D(n,"next"))),r)),!0}for(let s=0;s<r;s++){const r=n[s];if(r.length>0){let n=r[0];if(0===s&&(n=a(n)),e===v){const e=g();if(n.insertBefore(e),0===s){const r=t.isBackward()?"focus":"anchor",s=R(n.getKey(),0,"text");t[r].is(s)&&t[r].set(e.getKey(),0,"text")}}else B(n)&&n.remove()}}return!0}function Ro(e,t){const n=_();if(!A(n))return!1;const{anchor:r,focus:s}=n,i=r.offset,c=s.offset,u=r.getNode(),p=s.getNode(),h=e===N;if(!Lo(n)||!o(u)&&!B(u)||!o(p)&&!B(p))return!1;if(!t.altKey){if(n.isCollapsed()){const e=u.getParentOrThrow();if(h&&0===i&&null===u.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!0}else if(!h&&i===u.getTextContentSize()&&null===u.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!0}}return!1}let d,m;if(u.isBefore(p)?(d=a(u),m=l(p)):(d=a(p),m=l(u)),null==d||null==m)return!1;const g=d.getNodesBetween(m);for(let e=0;e<g.length;e++){const t=g[e];if(!o(t)&&!B(t)&&!I(t))return!1}t.preventDefault(),t.stopPropagation();const f=h?d.getPreviousSibling():m.getNextSibling();if(!I(f))return!0;const y=h?f.getPreviousSibling():f.getNextSibling();if(null==y)return!0;const k=o(y)||B(y)||I(y)?h?a(y):l(y):null;let b=null!=k?k:y;return f.remove(),g.forEach(e=>e.remove()),e===N?(g.forEach(e=>b.insertBefore(e)),b.insertBefore(f)):(b.insertAfter(f),b=f,g.forEach(e=>{b.insertAfter(e),b=e})),n.setTextNodeRange(u,i,p,c),!0}function To(e,t){const n=_();if(!A(n))return!1;const{anchor:r,focus:s}=n,i=r.getNode(),a=s.getNode(),l=e===E;if(!Lo(n)||!o(i)&&!B(i)||!o(a)&&!B(a))return!1;const h=a;if("rtl"===c(h)?!l:l){const e=u(h,s.offset);if(null!==e){const{node:t,offset:r}=e;I(t)?t.selectNext(0,0):n.setTextNodeRange(t,r,t,r)}else h.getParentOrThrow().selectStart()}else{p(h).select()}return t.preventDefault(),t.stopPropagation(),!0}function Mo(t,n){if(!t.hasNodes([s,i]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==n&&(n=vo);const r=[];return!0!==t._headless&&r.push(t.registerMutationListener(s,e=>{t.getEditorState().read(()=>{for(const[n,r]of e)if("destroyed"!==r){const e=d(n);null!==e&&No(e,t)}})},{skipInitialization:!1})),r.push(t.registerNodeTransform(s,e=>jo(e,t,n)),t.registerNodeTransform(k,e=>xo(e,t,n)),t.registerNodeTransform(i,e=>xo(e,t,n)),t.registerCommand(b,e=>{const n=function(e){const t=_();if(!A(t)||!Lo(t))return null;const n=e?x:v,r=e?x:C,s=t.anchor,i=t.focus;if(s.is(i))return r;const o=Io(t);if(1!==o.length)return n;const c=o[0];let u,p;0===c.length&&U(285),t.isBackward()?(u=i,p=s):(u=s,p=i);const h=a(c[0]),d=l(c[0]),m=R(h.getKey(),0,"text"),g=R(d.getKey(),d.getTextContentSize(),"text");return u.isBefore(m)||g.isBefore(p)?n:m.isBefore(u)||p.isBefore(g)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)},w),t.registerCommand(C,()=>!!Lo(_())&&(S([g()]),!0),w),t.registerCommand(v,e=>Po(v),w),t.registerCommand(x,e=>Po(x),w),t.registerCommand(N,t=>{const n=_();if(!A(n))return!1;const{anchor:r}=n,s=r.getNode();return!!Lo(n)&&(n.isCollapsed()&&0===r.offset&&null===s.getPreviousSibling()&&e(s.getParentOrThrow())?(t.preventDefault(),!0):Ro(N,t))},w),t.registerCommand(j,t=>{const n=_();if(!A(n))return!1;const{anchor:r}=n,s=r.getNode();return!!Lo(n)&&(n.isCollapsed()&&r.offset===s.getTextContentSize()&&null===s.getNextSibling()&&e(s.getParentOrThrow())?(t.preventDefault(),!0):Ro(j,t))},w),t.registerCommand(E,e=>To(E,e),w),t.registerCommand(L,e=>To(L,e),w)),h(...r)}const $o=f({config:y(vo),dependencies:[n],name:"@lexical/code-shiki",register:(e,t)=>Mo(e,t)});export{$o as CodeHighlighterShikiExtension,vo as ShikiTokenizer,wo as getCodeLanguageOptions,Co as getCodeThemeOptions,fo as isCodeLanguageLoaded,yo as loadCodeLanguage,bo as loadCodeTheme,_o as normalizeCodeLanguage,Mo as registerCodeHighlighting};
|