nao-core 0.0.38__py3-none-manylinux2014_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. nao_core/__init__.py +2 -0
  2. nao_core/__init__.py.bak +2 -0
  3. nao_core/bin/build-info.json +5 -0
  4. nao_core/bin/fastapi/main.py +268 -0
  5. nao_core/bin/fastapi/test_main.py +156 -0
  6. nao_core/bin/migrations-postgres/0000_user_auth_and_chat_tables.sql +98 -0
  7. nao_core/bin/migrations-postgres/0001_message_feedback.sql +9 -0
  8. nao_core/bin/migrations-postgres/0002_chat_message_stop_reason_and_error_message.sql +2 -0
  9. nao_core/bin/migrations-postgres/0003_handle_slack_with_thread.sql +2 -0
  10. nao_core/bin/migrations-postgres/0004_input_and_output_tokens.sql +8 -0
  11. nao_core/bin/migrations-postgres/0005_add_project_tables.sql +39 -0
  12. nao_core/bin/migrations-postgres/0006_llm_model_ids.sql +4 -0
  13. nao_core/bin/migrations-postgres/0007_chat_message_llm_info.sql +2 -0
  14. nao_core/bin/migrations-postgres/meta/0000_snapshot.json +707 -0
  15. nao_core/bin/migrations-postgres/meta/0001_snapshot.json +766 -0
  16. nao_core/bin/migrations-postgres/meta/0002_snapshot.json +778 -0
  17. nao_core/bin/migrations-postgres/meta/0003_snapshot.json +799 -0
  18. nao_core/bin/migrations-postgres/meta/0004_snapshot.json +847 -0
  19. nao_core/bin/migrations-postgres/meta/0005_snapshot.json +1129 -0
  20. nao_core/bin/migrations-postgres/meta/0006_snapshot.json +1141 -0
  21. nao_core/bin/migrations-postgres/meta/_journal.json +62 -0
  22. nao_core/bin/migrations-sqlite/0000_user_auth_and_chat_tables.sql +98 -0
  23. nao_core/bin/migrations-sqlite/0001_message_feedback.sql +8 -0
  24. nao_core/bin/migrations-sqlite/0002_chat_message_stop_reason_and_error_message.sql +2 -0
  25. nao_core/bin/migrations-sqlite/0003_handle_slack_with_thread.sql +2 -0
  26. nao_core/bin/migrations-sqlite/0004_input_and_output_tokens.sql +8 -0
  27. nao_core/bin/migrations-sqlite/0005_add_project_tables.sql +38 -0
  28. nao_core/bin/migrations-sqlite/0006_llm_model_ids.sql +4 -0
  29. nao_core/bin/migrations-sqlite/0007_chat_message_llm_info.sql +2 -0
  30. nao_core/bin/migrations-sqlite/meta/0000_snapshot.json +674 -0
  31. nao_core/bin/migrations-sqlite/meta/0001_snapshot.json +735 -0
  32. nao_core/bin/migrations-sqlite/meta/0002_snapshot.json +749 -0
  33. nao_core/bin/migrations-sqlite/meta/0003_snapshot.json +763 -0
  34. nao_core/bin/migrations-sqlite/meta/0004_snapshot.json +819 -0
  35. nao_core/bin/migrations-sqlite/meta/0005_snapshot.json +1086 -0
  36. nao_core/bin/migrations-sqlite/meta/0006_snapshot.json +1100 -0
  37. nao_core/bin/migrations-sqlite/meta/_journal.json +62 -0
  38. nao_core/bin/nao-chat-server +0 -0
  39. nao_core/bin/public/assets/code-block-F6WJLWQG-CV0uOmNJ.js +153 -0
  40. nao_core/bin/public/assets/index-DcbndLHo.css +1 -0
  41. nao_core/bin/public/assets/index-t1hZI3nl.js +560 -0
  42. nao_core/bin/public/favicon.ico +0 -0
  43. nao_core/bin/public/index.html +18 -0
  44. nao_core/bin/rg +0 -0
  45. nao_core/commands/__init__.py +6 -0
  46. nao_core/commands/chat.py +225 -0
  47. nao_core/commands/debug.py +158 -0
  48. nao_core/commands/init.py +358 -0
  49. nao_core/commands/sync/__init__.py +124 -0
  50. nao_core/commands/sync/accessors.py +290 -0
  51. nao_core/commands/sync/cleanup.py +156 -0
  52. nao_core/commands/sync/providers/__init__.py +32 -0
  53. nao_core/commands/sync/providers/base.py +113 -0
  54. nao_core/commands/sync/providers/databases/__init__.py +17 -0
  55. nao_core/commands/sync/providers/databases/bigquery.py +79 -0
  56. nao_core/commands/sync/providers/databases/databricks.py +79 -0
  57. nao_core/commands/sync/providers/databases/duckdb.py +78 -0
  58. nao_core/commands/sync/providers/databases/postgres.py +79 -0
  59. nao_core/commands/sync/providers/databases/provider.py +129 -0
  60. nao_core/commands/sync/providers/databases/snowflake.py +79 -0
  61. nao_core/commands/sync/providers/notion/__init__.py +5 -0
  62. nao_core/commands/sync/providers/notion/provider.py +205 -0
  63. nao_core/commands/sync/providers/repositories/__init__.py +5 -0
  64. nao_core/commands/sync/providers/repositories/provider.py +134 -0
  65. nao_core/commands/sync/registry.py +23 -0
  66. nao_core/config/__init__.py +30 -0
  67. nao_core/config/base.py +100 -0
  68. nao_core/config/databases/__init__.py +55 -0
  69. nao_core/config/databases/base.py +85 -0
  70. nao_core/config/databases/bigquery.py +99 -0
  71. nao_core/config/databases/databricks.py +79 -0
  72. nao_core/config/databases/duckdb.py +41 -0
  73. nao_core/config/databases/postgres.py +83 -0
  74. nao_core/config/databases/snowflake.py +125 -0
  75. nao_core/config/exceptions.py +7 -0
  76. nao_core/config/llm/__init__.py +19 -0
  77. nao_core/config/notion/__init__.py +8 -0
  78. nao_core/config/repos/__init__.py +3 -0
  79. nao_core/config/repos/base.py +11 -0
  80. nao_core/config/slack/__init__.py +12 -0
  81. nao_core/context/__init__.py +54 -0
  82. nao_core/context/base.py +57 -0
  83. nao_core/context/git.py +177 -0
  84. nao_core/context/local.py +59 -0
  85. nao_core/main.py +13 -0
  86. nao_core/templates/__init__.py +41 -0
  87. nao_core/templates/context.py +193 -0
  88. nao_core/templates/defaults/databases/columns.md.j2 +23 -0
  89. nao_core/templates/defaults/databases/description.md.j2 +32 -0
  90. nao_core/templates/defaults/databases/preview.md.j2 +22 -0
  91. nao_core/templates/defaults/databases/profiling.md.j2 +34 -0
  92. nao_core/templates/engine.py +133 -0
  93. nao_core/templates/render.py +196 -0
  94. nao_core-0.0.38.dist-info/METADATA +150 -0
  95. nao_core-0.0.38.dist-info/RECORD +98 -0
  96. nao_core-0.0.38.dist-info/WHEEL +4 -0
  97. nao_core-0.0.38.dist-info/entry_points.txt +2 -0
  98. nao_core-0.0.38.dist-info/licenses/LICENSE +22 -0
@@ -0,0 +1,153 @@
1
+ import{w as Pt,s as Mr,f as jn,a as Un,b as Hn,c as Kt,z as Wn,h as zn,d as qn,r as ae,T as Vn,j as L,p as Qn,g as Gt,C as Xn,F as Jn,e as Kn}from"./index-t1hZI3nl.js";let E=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Zn(t){return Mt(t)}function Mt(t){return Array.isArray(t)?Yn(t):t instanceof RegExp?t:typeof t=="object"?es(t):t}function Yn(t){let e=[];for(let r=0,n=t.length;r<n;r++)e[r]=Mt(t[r]);return e}function es(t){let e={};for(let r in t)e[r]=Mt(t[r]);return e}function Fr(t,...e){return e.forEach(r=>{for(let n in r)t[n]=r[n]}),t}function Or(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Or(t.substring(0,t.length-1)):t.substr(~e+1)}var rt=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ae=class{static hasCaptures(t){return t===null?!1:(rt.lastIndex=0,rt.test(t))}static replaceCaptures(t,e,r){return t.replace(rt,(n,s,o,a)=>{let c=r[parseInt(s||o,10)];if(c){let i=e.substring(c.start,c.end);for(;i[0]===".";)i=i.substring(1);switch(a){case"downcase":return i.toLowerCase();case"upcase":return i.toUpperCase();default:return i}}else return n})}};function Dr(t,e){return t<e?-1:t>e?1:0}function jr(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let r=t.length,n=e.length;if(r===n){for(let s=0;s<r;s++){let o=Dr(t[s],e[s]);if(o!==0)return o}return 0}return r-n}function Zt(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function Ur(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Hr=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},Fe=class{constructor(t,e,r){this._colorMap=t,this._defaults=e,this._root=r}static createFromRawTheme(t,e){return this.createFromParsedTheme(ns(t),e)}static createFromParsedTheme(t,e){return os(t,e)}_cachedMatchRoot=new Hr(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,n=this._cachedMatchRoot.get(e).find(s=>ts(t.parent,s.parentScopes));return n?new Wr(n.fontStyle,n.foreground,n.background):null}},nt=class Le{constructor(e,r){this.parent=e,this.scopeName=r}static push(e,r){for(const n of r)e=new Le(e,n);return e}static from(...e){let r=null;for(let n=0;n<e.length;n++)r=new Le(r,e[n]);return r}push(e){return new Le(this,e)}getSegments(){let e=this;const r=[];for(;e;)r.push(e.scopeName),e=e.parent;return r.reverse(),r}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const r=[];let n=this;for(;n&&n!==e;)r.push(n.scopeName),n=n.parent;return n===e?r.reverse():void 0}};function ts(t,e){if(e.length===0)return!0;for(let r=0;r<e.length;r++){let n=e[r],s=!1;if(n===">"){if(r===e.length-1)return!1;n=e[++r],s=!0}for(;t&&!rs(t.scopeName,n);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function rs(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var Wr=class{constructor(t,e,r){this.fontStyle=t,this.foregroundId=e,this.backgroundId=r}};function ns(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,r=[],n=0;for(let s=0,o=e.length;s<o;s++){let a=e[s];if(!a.settings)continue;let c;if(typeof a.scope=="string"){let d=a.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),c=d.split(",")}else Array.isArray(a.scope)?c=a.scope:c=[""];let i=-1;if(typeof a.settings.fontStyle=="string"){i=0;let d=a.settings.fontStyle.split(" ");for(let f=0,g=d.length;f<g;f++)switch(d[f]){case"italic":i=i|1;break;case"bold":i=i|2;break;case"underline":i=i|4;break;case"strikethrough":i=i|8;break}}let l=null;typeof a.settings.foreground=="string"&&Zt(a.settings.foreground)&&(l=a.settings.foreground);let u=null;typeof a.settings.background=="string"&&Zt(a.settings.background)&&(u=a.settings.background);for(let d=0,f=c.length;d<f;d++){let h=c[d].trim().split(" "),b=h[h.length-1],y=null;h.length>1&&(y=h.slice(0,h.length-1),y.reverse()),r[n++]=new ss(b,y,s,i,l,u)}}return r}var ss=class{constructor(t,e,r,n,s,o){this.scope=t,this.parentScopes=e,this.index=r,this.fontStyle=n,this.foreground=s,this.background=o}},N=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(N||{});function os(t,e){t.sort((i,l)=>{let u=Dr(i.scope,l.scope);return u!==0||(u=jr(i.parentScopes,l.parentScopes),u!==0)?u:i.index-l.index});let r=0,n="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let i=t.shift();i.fontStyle!==-1&&(r=i.fontStyle),i.foreground!==null&&(n=i.foreground),i.background!==null&&(s=i.background)}let o=new as(e),a=new Wr(r,o.getId(n),o.getId(s)),c=new cs(new kt(0,null,-1,0,0),[]);for(let i=0,l=t.length;i<l;i++){let u=t[i];c.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new Fe(o,a,c)}var as=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,r=t.length;e<r;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},is=Object.freeze([]),kt=class zr{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,r,n,s,o){this.scopeDepth=e,this.parentScopes=r||is,this.fontStyle=n,this.foreground=s,this.background=o}clone(){return new zr(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let r=[];for(let n=0,s=e.length;n<s;n++)r[n]=e[n].clone();return r}acceptOverwrite(e,r,n,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,r!==-1&&(this.fontStyle=r),n!==0&&(this.foreground=n),s!==0&&(this.background=s)}},cs=class Ct{constructor(e,r=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=r}_rulesWithParentScopes;static _cmpBySpecificity(e,r){if(e.scopeDepth!==r.scopeDepth)return r.scopeDepth-e.scopeDepth;let n=0,s=0;for(;e.parentScopes[n]===">"&&n++,r.parentScopes[s]===">"&&s++,!(n>=e.parentScopes.length||s>=r.parentScopes.length);){const o=r.parentScopes[s].length-e.parentScopes[n].length;if(o!==0)return o;n++,s++}return r.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let n=e.indexOf("."),s,o;if(n===-1?(s=e,o=""):(s=e.substring(0,n),o=e.substring(n+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const r=this._rulesWithParentScopes.concat(this._mainRule);return r.sort(Ct._cmpBySpecificity),r}insert(e,r,n,s,o,a){if(r===""){this._doInsertHere(e,n,s,o,a);return}let c=r.indexOf("."),i,l;c===-1?(i=r,l=""):(i=r.substring(0,c),l=r.substring(c+1));let u;this._children.hasOwnProperty(i)?u=this._children[i]:(u=new Ct(this._mainRule.clone(),kt.cloneArr(this._rulesWithParentScopes)),this._children[i]=u),u.insert(e+1,l,n,s,o,a)}_doInsertHere(e,r,n,s,o){if(r===null){this._mainRule.acceptOverwrite(e,n,s,o);return}for(let a=0,c=this._rulesWithParentScopes.length;a<c;a++){let i=this._rulesWithParentScopes[a];if(jr(i.parentScopes,r)===0){i.acceptOverwrite(e,n,s,o);return}}n===-1&&(n=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new kt(e,r,n,s,o))}},le=class B{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const r=B.getLanguageId(e),n=B.getTokenType(e),s=B.getFontStyle(e),o=B.getForeground(e),a=B.getBackground(e);console.log({languageId:r,tokenType:n,fontStyle:s,foreground:o,background:a})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,r,n,s,o,a,c){let i=B.getLanguageId(e),l=B.getTokenType(e),u=B.containsBalancedBrackets(e)?1:0,d=B.getFontStyle(e),f=B.getForeground(e),g=B.getBackground(e);return r!==0&&(i=r),n!==8&&(l=n),s!==null&&(u=s?1:0),o!==-1&&(d=o),a!==0&&(f=a),c!==0&&(g=c),(i<<0|l<<8|u<<10|d<<11|f<<15|g<<24)>>>0}};function Oe(t,e){const r=[],n=ls(t);let s=n.next();for(;s!==null;){let i=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":i=1;break;case"L":i=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=n.next()}let l=a();if(r.push({matcher:l,priority:i}),s!==",")break;s=n.next()}return r;function o(){if(s==="-"){s=n.next();const i=o();return l=>!!i&&!i(l)}if(s==="("){s=n.next();const i=c();return s===")"&&(s=n.next()),i}if(Yt(s)){const i=[];do i.push(s),s=n.next();while(Yt(s));return l=>e(i,l)}return null}function a(){const i=[];let l=o();for(;l;)i.push(l),l=o();return u=>i.every(d=>d(u))}function c(){const i=[];let l=a();for(;l&&(i.push(l),s==="|"||s===",");){do s=n.next();while(s==="|"||s===",");l=a()}return u=>i.some(d=>d(u))}}function Yt(t){return!!t&&!!t.match(/[\w\.:]+/)}function ls(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,r=e.exec(t);return{next:()=>{if(!r)return null;const n=r[0];return r=e.exec(t),n}}}function qr(t){typeof t.dispose=="function"&&t.dispose()}var we=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},us=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},ds=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},fs=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new we(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new ds;for(const r of t)hs(r,this.initialScopeName,this.repo,e);for(const r of e.references)if(r instanceof we){if(this.seenFullScopeRequests.has(r.scopeName))continue;this.seenFullScopeRequests.add(r.scopeName),this.Q.push(r)}else{if(this.seenFullScopeRequests.has(r.scopeName)||this.seenPartialScopeRequests.has(r.toKey()))continue;this.seenPartialScopeRequests.add(r.toKey()),this.Q.push(r)}}};function hs(t,e,r,n){const s=r.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const o=r.lookup(e);t instanceof we?Pe({baseGrammar:o,selfGrammar:s},n):_t(t.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},n);const a=r.injections(t.scopeName);if(a)for(const c of a)n.add(new we(c))}function _t(t,e,r){if(e.repository&&e.repository[t]){const n=e.repository[t];De([n],e,r)}}function Pe(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&De(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&De(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function De(t,e,r){for(const n of t){if(r.visitedRule.has(n))continue;r.visitedRule.add(n);const s=n.repository?Fr({},e.repository,n.repository):e.repository;Array.isArray(n.patterns)&&De(n.patterns,{...e,repository:s},r);const o=n.include;if(!o)continue;const a=Vr(o);switch(a.kind){case 0:Pe({...e,selfGrammar:e.baseGrammar},r);break;case 1:Pe(e,r);break;case 2:_t(a.ruleName,{...e,repository:s},r);break;case 3:case 4:const c=a.scopeName===e.selfGrammar.scopeName?e.selfGrammar:a.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(c){const i={baseGrammar:e.baseGrammar,selfGrammar:c,repository:s};a.kind===4?_t(a.ruleName,i,r):Pe(i,r)}else a.kind===4?r.add(new us(a.scopeName,a.ruleName)):r.add(new we(a.scopeName));break}}}var gs=class{kind=0},ps=class{kind=1},ms=class{constructor(t){this.ruleName=t}kind=2},bs=class{constructor(t){this.scopeName=t}kind=3},ys=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Vr(t){if(t==="$base")return new gs;if(t==="$self")return new ps;const e=t.indexOf("#");if(e===-1)return new bs(t);if(e===0)return new ms(t.substring(1));{const r=t.substring(0,e),n=t.substring(e+1);return new ys(r,n)}}var ws=/\\(\d+)/,er=/\\(\d+)/g,ks=-1,Qr=-2;var ve=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,r,n){this.$location=t,this.id=e,this._name=r||null,this._nameIsCapturing=Ae.hasCaptures(this._name),this._contentName=n||null,this._contentNameIsCapturing=Ae.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${Or(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:Ae.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ae.replaceCaptures(this._contentName,t,e)}},Cs=class extends ve{retokenizeCapturedWithRuleId;constructor(t,e,r,n,s){super(t,e,r,n),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,r,n){throw new Error("Not supported!")}},_s=class extends ve{_match;captures;_cachedCompiledPatterns;constructor(t,e,r,n,s){super(t,e,r,null),this._match=new ke(n,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,r,n){return this._getCachedCompiledPatterns(t).compileAG(t,r,n)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ce,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},tr=class extends ve{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,r,n,s){super(t,e,r,n),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const r of this.patterns)t.getRule(r).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,r,n){return this._getCachedCompiledPatterns(t).compileAG(t,r,n)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ce,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},St=class extends ve{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,r,n,s,o,a,c,i,l){super(t,e,r,n),this._begin=new ke(s,this.id),this.beginCaptures=o,this._end=new ke(a||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=c,this.applyEndPatternLast=i||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,r,n){return this._getCachedCompiledPatterns(t,e).compileAG(t,r,n)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ce;for(const r of this.patterns)t.getRule(r).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},je=class extends ve{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,r,n,s,o,a,c,i){super(t,e,r,n),this._begin=new ke(s,this.id),this.beginCaptures=o,this.whileCaptures=c,this._while=new ke(a,Qr),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,r,n){return this._getCachedCompiledPatterns(t).compileAG(t,r,n)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ce;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,r,n){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,r,n)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Ce,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},Xr=class I{static createCaptureRule(e,r,n,s,o){return e.registerRule(a=>new Cs(r,a,n,s,o))}static getCompiledRuleId(e,r,n){return e.id||r.registerRule(s=>{if(e.id=s,e.match)return new _s(e.$vscodeTextmateLocation,e.id,e.name,e.match,I._compileCaptures(e.captures,r,n));if(typeof e.begin>"u"){e.repository&&(n=Fr({},n,e.repository));let o=e.patterns;return typeof o>"u"&&e.include&&(o=[{include:e.include}]),new tr(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,I._compilePatterns(o,r,n))}return e.while?new je(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,I._compileCaptures(e.beginCaptures||e.captures,r,n),e.while,I._compileCaptures(e.whileCaptures||e.captures,r,n),I._compilePatterns(e.patterns,r,n)):new St(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,I._compileCaptures(e.beginCaptures||e.captures,r,n),e.end,I._compileCaptures(e.endCaptures||e.captures,r,n),e.applyEndPatternLast,I._compilePatterns(e.patterns,r,n))}),e.id}static _compileCaptures(e,r,n){let s=[];if(e){let o=0;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const c=parseInt(a,10);c>o&&(o=c)}for(let a=0;a<=o;a++)s[a]=null;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const c=parseInt(a,10);let i=0;e[a].patterns&&(i=I.getCompiledRuleId(e[a],r,n)),s[c]=I.createCaptureRule(r,e[a].$vscodeTextmateLocation,e[a].name,e[a].contentName,i)}}return s}static _compilePatterns(e,r,n){let s=[];if(e)for(let o=0,a=e.length;o<a;o++){const c=e[o];let i=-1;if(c.include){const l=Vr(c.include);switch(l.kind){case 0:case 1:i=I.getCompiledRuleId(n[c.include],r,n);break;case 2:let u=n[l.ruleName];u&&(i=I.getCompiledRuleId(u,r,n));break;case 3:case 4:const d=l.scopeName,f=l.kind===4?l.ruleName:null,g=r.getExternalGrammar(d,n);if(g)if(f){let h=g.repository[f];h&&(i=I.getCompiledRuleId(h,r,g.repository))}else i=I.getCompiledRuleId(g.repository.$self,r,g.repository);break}}else i=I.getCompiledRuleId(c,r,n);if(i!==-1){const l=r.getRule(i);let u=!1;if((l instanceof tr||l instanceof St||l instanceof je)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(i)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},ke=class Jr{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,r){if(e&&typeof e=="string"){const n=e.length;let s=0,o=[],a=!1;for(let c=0;c<n;c++)if(e.charAt(c)==="\\"&&c+1<n){const l=e.charAt(c+1);l==="z"?(o.push(e.substring(s,c)),o.push("$(?!\\n)(?<!\\n)"),s=c+2):(l==="A"||l==="G")&&(a=!0),c++}this.hasAnchor=a,s===0?this.source=e:(o.push(e.substring(s,n)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=r,typeof this.source=="string"?this.hasBackReferences=ws.test(this.source):this.hasBackReferences=!1}clone(){return new Jr(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,r){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let n=r.map(s=>e.substring(s.start,s.end));return er.lastIndex=0,this.source.replace(er,(s,o)=>Ur(n[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],r=[],n=[],s=[],o,a,c,i;for(o=0,a=this.source.length;o<a;o++)c=this.source.charAt(o),e[o]=c,r[o]=c,n[o]=c,s[o]=c,c==="\\"&&o+1<a&&(i=this.source.charAt(o+1),i==="A"?(e[o+1]="￿",r[o+1]="￿",n[o+1]="A",s[o+1]="A"):i==="G"?(e[o+1]="￿",r[o+1]="G",n[o+1]="￿",s[o+1]="G"):(e[o+1]=i,r[o+1]=i,n[o+1]=i,s[o+1]=i),o++);return{A0_G0:e.join(""),A0_G1:r.join(""),A1_G0:n.join(""),A1_G1:s.join("")}}resolveAnchors(e,r){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?r?this._anchorCache.A1_G1:this._anchorCache.A1_G0:r?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Ce=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(r=>r.source);this._cached=new rr(t,e,this._items.map(r=>r.ruleId))}return this._cached}compileAG(t,e,r){return this._hasAnchors?e?r?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,r)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,r)),this._anchorCache.A1_G0):r?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,r)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,r)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,r){let n=this._items.map(s=>s.resolveAnchors(e,r));return new rr(t,n,this._items.map(s=>s.ruleId))}},rr=class{constructor(t,e,r){this.regExps=e,this.rules=r,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,r=this.rules.length;e<r;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
2
+ `)}findNextMatchSync(t,e,r){const n=this.scanner.findNextMatchSync(t,e,r);return n?{ruleId:this.rules[n.index],captureIndices:n.captureIndices}:null}},st=class{constructor(t,e){this.languageId=t,this.tokenType=e}},Ss=class vt{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,r){this._defaultAttributes=new st(e,8),this._embeddedLanguagesMatcher=new vs(Object.entries(r||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?vt._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new st(0,0);_getBasicScopeAttributes=new Hr(e=>{const r=this._scopeToLanguage(e),n=this._toStandardTokenType(e);return new st(r,n)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const r=e.match(vt.STANDARD_TOKEN_TYPE_REGEXP);if(!r)return 8;switch(r[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/},vs=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([r,n])=>Ur(r));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},nr=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Kr(t,e,r,n,s,o,a,c){const i=e.content.length;let l=!1,u=-1;if(a){const g=xs(t,e,r,n,s,o);s=g.stack,n=g.linePos,r=g.isFirstLine,u=g.anchorPosition}const d=Date.now();for(;!l;){if(c!==0&&Date.now()-d>c)return new nr(s,!0);f()}return new nr(s,!1);function f(){const g=Es(t,e,r,n,s,u);if(!g){o.produce(s,i),l=!0;return}const h=g.captureIndices,b=g.matchedRuleId,y=h&&h.length>0?h[0].end>n:!1;if(b===ks){const p=s.getRule(t);o.produce(s,h[0].start),s=s.withContentNameScopesList(s.nameScopesList),me(t,e,r,s,o,p.endCaptures,h),o.produce(s,h[0].end);const w=s;if(s=s.parent,u=w.getAnchorPos(),!y&&w.getEnterPos()===n){s=w,o.produce(s,i),l=!0;return}}else{const p=t.getRule(b);o.produce(s,h[0].start);const w=s,m=p.getName(e.content,h),k=s.contentNameScopesList.pushAttributed(m,t);if(s=s.push(b,n,u,h[0].end===i,null,k,k),p instanceof St){const _=p;me(t,e,r,s,o,_.beginCaptures,h),o.produce(s,h[0].end),u=h[0].end;const $=_.getContentName(e.content,h),R=k.pushAttributed($,t);if(s=s.withContentNameScopesList(R),_.endHasBackReferences&&(s=s.withEndRule(_.getEndWithResolvedBackReferences(e.content,h))),!y&&w.hasSameRuleAs(s)){s=s.pop(),o.produce(s,i),l=!0;return}}else if(p instanceof je){const _=p;me(t,e,r,s,o,_.beginCaptures,h),o.produce(s,h[0].end),u=h[0].end;const $=_.getContentName(e.content,h),R=k.pushAttributed($,t);if(s=s.withContentNameScopesList(R),_.whileHasBackReferences&&(s=s.withEndRule(_.getWhileWithResolvedBackReferences(e.content,h))),!y&&w.hasSameRuleAs(s)){s=s.pop(),o.produce(s,i),l=!0;return}}else if(me(t,e,r,s,o,p.captures,h),o.produce(s,h[0].end),s=s.pop(),!y){s=s.safePop(),o.produce(s,i),l=!0;return}}h[0].end>n&&(n=h[0].end,r=!1)}}function xs(t,e,r,n,s,o){let a=s.beginRuleCapturedEOL?0:-1;const c=[];for(let i=s;i;i=i.pop()){const l=i.getRule(t);l instanceof je&&c.push({rule:l,stack:i})}for(let i=c.pop();i;i=c.pop()){const{ruleScanner:l,findOptions:u}=Ns(i.rule,t,i.stack.endRule,r,n===a),d=l.findNextMatchSync(e,n,u);if(d){if(d.ruleId!==Qr){s=i.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(o.produce(i.stack,d.captureIndices[0].start),me(t,e,r,i.stack,o,i.rule.whileCaptures,d.captureIndices),o.produce(i.stack,d.captureIndices[0].end),a=d.captureIndices[0].end,d.captureIndices[0].end>n&&(n=d.captureIndices[0].end,r=!1))}else{s=i.stack.pop();break}}return{stack:s,linePos:n,anchorPosition:a,isFirstLine:r}}function Es(t,e,r,n,s,o){const a=As(t,e,r,n,s,o),c=t.getInjections();if(c.length===0)return a;const i=Is(c,t,e,r,n,s,o);if(!i)return a;if(!a)return i;const l=a.captureIndices[0].start,u=i.captureIndices[0].start;return u<l||i.priorityMatch&&u===l?i:a}function As(t,e,r,n,s,o){const a=s.getRule(t),{ruleScanner:c,findOptions:i}=Zr(a,t,s.endRule,r,n===o),l=c.findNextMatchSync(e,n,i);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}function Is(t,e,r,n,s,o,a){let c=Number.MAX_VALUE,i=null,l,u=0;const d=o.contentNameScopesList.getScopeNames();for(let f=0,g=t.length;f<g;f++){const h=t[f];if(!h.matcher(d))continue;const b=e.getRule(h.ruleId),{ruleScanner:y,findOptions:p}=Zr(b,e,null,n,s===a),w=y.findNextMatchSync(r,s,p);if(!w)continue;const m=w.captureIndices[0].start;if(!(m>=c)&&(c=m,i=w.captureIndices,l=w.ruleId,u=h.priority,c===s))break}return i?{priorityMatch:u===-1,captureIndices:i,matchedRuleId:l}:null}function Zr(t,e,r,n,s){return{ruleScanner:t.compileAG(e,r,n,s),findOptions:0}}function Ns(t,e,r,n,s){return{ruleScanner:t.compileWhileAG(e,r,n,s),findOptions:0}}function me(t,e,r,n,s,o,a){if(o.length===0)return;const c=e.content,i=Math.min(o.length,a.length),l=[],u=a[0].end;for(let d=0;d<i;d++){const f=o[d];if(f===null)continue;const g=a[d];if(g.length===0)continue;if(g.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=g.start;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?s.produceFromScopes(l[l.length-1].scopes,g.start):s.produce(n,g.start),f.retokenizeCapturedWithRuleId){const b=f.getName(c,a),y=n.contentNameScopesList.pushAttributed(b,t),p=f.getContentName(c,a),w=y.pushAttributed(p,t),m=n.push(f.retokenizeCapturedWithRuleId,g.start,-1,!1,null,y,w),k=t.createOnigString(c.substring(0,g.end));Kr(t,k,r&&g.start===0,g.start,m,s,!1,0),qr(k);continue}const h=f.getName(c,a);if(h!==null){const y=(l.length>0?l[l.length-1].scopes:n.contentNameScopesList).pushAttributed(h,t);l.push(new $s(y,g.end))}}for(;l.length>0;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var $s=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function Rs(t,e,r,n,s,o,a,c){return new Ts(t,e,r,n,s,o,a,c)}function sr(t,e,r,n,s){const o=Oe(e,Ue),a=Xr.getCompiledRuleId(r,n,s.repository);for(const c of o)t.push({debugSelector:e,matcher:c.matcher,ruleId:a,grammar:s,priority:c.priority})}function Ue(t,e){if(e.length<t.length)return!1;let r=0;return t.every(n=>{for(let s=r;s<e.length;s++)if(Bs(e[s],n))return r=s+1,!0;return!1})}function Bs(t,e){if(!t)return!1;if(t===e)return!0;const r=e.length;return t.length>r&&t.substr(0,r)===e&&t[r]==="."}var Ts=class{constructor(t,e,r,n,s,o,a,c){if(this._rootScopeName=t,this.balancedBracketSelectors=o,this._onigLib=c,this._basicScopeAttributesProvider=new Ss(r,n),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=a,this._grammar=or(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const i of Object.keys(s)){const l=Oe(i,Ue);for(const u of l)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[i]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},e=[],r=this._rootScopeName,n=t.lookup(r);if(n){const s=n.injections;if(s)for(let a in s)sr(e,a,s[a],this,n);const o=this._grammarRepository.injections(r);o&&o.forEach(a=>{const c=this.getExternalGrammar(a);if(c){const i=c.injectionSelector;i&&sr(e,i,c,this,c)}})}return e.sort((s,o)=>s.priority-o.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,r=t(e);return this._ruleId2desc[e]=r,r}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const r=this._grammarRepository.lookup(t);if(r)return this._includedGrammars[t]=or(r,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,r=0){const n=this._tokenize(t,e,!1,r);return{tokens:n.lineTokens.getResult(n.ruleStack,n.lineLength),ruleStack:n.ruleStack,stoppedEarly:n.stoppedEarly}}tokenizeLine2(t,e,r=0){const n=this._tokenize(t,e,!0,r);return{tokens:n.lineTokens.getBinaryResult(n.ruleStack,n.lineLength),ruleStack:n.ruleStack,stoppedEarly:n.stoppedEarly}}_tokenize(t,e,r,n){this._rootId===-1&&(this._rootId=Xr.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!e||e===xt.NULL){s=!0;const l=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),d=le.set(0,l.languageId,l.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null);let g;f?g=be.createRootAndLookUpScopeName(f,d,this):g=be.createRoot("unknown",d),e=new xt(null,this._rootId,-1,-1,!1,null,g,g)}else s=!1,e.reset();t=t+`
3
+ `;const o=this.createOnigString(t),a=o.content.length,c=new Ps(r,t,this._tokenTypeMatchers,this.balancedBracketSelectors),i=Kr(this,o,s,0,e,c,!0,n);return qr(o),{lineLength:a,lineTokens:c,ruleStack:i.stack,stoppedEarly:i.stoppedEarly}}};function or(t,e){return t=Zn(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var be=class M{constructor(e,r,n){this.parent=e,this.scopePath=r,this.tokenAttributes=n}static fromExtension(e,r){let n=e,s=e?.scopePath??null;for(const o of r)s=nt.push(s,o.scopeNames),n=new M(n,s,o.encodedTokenAttributes);return n}static createRoot(e,r){return new M(null,new nt(null,e),r)}static createRootAndLookUpScopeName(e,r,n){const s=n.getMetadataForScope(e),o=new nt(null,e),a=n.themeProvider.themeMatch(o),c=M.mergeAttributes(r,s,a);return new M(null,o,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return M.equals(this,e)}static equals(e,r){do{if(e===r||!e&&!r)return!0;if(!e||!r||e.scopeName!==r.scopeName||e.tokenAttributes!==r.tokenAttributes)return!1;e=e.parent,r=r.parent}while(!0)}static mergeAttributes(e,r,n){let s=-1,o=0,a=0;return n!==null&&(s=n.fontStyle,o=n.foregroundId,a=n.backgroundId),le.set(e,r.languageId,r.tokenType,null,s,o,a)}pushAttributed(e,r){if(e===null)return this;if(e.indexOf(" ")===-1)return M._pushAttributed(this,e,r);const n=e.split(/ /g);let s=this;for(const o of n)s=M._pushAttributed(s,o,r);return s}static _pushAttributed(e,r,n){const s=n.getMetadataForScope(r),o=e.scopePath.push(r),a=n.themeProvider.themeMatch(o),c=M.mergeAttributes(e.tokenAttributes,s,a);return new M(e,o,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const r=[];let n=this;for(;n&&n!==e;)r.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?r.reverse():void 0}},xt=class X{constructor(e,r,n,s,o,a,c,i){this.parent=e,this.ruleId=r,this.beginRuleCapturedEOL=o,this.endRule=a,this.nameScopesList=c,this.contentNameScopesList=i,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new X(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:X._equals(this,e)}static _equals(e,r){return e===r?!0:this._structuralEquals(e,r)?be.equals(e.contentNameScopesList,r.contentNameScopesList):!1}static _structuralEquals(e,r){do{if(e===r||!e&&!r)return!0;if(!e||!r||e.depth!==r.depth||e.ruleId!==r.ruleId||e.endRule!==r.endRule)return!1;e=e.parent,r=r.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){X._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,r,n,s,o,a,c){return new X(this,e,r,n,s,o,a,c)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,r){return this.parent&&(r=this.parent._writeString(e,r)),e[r++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,r}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new X(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let r=this;for(;r&&r._enterPos===e._enterPos;){if(r.ruleId===e.ruleId)return!0;r=r.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,r){const n=be.fromExtension(e?.nameScopesList??null,r.nameScopesList);return new X(e,r.ruleId,r.enterPos??-1,r.anchorPos??-1,r.beginRuleCapturedEOL,r.endRule,n,be.fromExtension(n,r.contentNameScopesList))}},Ls=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(r=>r==="*"?(this.allowAny=!0,[]):Oe(r,Ue).map(n=>n.matcher)),this.unbalancedBracketScopes=e.flatMap(r=>Oe(r,Ue).map(n=>n.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},Ps=class{constructor(t,e,r,n){this.balancedBracketSelectors=n,this._emitBinaryTokens=t,this._tokenTypeOverrides=r,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let n=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=t?.getScopeNames()??[];for(const a of this._tokenTypeOverrides)a.matcher(o)&&(n=le.set(n,0,a.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(n=le.set(n,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=e;return}const r=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:r}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const r=new Uint32Array(this._binaryTokens.length);for(let n=0,s=this._binaryTokens.length;n<s;n++)r[n]=this._binaryTokens[n];return r}},Gs=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,r,n,s){if(!this._grammars.has(t)){let o=this._rawGrammars.get(t);if(!o)return null;this._grammars.set(t,Rs(t,o,e,r,n,s,this,this._onigLib))}return this._grammars.get(t)}},Ms=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Gs(Fe.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,r){this._syncRegistry.setTheme(Fe.createFromRawTheme(e,r))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,r,n){return this.loadGrammarWithConfiguration(e,r,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,r,n){return this._loadGrammar(e,r,n.embeddedLanguages,n.tokenTypes,new Ls(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,r,n,s,o){const a=new fs(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(c=>this._loadSingleGrammar(c.scopeName)),a.processQueue();return this._grammarForScopeName(e,r,n,s,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const r=this._options.loadGrammar(e);if(r){const n=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(r,n)}}addGrammar(e,r=[],n=0,s=null){return this._syncRegistry.addGrammar(e,r),this._grammarForScopeName(e.scopeName,n,s)}_grammarForScopeName(e,r=0,n=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(e,r,n,s,o)}},Et=xt.NULL;const Fs=/["&'<>`]/g,Os=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ds=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,js=/[|\\{}()[\]^$+*?.]/g,ar=new WeakMap;function Us(t,e){if(t=t.replace(e.subset?Hs(e.subset):Fs,n),e.subset||e.escapeOnly)return t;return t.replace(Os,r).replace(Ds,n);function r(s,o,a){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,a.charCodeAt(o+2),e)}function n(s,o,a){return e.format(s.charCodeAt(0),a.charCodeAt(o+1),e)}}function Hs(t){let e=ar.get(t);return e||(e=Ws(t),ar.set(t,e)),e}function Ws(t){const e=[];let r=-1;for(;++r<t.length;)e.push(t[r].replace(js,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const zs=/[\dA-Fa-f]/;function qs(t,e,r){const n="&#x"+t.toString(16).toUpperCase();return r&&e&&!zs.test(String.fromCharCode(e))?n:n+";"}const Vs=/\d/;function Qs(t,e,r){const n="&#"+String(t);return r&&e&&!Vs.test(String.fromCharCode(e))?n:n+";"}const Xs=["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"],ot={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:"€"},Js=["cent","copy","divide","gt","lt","not","para","times"],Yr={}.hasOwnProperty,At={};let Ie;for(Ie in ot)Yr.call(ot,Ie)&&(At[ot[Ie]]=Ie);const Ks=/[^\dA-Za-z]/;function Zs(t,e,r,n){const s=String.fromCharCode(t);if(Yr.call(At,s)){const o=At[s],a="&"+o;return r&&Xs.includes(o)&&!Js.includes(o)&&(!n||e&&e!==61&&Ks.test(String.fromCharCode(e)))?a:a+";"}return""}function Ys(t,e,r){let n=qs(t,e,r.omitOptionalSemicolons),s;if((r.useNamedReferences||r.useShortestReferences)&&(s=Zs(t,e,r.omitOptionalSemicolons,r.attribute)),(r.useShortestReferences||!s)&&r.useShortestReferences){const o=Qs(t,e,r.omitOptionalSemicolons);o.length<n.length&&(n=o)}return s&&(!r.useShortestReferences||s.length<n.length)?s:n}function ce(t,e){return Us(t,Object.assign({format:Ys},e))}const eo=/^>|^->|<!--|-->|--!>|<!-$/g,to=[">"],ro=["<",">"];function no(t,e,r,n){return n.settings.bogusComments?"<?"+ce(t.value,Object.assign({},n.settings.characterReferences,{subset:to}))+">":"<!--"+t.value.replace(eo,s)+"-->";function s(o){return ce(o,Object.assign({},n.settings.characterReferences,{subset:ro}))}}function so(t,e,r,n){return"<!"+(n.settings.upperDoctype?"DOCTYPE":"doctype")+(n.settings.tightDoctype?"":" ")+"html>"}const x=tn(1),en=tn(-1),oo=[];function tn(t){return e;function e(r,n,s){const o=r?r.children:oo;let a=(n||0)+t,c=o[a];if(!s)for(;c&&Pt(c);)a+=t,c=o[a];return c}}const ao={}.hasOwnProperty;function rn(t){return e;function e(r,n,s){return ao.call(t,r.tagName)&&t[r.tagName](r,n,s)}}const Ft=rn({body:co,caption:at,colgroup:at,dd:ho,dt:fo,head:at,html:io,li:uo,optgroup:go,option:po,p:lo,rp:ir,rt:ir,tbody:bo,td:cr,tfoot:yo,th:cr,thead:mo,tr:wo});function at(t,e,r){const n=x(r,e,!0);return!n||n.type!=="comment"&&!(n.type==="text"&&Pt(n.value.charAt(0)))}function io(t,e,r){const n=x(r,e);return!n||n.type!=="comment"}function co(t,e,r){const n=x(r,e);return!n||n.type!=="comment"}function lo(t,e,r){const n=x(r,e);return n?n.type==="element"&&(n.tagName==="address"||n.tagName==="article"||n.tagName==="aside"||n.tagName==="blockquote"||n.tagName==="details"||n.tagName==="div"||n.tagName==="dl"||n.tagName==="fieldset"||n.tagName==="figcaption"||n.tagName==="figure"||n.tagName==="footer"||n.tagName==="form"||n.tagName==="h1"||n.tagName==="h2"||n.tagName==="h3"||n.tagName==="h4"||n.tagName==="h5"||n.tagName==="h6"||n.tagName==="header"||n.tagName==="hgroup"||n.tagName==="hr"||n.tagName==="main"||n.tagName==="menu"||n.tagName==="nav"||n.tagName==="ol"||n.tagName==="p"||n.tagName==="pre"||n.tagName==="section"||n.tagName==="table"||n.tagName==="ul"):!r||!(r.type==="element"&&(r.tagName==="a"||r.tagName==="audio"||r.tagName==="del"||r.tagName==="ins"||r.tagName==="map"||r.tagName==="noscript"||r.tagName==="video"))}function uo(t,e,r){const n=x(r,e);return!n||n.type==="element"&&n.tagName==="li"}function fo(t,e,r){const n=x(r,e);return!!(n&&n.type==="element"&&(n.tagName==="dt"||n.tagName==="dd"))}function ho(t,e,r){const n=x(r,e);return!n||n.type==="element"&&(n.tagName==="dt"||n.tagName==="dd")}function ir(t,e,r){const n=x(r,e);return!n||n.type==="element"&&(n.tagName==="rp"||n.tagName==="rt")}function go(t,e,r){const n=x(r,e);return!n||n.type==="element"&&n.tagName==="optgroup"}function po(t,e,r){const n=x(r,e);return!n||n.type==="element"&&(n.tagName==="option"||n.tagName==="optgroup")}function mo(t,e,r){const n=x(r,e);return!!(n&&n.type==="element"&&(n.tagName==="tbody"||n.tagName==="tfoot"))}function bo(t,e,r){const n=x(r,e);return!n||n.type==="element"&&(n.tagName==="tbody"||n.tagName==="tfoot")}function yo(t,e,r){return!x(r,e)}function wo(t,e,r){const n=x(r,e);return!n||n.type==="element"&&n.tagName==="tr"}function cr(t,e,r){const n=x(r,e);return!n||n.type==="element"&&(n.tagName==="td"||n.tagName==="th")}const ko=rn({body:So,colgroup:vo,head:_o,html:Co,tbody:xo});function Co(t){const e=x(t,-1);return!e||e.type!=="comment"}function _o(t){const e=new Set;for(const n of t.children)if(n.type==="element"&&(n.tagName==="base"||n.tagName==="title")){if(e.has(n.tagName))return!1;e.add(n.tagName)}const r=t.children[0];return!r||r.type==="element"}function So(t){const e=x(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&Pt(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function vo(t,e,r){const n=en(r,e),s=x(t,-1,!0);return r&&n&&n.type==="element"&&n.tagName==="colgroup"&&Ft(n,r.children.indexOf(n),r)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function xo(t,e,r){const n=en(r,e),s=x(t,-1);return r&&n&&n.type==="element"&&(n.tagName==="thead"||n.tagName==="tbody")&&Ft(n,r.children.indexOf(n),r)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const Ne={name:[[`
4
+ \f\r &/=>`.split(""),`
5
+ \f\r "&'/=>\``.split("")],[`\0
6
+ \f\r "&'/<=>`.split(""),`\0
7
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
8
+ \f\r &>`.split(""),`\0
9
+ \f\r "&'<=>\``.split("")],[`\0
10
+ \f\r "&'<=>\``.split(""),`\0
11
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Eo(t,e,r,n){const s=n.schema,o=s.space==="svg"?!1:n.settings.omitOptionalTags;let a=s.space==="svg"?n.settings.closeEmptyElements:n.settings.voids.includes(t.tagName.toLowerCase());const c=[];let i;s.space==="html"&&t.tagName==="svg"&&(n.schema=Mr);const l=Ao(n,t.properties),u=n.all(s.space==="html"&&t.tagName==="template"?t.content:t);return n.schema=s,u&&(a=!1),(l||!o||!ko(t,e,r))&&(c.push("<",t.tagName,l?" "+l:""),a&&(s.space==="svg"||n.settings.closeSelfClosing)&&(i=l.charAt(l.length-1),(!n.settings.tightSelfClosing||i==="/"||i&&i!=='"'&&i!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(u),!a&&(!o||!Ft(t,e,r))&&c.push("</"+t.tagName+">"),c.join("")}function Ao(t,e){const r=[];let n=-1,s;if(e){for(s in e)if(e[s]!==null&&e[s]!==void 0){const o=Io(t,s,e[s]);o&&r.push(o)}}for(;++n<r.length;){const o=t.settings.tightAttributes?r[n].charAt(r[n].length-1):void 0;n!==r.length-1&&o!=='"'&&o!=="'"&&(r[n]+=" ")}return r.join("")}function Io(t,e,r){const n=jn(t.schema,e),s=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,o=t.settings.allowDangerousCharacters?0:1;let a=t.quote,c;if(n.overloadedBoolean&&(r===n.attribute||r==="")?r=!0:(n.boolean||n.overloadedBoolean)&&(typeof r!="string"||r===n.attribute||r==="")&&(r=!!r),r==null||r===!1||typeof r=="number"&&Number.isNaN(r))return"";const i=ce(n.attribute,Object.assign({},t.settings.characterReferences,{subset:Ne.name[s][o]}));return r===!0||(r=Array.isArray(r)?(n.commaSeparated?Un:Hn)(r,{padLeft:!t.settings.tightCommaSeparatedLists}):String(r),t.settings.collapseEmptyAttributes&&!r)?i:(t.settings.preferUnquoted&&(c=ce(r,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:Ne.unquoted[s][o]}))),c!==r&&(t.settings.quoteSmart&&Kt(r,a)>Kt(r,t.alternative)&&(a=t.alternative),c=a+ce(r,Object.assign({},t.settings.characterReferences,{subset:(a==="'"?Ne.single:Ne.double)[s][o],attribute:!0}))+a),i+(c&&"="+c))}const No=["<","&"];function nn(t,e,r,n){return r&&r.type==="element"&&(r.tagName==="script"||r.tagName==="style")?t.value:ce(t.value,Object.assign({},n.settings.characterReferences,{subset:No}))}function $o(t,e,r,n){return n.settings.allowDangerousHtml?t.value:nn(t,e,r,n)}function Ro(t,e,r,n){return n.all(t)}const Bo=Wn("type",{invalid:To,unknown:Lo,handlers:{comment:no,doctype:so,element:Eo,raw:$o,root:Ro,text:nn}});function To(t){throw new Error("Expected node, not `"+t+"`")}function Lo(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const Po={},Go={},Mo=[];function Fo(t,e){const r=e||Po,n=r.quote||'"',s=n==='"'?"'":'"';if(n!=='"'&&n!=="'")throw new Error("Invalid quote `"+n+"`, expected `'` or `\"`");return{one:Oo,all:Do,settings:{omitOptionalTags:r.omitOptionalTags||!1,allowParseErrors:r.allowParseErrors||!1,allowDangerousCharacters:r.allowDangerousCharacters||!1,quoteSmart:r.quoteSmart||!1,preferUnquoted:r.preferUnquoted||!1,tightAttributes:r.tightAttributes||!1,upperDoctype:r.upperDoctype||!1,tightDoctype:r.tightDoctype||!1,bogusComments:r.bogusComments||!1,tightCommaSeparatedLists:r.tightCommaSeparatedLists||!1,tightSelfClosing:r.tightSelfClosing||!1,collapseEmptyAttributes:r.collapseEmptyAttributes||!1,allowDangerousHtml:r.allowDangerousHtml||!1,voids:r.voids||qn,characterReferences:r.characterReferences||Go,closeSelfClosing:r.closeSelfClosing||!1,closeEmptyElements:r.closeEmptyElements||!1},schema:r.space==="svg"?Mr:zn,quote:n,alternative:s}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function Oo(t,e,r){return Bo(t,e,r,this)}function Do(t){const e=[],r=t&&t.children||Mo;let n=-1;for(;++n<r.length;)e[n]=this.one(r[n],n,t);return e.join("")}function He(t,e){const r=typeof t=="string"?{}:{...t.colorReplacements},n=typeof t=="string"?t:t.name;for(const[s,o]of Object.entries(e?.colorReplacements||{}))typeof o=="string"?r[s]=o:s===n&&Object.assign(r,o);return r}function V(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function jo(t){return Array.isArray(t)?t:[t]}async function sn(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function Ot(t){return!t||["plaintext","txt","text","plain"].includes(t)}function Uo(t){return t==="ansi"||Ot(t)}function Dt(t){return t==="none"}function Ho(t){return Dt(t)}function on(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const r=Array.isArray(e)?e:e.split(/\s+/g);for(const n of r)n&&!t.properties.class.includes(n)&&t.properties.class.push(n);return t}function Xe(t,e=!1){if(t.length===0)return[["",0]];const r=t.split(/(\r?\n)/g);let n=0;const s=[];for(let o=0;o<r.length;o+=2){const a=e?r[o]+(r[o+1]||""):r[o];s.push([a,n]),n+=r[o].length,n+=r[o+1]?.length||0}return s}function Wo(t){const e=Xe(t,!0).map(([s])=>s);function r(s){if(s===t.length)return{line:e.length-1,character:e[e.length-1].length};let o=s,a=0;for(const c of e){if(o<c.length)break;o-=c.length,a++}return{line:a,character:o}}function n(s,o){let a=0;for(let c=0;c<s;c++)a+=e[c].length;return a+=o,a}return{lines:e,indexToPos:r,posToIndex:n}}const jt="light-dark()",zo=["color","background-color"];function qo(t,e){let r=0;const n=[];for(const s of e)s>r&&n.push({...t,content:t.content.slice(r,s),offset:t.offset+r}),r=s;return r<t.content.length&&n.push({...t,content:t.content.slice(r),offset:t.offset+r}),n}function Vo(t,e){const r=Array.from(e instanceof Set?e:new Set(e)).sort((n,s)=>n-s);return r.length?t.map(n=>n.flatMap(s=>{const o=r.filter(a=>s.offset<a&&a<s.offset+s.content.length).map(a=>a-s.offset).sort((a,c)=>a-c);return o.length?qo(s,o):s})):t}function Qo(t,e,r,n,s="css-vars"){const o={content:t.content,explanation:t.explanation,offset:t.offset},a=e.map(u=>We(t.variants[u])),c=new Set(a.flatMap(u=>Object.keys(u))),i={},l=(u,d)=>{const f=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return r+e[u]+(d==="color"?"":f)};return a.forEach((u,d)=>{for(const f of c){const g=u[f]||"inherit";if(d===0&&n&&zo.includes(f))if(n===jt&&a.length>1){const h=e.findIndex(w=>w==="light"),b=e.findIndex(w=>w==="dark");if(h===-1||b===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const y=a[h][f]||"inherit",p=a[b][f]||"inherit";i[f]=`light-dark(${y}, ${p})`,s==="css-vars"&&(i[l(d,f)]=g)}else i[f]=g;else s==="css-vars"&&(i[l(d,f)]=g)}}),o.htmlStyle=i,o}function We(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&N.Italic&&(e["font-style"]="italic"),t.fontStyle&N.Bold&&(e["font-weight"]="bold");const r=[];t.fontStyle&N.Underline&&r.push("underline"),t.fontStyle&N.Strikethrough&&r.push("line-through"),r.length&&(e["text-decoration"]=r.join(" "))}return e}function It(t){return typeof t=="string"?t:Object.entries(t).map(([e,r])=>`${e}:${r}`).join(";")}const an=new WeakMap;function Je(t,e){an.set(t,e)}function _e(t){return an.get(t)}class ue{_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,r){return new ue(Object.fromEntries(jo(r).map(n=>[n,Et])),e)}constructor(...e){if(e.length===2){const[r,n]=e;this.lang=n,this._stacks=r}else{const[r,n,s]=e;this.lang=n,this._stacks={[s]:r}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Xo(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function Xo(t){const e=[],r=new Set;function n(s){if(r.has(s))return;r.add(s);const o=s?.nameScopesList?.scopeName;o&&e.push(o),s.parent&&n(s.parent)}return n(t),e}function Jo(t,e){if(!(t instanceof ue))throw new E("Invalid grammar state");return t.getInternalStack(e)}function Ko(){const t=new WeakMap;function e(r){if(!t.has(r.meta)){let n=function(a){if(typeof a=="number"){if(a<0||a>r.source.length)throw new E(`Invalid decoration offset: ${a}. Code length: ${r.source.length}`);return{...s.indexToPos(a),offset:a}}else{const c=s.lines[a.line];if(c===void 0)throw new E(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${s.lines.length}`);let i=a.character;if(i<0&&(i=c.length+i),i<0||i>c.length)throw new E(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${c.length}`);return{...a,character:i,offset:s.posToIndex(a.line,i)}}};const s=Wo(r.source),o=(r.options.decorations||[]).map(a=>({...a,start:n(a.start),end:n(a.end)}));Zo(o),t.set(r.meta,{decorations:o,converter:s,source:r.source})}return t.get(r.meta)}return{name:"shiki:decorations",tokens(r){if(!this.options.decorations?.length)return;const s=e(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]);return Vo(r,s)},code(r){if(!this.options.decorations?.length)return;const n=e(this),s=Array.from(r.children).filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==n.converter.lines.length)throw new E(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function o(u,d,f,g){const h=s[u];let b="",y=-1,p=-1;if(d===0&&(y=0),f===0&&(p=0),f===Number.POSITIVE_INFINITY&&(p=h.children.length),y===-1||p===-1)for(let m=0;m<h.children.length;m++)b+=cn(h.children[m]),y===-1&&b.length===d&&(y=m+1),p===-1&&b.length===f&&(p=m+1);if(y===-1)throw new E(`Failed to find start index for decoration ${JSON.stringify(g.start)}`);if(p===-1)throw new E(`Failed to find end index for decoration ${JSON.stringify(g.end)}`);const w=h.children.slice(y,p);if(!g.alwaysWrap&&w.length===h.children.length)c(h,g,"line");else if(!g.alwaysWrap&&w.length===1&&w[0].type==="element")c(w[0],g,"token");else{const m={type:"element",tagName:"span",properties:{},children:w};c(m,g,"wrapper"),h.children.splice(y,w.length,m)}}function a(u,d){s[u]=c(s[u],d,"line")}function c(u,d,f){const g=d.properties||{},h=d.transform||(b=>b);return u.tagName=d.tagName||"span",u.properties={...u.properties,...g,class:u.properties.class},d.properties?.class&&on(u,d.properties.class),u=h(u,f)||u,u}const i=[],l=n.decorations.sort((u,d)=>d.start.offset-u.start.offset||u.end.offset-d.end.offset);for(const u of l){const{start:d,end:f}=u;if(d.line===f.line)o(d.line,d.character,f.character,u);else if(d.line<f.line){o(d.line,d.character,Number.POSITIVE_INFINITY,u);for(let g=d.line+1;g<f.line;g++)i.unshift(()=>a(g,u));o(f.line,0,f.character,u)}}i.forEach(u=>u())}}}function Zo(t){for(let e=0;e<t.length;e++){const r=t[e];if(r.start.offset>r.end.offset)throw new E(`Invalid decoration range: ${JSON.stringify(r.start)} - ${JSON.stringify(r.end)}`);for(let n=e+1;n<t.length;n++){const s=t[n],o=r.start.offset<=s.start.offset&&s.start.offset<r.end.offset,a=r.start.offset<s.end.offset&&s.end.offset<=r.end.offset,c=s.start.offset<=r.start.offset&&r.start.offset<s.end.offset,i=s.start.offset<r.end.offset&&r.end.offset<=s.end.offset;if(o||a||c||i){if(o&&a||c&&i||c&&r.start.offset===r.end.offset||a&&s.start.offset===s.end.offset)continue;throw new E(`Decorations ${JSON.stringify(r.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function cn(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(cn).join(""):""}const Yo=[Ko()];function ze(t){const e=ea(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...Yo]}function ea(t){const e=[],r=[],n=[];for(const s of t)switch(s.enforce){case"pre":e.push(s);break;case"post":r.push(s);break;default:n.push(s)}return{pre:e,post:r,normal:n}}var K=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],it={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function ta(t,e){const r=t.indexOf("\x1B",e);if(r!==-1&&t[r+1]==="["){const n=t.indexOf("m",r);if(n!==-1)return{sequence:t.substring(r+2,n).split(";"),startPosition:r,position:n+1}}return{position:t.length}}function lr(t){const e=t.shift();if(e==="2"){const r=t.splice(0,3).map(n=>Number.parseInt(n));return r.length!==3||r.some(n=>Number.isNaN(n))?void 0:{type:"rgb",rgb:r}}else if(e==="5"){const r=t.shift();if(r)return{type:"table",index:Number(r)}}}function ra(t){const e=[];for(;t.length>0;){const r=t.shift();if(!r)continue;const n=Number.parseInt(r);if(!Number.isNaN(n))if(n===0)e.push({type:"resetAll"});else if(n<=9)it[n]&&e.push({type:"setDecoration",value:it[n]});else if(n<=29){const s=it[n-20];s&&(e.push({type:"resetDecoration",value:s}),s==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(n<=37)e.push({type:"setForegroundColor",value:{type:"named",name:K[n-30]}});else if(n===38){const s=lr(t);s&&e.push({type:"setForegroundColor",value:s})}else if(n===39)e.push({type:"resetForegroundColor"});else if(n<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:K[n-40]}});else if(n===48){const s=lr(t);s&&e.push({type:"setBackgroundColor",value:s})}else n===49?e.push({type:"resetBackgroundColor"}):n===53?e.push({type:"setDecoration",value:"overline"}):n===55?e.push({type:"resetDecoration",value:"overline"}):n>=90&&n<=97?e.push({type:"setForegroundColor",value:{type:"named",name:K[n-90+8]}}):n>=100&&n<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:K[n-100+8]}})}return e}function na(){let t=null,e=null,r=new Set;return{parse(n){const s=[];let o=0;do{const a=ta(n,o),c=a.sequence?n.substring(o,a.startPosition):n.substring(o);if(c.length>0&&s.push({value:c,foreground:t,background:e,decorations:new Set(r)}),a.sequence){const i=ra(a.sequence);for(const l of i)l.type==="resetAll"?(t=null,e=null,r.clear()):l.type==="resetForegroundColor"?t=null:l.type==="resetBackgroundColor"?e=null:l.type==="resetDecoration"&&r.delete(l.value);for(const l of i)l.type==="setForegroundColor"?t=l.value:l.type==="setBackgroundColor"?e=l.value:l.type==="setDecoration"&&r.add(l.value)}o=a.position}while(o<n.length);return s}}}var sa={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 oa(t=sa){function e(c){return t[c]}function r(c){return`#${c.map(i=>Math.max(0,Math.min(i,255)).toString(16).padStart(2,"0")).join("")}`}let n;function s(){if(n)return n;n=[];for(let l=0;l<K.length;l++)n.push(e(K[l]));let c=[0,95,135,175,215,255];for(let l=0;l<6;l++)for(let u=0;u<6;u++)for(let d=0;d<6;d++)n.push(r([c[l],c[u],c[d]]));let i=8;for(let l=0;l<24;l++,i+=10)n.push(r([i,i,i]));return n}function o(c){return s()[c]}function a(c){switch(c.type){case"named":return e(c.name);case"rgb":return r(c.rgb);case"table":return o(c.index)}}return{value:a}}const aa={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function ia(t,e,r){const n=He(t,r),s=Xe(e),o=Object.fromEntries(K.map(i=>{const l=`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`,u=t.colors?.[l];return[i,u||aa[i]]})),a=oa(o),c=na();return s.map(i=>c.parse(i[0]).map(l=>{let u,d;l.decorations.has("reverse")?(u=l.background?a.value(l.background):t.bg,d=l.foreground?a.value(l.foreground):t.fg):(u=l.foreground?a.value(l.foreground):t.fg,d=l.background?a.value(l.background):void 0),u=V(u,n),d=V(d,n),l.decorations.has("dim")&&(u=ca(u));let f=N.None;return l.decorations.has("bold")&&(f|=N.Bold),l.decorations.has("italic")&&(f|=N.Italic),l.decorations.has("underline")&&(f|=N.Underline),l.decorations.has("strikethrough")&&(f|=N.Strikethrough),{content:l.value,offset:i[1],color:u,bgColor:d,fontStyle:f}}))}function ca(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const n=e[1];if(n.length===8){const s=Math.round(Number.parseInt(n.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${n.slice(0,6)}${s}`}else{if(n.length===6)return`#${n}80`;if(n.length===4){const s=n[0],o=n[1],a=n[2],c=n[3],i=Math.round(Number.parseInt(`${c}${c}`,16)/2).toString(16).padStart(2,"0");return`#${s}${s}${o}${o}${a}${a}${i}`}else if(n.length===3){const s=n[0],o=n[1],a=n[2];return`#${s}${s}${o}${o}${a}${a}80`}}}const r=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return r?`var(${r[1]}-dim)`:t}function Ut(t,e,r={}){const{theme:n=t.getLoadedThemes()[0]}=r,s=t.resolveLangAlias(r.lang||"text");if(Ot(s)||Dt(n))return Xe(e).map(i=>[{content:i[0],offset:i[1]}]);const{theme:o,colorMap:a}=t.setTheme(n);if(s==="ansi")return ia(o,e,r);const c=t.getLanguage(r.lang||"text");if(r.grammarState){if(r.grammarState.lang!==c.name)throw new E(`Grammar state language "${r.grammarState.lang}" does not match highlight language "${c.name}"`);if(!r.grammarState.themes.includes(o.name))throw new E(`Grammar state themes "${r.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return ua(e,c,o,a,r)}function la(...t){if(t.length===2)return _e(t[1]);const[e,r,n={}]=t,{lang:s="text",theme:o=e.getLoadedThemes()[0]}=n;if(Ot(s)||Dt(o))throw new E("Plain language does not have grammar state");if(s==="ansi")throw new E("ANSI language does not have grammar state");const{theme:a,colorMap:c}=e.setTheme(o),i=e.getLanguage(s);return new ue(Ht(r,i,a,c,n).stateStack,i.name,a.name)}function ua(t,e,r,n,s){const o=Ht(t,e,r,n,s),a=new ue(o.stateStack,e.name,r.name);return Je(o.tokens,a),o.tokens}function Ht(t,e,r,n,s){const o=He(r,s),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:c=500}=s,i=Xe(t);let l=s.grammarState?Jo(s.grammarState,r.name)??Et:s.grammarContextCode!=null?Ht(s.grammarContextCode,e,r,n,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:Et,u=[];const d=[];for(let f=0,g=i.length;f<g;f++){const[h,b]=i[f];if(h===""){u=[],d.push([]);continue}if(a>0&&h.length>=a){u=[],d.push([{content:h,offset:b,color:"",fontStyle:0}]);continue}let y,p,w;s.includeExplanation&&(y=e.tokenizeLine(h,l,c),p=y.tokens,w=0);const m=e.tokenizeLine2(h,l,c),k=m.tokens.length/2;for(let _=0;_<k;_++){const $=m.tokens[2*_],R=_+1<k?m.tokens[2*_+2]:h.length;if($===R)continue;const F=m.tokens[2*_+1],Ee=V(n[le.getForeground(F)],o),et=le.getFontStyle(F),he={content:h.substring($,R),offset:b+$,color:Ee,fontStyle:et};if(s.includeExplanation){const W=[];if(s.includeExplanation!=="scopeName")for(const O of r.settings){let ee;switch(typeof O.scope){case"string":ee=O.scope.split(/,/).map(tt=>tt.trim());break;case"object":ee=O.scope;break;default:continue}W.push({settings:O,selectors:ee.map(tt=>tt.split(/ /))})}he.explanation=[];let Jt=0;for(;$+Jt<R;){const O=p[w],ee=h.substring(O.startIndex,O.endIndex);Jt+=ee.length,he.explanation.push({content:ee,scopes:s.includeExplanation==="scopeName"?da(O.scopes):fa(W,O.scopes)}),w+=1}}u.push(he)}d.push(u),u=[],l=m.ruleStack}return{tokens:d,stateStack:l}}function da(t){return t.map(e=>({scopeName:e}))}function fa(t,e){const r=[];for(let n=0,s=e.length;n<s;n++){const o=e[n];r[n]={scopeName:o,themeMatches:ga(t,o,e.slice(0,n))}}return r}function ur(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function ha(t,e,r){if(!ur(t[t.length-1],e))return!1;let n=t.length-2,s=r.length-1;for(;n>=0&&s>=0;)ur(t[n],r[s])&&(n-=1),s-=1;return n===-1}function ga(t,e,r){const n=[];for(const{selectors:s,settings:o}of t)for(const a of s)if(ha(a,e,r)){n.push(o);break}return n}function ln(t,e,r){const n=Object.entries(r.themes).filter(i=>i[1]).map(i=>({color:i[0],theme:i[1]})),s=n.map(i=>{const l=Ut(t,e,{...r,theme:i.theme}),u=_e(l),d=typeof i.theme=="string"?i.theme:i.theme.name;return{tokens:l,state:u,theme:d}}),o=pa(...s.map(i=>i.tokens)),a=o[0].map((i,l)=>i.map((u,d)=>{const f={content:u.content,variants:{},offset:u.offset};return"includeExplanation"in r&&r.includeExplanation&&(f.explanation=u.explanation),o.forEach((g,h)=>{const{content:b,explanation:y,offset:p,...w}=g[l][d];f.variants[n[h].color]=w}),f})),c=s[0].state?new ue(Object.fromEntries(s.map(i=>[i.theme,i.state?.getInternalStack(i.theme)])),s[0].state.lang):void 0;return c&&Je(a,c),a}function pa(...t){const e=t.map(()=>[]),r=t.length;for(let n=0;n<t[0].length;n++){const s=t.map(i=>i[n]),o=e.map(()=>[]);e.forEach((i,l)=>i.push(o[l]));const a=s.map(()=>0),c=s.map(i=>i[0]);for(;c.every(i=>i);){const i=Math.min(...c.map(l=>l.content.length));for(let l=0;l<r;l++){const u=c[l];u.content.length===i?(o[l].push(u),a[l]+=1,c[l]=s[l][a[l]]):(o[l].push({...u,content:u.content.slice(0,i)}),c[l]={...u,content:u.content.slice(i),offset:u.offset+i})}}}return e}function qe(t,e,r){let n,s,o,a,c,i;if("themes"in r){const{defaultColor:l="light",cssVariablePrefix:u="--shiki-",colorsRendering:d="css-vars"}=r,f=Object.entries(r.themes).filter(p=>p[1]).map(p=>({color:p[0],theme:p[1]})).sort((p,w)=>p.color===l?-1:w.color===l?1:0);if(f.length===0)throw new E("`themes` option must not be empty");const g=ln(t,e,r);if(i=_e(g),l&&jt!==l&&!f.find(p=>p.color===l))throw new E(`\`themes\` option must contain the defaultColor key \`${l}\``);const h=f.map(p=>t.getTheme(p.theme)),b=f.map(p=>p.color);o=g.map(p=>p.map(w=>Qo(w,b,u,l,d))),i&&Je(o,i);const y=f.map(p=>He(p.theme,r));s=dr(f,h,y,u,l,"fg",d),n=dr(f,h,y,u,l,"bg",d),a=`shiki-themes ${h.map(p=>p.name).join(" ")}`,c=l?void 0:[s,n].join(";")}else if("theme"in r){const l=He(r.theme,r);o=Ut(t,e,r);const u=t.getTheme(r.theme);n=V(u.bg,l),s=V(u.fg,l),a=u.name,i=_e(o)}else throw new E("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:n,themeName:a,rootStyle:c,grammarState:i}}function dr(t,e,r,n,s,o,a){return t.map((c,i)=>{const l=V(e[i][o],r[i])||"inherit",u=`${n+c.color}${o==="bg"?"-bg":""}:${l}`;if(i===0&&s){if(s===jt&&t.length>1){const d=t.findIndex(b=>b.color==="light"),f=t.findIndex(b=>b.color==="dark");if(d===-1||f===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const g=V(e[d][o],r[d])||"inherit",h=V(e[f][o],r[f])||"inherit";return`light-dark(${g}, ${h});${u}`}return l}return a==="css-vars"?u:null}).filter(c=>!!c).join(";")}function Ve(t,e,r,n={meta:{},options:r,codeToHast:(s,o)=>Ve(t,s,o),codeToTokens:(s,o)=>qe(t,s,o)}){let s=e;for(const h of ze(r))s=h.preprocess?.call(n,s,r)||s;let{tokens:o,fg:a,bg:c,themeName:i,rootStyle:l,grammarState:u}=qe(t,s,r);const{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=r;d===!0?o=ba(o):d==="never"&&(o=ya(o)),f&&(o=wa(o));const g={...n,get source(){return s}};for(const h of ze(r))o=h.tokens?.call(g,o)||o;return ma(o,{...r,fg:a,bg:c,themeName:i,rootStyle:r.rootStyle===!1?!1:r.rootStyle??l},g,u)}function ma(t,e,r,n=_e(t)){const s=ze(e),o=[],a={type:"root",children:[]},{structure:c="classic",tabindex:i="0"}=e,l={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?l.style=e.rootStyle:l.style=`background-color:${e.bg};color:${e.fg}`),i!==!1&&i!=null&&(l.tabindex=i.toString());for(const[b,y]of Object.entries(e.meta||{}))b.startsWith("_")||(l[b]=y);let u={type:"element",tagName:"pre",properties:l,children:[],data:e.data},d={type:"element",tagName:"code",properties:{},children:o};const f=[],g={...r,structure:c,addClassToHast:on,get source(){return r.source},get tokens(){return t},get options(){return e},get root(){return a},get pre(){return u},get code(){return d},get lines(){return f}};if(t.forEach((b,y)=>{y&&(c==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&o.push({type:"text",value:`
12
+ `}));let p={type:"element",tagName:"span",properties:{class:"line"},children:[]},w=0;for(const m of b){let k={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]};const _=It(m.htmlStyle||We(m));_&&(k.properties.style=_);for(const $ of s)k=$?.span?.call(g,k,y+1,w,p,m)||k;c==="inline"?a.children.push(k):c==="classic"&&p.children.push(k),w+=m.content.length}if(c==="classic"){for(const m of s)p=m?.line?.call(g,p,y+1)||p;f.push(p),o.push(p)}else c==="inline"&&f.push(p)}),c==="classic"){for(const b of s)d=b?.code?.call(g,d)||d;u.children.push(d);for(const b of s)u=b?.pre?.call(g,u)||u;a.children.push(u)}else if(c==="inline"){const b=[];let y={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const m of a.children)m.type==="element"&&m.tagName==="br"?(b.push(y),y={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&y.children.push(m);b.push(y);let w={type:"element",tagName:"code",properties:{},children:b};for(const m of s)w=m?.code?.call(g,w)||w;a.children=[];for(let m=0;m<w.children.length;m++){m>0&&a.children.push({type:"element",tagName:"br",properties:{},children:[]});const k=w.children[m];k.type==="element"&&a.children.push(...k.children)}}let h=a;for(const b of s)h=b?.root?.call(g,h)||h;return n&&Je(h,n),h}function ba(t){return t.map(e=>{const r=[];let n="",s;return e.forEach((o,a)=>{const i=!(o.fontStyle&&(o.fontStyle&N.Underline||o.fontStyle&N.Strikethrough));i&&o.content.match(/^\s+$/)&&e[a+1]?(s===void 0&&(s=o.offset),n+=o.content):n?(i?r.push({...o,offset:s,content:n+o.content}):r.push({content:n,offset:s},o),s=void 0,n=""):r.push(o)}),r})}function ya(t){return t.map(e=>e.flatMap(r=>{if(r.content.match(/^\s+$/))return r;const n=r.content.match(/^(\s*)(.*?)(\s*)$/);if(!n)return r;const[,s,o,a]=n;if(!s&&!a)return r;const c=[{...r,offset:r.offset+s.length,content:o}];return s&&c.unshift({content:s,offset:r.offset}),a&&c.push({content:a,offset:r.offset+s.length+o.length}),c}))}function wa(t){return t.map(e=>{const r=[];for(const n of e){if(r.length===0){r.push({...n});continue}const s=r[r.length-1],o=It(s.htmlStyle||We(s)),a=It(n.htmlStyle||We(n)),c=s.fontStyle&&(s.fontStyle&N.Underline||s.fontStyle&N.Strikethrough),i=n.fontStyle&&(n.fontStyle&N.Underline||n.fontStyle&N.Strikethrough);!c&&!i&&o===a?s.content+=n.content:r.push({...n})}return r})}const ka=Fo;function Ca(t,e,r){const n={meta:{},options:r,codeToHast:(o,a)=>Ve(t,o,a),codeToTokens:(o,a)=>qe(t,o,a)};let s=ka(Ve(t,e,r,n));for(const o of ze(r))s=o.postprocess?.call(n,s,r)||s;return s}const fr={light:"#333333",dark:"#bbbbbb"},hr={light:"#fffffe",dark:"#1e1e1e"},gr="__shiki_resolved";function Wt(t){if(t?.[gr])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:r,fg:n}=e;if(!r||!n){const c=e.settings?e.settings.find(i=>!i.name&&!i.scope):void 0;c?.settings?.foreground&&(n=c.settings.foreground),c?.settings?.background&&(r=c.settings.background),!n&&e?.colors?.["editor.foreground"]&&(n=e.colors["editor.foreground"]),!r&&e?.colors?.["editor.background"]&&(r=e.colors["editor.background"]),n||(n=e.type==="light"?fr.light:fr.dark),r||(r=e.type==="light"?hr.light:hr.dark),e.fg=n,e.bg=r}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0;const o=new Map;function a(c){if(o.has(c))return o.get(c);s+=1;const i=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${i}`]?a(c):(o.set(c,i),i)}e.settings=e.settings.map(c=>{const i=c.settings?.foreground&&!c.settings.foreground.startsWith("#"),l=c.settings?.background&&!c.settings.background.startsWith("#");if(!i&&!l)return c;const u={...c,settings:{...c.settings}};if(i){const d=a(c.settings.foreground);e.colorReplacements[d]=c.settings.foreground,u.settings.foreground=d}if(l){const d=a(c.settings.background);e.colorReplacements[d]=c.settings.background,u.settings.background=d}return u});for(const c of Object.keys(e.colors||{}))if((c==="editor.foreground"||c==="editor.background"||c.startsWith("terminal.ansi"))&&!e.colors[c]?.startsWith("#")){const i=a(e.colors[c]);e.colorReplacements[i]=e.colors[c],e.colors[c]=i}return Object.defineProperty(e,gr,{enumerable:!1,writable:!1,value:!0}),e}async function un(t){return Array.from(new Set((await Promise.all(t.filter(e=>!Uo(e)).map(async e=>await sn(e).then(r=>Array.isArray(r)?r:[r])))).flat()))}async function dn(t){return(await Promise.all(t.map(async r=>Ho(r)?null:Wt(await sn(r))))).filter(r=>!!r)}let _a=3;function Sa(t,e=3){e>_a||console.trace(`[SHIKI DEPRECATE]: ${t}`)}class ie extends Error{constructor(e){super(e),this.name="ShikiError"}}function fn(t,e){if(!e)return t;if(e[t]){const r=new Set([t]);for(;e[t];){if(t=e[t],r.has(t))throw new ie(`Circular alias \`${Array.from(r).join(" -> ")} -> ${t}\``);r.add(t)}}return t}class va extends Ms{constructor(e,r,n,s={}){super(e),this._resolver=e,this._themes=r,this._langs=n,this._alias=s,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const r=Wt(e);return r.name&&(this._resolvedThemes.set(r.name,r),this._loadedThemesCache=null),r}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let r=this._textmateThemeCache.get(e);r||(r=Fe.createFromRawTheme(e),this._textmateThemeCache.set(e,r)),this._syncRegistry.setTheme(r)}getGrammar(e){return e=fn(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const r=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const s=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(s.name=e.name,this._resolvedGrammars.set(e.name,s),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,r.size)for(const o of r)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const s of e)this.resolveEmbeddedLanguages(s);const r=Array.from(this._langGraph.entries()),n=r.filter(([s,o])=>!o);if(n.length){const s=r.filter(([o,a])=>a?(a.embeddedLanguages||a.embeddedLangs)?.some(i=>n.map(([l])=>l).includes(i)):!1).filter(o=>!n.includes(o));throw new ie(`Missing languages ${n.map(([o])=>`\`${o}\``).join(", ")}, required by ${s.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[s,o]of r)this._resolver.addLanguage(o);for(const[s,o]of r)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const r=e.embeddedLanguages??e.embeddedLangs;if(r)for(const n of r)this._langGraph.set(n,this._langMap.get(n))}}class xa{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,r){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},r.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(r=>{this._langs.set(r,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(r=>{this._injections.get(r)||this._injections.set(r,[]),this._injections.get(r).push(e.scopeName)})}getInjections(e){const r=e.split(".");let n=[];for(let s=1;s<=r.length;s++){const o=r.slice(0,s).join(".");n=[...n,...this._injections.get(o)||[]]}return n}}let ge=0;function Ea(t){ge+=1,t.warnings!==!1&&ge>=10&&ge%10===0&&console.warn(`[Shiki] ${ge} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new ie("`engine` option is required for synchronous mode");const r=(t.langs||[]).flat(1),n=(t.themes||[]).flat(1).map(Wt),s=new xa(t.engine,r),o=new va(s,n,r,t.langAlias);let a;function c(m){return fn(m,t.langAlias)}function i(m){p();const k=o.getGrammar(typeof m=="string"?m:m.name);if(!k)throw new ie(`Language \`${m}\` not found, you may need to load it first`);return k}function l(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};p();const k=o.getTheme(m);if(!k)throw new ie(`Theme \`${m}\` not found, you may need to load it first`);return k}function u(m){p();const k=l(m);a!==m&&(o.setTheme(k),a=m);const _=o.getColorMap();return{theme:k,colorMap:_}}function d(){return p(),o.getLoadedThemes()}function f(){return p(),o.getLoadedLanguages()}function g(...m){p(),o.loadLanguages(m.flat(1))}async function h(...m){return g(await un(m))}function b(...m){p();for(const k of m.flat(1))o.loadTheme(k)}async function y(...m){return p(),b(await dn(m))}function p(){if(e)throw new ie("Shiki instance has been disposed")}function w(){e||(e=!0,o.dispose(),ge-=1)}return{setTheme:u,getTheme:l,getLanguage:i,getLoadedThemes:d,getLoadedLanguages:f,resolveLangAlias:c,loadLanguage:h,loadLanguageSync:g,loadTheme:y,loadThemeSync:b,dispose:w,[Symbol.dispose]:w}}async function Aa(t){t.engine||Sa("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,r,n]=await Promise.all([dn(t.themes||[]),un(t.langs||[]),t.engine]);return Ea({...t,themes:e,langs:r,engine:n})}async function Ia(t){const e=await Aa(t);return{getLastGrammarState:(...r)=>la(e,...r),codeToTokensBase:(r,n)=>Ut(e,r,n),codeToTokensWithThemes:(r,n)=>ln(e,r,n),codeToTokens:(r,n)=>qe(e,r,n),codeToHast:(r,n)=>Ve(e,r,n),codeToHtml:(r,n)=>Ca(e,r,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function de(t){if([...t].length!==1)throw new Error(`Expected "${t}" to be a single code point`);return t.codePointAt(0)}function Na(t,e,r){return t.has(e)||t.set(e,r),t.get(e)}const zt=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),A=String.raw;function fe(t,e){if(t==null)throw new Error(e??"Value expected");return t}const hn=A`\[\^?`,gn=`c.? | C(?:-.?)?|${A`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${A`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${A`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${A`o\{[^\}]*\}?`}|${A`\d{1,3}`}`,qt=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,$e=new RegExp(A`
13
+ \\ (?:
14
+ ${gn}
15
+ | [gk]<[^>]*>?
16
+ | [gk]'[^']*'?
17
+ | .
18
+ )
19
+ | \( (?:
20
+ \? (?:
21
+ [:=!>({]
22
+ | <[=!]
23
+ | <[^>]*>
24
+ | '[^']*'
25
+ | ~\|?
26
+ | #(?:[^)\\]|\\.?)*
27
+ | [^:)]*[:)]
28
+ )?
29
+ | \*[^\)]*\)?
30
+ )?
31
+ | (?:${qt.source})+
32
+ | ${hn}
33
+ | .
34
+ `.replace(/\s+/g,""),"gsu"),ct=new RegExp(A`
35
+ \\ (?:
36
+ ${gn}
37
+ | .
38
+ )
39
+ | \[:(?:\^?\p{Alpha}+|\^):\]
40
+ | ${hn}
41
+ | &&
42
+ | .
43
+ `.replace(/\s+/g,""),"gsu");function $a(t,e={}){const r={flags:"",...e,rules:{captureGroup:!1,singleline:!1,...e.rules}};if(typeof t!="string")throw new Error("String expected as pattern");const n=Xa(r.flags),s=[n.extended],o={captureGroup:r.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop()},pushModX(d){s.push(d)},replaceCurrentModX(d){s[s.length-1]=d},singleline:r.rules.singleline};let a=[],c;for($e.lastIndex=0;c=$e.exec(t);){const d=Ra(o,t,c[0],$e.lastIndex);d.tokens?a.push(...d.tokens):d.token&&a.push(d.token),d.lastIndex!==void 0&&($e.lastIndex=d.lastIndex)}const i=[];let l=0;a.filter(d=>d.type==="GroupOpen").forEach(d=>{d.kind==="capturing"?d.number=++l:d.raw==="("&&i.push(d)}),l||i.forEach((d,f)=>{d.kind="capturing",d.number=f+1});const u=l||i.length;return{tokens:a.map(d=>d.type==="EscapedNumber"?Ka(d,u):d).flat(),flags:n}}function Ra(t,e,r,n){const[s,o]=r;if(r==="["||r==="[^"){const a=Ba(e,r,n);return{tokens:a.tokens,lastIndex:a.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(o))return{token:pr(r,r)};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:Ua(r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:mn(r)}}if(o==="K")return{token:bn("keep",r)};if(o==="N"||o==="R")return{token:Z("newline",r,{negate:o==="N"})};if(o==="O")return{token:Z("any",r)};if(o==="X")return{token:Z("text_segment",r)};const a=pn(r,{inCharClass:!1});return Array.isArray(a)?{tokens:a}:{token:a}}if(s==="("){if(o==="*")return{token:qa(r)};if(r==="(?{")throw new Error(`Unsupported callout "${r}"`);if(r.startsWith("(?#")){if(e[n]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:n+1}}if(/^\(\?[-imx]+[:)]$/.test(r))return{token:za(r,t)};if(t.pushModX(t.getCurrentModX()),t.numOpenGroups++,r==="("&&!t.captureGroup||r==="(?:")return{token:se("group",r)};if(r==="(?>")return{token:se("atomic",r)};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:se(r[2]==="<"?"lookbehind":"lookahead",r,{negate:r.endsWith("!")})};if(r==="("&&t.captureGroup||r.startsWith("(?<")&&r.endsWith(">")||r.startsWith("(?'")&&r.endsWith("'"))return{token:se("capturing",r,{...r!=="("&&{name:r.slice(3,-1)}})};if(r.startsWith("(?~")){if(r==="(?~|")throw new Error(`Unsupported absence function kind "${r}"`);return{token:se("absence_repeater",r)}}throw r==="(?("?new Error(`Unsupported conditional "${r}"`):new Error(`Invalid or unsupported group option "${r}"`)}if(r===")"){if(t.popModX(),t.numOpenGroups--,t.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Oa(r)}}if(t.getCurrentModX()){if(r==="#"){const a=e.indexOf(`
44
+ `,n);return{lastIndex:a===-1?e.length:a}}if(/^\s$/.test(r)){const a=/\s+/y;return a.lastIndex=n,{lastIndex:a.exec(e)?a.lastIndex:n}}}if(r===".")return{token:Z("dot",r)};if(r==="^"||r==="$"){const a=t.singleline?{"^":A`\A`,$:A`\Z`}[r]:r;return{token:pr(a,r)}}return r==="|"?{token:La(r)}:qt.test(r)?{tokens:Za(r)}:{token:U(de(r),r)}}function Ba(t,e,r){const n=[mr(e[1]==="^",e)];let s=1,o;for(ct.lastIndex=r;o=ct.exec(t);){const a=o[0];if(a[0]==="["&&a[1]!==":")s++,n.push(mr(a[1]==="^",a));else if(a==="]"){if(n.at(-1).type==="CharacterClassOpen")n.push(U(93,a));else if(s--,n.push(Pa(a)),!s)break}else{const c=Ta(a);Array.isArray(c)?n.push(...c):n.push(c)}}return{tokens:n,lastIndex:ct.lastIndex||t.length}}function Ta(t){if(t[0]==="\\")return pn(t,{inCharClass:!0});if(t[0]==="["){const e=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(t);if(!e||!zt.has(e.groups.name))throw new Error(`Invalid POSIX class "${t}"`);return Z("posix",t,{value:e.groups.name,negate:!!e.groups.negate})}return t==="-"?Ga(t):t==="&&"?Ma(t):U(de(t),t)}function pn(t,{inCharClass:e}){const r=t[1];if(r==="c"||r==="C")return Wa(t);if("dDhHsSwW".includes(r))return Va(t);if(t.startsWith(A`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${t}"`);if(/^\\[pP]\{/.test(t)){if(t.length===3)throw new Error(`Incomplete or invalid Unicode property "${t}"`);return Qa(t)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(t))try{const n=t.split(/\\x/).slice(1).map(a=>parseInt(a,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(n)),o=new TextEncoder;return[...s].map(a=>{const c=[...o.encode(a)].map(i=>`\\x${i.toString(16)}`).join("");return U(de(a),c)})}catch{throw new Error(`Multibyte code "${t}" incomplete or invalid in Oniguruma`)}if(r==="u"||r==="x")return U(Ja(t),t);if(br.has(r))return U(br.get(r),t);if(/\d/.test(r))return Fa(e,t);if(t==="\\")throw new Error(A`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${t}"`);if([...t].length===2)return U(t.codePointAt(1),t);throw new Error(`Unexpected escape "${t}"`)}function La(t){return{type:"Alternator",raw:t}}function pr(t,e){return{type:"Assertion",kind:t,raw:e}}function mn(t){return{type:"Backreference",raw:t}}function U(t,e){return{type:"Character",value:t,raw:e}}function Pa(t){return{type:"CharacterClassClose",raw:t}}function Ga(t){return{type:"CharacterClassHyphen",raw:t}}function Ma(t){return{type:"CharacterClassIntersector",raw:t}}function mr(t,e){return{type:"CharacterClassOpen",negate:t,raw:e}}function Z(t,e,r={}){return{type:"CharacterSet",kind:t,...r,raw:e}}function bn(t,e,r={}){return t==="keep"?{type:"Directive",kind:t,raw:e}:{type:"Directive",kind:t,flags:fe(r.flags),raw:e}}function Fa(t,e){return{type:"EscapedNumber",inCharClass:t,raw:e}}function Oa(t){return{type:"GroupClose",raw:t}}function se(t,e,r={}){return{type:"GroupOpen",kind:t,...r,raw:e}}function Da(t,e,r,n){return{type:"NamedCallout",kind:t,tag:e,arguments:r,raw:n}}function ja(t,e,r,n){return{type:"Quantifier",kind:t,min:e,max:r,raw:n}}function Ua(t){return{type:"Subroutine",raw:t}}const Ha=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),br=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Wa(t){const e=t[1]==="c"?t[2]:t[3];if(!e||!/[A-Za-z]/.test(e))throw new Error(`Unsupported control character "${t}"`);return U(de(e.toUpperCase())-64,t)}function za(t,e){let{on:r,off:n}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(t).groups;n??="";const s=(e.getCurrentModX()||r.includes("x"))&&!n.includes("x"),o=wr(r),a=wr(n),c={};if(o&&(c.enable=o),a&&(c.disable=a),t.endsWith(")"))return e.replaceCurrentModX(s),bn("flags",t,{flags:c});if(t.endsWith(":"))return e.pushModX(s),e.numOpenGroups++,se("group",t,{...(o||a)&&{flags:c}});throw new Error(`Unexpected flag modifier "${t}"`)}function qa(t){const e=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(t);if(!e)throw new Error(`Incomplete or invalid named callout "${t}"`);const{name:r,tag:n,args:s}=e.groups;if(!r)throw new Error(`Invalid named callout "${t}"`);if(n==="")throw new Error(`Named callout tag with empty value not allowed "${t}"`);const o=s?s.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[a,c,i]=o,l=Ha.has(r)?r.toLowerCase():"custom";switch(l){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof a=="string")throw new Error(`Named callout argument must be a number "${a}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(o.length===2&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${c}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(typeof c=="number"||!/^(?:[<>!=]=|[<>])$/.test(c))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${c}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument three must be a tag or number "${i}"`);break;case"custom":throw new Error(`Undefined callout name "${r}"`);default:throw new Error(`Unexpected named callout kind "${l}"`)}return Da(l,n??null,s?.split(",")??null,t)}function yr(t){let e=null,r,n;if(t[0]==="{"){const{minStr:s,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(t).groups,a=1e5;if(+s>a||o&&+o>a)throw new Error("Quantifier value unsupported in Oniguruma");if(r=+s,n=o===void 0?+s:o===""?1/0:+o,r>n&&(e="possessive",[r,n]=[n,r]),t.endsWith("?")){if(e==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');e="lazy"}else e||(e="greedy")}else r=t[0]==="+"?1:0,n=t[0]==="?"?1:1/0,e=t[1]==="+"?"possessive":t[1]==="?"?"lazy":"greedy";return ja(e,r,n,t)}function Va(t){const e=t[1].toLowerCase();return Z({d:"digit",h:"hex",s:"space",w:"word"}[e],t,{negate:t[1]!==e})}function Qa(t){const{p:e,neg:r,value:n}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(t).groups;return Z("property",t,{value:n,negate:e==="P"&&!r||e==="p"&&!!r})}function wr(t){const e={};return t.includes("i")&&(e.ignoreCase=!0),t.includes("m")&&(e.dotAll=!0),t.includes("x")&&(e.extended=!0),Object.keys(e).length?e:null}function Xa(t){const e={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let r=0;r<t.length;r++){const n=t[r];if(!"imxDPSWy".includes(n))throw new Error(`Invalid flag "${n}"`);if(n==="y"){if(!/^y{[gw]}/.test(t.slice(r)))throw new Error('Invalid or unspecified flag "y" mode');e.textSegmentMode=t[r+2]==="g"?"grapheme":"word",r+=3;continue}e[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[n]]=!0}return e}function Ja(t){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(t))throw new Error(`Incomplete or invalid escape "${t}"`);const e=t[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(t).groups.hex:t.slice(2);return parseInt(e,16)}function Ka(t,e){const{raw:r,inCharClass:n}=t,s=r.slice(1);if(!n&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=e))return[mn(r)];const o=[],a=s.match(/^[0-7]+|\d/g);for(let c=0;c<a.length;c++){const i=a[c];let l;if(c===0&&i!=="8"&&i!=="9"){if(l=parseInt(i,8),l>127)throw new Error(A`Octal encoded byte above 177 unsupported "${r}"`)}else l=de(i);o.push(U(l,(c===0?"\\":"")+i))}return o}function Za(t){const e=[],r=new RegExp(qt,"gy");let n;for(;n=r.exec(t);){const s=n[0];if(s[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(o){const{min:a,max:c}=o.groups;if(+a>+c&&s.endsWith("?")){r.lastIndex--,e.push(yr(s.slice(0,-1)));continue}}}e.push(yr(s))}return e}function yn(t,e){if(!Array.isArray(t.body))throw new Error("Expected node with body array");if(t.body.length!==1)return!1;const r=t.body[0];return!e||Object.keys(e).every(n=>e[n]===r[n])}function Ya(t){return ei.has(t.type)}const ei=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function wn(t,e={}){const r={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e,rules:{captureGroup:!1,singleline:!1,...e.rules}},n=$a(t,{flags:r.flags,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline}}),s=(f,g)=>{const h=n.tokens[o.nextIndex];switch(o.parent=f,o.nextIndex++,h.type){case"Alternator":return Y();case"Assertion":return ti(h);case"Backreference":return ri(h,o);case"Character":return Ke(h.value,{useLastValid:!!g.isCheckingRangeEnd});case"CharacterClassHyphen":return ni(h,o,g);case"CharacterClassOpen":return si(h,o,g);case"CharacterSet":return oi(h,o);case"Directive":return di(h.kind,{flags:h.flags});case"GroupOpen":return ai(h,o,g);case"NamedCallout":return hi(h.kind,h.tag,h.arguments);case"Quantifier":return ii(h,o);case"Subroutine":return ci(h,o);default:throw new Error(`Unexpected token type "${h.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:r.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:r.skipBackrefValidation,skipLookbehindValidation:r.skipLookbehindValidation,skipPropertyNameValidation:r.skipPropertyNameValidation,subroutines:[],tokens:n.tokens,unicodePropertyMap:r.unicodePropertyMap,walk:s},a=pi(fi(n.flags));let c=a.body[0];for(;o.nextIndex<n.tokens.length;){const f=s(c,{});f.type==="Alternative"?(a.body.push(f),c=f):c.body.push(f)}const{capturingGroups:i,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=o;if(l&&u.size&&!r.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:f}of d)if(typeof f=="number"){if(f>i.length)throw new Error("Subroutine uses a group number that's not defined");f&&(i[f-1].isSubroutined=!0)}else if(u.has(f)){if(u.get(f).length>1)throw new Error(A`Subroutine uses a duplicate group name "\g<${f}>"`);u.get(f)[0].isSubroutined=!0}else throw new Error(A`Subroutine uses a group name that's not defined "\g<${f}>"`);return a}function ti({kind:t}){return Nt(fe({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[t],`Unexpected assertion kind "${t}"`),{negate:t===A`\B`||t===A`\Y`})}function ri({raw:t},e){const r=/^\\k[<']/.test(t),n=r?t.slice(3,-1):t.slice(1),s=(o,a=!1)=>{const c=e.capturingGroups.length;let i=!1;if(o>c)if(e.skipBackrefValidation)i=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,$t(a?c+1-o:o,{orphan:i})};if(r){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(n))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(n))throw new Error(`Group name not defined to the left "${t}"`);return $t(n)}return s(+n)}function ni(t,e,r){const{tokens:n,walk:s}=e,o=e.parent,a=o.body.at(-1),c=n[e.nextIndex];if(!r.isCheckingRangeEnd&&a&&a.type!=="CharacterClass"&&a.type!=="CharacterClassRange"&&c&&c.type!=="CharacterClassOpen"&&c.type!=="CharacterClassClose"&&c.type!=="CharacterClassIntersector"){const i=s(o,{...r,isCheckingRangeEnd:!0});if(a.type==="Character"&&i.type==="Character")return o.body.pop(),ui(a,i);throw new Error("Invalid character class range")}return Ke(de("-"))}function si({negate:t},e,r){const{tokens:n,walk:s}=e,o=n[e.nextIndex],a=[Ge()];let c=_r(o);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")a.push(Ge()),e.nextIndex++;else{const l=a.at(-1);l.body.push(s(l,r))}c=_r(n[e.nextIndex],o)}const i=Ge({negate:t});return a.length===1?i.body=a[0].body:(i.kind="intersection",i.body=a.map(l=>l.body.length===1?l.body[0]:l)),e.nextIndex++,i}function oi({kind:t,negate:e,value:r},n){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a}=n;if(t==="property"){const c=Ze(r);if(zt.has(c)&&!a?.has(c))t="posix",r=c;else return oe(r,{negate:e,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a})}return t==="posix"?gi(r,{negate:e}):Rt(t,{negate:e})}function ai(t,e,r){const{tokens:n,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:a,walk:c}=e,i=mi(t),l=i.type==="AbsenceFunction",u=Cr(i),d=u&&i.negate;if(i.type==="CapturingGroup"&&(s.push(i),i.name&&Na(o,i.name,[]).push(i)),l&&r.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=Sr(n[e.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")i.body.push(Y()),e.nextIndex++;else{const g=i.body.at(-1),h=c(g,{...r,isInAbsenceFunction:r.isInAbsenceFunction||l,isInLookbehind:r.isInLookbehind||u,isInNegLookbehind:r.isInNegLookbehind||d});if(g.body.push(h),(u||r.isInLookbehind)&&!a){const b="Lookbehind includes a pattern not allowed by Oniguruma";if(d||r.isInNegLookbehind){if(kr(h)||h.type==="CapturingGroup")throw new Error(b)}else if(kr(h)||Cr(h)&&h.negate)throw new Error(b)}}f=Sr(n[e.nextIndex])}return e.nextIndex++,i}function ii({kind:t,min:e,max:r},n){const s=n.parent,o=s.body.at(-1);if(!o||!Ya(o))throw new Error("Quantifier requires a repeatable token");const a=Cn(t,e,r,o);return s.body.pop(),a}function ci({raw:t},e){const{capturingGroups:r,subroutines:n}=e;let s=t.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const c=+o.groups.num,i=r.length;if(e.hasNumberedRef=!0,s={"":c,"+":i+c,"-":i+1-c}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const a=_n(s);return n.push(a),a}function li(t,e){return{type:"AbsenceFunction",kind:t,body:xe(e?.body)}}function Y(t){return{type:"Alternative",body:Sn(t?.body)}}function Nt(t,e){const r={type:"Assertion",kind:t};return(t==="word_boundary"||t==="text_segment_boundary")&&(r.negate=!!e?.negate),r}function $t(t,e){const r=!!e?.orphan;return{type:"Backreference",ref:t,...r&&{orphan:r}}}function kn(t,e){const r={name:void 0,isSubroutined:!1,...e};if(r.name!==void 0&&!bi(r.name))throw new Error(`Group name "${r.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:t,...r.name&&{name:r.name},...r.isSubroutined&&{isSubroutined:r.isSubroutined},body:xe(e?.body)}}function Ke(t,e){const r={useLastValid:!1,...e};if(t>1114111){const n=t.toString(16);if(r.useLastValid)t=1114111;else throw t>1310719?new Error(`Invalid code point out of range "\\x{${n}}"`):new Error(`Invalid code point out of range in JS "\\x{${n}}"`)}return{type:"Character",value:t}}function Ge(t){const e={kind:"union",negate:!1,...t};return{type:"CharacterClass",kind:e.kind,negate:e.negate,body:Sn(t?.body)}}function ui(t,e){if(e.value<t.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:t,max:e}}function Rt(t,e){const r=!!e?.negate,n={type:"CharacterSet",kind:t};return(t==="digit"||t==="hex"||t==="newline"||t==="space"||t==="word")&&(n.negate=r),(t==="text_segment"||t==="newline"&&!r)&&(n.variableLength=!0),n}function di(t,e={}){if(t==="keep")return{type:"Directive",kind:t};if(t==="flags")return{type:"Directive",kind:t,flags:fe(e.flags)};throw new Error(`Unexpected directive kind "${t}"`)}function fi(t){return{type:"Flags",...t}}function G(t){const e=t?.atomic,r=t?.flags;if(e&&r)throw new Error("Atomic group cannot have flags");return{type:"Group",...e&&{atomic:e},...r&&{flags:r},body:xe(t?.body)}}function J(t){const e={behind:!1,negate:!1,...t};return{type:"LookaroundAssertion",kind:e.behind?"lookbehind":"lookahead",negate:e.negate,body:xe(t?.body)}}function hi(t,e,r){return{type:"NamedCallout",kind:t,tag:e,arguments:r}}function gi(t,e){const r=!!e?.negate;if(!zt.has(t))throw new Error(`Invalid POSIX class "${t}"`);return{type:"CharacterSet",kind:"posix",value:t,negate:r}}function Cn(t,e,r,n){if(e>r)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:t,min:e,max:r,body:n}}function pi(t,e){return{type:"Regex",body:xe(e?.body),flags:t}}function _n(t){return{type:"Subroutine",ref:t}}function oe(t,e){const r={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e};let n=r.unicodePropertyMap?.get(Ze(t));if(!n){if(r.normalizeUnknownPropertyNames)n=yi(t);else if(r.unicodePropertyMap&&!r.skipPropertyNameValidation)throw new Error(A`Invalid Unicode property "\p{${t}}"`)}return{type:"CharacterSet",kind:"property",value:n??t,negate:r.negate}}function mi({flags:t,kind:e,name:r,negate:n,number:s}){switch(e){case"absence_repeater":return li("repeater");case"atomic":return G({atomic:!0});case"capturing":return kn(s,{name:r});case"group":return G({flags:t});case"lookahead":case"lookbehind":return J({behind:e==="lookbehind",negate:n});default:throw new Error(`Unexpected group kind "${e}"`)}}function xe(t){if(t===void 0)t=[Y()];else if(!Array.isArray(t)||!t.length||!t.every(e=>e.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return t}function Sn(t){if(t===void 0)t=[];else if(!Array.isArray(t)||!t.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return t}function kr(t){return t.type==="LookaroundAssertion"&&t.kind==="lookahead"}function Cr(t){return t.type==="LookaroundAssertion"&&t.kind==="lookbehind"}function bi(t){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(t)}function yi(t){return t.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function Ze(t){return t.replace(/[- _]+/g,"").toLowerCase()}function _r(t,e){return fe(t,`${e?.type==="Character"&&e.value===93?"Empty":"Unclosed"} character class`)}function Sr(t){return fe(t,"Unclosed group")}function ye(t,e,r=null){function n(o,a){for(let c=0;c<o.length;c++){const i=s(o[c],a,c,o);c=Math.max(-1,c+i)}}function s(o,a=null,c=null,i=null){let l=0,u=!1;const d={node:o,parent:a,key:c,container:i,root:t,remove(){Re(i).splice(Math.max(0,te(c)+l),1),l--,u=!0},removeAllNextSiblings(){return Re(i).splice(te(c)+1)},removeAllPrevSiblings(){const p=te(c)+l;return l-=p,Re(i).splice(0,Math.max(0,p))},replaceWith(p,w={}){const m=!!w.traverse;i?i[Math.max(0,te(c)+l)]=p:fe(a,"Can't replace root node")[c]=p,m&&s(p,a,c,i),u=!0},replaceWithMultiple(p,w={}){const m=!!w.traverse;if(Re(i).splice(Math.max(0,te(c)+l),1,...p),l+=p.length-1,m){let k=0;for(let _=0;_<p.length;_++)k+=s(p[_],a,te(c)+_+k,i)}u=!0},skip(){u=!0}},{type:f}=o,g=e["*"],h=e[f],b=typeof g=="function"?g:g?.enter,y=typeof h=="function"?h:h?.enter;if(b?.(d,r),y?.(d,r),!u)switch(f){case"AbsenceFunction":case"CapturingGroup":case"Group":n(o.body,o);break;case"Alternative":case"CharacterClass":n(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":s(o.min,o,"min"),s(o.max,o,"max");break;case"LookaroundAssertion":n(o.body,o);break;case"Quantifier":s(o.body,o,"body");break;case"Regex":n(o.body,o),s(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${f}"`)}return h?.exit?.(d,r),g?.exit?.(d,r),l}return s(t),t}function Re(t){if(!Array.isArray(t))throw new Error("Container expected");return t}function te(t){if(typeof t!="number")throw new Error("Numeric key expected");return t}const wi=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function ki(t,e){for(let r=0;r<t.length;r++)t[r]>=e&&t[r]++}function Ci(t,e,r,n){return t.slice(0,e)+n+t.slice(e+r.length)}const P=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Vt(t,e,r,n){const s=new RegExp(String.raw`${e}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let a=0,c="";for(const i of t.matchAll(s)){const{0:l,groups:{$skip:u}}=i;if(!u&&(!n||n===P.DEFAULT==!a)){r instanceof Function?c+=r(i,{context:a?P.CHAR_CLASS:P.DEFAULT,negated:o[o.length-1]}):c+=r;continue}l[0]==="["?(a++,o.push(l[1]==="^")):l==="]"&&a&&(a--,o.pop()),c+=l}return c}function vn(t,e,r,n){Vt(t,e,r,n)}function _i(t,e,r=0,n){if(!new RegExp(e,"su").test(t))return null;const s=new RegExp(`${e}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=r;let o=0,a;for(;a=s.exec(t);){const{0:c,groups:{$skip:i}}=a;if(!i&&(!n||n===P.DEFAULT==!o))return a;c==="["?o++:c==="]"&&o&&o--,s.lastIndex==a.index&&s.lastIndex++}return null}function Be(t,e,r){return!!_i(t,e,0,r)}function Si(t,e){const r=/\\?./gsu;r.lastIndex=e;let n=t.length,s=0,o=1,a;for(;a=r.exec(t);){const[c]=a;if(c==="[")s++;else if(s)c==="]"&&s--;else if(c==="(")o++;else if(c===")"&&(o--,!o)){n=a.index;break}}return t.slice(e,n)}const vr=new RegExp(String.raw`(?<noncapturingStart>${wi})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function vi(t,e){const r=e?.hiddenCaptures??[];let n=e?.captureTransfers??new Map;if(!/\(\?>/.test(t))return{pattern:t,captureTransfers:n,hiddenCaptures:r};const s="(?>",o="(?:(?=(",a=[0],c=[];let i=0,l=0,u=NaN,d;do{d=!1;let f=0,g=0,h=!1,b;for(vr.lastIndex=Number.isNaN(u)?0:u+o.length;b=vr.exec(t);){const{0:y,index:p,groups:{capturingStart:w,noncapturingStart:m}}=b;if(y==="[")f++;else if(f)y==="]"&&f--;else if(y===s&&!h)u=p,h=!0;else if(h&&m)g++;else if(w)h?g++:(i++,a.push(i+l));else if(y===")"&&h){if(!g){l++;const k=i+l;if(t=`${t.slice(0,u)}${o}${t.slice(u+s.length,p)}))<$$${k}>)${t.slice(p+1)}`,d=!0,c.push(k),ki(r,k),n.size){const _=new Map;n.forEach(($,R)=>{_.set(R>=k?R+1:R,$.map(F=>F>=k?F+1:F))}),n=_}break}g--}}}while(d);return r.push(...c),t=Vt(t,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:g,wrappedBackrefNum:h}})=>{if(g){const b=+g;if(b>a.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${a[b]}`}return`\\${h}`},P.DEFAULT),{pattern:t,captureTransfers:n,hiddenCaptures:r}}const xn=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,lt=new RegExp(String.raw`
45
+ \\(?: \d+
46
+ | c[A-Za-z]
47
+ | [gk]<[^>]+>
48
+ | [pPu]\{[^\}]+\}
49
+ | u[A-Fa-f\d]{4}
50
+ | x[A-Fa-f\d]{2}
51
+ )
52
+ | \((?: \? (?: [:=!>]
53
+ | <(?:[=!]|[^>]+>)
54
+ | [A-Za-z\-]+:
55
+ | \(DEFINE\)
56
+ ))?
57
+ | (?<qBase>${xn})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
58
+ | \\?.
59
+ `.replace(/\s+/g,""),"gsu");function xi(t){if(!new RegExp(`${xn}\\+`).test(t))return{pattern:t};const e=[];let r=null,n=null,s="",o=0,a;for(lt.lastIndex=0;a=lt.exec(t);){const{0:c,index:i,groups:{qBase:l,qMod:u,invalidQ:d}}=a;if(c==="[")o||(n=i),o++;else if(c==="]")o?o--:n=null;else if(!o)if(u==="+"&&s&&!s.startsWith("(")){if(d)throw new Error(`Invalid quantifier "${c}"`);let f=-1;if(/^\{\d+\}$/.test(l))t=Ci(t,i+l.length,u,"");else{if(s===")"||s==="]"){const g=s===")"?r:n;if(g===null)throw new Error(`Invalid unmatched "${s}"`);t=`${t.slice(0,g)}(?>${t.slice(g,i)}${l})${t.slice(i+c.length)}`}else t=`${t.slice(0,i-s.length)}(?>${s}${l})${t.slice(i+c.length)}`;f+=4}lt.lastIndex+=f}else c[0]==="("?e.push(i):c===")"&&(r=e.length?e.pop():null);s=c}return{pattern:t}}const T=String.raw,Ei=T`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Bt=T`\(\?R=(?<rDepth>[^\)]+)\)|${Ei}`,Ye=T`\(\?<(?![=!])(?<captureName>[^>]+)>`,En=T`${Ye}|(?<unnamed>\()(?!\?)`,Q=new RegExp(T`${Ye}|${Bt}|\(\?|\\?.`,"gsu"),ut="Cannot use multiple overlapping recursions";function Ai(t,e){const{hiddenCaptures:r,mode:n}={hiddenCaptures:[],mode:"plugin",...e};let s=e?.captureTransfers??new Map;if(!new RegExp(Bt,"su").test(t))return{pattern:t,captureTransfers:s,hiddenCaptures:r};if(n==="plugin"&&Be(t,T`\(\?\(DEFINE\)`,P.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],a=Be(t,T`\\[1-9]`,P.DEFAULT),c=new Map,i=[];let l=!1,u=0,d=0,f;for(Q.lastIndex=0;f=Q.exec(t);){const{0:g,groups:{captureName:h,rDepth:b,gRNameOrNum:y,gRDepth:p}}=f;if(g==="[")u++;else if(u)g==="]"&&u--;else if(b){if(xr(b),l)throw new Error(ut);if(a)throw new Error(`${n==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const w=t.slice(0,f.index),m=t.slice(Q.lastIndex);if(Be(m,Bt,P.DEFAULT))throw new Error(ut);const k=+b-1;t=Er(w,m,k,!1,r,o,d),s=Ir(s,w,k,o.length,0,d);break}else if(y){xr(p);let w=!1;for(const W of i)if(W.name===y||W.num===+y){if(w=!0,W.hasRecursedWithin)throw new Error(ut);break}if(!w)throw new Error(T`Recursive \g cannot be used outside the referenced group "${n==="external"?y:T`\g<${y}&R=${p}>`}"`);const m=c.get(y),k=Si(t,m);if(a&&Be(k,T`${Ye}|\((?!\?)`,P.DEFAULT))throw new Error(`${n==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const _=t.slice(m,f.index),$=k.slice(_.length+g.length),R=o.length,F=+p-1,Ee=Er(_,$,F,!0,r,o,d);s=Ir(s,_,F,o.length-R,R,d);const et=t.slice(0,m),he=t.slice(m+k.length);t=`${et}${Ee}${he}`,Q.lastIndex+=Ee.length-g.length-_.length-$.length,i.forEach(W=>W.hasRecursedWithin=!0),l=!0}else if(h)d++,c.set(String(d),Q.lastIndex),c.set(h,Q.lastIndex),i.push({num:d,name:h});else if(g[0]==="("){const w=g==="(";w&&(d++,c.set(String(d),Q.lastIndex)),i.push(w?{num:d}:{})}else g===")"&&i.pop()}return r.push(...o),{pattern:t,captureTransfers:s,hiddenCaptures:r}}function xr(t){const e=`Max depth must be integer between 2 and 100; used ${t}`;if(!/^[1-9]\d*$/.test(t))throw new Error(e);if(t=+t,t<2||t>100)throw new Error(e)}function Er(t,e,r,n,s,o,a){const c=new Set;n&&vn(t+e,Ye,({groups:{captureName:l}})=>{c.add(l)},P.DEFAULT);const i=[r,n?c:null,s,o,a];return`${t}${Ar(`(?:${t}`,"forward",...i)}(?:)${Ar(`${e})`,"backward",...i)}${e}`}function Ar(t,e,r,n,s,o,a){const i=u=>e==="forward"?u+2:r-u+2-1;let l="";for(let u=0;u<r;u++){const d=i(u);l+=Vt(t,T`${En}|\\k<(?<backref>[^>]+)>`,({0:f,groups:{captureName:g,unnamed:h,backref:b}})=>{if(b&&n&&!n.has(b))return f;const y=`_$${d}`;if(h||g){const p=a+o.length+1;return o.push(p),Ii(s,p),h?f:`(?<${g}${y}>`}return T`\k<${b}${y}>`},P.DEFAULT)}return l}function Ii(t,e){for(let r=0;r<t.length;r++)t[r]>=e&&t[r]++}function Ir(t,e,r,n,s,o){if(t.size&&n){let a=0;vn(e,En,()=>a++,P.DEFAULT);const c=o-a+s,i=new Map;return t.forEach((l,u)=>{const d=(n-a*r)/r,f=a*r,g=u>c+a?u+n:u,h=[];for(const b of l)if(b<=c)h.push(b);else if(b>c+a+d)h.push(b+n);else if(b<=c+a)for(let y=0;y<=r;y++)h.push(b+a*y);else for(let y=0;y<=r;y++)h.push(b+f+d*y);i.set(g,h)}),i}return t}var v=String.fromCodePoint,C=String.raw,H={flagGroups:(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),unicodeSets:(()=>{try{new RegExp("[[]]","v")}catch{return!1}return!0})()};H.bugFlagVLiteralHyphenIsRange=H.unicodeSets?(()=>{try{new RegExp(C`[\d\-a]`,"v")}catch{return!0}return!1})():!1;H.bugNestedClassIgnoresNegation=H.unicodeSets&&new RegExp("[[^a]]","v").test("a");function Qe(t,{enable:e,disable:r}){return{dotAll:!r?.dotAll&&!!(e?.dotAll||t.dotAll),ignoreCase:!r?.ignoreCase&&!!(e?.ignoreCase||t.ignoreCase)}}function Se(t,e,r){return t.has(e)||t.set(e,r),t.get(e)}function Tt(t,e){return Nr[t]>=Nr[e]}function Ni(t,e){if(t==null)throw new Error(e??"Value expected");return t}var Nr={ES2025:2025,ES2024:2024,ES2018:2018},$i={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function An(t={}){if({}.toString.call(t)!=="[object Object]")throw new Error("Unexpected options");if(t.target!==void 0&&!$i[t.target])throw new Error(`Unexpected target "${t.target}"`);const e={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...t,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...t.rules}};return e.target==="auto"&&(e.target=H.flagGroups?"ES2025":H.unicodeSets?"ES2024":"ES2018"),e}var Ri="[ -\r ]",Bi=new Set([v(304),v(305)]),D=C`[\p{L}\p{M}\p{N}\p{Pc}]`;function In(t){if(Bi.has(t))return[t];const e=new Set,r=t.toLowerCase(),n=r.toUpperCase(),s=Pi.get(r),o=Ti.get(r),a=Li.get(r);return[...n].length===1&&e.add(n),a&&e.add(a),s&&e.add(s),e.add(r),o&&e.add(o),[...e]}var Qt=new Map(`C Other
60
+ Cc Control cntrl
61
+ Cf Format
62
+ Cn Unassigned
63
+ Co Private_Use
64
+ Cs Surrogate
65
+ L Letter
66
+ LC Cased_Letter
67
+ Ll Lowercase_Letter
68
+ Lm Modifier_Letter
69
+ Lo Other_Letter
70
+ Lt Titlecase_Letter
71
+ Lu Uppercase_Letter
72
+ M Mark Combining_Mark
73
+ Mc Spacing_Mark
74
+ Me Enclosing_Mark
75
+ Mn Nonspacing_Mark
76
+ N Number
77
+ Nd Decimal_Number digit
78
+ Nl Letter_Number
79
+ No Other_Number
80
+ P Punctuation punct
81
+ Pc Connector_Punctuation
82
+ Pd Dash_Punctuation
83
+ Pe Close_Punctuation
84
+ Pf Final_Punctuation
85
+ Pi Initial_Punctuation
86
+ Po Other_Punctuation
87
+ Ps Open_Punctuation
88
+ S Symbol
89
+ Sc Currency_Symbol
90
+ Sk Modifier_Symbol
91
+ Sm Math_Symbol
92
+ So Other_Symbol
93
+ Z Separator
94
+ Zl Line_Separator
95
+ Zp Paragraph_Separator
96
+ Zs Space_Separator
97
+ ASCII
98
+ ASCII_Hex_Digit AHex
99
+ Alphabetic Alpha
100
+ Any
101
+ Assigned
102
+ Bidi_Control Bidi_C
103
+ Bidi_Mirrored Bidi_M
104
+ Case_Ignorable CI
105
+ Cased
106
+ Changes_When_Casefolded CWCF
107
+ Changes_When_Casemapped CWCM
108
+ Changes_When_Lowercased CWL
109
+ Changes_When_NFKC_Casefolded CWKCF
110
+ Changes_When_Titlecased CWT
111
+ Changes_When_Uppercased CWU
112
+ Dash
113
+ Default_Ignorable_Code_Point DI
114
+ Deprecated Dep
115
+ Diacritic Dia
116
+ Emoji
117
+ Emoji_Component EComp
118
+ Emoji_Modifier EMod
119
+ Emoji_Modifier_Base EBase
120
+ Emoji_Presentation EPres
121
+ Extended_Pictographic ExtPict
122
+ Extender Ext
123
+ Grapheme_Base Gr_Base
124
+ Grapheme_Extend Gr_Ext
125
+ Hex_Digit Hex
126
+ IDS_Binary_Operator IDSB
127
+ IDS_Trinary_Operator IDST
128
+ ID_Continue IDC
129
+ ID_Start IDS
130
+ Ideographic Ideo
131
+ Join_Control Join_C
132
+ Logical_Order_Exception LOE
133
+ Lowercase Lower
134
+ Math
135
+ Noncharacter_Code_Point NChar
136
+ Pattern_Syntax Pat_Syn
137
+ Pattern_White_Space Pat_WS
138
+ Quotation_Mark QMark
139
+ Radical
140
+ Regional_Indicator RI
141
+ Sentence_Terminal STerm
142
+ Soft_Dotted SD
143
+ Terminal_Punctuation Term
144
+ Unified_Ideograph UIdeo
145
+ Uppercase Upper
146
+ Variation_Selector VS
147
+ White_Space space
148
+ XID_Continue XIDC
149
+ XID_Start XIDS`.split(/\s/).map(t=>[Ze(t),t])),Ti=new Map([["s",v(383)],[v(383),"s"]]),Li=new Map([[v(223),v(7838)],[v(107),v(8490)],[v(229),v(8491)],[v(969),v(8486)]]),Pi=new Map([z(453),z(456),z(459),z(498),...dt(8072,8079),...dt(8088,8095),...dt(8104,8111),z(8124),z(8140),z(8188)]),Gi=new Map([["alnum",C`[\p{Alpha}\p{Nd}]`],["alpha",C`\p{Alpha}`],["ascii",C`\p{ASCII}`],["blank",C`[\p{Zs}\t]`],["cntrl",C`\p{Cc}`],["digit",C`\p{Nd}`],["graph",C`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",C`\p{Lower}`],["print",C`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",C`[\p{P}\p{S}]`],["space",C`\p{space}`],["upper",C`\p{Upper}`],["word",C`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",C`\p{AHex}`]]);function Mi(t,e){const r=[];for(let n=t;n<=e;n++)r.push(n);return r}function z(t){const e=v(t);return[e.toLowerCase(),e]}function dt(t,e){return Mi(t,e).map(r=>z(r))}var Nn=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function Fi(t,e){const r={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...e};$n(t);const n={accuracy:r.accuracy,asciiWordBoundaries:r.asciiWordBoundaries,avoidSubclass:r.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Tt(r.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:t.flags.digitIsAscii,spaceIsAscii:t.flags.spaceIsAscii,wordIsAscii:t.flags.wordIsAscii};ye(t,Oi,n);const s={dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},o={currentFlags:s,prevFlags:null,globalFlags:s,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:n.subroutineRefMap};ye(t,Di,o);const a={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return ye(t,ji,a),t._originMap=o.groupOriginByCopy,t._strategy=n.strategy,t}var Oi={AbsenceFunction({node:t,parent:e,replaceWith:r}){const{body:n,kind:s}=t;if(s==="repeater"){const o=G();o.body[0].body.push(J({negate:!0,body:n}),oe("Any"));const a=G();a.body[0].body.push(Cn("greedy",0,1/0,o)),r(S(a,e),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:t,parent:e,key:r},{flagDirectivesByAlt:n}){const s=t.body.filter(o=>o.kind==="flags");for(let o=r+1;o<e.body.length;o++){const a=e.body[o];Se(n,a,[]).push(...s)}},exit({node:t},{flagDirectivesByAlt:e}){if(e.get(t)?.length){const r=Bn(e.get(t));if(r){const n=G({flags:r});n.body[0].body=t.body,t.body=[S(n,t)]}}}},Assertion({node:t,parent:e,key:r,container:n,root:s,remove:o,replaceWith:a},c){const{kind:i,negate:l}=t,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:g}=c;if(i==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${l?"Y":"y"}"`);if(i==="line_end")a(S(J({body:[Y({body:[Nt("string_end")]}),Y({body:[Ke(10)]})]}),e));else if(i==="line_start")a(S(j(C`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),e));else if(i==="search_start")if(f.has(t))s.flags.sticky=!0,o();else{const h=n[r-1];if(h&&Vi(h))a(S(J({negate:!0}),e));else{if(d)throw new Error(C`Uses "\G" in a way that requires a subclass`);a(q(Nt("string_start"),e)),c.strategy="clip_search"}}else if(!(i==="string_end"||i==="string_start"))if(i==="string_end_newline")a(S(j(C`(?=\n?\z)`),e));else if(i==="word_boundary"){if(!g&&!u){const h=`(?:(?<=${D})(?!${D})|(?<!${D})(?=${D}))`,b=`(?:(?<=${D})(?=${D})|(?<!${D})(?!${D}))`;a(S(j(l?b:h),e))}}else throw new Error(`Unexpected assertion kind "${i}"`)},Backreference({node:t},{jsGroupNameMap:e}){let{ref:r}=t;typeof r=="string"&&!ht(r)&&(r=ft(r,e),t.ref=r)},CapturingGroup({node:t},{jsGroupNameMap:e,subroutineRefMap:r}){let{name:n}=t;n&&!ht(n)&&(n=ft(n,e),t.name=n),r.set(t.number,t),n&&r.set(n,t)},CharacterClassRange({node:t,parent:e,replaceWith:r}){if(e.kind==="intersection"){const n=Ge({body:[t]});r(S(n,e),{traverse:!0})}},CharacterSet({node:t,parent:e,replaceWith:r},{accuracy:n,minTargetEs2024:s,digitIsAscii:o,spaceIsAscii:a,wordIsAscii:c}){const{kind:i,negate:l,value:u}=t;if(o&&(i==="digit"||u==="digit")){r(q(Rt("digit",{negate:l}),e));return}if(a&&(i==="space"||u==="space")){r(S(gt(j(Ri),l),e));return}if(c&&(i==="word"||u==="word")){r(q(Rt("word",{negate:l}),e));return}if(i==="any")r(q(oe("Any"),e));else if(i==="digit")r(q(oe("Nd",{negate:l}),e));else if(i!=="dot")if(i==="text_segment"){if(n==="strict")throw new Error(C`Use of "\X" requires non-strict accuracy`);const d="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=C`\p{RI}{2}|${d}(?:\u200D${d})*`;r(S(j(C`(?>\r\n|${s?C`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),e))}else if(i==="hex")r(q(oe("AHex",{negate:l}),e));else if(i==="newline")r(S(j(l?`[^
150
+ ]`:`(?>\r
151
+ ?|[
152
+ \v\f…\u2028\u2029])`),e));else if(i==="posix")if(!s&&(u==="graph"||u==="print")){if(n==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let d={graph:"!-~",print:" -~"}[u];l&&(d=`\0-${v(d.codePointAt(0)-1)}${v(d.codePointAt(2)+1)}-􏿿`),r(S(j(`[${d}]`),e))}else r(S(gt(j(Gi.get(u)),l),e));else if(i==="property")Qt.has(Ze(u))||(t.key="sc");else if(i==="space")r(q(oe("space",{negate:l}),e));else if(i==="word")r(S(gt(j(D),l),e));else throw new Error(`Unexpected character set kind "${i}"`)},Directive({node:t,parent:e,root:r,remove:n,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:a}){const{kind:c,flags:i}=t;if(c==="flags")if(!i.enable&&!i.disable)n();else{const l=G({flags:i});l.body[0].body=a(),s(S(l,e),{traverse:!0})}else if(c==="keep"){const l=r.body[0],d=r.body.length===1&&yn(l,{type:"Group"})&&l.body[0].body.length===1?l.body[0]:r;if(e.parent!==d||d.body.length>1)throw new Error(C`Uses "\K" in a way that's unsupported`);const f=J({behind:!0});f.body[0].body=o(),s(S(f,e))}else throw new Error(`Unexpected directive kind "${c}"`)},Flags({node:t,parent:e}){if(t.posixIsAscii)throw new Error('Unsupported flag "P"');if(t.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(r=>delete t[r]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:r}=t.flags;e?.extended&&delete e.extended,r?.extended&&delete r.extended,e?.dotAll&&r?.dotAll&&delete e.dotAll,e?.ignoreCase&&r?.ignoreCase&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,r&&!Object.keys(r).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},LookaroundAssertion({node:t},e){const{kind:r}=t;r==="lookbehind"&&(e.passedLookbehind=!0)},NamedCallout({node:t,parent:e,replaceWith:r}){const{kind:n}=t;if(n==="fail")r(S(J({negate:!0}),e));else throw new Error(`Unsupported named callout "(*${n.toUpperCase()}"`)},Quantifier({node:t}){if(t.body.type==="Quantifier"){const e=G();e.body[0].body.push(t.body),t.body=S(e,t)}},Regex:{enter({node:t},{supportedGNodes:e}){const r=[];let n=!1,s=!1;for(const o of t.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const a=Ln(o.body);a?(n=!0,Array.isArray(a)?r.push(...a):r.push(a)):s=!0}n&&!s&&r.forEach(o=>e.add(o))},exit(t,{accuracy:e,passedLookbehind:r,strategy:n}){if(e==="strict"&&r&&n)throw new Error(C`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:r}=t;typeof r=="string"&&!ht(r)&&(r=ft(r,e),t.ref=r)}},Di={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:r}){const{orphan:n,ref:s}=t;n||r.set(t,[...e.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:t,parent:e,replaceWith:r,skip:n},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:a,openRefs:c,reffedNodesByReferencer:i}){const l=s.get(t);if(l&&c.has(t.number)){const d=q($r(t.number),e);i.set(d,c.get(t.number)),r(d);return}c.set(t.number,t),a.set(t.number,[]),t.name&&Se(a,t.name,[]);const u=a.get(t.name??t.number);for(let d=0;d<u.length;d++){const f=u[d];if(l===f.node||l&&l===f.origin||t===f.origin){u.splice(d,1);break}}if(a.get(t.number).push({node:t,origin:l}),t.name&&a.get(t.name).push({node:t,origin:l}),t.name){const d=Se(o,t.name,new Map);let f=!1;if(l)f=!0;else for(const g of d.values())if(!g.hasDuplicateNameToRemove){f=!0;break}o.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:f})}},exit({node:t},{openRefs:e}){e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=Qe(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Subroutine({node:t,parent:e,replaceWith:r},n){const{isRecursive:s,ref:o}=t;if(s){let u=e;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===o||u.number===o)););n.reffedNodesByReferencer.set(t,u);return}const a=n.subroutineRefMap.get(o),c=o===0,i=c?$r(0):Rn(a,n.groupOriginByCopy,null);let l=i;if(!c){const u=Bn(Wi(a,f=>f.type==="Group"&&!!f.flags)),d=u?Qe(n.globalFlags,u):n.globalFlags;Ui(d,n.currentFlags)||(l=G({flags:zi(d)}),l.body[0].body.push(i))}r(S(l,e),{traverse:!c})}},ji={Backreference({node:t,parent:e,replaceWith:r},n){if(t.orphan){n.highestOrphanBackref=Math.max(n.highestOrphanBackref,t.ref);return}const o=n.reffedNodesByReferencer.get(t).filter(a=>Hi(a,t));if(!o.length)r(S(J({negate:!0}),e));else if(o.length>1){const a=G({atomic:!0,body:o.reverse().map(c=>Y({body:[$t(c.number)]}))});r(S(a,e))}else t.ref=o[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Regex:{exit({node:t},e){const r=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let n=0;n<r;n++){const s=kn();t.body.at(-1).body.push(s)}}},Subroutine({node:t},e){!t.isRecursive||t.ref===0||(t.ref=e.reffedNodesByReferencer.get(t).number)}};function $n(t){ye(t,{"*"({node:e,parent:r}){e.parent=r}})}function Ui(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function Hi(t,e){let r=e;do{if(r.type==="Regex")return!1;if(r.type==="Alternative")continue;if(r===t)return!1;const n=Tn(r.parent);for(const s of n){if(s===r)break;if(s===t||Pn(s,t))return!0}}while(r=r.parent);throw new Error("Unexpected path")}function Rn(t,e,r,n){const s=Array.isArray(t)?[]:{};for(const[o,a]of Object.entries(t))o==="parent"?s.parent=Array.isArray(r)?n:r:a&&typeof a=="object"?s[o]=Rn(a,e,s,r):(o==="type"&&a==="CapturingGroup"&&e.set(s,e.get(t)??t),s[o]=a);return s}function $r(t){const e=_n(t);return e.isRecursive=!0,e}function Wi(t,e){const r=[];for(;t=t.parent;)(!e||e(t))&&r.push(t);return r}function ft(t,e){if(e.has(t))return e.get(t);const r=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,r),r}function Bn(t){const e=["dotAll","ignoreCase"],r={enable:{},disable:{}};return t.forEach(({flags:n})=>{e.forEach(s=>{n.enable?.[s]&&(delete r.disable[s],r.enable[s]=!0),n.disable?.[s]&&(r.disable[s]=!0)})}),Object.keys(r.enable).length||delete r.enable,Object.keys(r.disable).length||delete r.disable,r.enable||r.disable?r:null}function zi({dotAll:t,ignoreCase:e}){const r={};return(t||e)&&(r.enable={},t&&(r.enable.dotAll=!0),e&&(r.enable.ignoreCase=!0)),(!t||!e)&&(r.disable={},!t&&(r.disable.dotAll=!0),!e&&(r.disable.ignoreCase=!0)),r}function Tn(t){if(!t)throw new Error("Node expected");const{body:e}=t;return Array.isArray(e)?e:e?[e]:null}function Ln(t){const e=t.find(r=>r.kind==="search_start"||Qi(r,{negate:!1})||!qi(r));if(!e)return null;if(e.kind==="search_start")return e;if(e.type==="LookaroundAssertion")return e.body[0].body[0];if(e.type==="CapturingGroup"||e.type==="Group"){const r=[];for(const n of e.body){const s=Ln(n.body);if(!s)return null;Array.isArray(s)?r.push(...s):r.push(s)}return r}return null}function Pn(t,e){const r=Tn(t)??[];for(const n of r)if(n===e||Pn(n,e))return!0;return!1}function qi({type:t}){return t==="Assertion"||t==="Directive"||t==="LookaroundAssertion"}function Vi(t){const e=["Character","CharacterClass","CharacterSet"];return e.includes(t.type)||t.type==="Quantifier"&&t.min&&e.includes(t.body.type)}function Qi(t,e){const r={negate:null,...e};return t.type==="LookaroundAssertion"&&(r.negate===null||t.negate===r.negate)&&t.body.length===1&&yn(t.body[0],{type:"Assertion",kind:"search_start"})}function ht(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function j(t,e){const n=wn(t,{...e,unicodePropertyMap:Qt}).body;return n.length>1||n[0].body.length>1?G({body:n}):n[0].body[0]}function gt(t,e){return t.negate=e,t}function q(t,e){return t.parent=e,t}function S(t,e){return $n(t),t.parent=e,t}function Xi(t,e){const r=An(e),n=Tt(r.target,"ES2024"),s=Tt(r.target,"ES2025"),o=r.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let a=null,c=null;if(!s){const g=[t.flags.ignoreCase];ye(t,Ji,{getCurrentModI:()=>g.at(-1),popModI(){g.pop()},pushModI(h){g.push(h)},setHasCasedChar(){g.at(-1)?a=!0:c=!0}})}const i={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||a)&&!c)};let l=t;const u={accuracy:r.accuracy,appliedGlobalFlags:i,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:t._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&a&&c),useFlagMods:s,useFlagV:n,verbose:r.verbose};function d(g){return u.lastNode=l,l=g,Ni(Ki[g.type],`Unexpected node type "${g.type}"`)(g,u,d)}const f={pattern:t.body.map(d).join("|"),flags:d(t.flags),options:{...t.options}};return n||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((g,h)=>{g.hidden&&f._hiddenCaptures.push(h),g.transferTo&&Se(f._captureTransfers,g.transferTo,[]).push(h)}),f}var Ji={"*":{enter({node:t},e){if(Br(t)){const r=e.getCurrentModI();e.pushModI(t.flags?Qe({ignoreCase:r},t.flags).ignoreCase:r)}},exit({node:t},e){Br(t)&&e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){Xt(v(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},r){e(),Gn(t,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:t},e){t.kind==="property"&&Nn.has(t.value)&&e.setHasCasedChar()}},Ki={Alternative({body:t},e,r){return t.map(r).join("")},Assertion({kind:t,negate:e}){if(t==="string_end")return"$";if(t==="string_start")return"^";if(t==="word_boundary")return e?C`\B`:C`\b`;throw new Error(`Unexpected assertion kind "${t}"`)},Backreference({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t},CapturingGroup(t,e,r){const{body:n,name:s,number:o}=t,a={ignoreCase:e.currentFlags.ignoreCase},c=e.originMap.get(t);return c&&(a.hidden=!0,o>c.number&&(a.transferTo=c.number)),e.captureMap.set(o,a),`(${s?`?<${s}>`:""}${n.map(r).join("|")})`},Character({value:t},e){const r=v(t),n=re(t,{escDigit:e.lastNode.type==="Backreference",inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(n!==r)return n;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&Xt(r)){const s=In(r);return e.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return r},CharacterClass(t,e,r){const{kind:n,negate:s,parent:o}=t;let{body:a}=t;if(n==="intersection"&&!e.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");H.bugFlagVLiteralHyphenIsRange&&e.useFlagV&&a.some(Tr)&&(a=[Ke(45),...a.filter(l=>!Tr(l))]);const c=()=>`[${s?"^":""}${a.map(r).join(n==="intersection"?"&&":"")}]`;if(!e.inCharClass){if((!e.useFlagV||H.bugNestedClassIgnoresNegation)&&!s){const u=a.filter(d=>d.type==="CharacterClass"&&d.kind==="union"&&d.negate);if(u.length){const d=G(),f=d.body[0];return d.parent=o,f.parent=d,a=a.filter(g=>!u.includes(g)),t.body=a,a.length?(t.parent=f,f.body.push(t)):d.body.pop(),u.forEach(g=>{const h=Y({body:[g]});g.parent=h,h.parent=d,d.body.push(h)}),r(d)}}e.inCharClass=!0;const l=c();return e.inCharClass=!1,l}const i=a[0];if(n==="union"&&!s&&i&&((!e.useFlagV||!e.verbose)&&o.kind==="union"&&!(H.bugFlagVLiteralHyphenIsRange&&e.useFlagV)||!e.verbose&&o.kind==="intersection"&&a.length===1&&i.type!=="CharacterClassRange"))return a.map(r).join("");if(!e.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return c()},CharacterClassRange(t,e){const r=t.min.value,n=t.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:e.useFlagV},o=re(r,s),a=re(n,s),c=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const i=Gn(t);rc(i).forEach(u=>{c.add(Array.isArray(u)?`${re(u[0],s)}-${re(u[1],s)}`:re(u,s))})}return`${o}-${a}${[...c].join("")}`},CharacterSet({kind:t,negate:e,value:r,key:n},s){if(t==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":C`[^\n]`;if(t==="digit")return e?C`\D`:C`\d`;if(t==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&Nn.has(r))throw new Error(`Unicode property "${r}" can't be case-insensitive when other chars have specific case`);return`${e?C`\P`:C`\p`}{${n?`${n}=`:""}${r}}`}if(t==="word")return e?C`\W`:C`\w`;throw new Error(`Unexpected character set kind "${t}"`)},Flags(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")},Group({atomic:t,body:e,flags:r,parent:n},s,o){const a=s.currentFlags;r&&(s.currentFlags=Qe(a,r));const c=e.map(o).join("|"),i=!s.verbose&&e.length===1&&n.type!=="Quantifier"&&!t&&(!s.useFlagMods||!r)?c:`(?${nc(t,r,s.useFlagMods)}${c})`;return s.currentFlags=a,i},LookaroundAssertion({body:t,kind:e,negate:r},n,s){return`(?${`${e==="lookahead"?"":"<"}${r?"!":"="}`}${t.map(s).join("|")})`},Quantifier(t,e,r){return r(t.body)+sc(t)},Subroutine({isRecursive:t,ref:e},r){if(!t)throw new Error("Unexpected non-recursive subroutine in transformed AST");const n=r.recursionLimit;return e===0?`(?R=${n})`:C`\g<${e}&R=${n}>`}},Zi=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Yi=new Set(["-","\\","]","^","["]),ec=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Rr=new Map([[9,C`\t`],[10,C`\n`],[11,C`\v`],[12,C`\f`],[13,C`\r`],[8232,C`\u2028`],[8233,C`\u2029`],[65279,C`\uFEFF`]]),tc=new RegExp("^\\p{Cased}$","u");function Xt(t){return tc.test(t)}function Gn(t,e){const r=!!e?.firstOnly,n=t.min.value,s=t.max.value,o=[];if(n<65&&(s===65535||s>=131071)||n===65536&&s>=131071)return o;for(let a=n;a<=s;a++){const c=v(a);if(!Xt(c))continue;const i=In(c).filter(l=>{const u=l.codePointAt(0);return u<n||u>s});if(i.length&&(o.push(...i),r))break}return o}function re(t,{escDigit:e,inCharClass:r,useFlagV:n}){if(Rr.has(t))return Rr.get(t);if(t<32||t>126&&t<160||t>262143||e&&oc(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const s=r?n?ec:Yi:Zi,o=v(t);return(s.has(o)?"\\":"")+o}function rc(t){const e=t.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),r=[];let n=null;for(let s=0;s<e.length;s++)e[s+1]===e[s]+1?n??=e[s]:n===null?r.push(e[s]):(r.push([n,e[s]]),n=null);return r}function nc(t,e,r){if(t)return">";let n="";if(e&&r){const{enable:s,disable:o}=e;n=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${n}:`}function sc({kind:t,max:e,min:r}){let n;return!r&&e===1?n="?":!r&&e===1/0?n="*":r===1&&e===1/0?n="+":r===e?n=`{${r}}`:n=`{${r},${e===1/0?"":e}}`,n+{greedy:"",lazy:"?",possessive:"+"}[t]}function Br({type:t}){return t==="CapturingGroup"||t==="Group"||t==="LookaroundAssertion"}function oc(t){return t>47&&t<58}function Tr({type:t,value:e}){return t==="Character"&&e===45}var ac=class Lt extends RegExp{#t=new Map;#e=null;#n;#r=null;#s=null;rawOptions={};get source(){return this.#n||"(?:)"}constructor(e,r,n){const s=!!n?.lazyCompile;if(e instanceof RegExp){if(n)throw new Error("Cannot provide options when copying a regexp");const o=e;super(o,r),this.#n=o.source,o instanceof Lt&&(this.#t=o.#t,this.#r=o.#r,this.#s=o.#s,this.rawOptions=o.rawOptions)}else{const o={hiddenCaptures:[],strategy:null,transfers:[],...n};super(s?"":e,r),this.#n=e,this.#t=cc(o.hiddenCaptures,o.transfers),this.#s=o.strategy,this.rawOptions=n??{}}s||(this.#e=this)}exec(e){if(!this.#e){const{lazyCompile:s,...o}=this.rawOptions;this.#e=new Lt(this.#n,this.flags,o)}const r=this.global||this.sticky,n=this.lastIndex;if(this.#s==="clip_search"&&r&&n){this.lastIndex=0;const s=this.#o(e.slice(n));return s&&(ic(s,n,e,this.hasIndices),this.lastIndex+=n),s}return this.#o(e)}#o(e){this.#e.lastIndex=this.lastIndex;const r=super.exec.call(this.#e,e);if(this.lastIndex=this.#e.lastIndex,!r||!this.#t.size)return r;const n=[...r];r.length=1;let s;this.hasIndices&&(s=[...r.indices],r.indices.length=1);const o=[0];for(let a=1;a<n.length;a++){const{hidden:c,transferTo:i}=this.#t.get(a)??{};if(c?o.push(null):(o.push(r.length),r.push(n[a]),this.hasIndices&&r.indices.push(s[a])),i&&n[a]!==void 0){const l=o[i];if(!l)throw new Error(`Invalid capture transfer to "${l}"`);if(r[l]=n[a],this.hasIndices&&(r.indices[l]=s[a]),r.groups){this.#r||(this.#r=lc(this.source));const u=this.#r.get(i);u&&(r.groups[u]=n[a],this.hasIndices&&(r.indices.groups[u]=s[a]))}}}return r}};function ic(t,e,r,n){if(t.index+=e,t.input=r,n){const s=t.indices;for(let a=0;a<s.length;a++){const c=s[a];c&&(s[a]=[c[0]+e,c[1]+e])}const o=s.groups;o&&Object.keys(o).forEach(a=>{const c=o[a];c&&(o[a]=[c[0]+e,c[1]+e])})}}function cc(t,e){const r=new Map;for(const n of t)r.set(n,{hidden:!0});for(const[n,s]of e)for(const o of s)Se(r,o,{}).transferTo=n;return r}function lc(t){const e=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,r=new Map;let n=0,s=0,o;for(;o=e.exec(t);){const{0:a,groups:{capture:c,name:i}}=o;a==="["?n++:n?a==="]"&&n--:c&&(s++,i&&r.set(s,i))}return r}function uc(t,e){const r=dc(t,e);return r.options?new ac(r.pattern,r.flags,r.options):new RegExp(r.pattern,r.flags)}function dc(t,e){const r=An(e),n=wn(t,{flags:r.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline},skipBackrefValidation:r.rules.allowOrphanBackrefs,unicodePropertyMap:Qt}),s=Fi(n,{accuracy:r.accuracy,asciiWordBoundaries:r.rules.asciiWordBoundaries,avoidSubclass:r.avoidSubclass,bestEffortTarget:r.target}),o=Xi(s,r),a=Ai(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),c=xi(a.pattern),i=vi(c.pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),l={pattern:i.pattern,flags:`${r.hasIndices?"d":""}${r.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(r.avoidSubclass){if(r.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const u=i.hiddenCaptures.sort((h,b)=>h-b),d=Array.from(i.captureTransfers),f=s._strategy,g=l.pattern.length>=r.lazyCompileLength;(u.length||d.length||f||g)&&(l.options={...u.length&&{hiddenCaptures:u},...d.length&&{transfers:d},...f&&{strategy:f},...g&&{lazyCompile:g}})}return l}const Lr=4294967295;class fc{constructor(e,r={}){this.patterns=e,this.options=r;const{forgiving:n=!1,cache:s,regexConstructor:o}=r;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(a=>{if(typeof a!="string")return a;const c=s?.get(a);if(c){if(c instanceof RegExp)return c;if(n)return null;throw c}try{const i=o(a);return s?.set(a,i),i}catch(i){if(s?.set(a,i),n)return null;throw i}})}regexps;findNextMatchSync(e,r,n){const s=typeof e=="string"?e:e.content,o=[];function a(c,i,l=0){return{index:c,captureIndices:i.indices.map(u=>u==null?{start:Lr,end:Lr,length:0}:{start:u[0]+l,end:u[1]+l,length:u[1]-u[0]})}}for(let c=0;c<this.regexps.length;c++){const i=this.regexps[c];if(i)try{i.lastIndex=r;const l=i.exec(s);if(!l)continue;if(l.index===r)return a(c,l,0);o.push([c,l,0])}catch(l){if(this.options.forgiving)continue;throw l}}if(o.length){const c=Math.min(...o.map(i=>i[1].index));for(const[i,l,u]of o)if(l.index===c)return a(i,l,u)}return null}}function hc(t,e){return uc(t,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function gc(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||=r=>hc(r,{target:e.target}),{createScanner(r){return new fc(r,e)},createString(r){return{content:r}}}}const pc=Object.freeze(JSON.parse('{"colors":{"activityBar.activeBorder":"#f9826c","activityBar.background":"#24292e","activityBar.border":"#1b1f23","activityBar.foreground":"#e1e4e8","activityBar.inactiveForeground":"#6a737d","activityBarBadge.background":"#0366d6","activityBarBadge.foreground":"#fff","badge.background":"#044289","badge.foreground":"#c8e1ff","breadcrumb.activeSelectionForeground":"#d1d5da","breadcrumb.focusForeground":"#e1e4e8","breadcrumb.foreground":"#959da5","breadcrumbPicker.background":"#2b3036","button.background":"#176f2c","button.foreground":"#dcffe4","button.hoverBackground":"#22863a","button.secondaryBackground":"#444d56","button.secondaryForeground":"#fff","button.secondaryHoverBackground":"#586069","checkbox.background":"#444d56","checkbox.border":"#1b1f23","debugToolBar.background":"#2b3036","descriptionForeground":"#959da5","diffEditor.insertedTextBackground":"#28a74530","diffEditor.removedTextBackground":"#d73a4930","dropdown.background":"#2f363d","dropdown.border":"#1b1f23","dropdown.foreground":"#e1e4e8","dropdown.listBackground":"#24292e","editor.background":"#24292e","editor.findMatchBackground":"#ffd33d44","editor.findMatchHighlightBackground":"#ffd33d22","editor.focusedStackFrameHighlightBackground":"#2b6a3033","editor.foldBackground":"#58606915","editor.foreground":"#e1e4e8","editor.inactiveSelectionBackground":"#3392FF22","editor.lineHighlightBackground":"#2b3036","editor.linkedEditingBackground":"#3392FF22","editor.selectionBackground":"#3392FF44","editor.selectionHighlightBackground":"#17E5E633","editor.selectionHighlightBorder":"#17E5E600","editor.stackFrameHighlightBackground":"#C6902625","editor.wordHighlightBackground":"#17E5E600","editor.wordHighlightBorder":"#17E5E699","editor.wordHighlightStrongBackground":"#17E5E600","editor.wordHighlightStrongBorder":"#17E5E666","editorBracketHighlight.foreground1":"#79b8ff","editorBracketHighlight.foreground2":"#ffab70","editorBracketHighlight.foreground3":"#b392f0","editorBracketHighlight.foreground4":"#79b8ff","editorBracketHighlight.foreground5":"#ffab70","editorBracketHighlight.foreground6":"#b392f0","editorBracketMatch.background":"#17E5E650","editorBracketMatch.border":"#17E5E600","editorCursor.foreground":"#c8e1ff","editorError.foreground":"#f97583","editorGroup.border":"#1b1f23","editorGroupHeader.tabsBackground":"#1f2428","editorGroupHeader.tabsBorder":"#1b1f23","editorGutter.addedBackground":"#28a745","editorGutter.deletedBackground":"#ea4a5a","editorGutter.modifiedBackground":"#2188ff","editorIndentGuide.activeBackground":"#444d56","editorIndentGuide.background":"#2f363d","editorLineNumber.activeForeground":"#e1e4e8","editorLineNumber.foreground":"#444d56","editorOverviewRuler.border":"#1b1f23","editorWarning.foreground":"#ffea7f","editorWhitespace.foreground":"#444d56","editorWidget.background":"#1f2428","errorForeground":"#f97583","focusBorder":"#005cc5","foreground":"#d1d5da","gitDecoration.addedResourceForeground":"#34d058","gitDecoration.conflictingResourceForeground":"#ffab70","gitDecoration.deletedResourceForeground":"#ea4a5a","gitDecoration.ignoredResourceForeground":"#6a737d","gitDecoration.modifiedResourceForeground":"#79b8ff","gitDecoration.submoduleResourceForeground":"#6a737d","gitDecoration.untrackedResourceForeground":"#34d058","input.background":"#2f363d","input.border":"#1b1f23","input.foreground":"#e1e4e8","input.placeholderForeground":"#959da5","list.activeSelectionBackground":"#39414a","list.activeSelectionForeground":"#e1e4e8","list.focusBackground":"#044289","list.hoverBackground":"#282e34","list.hoverForeground":"#e1e4e8","list.inactiveFocusBackground":"#1d2d3e","list.inactiveSelectionBackground":"#282e34","list.inactiveSelectionForeground":"#e1e4e8","notificationCenterHeader.background":"#24292e","notificationCenterHeader.foreground":"#959da5","notifications.background":"#2f363d","notifications.border":"#1b1f23","notifications.foreground":"#e1e4e8","notificationsErrorIcon.foreground":"#ea4a5a","notificationsInfoIcon.foreground":"#79b8ff","notificationsWarningIcon.foreground":"#ffab70","panel.background":"#1f2428","panel.border":"#1b1f23","panelInput.border":"#2f363d","panelTitle.activeBorder":"#f9826c","panelTitle.activeForeground":"#e1e4e8","panelTitle.inactiveForeground":"#959da5","peekViewEditor.background":"#1f242888","peekViewEditor.matchHighlightBackground":"#ffd33d33","peekViewResult.background":"#1f2428","peekViewResult.matchHighlightBackground":"#ffd33d33","pickerGroup.border":"#444d56","pickerGroup.foreground":"#e1e4e8","progressBar.background":"#0366d6","quickInput.background":"#24292e","quickInput.foreground":"#e1e4e8","scrollbar.shadow":"#0008","scrollbarSlider.activeBackground":"#6a737d88","scrollbarSlider.background":"#6a737d33","scrollbarSlider.hoverBackground":"#6a737d44","settings.headerForeground":"#e1e4e8","settings.modifiedItemIndicator":"#0366d6","sideBar.background":"#1f2428","sideBar.border":"#1b1f23","sideBar.foreground":"#d1d5da","sideBarSectionHeader.background":"#1f2428","sideBarSectionHeader.border":"#1b1f23","sideBarSectionHeader.foreground":"#e1e4e8","sideBarTitle.foreground":"#e1e4e8","statusBar.background":"#24292e","statusBar.border":"#1b1f23","statusBar.debuggingBackground":"#931c06","statusBar.debuggingForeground":"#fff","statusBar.foreground":"#d1d5da","statusBar.noFolderBackground":"#24292e","statusBarItem.prominentBackground":"#282e34","statusBarItem.remoteBackground":"#24292e","statusBarItem.remoteForeground":"#d1d5da","tab.activeBackground":"#24292e","tab.activeBorder":"#24292e","tab.activeBorderTop":"#f9826c","tab.activeForeground":"#e1e4e8","tab.border":"#1b1f23","tab.hoverBackground":"#24292e","tab.inactiveBackground":"#1f2428","tab.inactiveForeground":"#959da5","tab.unfocusedActiveBorder":"#24292e","tab.unfocusedActiveBorderTop":"#1b1f23","tab.unfocusedHoverBackground":"#24292e","terminal.ansiBlack":"#586069","terminal.ansiBlue":"#2188ff","terminal.ansiBrightBlack":"#959da5","terminal.ansiBrightBlue":"#79b8ff","terminal.ansiBrightCyan":"#56d4dd","terminal.ansiBrightGreen":"#85e89d","terminal.ansiBrightMagenta":"#b392f0","terminal.ansiBrightRed":"#f97583","terminal.ansiBrightWhite":"#fafbfc","terminal.ansiBrightYellow":"#ffea7f","terminal.ansiCyan":"#39c5cf","terminal.ansiGreen":"#34d058","terminal.ansiMagenta":"#b392f0","terminal.ansiRed":"#ea4a5a","terminal.ansiWhite":"#d1d5da","terminal.ansiYellow":"#ffea7f","terminal.foreground":"#d1d5da","terminal.tab.activeBorder":"#f9826c","terminalCursor.background":"#586069","terminalCursor.foreground":"#79b8ff","textBlockQuote.background":"#24292e","textBlockQuote.border":"#444d56","textCodeBlock.background":"#2f363d","textLink.activeForeground":"#c8e1ff","textLink.foreground":"#79b8ff","textPreformat.foreground":"#d1d5da","textSeparator.foreground":"#586069","titleBar.activeBackground":"#24292e","titleBar.activeForeground":"#e1e4e8","titleBar.border":"#1b1f23","titleBar.inactiveBackground":"#1f2428","titleBar.inactiveForeground":"#959da5","tree.indentGuidesStroke":"#2f363d","welcomePage.buttonBackground":"#2f363d","welcomePage.buttonHoverBackground":"#444d56"},"displayName":"GitHub Dark","name":"github-dark","semanticHighlighting":true,"tokenColors":[{"scope":["comment","punctuation.definition.comment","string.comment"],"settings":{"foreground":"#6a737d"}},{"scope":["constant","entity.name.constant","variable.other.constant","variable.other.enummember","variable.language"],"settings":{"foreground":"#79b8ff"}},{"scope":["entity","entity.name"],"settings":{"foreground":"#b392f0"}},{"scope":"variable.parameter.function","settings":{"foreground":"#e1e4e8"}},{"scope":"entity.name.tag","settings":{"foreground":"#85e89d"}},{"scope":"keyword","settings":{"foreground":"#f97583"}},{"scope":["storage","storage.type"],"settings":{"foreground":"#f97583"}},{"scope":["storage.modifier.package","storage.modifier.import","storage.type.java"],"settings":{"foreground":"#e1e4e8"}},{"scope":["string","punctuation.definition.string","string punctuation.section.embedded source"],"settings":{"foreground":"#9ecbff"}},{"scope":"support","settings":{"foreground":"#79b8ff"}},{"scope":"meta.property-name","settings":{"foreground":"#79b8ff"}},{"scope":"variable","settings":{"foreground":"#ffab70"}},{"scope":"variable.other","settings":{"foreground":"#e1e4e8"}},{"scope":"invalid.broken","settings":{"fontStyle":"italic","foreground":"#fdaeb7"}},{"scope":"invalid.deprecated","settings":{"fontStyle":"italic","foreground":"#fdaeb7"}},{"scope":"invalid.illegal","settings":{"fontStyle":"italic","foreground":"#fdaeb7"}},{"scope":"invalid.unimplemented","settings":{"fontStyle":"italic","foreground":"#fdaeb7"}},{"scope":"carriage-return","settings":{"background":"#f97583","content":"^M","fontStyle":"italic underline","foreground":"#24292e"}},{"scope":"message.error","settings":{"foreground":"#fdaeb7"}},{"scope":"string variable","settings":{"foreground":"#79b8ff"}},{"scope":["source.regexp","string.regexp"],"settings":{"foreground":"#dbedff"}},{"scope":["string.regexp.character-class","string.regexp constant.character.escape","string.regexp source.ruby.embedded","string.regexp string.regexp.arbitrary-repitition"],"settings":{"foreground":"#dbedff"}},{"scope":"string.regexp constant.character.escape","settings":{"fontStyle":"bold","foreground":"#85e89d"}},{"scope":"support.constant","settings":{"foreground":"#79b8ff"}},{"scope":"support.variable","settings":{"foreground":"#79b8ff"}},{"scope":"meta.module-reference","settings":{"foreground":"#79b8ff"}},{"scope":"punctuation.definition.list.begin.markdown","settings":{"foreground":"#ffab70"}},{"scope":["markup.heading","markup.heading entity.name"],"settings":{"fontStyle":"bold","foreground":"#79b8ff"}},{"scope":"markup.quote","settings":{"foreground":"#85e89d"}},{"scope":"markup.italic","settings":{"fontStyle":"italic","foreground":"#e1e4e8"}},{"scope":"markup.bold","settings":{"fontStyle":"bold","foreground":"#e1e4e8"}},{"scope":["markup.underline"],"settings":{"fontStyle":"underline"}},{"scope":["markup.strikethrough"],"settings":{"fontStyle":"strikethrough"}},{"scope":"markup.inline.raw","settings":{"foreground":"#79b8ff"}},{"scope":["markup.deleted","meta.diff.header.from-file","punctuation.definition.deleted"],"settings":{"background":"#86181d","foreground":"#fdaeb7"}},{"scope":["markup.inserted","meta.diff.header.to-file","punctuation.definition.inserted"],"settings":{"background":"#144620","foreground":"#85e89d"}},{"scope":["markup.changed","punctuation.definition.changed"],"settings":{"background":"#c24e00","foreground":"#ffab70"}},{"scope":["markup.ignored","markup.untracked"],"settings":{"background":"#79b8ff","foreground":"#2f363d"}},{"scope":"meta.diff.range","settings":{"fontStyle":"bold","foreground":"#b392f0"}},{"scope":"meta.diff.header","settings":{"foreground":"#79b8ff"}},{"scope":"meta.separator","settings":{"fontStyle":"bold","foreground":"#79b8ff"}},{"scope":"meta.output","settings":{"foreground":"#79b8ff"}},{"scope":["brackethighlighter.tag","brackethighlighter.curly","brackethighlighter.round","brackethighlighter.square","brackethighlighter.angle","brackethighlighter.quote"],"settings":{"foreground":"#d1d5da"}},{"scope":"brackethighlighter.unmatched","settings":{"foreground":"#fdaeb7"}},{"scope":["constant.other.reference.link","string.other.link"],"settings":{"fontStyle":"underline","foreground":"#dbedff"}}],"type":"dark"}')),mc=Object.freeze(JSON.parse('{"colors":{"activityBar.activeBorder":"#f9826c","activityBar.background":"#fff","activityBar.border":"#e1e4e8","activityBar.foreground":"#2f363d","activityBar.inactiveForeground":"#959da5","activityBarBadge.background":"#2188ff","activityBarBadge.foreground":"#fff","badge.background":"#dbedff","badge.foreground":"#005cc5","breadcrumb.activeSelectionForeground":"#586069","breadcrumb.focusForeground":"#2f363d","breadcrumb.foreground":"#6a737d","breadcrumbPicker.background":"#fafbfc","button.background":"#159739","button.foreground":"#fff","button.hoverBackground":"#138934","button.secondaryBackground":"#e1e4e8","button.secondaryForeground":"#1b1f23","button.secondaryHoverBackground":"#d1d5da","checkbox.background":"#fafbfc","checkbox.border":"#d1d5da","debugToolBar.background":"#fff","descriptionForeground":"#6a737d","diffEditor.insertedTextBackground":"#34d05822","diffEditor.removedTextBackground":"#d73a4922","dropdown.background":"#fafbfc","dropdown.border":"#e1e4e8","dropdown.foreground":"#2f363d","dropdown.listBackground":"#fff","editor.background":"#fff","editor.findMatchBackground":"#ffdf5d","editor.findMatchHighlightBackground":"#ffdf5d66","editor.focusedStackFrameHighlightBackground":"#28a74525","editor.foldBackground":"#d1d5da11","editor.foreground":"#24292e","editor.inactiveSelectionBackground":"#0366d611","editor.lineHighlightBackground":"#f6f8fa","editor.linkedEditingBackground":"#0366d611","editor.selectionBackground":"#0366d625","editor.selectionHighlightBackground":"#34d05840","editor.selectionHighlightBorder":"#34d05800","editor.stackFrameHighlightBackground":"#ffd33d33","editor.wordHighlightBackground":"#34d05800","editor.wordHighlightBorder":"#24943e99","editor.wordHighlightStrongBackground":"#34d05800","editor.wordHighlightStrongBorder":"#24943e50","editorBracketHighlight.foreground1":"#005cc5","editorBracketHighlight.foreground2":"#e36209","editorBracketHighlight.foreground3":"#5a32a3","editorBracketHighlight.foreground4":"#005cc5","editorBracketHighlight.foreground5":"#e36209","editorBracketHighlight.foreground6":"#5a32a3","editorBracketMatch.background":"#34d05840","editorBracketMatch.border":"#34d05800","editorCursor.foreground":"#044289","editorError.foreground":"#cb2431","editorGroup.border":"#e1e4e8","editorGroupHeader.tabsBackground":"#f6f8fa","editorGroupHeader.tabsBorder":"#e1e4e8","editorGutter.addedBackground":"#28a745","editorGutter.deletedBackground":"#d73a49","editorGutter.modifiedBackground":"#2188ff","editorIndentGuide.activeBackground":"#d7dbe0","editorIndentGuide.background":"#eff2f6","editorLineNumber.activeForeground":"#24292e","editorLineNumber.foreground":"#1b1f234d","editorOverviewRuler.border":"#fff","editorWarning.foreground":"#f9c513","editorWhitespace.foreground":"#d1d5da","editorWidget.background":"#f6f8fa","errorForeground":"#cb2431","focusBorder":"#2188ff","foreground":"#444d56","gitDecoration.addedResourceForeground":"#28a745","gitDecoration.conflictingResourceForeground":"#e36209","gitDecoration.deletedResourceForeground":"#d73a49","gitDecoration.ignoredResourceForeground":"#959da5","gitDecoration.modifiedResourceForeground":"#005cc5","gitDecoration.submoduleResourceForeground":"#959da5","gitDecoration.untrackedResourceForeground":"#28a745","input.background":"#fafbfc","input.border":"#e1e4e8","input.foreground":"#2f363d","input.placeholderForeground":"#959da5","list.activeSelectionBackground":"#e2e5e9","list.activeSelectionForeground":"#2f363d","list.focusBackground":"#cce5ff","list.hoverBackground":"#ebf0f4","list.hoverForeground":"#2f363d","list.inactiveFocusBackground":"#dbedff","list.inactiveSelectionBackground":"#e8eaed","list.inactiveSelectionForeground":"#2f363d","notificationCenterHeader.background":"#e1e4e8","notificationCenterHeader.foreground":"#6a737d","notifications.background":"#fafbfc","notifications.border":"#e1e4e8","notifications.foreground":"#2f363d","notificationsErrorIcon.foreground":"#d73a49","notificationsInfoIcon.foreground":"#005cc5","notificationsWarningIcon.foreground":"#e36209","panel.background":"#f6f8fa","panel.border":"#e1e4e8","panelInput.border":"#e1e4e8","panelTitle.activeBorder":"#f9826c","panelTitle.activeForeground":"#2f363d","panelTitle.inactiveForeground":"#6a737d","pickerGroup.border":"#e1e4e8","pickerGroup.foreground":"#2f363d","progressBar.background":"#2188ff","quickInput.background":"#fafbfc","quickInput.foreground":"#2f363d","scrollbar.shadow":"#6a737d33","scrollbarSlider.activeBackground":"#959da588","scrollbarSlider.background":"#959da533","scrollbarSlider.hoverBackground":"#959da544","settings.headerForeground":"#2f363d","settings.modifiedItemIndicator":"#2188ff","sideBar.background":"#f6f8fa","sideBar.border":"#e1e4e8","sideBar.foreground":"#586069","sideBarSectionHeader.background":"#f6f8fa","sideBarSectionHeader.border":"#e1e4e8","sideBarSectionHeader.foreground":"#2f363d","sideBarTitle.foreground":"#2f363d","statusBar.background":"#fff","statusBar.border":"#e1e4e8","statusBar.debuggingBackground":"#f9826c","statusBar.debuggingForeground":"#fff","statusBar.foreground":"#586069","statusBar.noFolderBackground":"#fff","statusBarItem.prominentBackground":"#e8eaed","statusBarItem.remoteBackground":"#fff","statusBarItem.remoteForeground":"#586069","tab.activeBackground":"#fff","tab.activeBorder":"#fff","tab.activeBorderTop":"#f9826c","tab.activeForeground":"#2f363d","tab.border":"#e1e4e8","tab.hoverBackground":"#fff","tab.inactiveBackground":"#f6f8fa","tab.inactiveForeground":"#6a737d","tab.unfocusedActiveBorder":"#fff","tab.unfocusedActiveBorderTop":"#e1e4e8","tab.unfocusedHoverBackground":"#fff","terminal.ansiBlack":"#24292e","terminal.ansiBlue":"#0366d6","terminal.ansiBrightBlack":"#959da5","terminal.ansiBrightBlue":"#005cc5","terminal.ansiBrightCyan":"#3192aa","terminal.ansiBrightGreen":"#22863a","terminal.ansiBrightMagenta":"#5a32a3","terminal.ansiBrightRed":"#cb2431","terminal.ansiBrightWhite":"#d1d5da","terminal.ansiBrightYellow":"#b08800","terminal.ansiCyan":"#1b7c83","terminal.ansiGreen":"#28a745","terminal.ansiMagenta":"#5a32a3","terminal.ansiRed":"#d73a49","terminal.ansiWhite":"#6a737d","terminal.ansiYellow":"#dbab09","terminal.foreground":"#586069","terminal.tab.activeBorder":"#f9826c","terminalCursor.background":"#d1d5da","terminalCursor.foreground":"#005cc5","textBlockQuote.background":"#fafbfc","textBlockQuote.border":"#e1e4e8","textCodeBlock.background":"#f6f8fa","textLink.activeForeground":"#005cc5","textLink.foreground":"#0366d6","textPreformat.foreground":"#586069","textSeparator.foreground":"#d1d5da","titleBar.activeBackground":"#fff","titleBar.activeForeground":"#2f363d","titleBar.border":"#e1e4e8","titleBar.inactiveBackground":"#f6f8fa","titleBar.inactiveForeground":"#6a737d","tree.indentGuidesStroke":"#e1e4e8","welcomePage.buttonBackground":"#f6f8fa","welcomePage.buttonHoverBackground":"#e1e4e8"},"displayName":"GitHub Light","name":"github-light","semanticHighlighting":true,"tokenColors":[{"scope":["comment","punctuation.definition.comment","string.comment"],"settings":{"foreground":"#6a737d"}},{"scope":["constant","entity.name.constant","variable.other.constant","variable.other.enummember","variable.language"],"settings":{"foreground":"#005cc5"}},{"scope":["entity","entity.name"],"settings":{"foreground":"#6f42c1"}},{"scope":"variable.parameter.function","settings":{"foreground":"#24292e"}},{"scope":"entity.name.tag","settings":{"foreground":"#22863a"}},{"scope":"keyword","settings":{"foreground":"#d73a49"}},{"scope":["storage","storage.type"],"settings":{"foreground":"#d73a49"}},{"scope":["storage.modifier.package","storage.modifier.import","storage.type.java"],"settings":{"foreground":"#24292e"}},{"scope":["string","punctuation.definition.string","string punctuation.section.embedded source"],"settings":{"foreground":"#032f62"}},{"scope":"support","settings":{"foreground":"#005cc5"}},{"scope":"meta.property-name","settings":{"foreground":"#005cc5"}},{"scope":"variable","settings":{"foreground":"#e36209"}},{"scope":"variable.other","settings":{"foreground":"#24292e"}},{"scope":"invalid.broken","settings":{"fontStyle":"italic","foreground":"#b31d28"}},{"scope":"invalid.deprecated","settings":{"fontStyle":"italic","foreground":"#b31d28"}},{"scope":"invalid.illegal","settings":{"fontStyle":"italic","foreground":"#b31d28"}},{"scope":"invalid.unimplemented","settings":{"fontStyle":"italic","foreground":"#b31d28"}},{"scope":"carriage-return","settings":{"background":"#d73a49","content":"^M","fontStyle":"italic underline","foreground":"#fafbfc"}},{"scope":"message.error","settings":{"foreground":"#b31d28"}},{"scope":"string variable","settings":{"foreground":"#005cc5"}},{"scope":["source.regexp","string.regexp"],"settings":{"foreground":"#032f62"}},{"scope":["string.regexp.character-class","string.regexp constant.character.escape","string.regexp source.ruby.embedded","string.regexp string.regexp.arbitrary-repitition"],"settings":{"foreground":"#032f62"}},{"scope":"string.regexp constant.character.escape","settings":{"fontStyle":"bold","foreground":"#22863a"}},{"scope":"support.constant","settings":{"foreground":"#005cc5"}},{"scope":"support.variable","settings":{"foreground":"#005cc5"}},{"scope":"meta.module-reference","settings":{"foreground":"#005cc5"}},{"scope":"punctuation.definition.list.begin.markdown","settings":{"foreground":"#e36209"}},{"scope":["markup.heading","markup.heading entity.name"],"settings":{"fontStyle":"bold","foreground":"#005cc5"}},{"scope":"markup.quote","settings":{"foreground":"#22863a"}},{"scope":"markup.italic","settings":{"fontStyle":"italic","foreground":"#24292e"}},{"scope":"markup.bold","settings":{"fontStyle":"bold","foreground":"#24292e"}},{"scope":["markup.underline"],"settings":{"fontStyle":"underline"}},{"scope":["markup.strikethrough"],"settings":{"fontStyle":"strikethrough"}},{"scope":"markup.inline.raw","settings":{"foreground":"#005cc5"}},{"scope":["markup.deleted","meta.diff.header.from-file","punctuation.definition.deleted"],"settings":{"background":"#ffeef0","foreground":"#b31d28"}},{"scope":["markup.inserted","meta.diff.header.to-file","punctuation.definition.inserted"],"settings":{"background":"#f0fff4","foreground":"#22863a"}},{"scope":["markup.changed","punctuation.definition.changed"],"settings":{"background":"#ffebda","foreground":"#e36209"}},{"scope":["markup.ignored","markup.untracked"],"settings":{"background":"#005cc5","foreground":"#f6f8fa"}},{"scope":"meta.diff.range","settings":{"fontStyle":"bold","foreground":"#6f42c1"}},{"scope":"meta.diff.header","settings":{"foreground":"#005cc5"}},{"scope":"meta.separator","settings":{"fontStyle":"bold","foreground":"#005cc5"}},{"scope":"meta.output","settings":{"foreground":"#005cc5"}},{"scope":["brackethighlighter.tag","brackethighlighter.curly","brackethighlighter.round","brackethighlighter.square","brackethighlighter.angle","brackethighlighter.quote"],"settings":{"foreground":"#586069"}},{"scope":"brackethighlighter.unmatched","settings":{"foreground":"#b31d28"}},{"scope":["constant.other.reference.link","string.other.link"],"settings":{"fontStyle":"underline","foreground":"#032f62"}}],"type":"light"}'));var bc=Gt("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),yc=ae.memo(({children:t,result:e,language:r,className:n,...s})=>{let o=ae.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return L.jsx("pre",{className:Gt(n,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":r,"data-streamdown":"code-block-body",style:o,...s,children:L.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,c)=>L.jsx("span",{className:bc,children:a.map((i,l)=>L.jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:i.color,backgroundColor:i.bgColor,...i.htmlStyle},...i.htmlAttrs,children:i.content},l))},c))})})},(t,e)=>t.result===e.result&&t.language===e.language&&t.className===e.className),wc=({className:t,language:e,style:r,...n})=>L.jsx("div",{className:Gt("my-4 w-full overflow-hidden rounded-xl border border-border",t),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...r},...n}),kc=({language:t,children:e})=>L.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":t,"data-streamdown":"code-block-header",children:[L.jsx("span",{className:"ml-1 font-mono lowercase",children:t}),L.jsx("div",{className:"flex items-center gap-2",children:e})]}),Me={"github-light":mc,"github-dark":pc},Cc=t=>t in Me,_c=Kn.dependencies.shiki.replace(/^\^/,""),Mn=5e3,Fn=t=>`${t}/shiki/${_c}`,pe=new Map,pt=new Map,mt=new Set,Pr=new Set,On=/JSON\.parse\(("(?:[^"\\]|\\.)*")\)/,bt=/import\s+\w+\s+from\s+['"]\.\/([\w-]+)\.mjs['"]/g,Te=new Set;async function Sc(t,e,r){let n=`${e}/${t}.mjs`,s=new AbortController,o=setTimeout(()=>s.abort(),r),a=await fetch(n,{signal:s.signal});if(clearTimeout(o),!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);let c=await a.text(),i=[],l=bt.exec(c);for(;l!==null;)i.push(l[1]),l=bt.exec(c);bt.lastIndex=0;let u=c.match(On);if(!u)throw new Error("Could not find JSON.parse() in CDN response");let d=JSON.parse(u[1]);return{grammar:JSON.parse(d),dependencies:i}}async function Dn(t,e,r=Mn){if(e==null)return null;let n=`${Fn(e)}/langs`,s=`${n}/${t}`;if(pe.has(s))return pe.get(s);if(mt.has(s)||Te.has(s))return null;try{Te.add(s);let o=await Sc(t,n,r);if(!o)throw new Error("Failed to load language");let{grammar:a,dependencies:c}=o,i=[];for(let l of c){let u=`${n}/${l}`;if(pe.has(u)){let f=pe.get(u);i.push(...f);continue}if(Te.has(u)||mt.has(u))continue;let d=await Dn(l,e,r);d&&i.push(...d)}return i.push(a),pe.set(s,[a]),i}catch(o){mt.add(s);let a=o instanceof Error?o.message:"Unknown error";return console.warn(`[Streamdown] Failed to load language "${t}" from CDN: ${a}`),null}finally{Te.delete(s)}}async function vc(t,e,r=Mn){if(e==null)return null;let n=`${Fn(e)}/themes`,s=`${n}/${t}`;if(pt.has(s))return pt.get(s);if(Pr.has(s))return null;try{let o=`${n}/${t}.mjs`,a=new AbortController,c=setTimeout(()=>a.abort(),r),i=await fetch(o,{signal:a.signal});if(clearTimeout(c),!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);let l=await i.text();try{let u=l.match(On);if(!u)throw new Error("Could not find JSON.parse() in CDN response");let d=JSON.parse(u[1]),f=JSON.parse(d);return pt.set(s,f),f}catch(u){throw new Error(`Failed to parse theme: ${u instanceof Error?u.message:"Unknown error"}`)}}catch(o){Pr.add(s);let a=o instanceof Error?o.message:"Unknown error";return console.warn(`[Streamdown] Failed to load theme "${t}" from CDN: ${a}`),null}}var xc=gc({forgiving:!0}),yt=new Map,wt=new Map,ne=new Map,Ec=(t,e)=>`${t}-${e[0]}-${e[1]}`,Ac=(t,e,r)=>{let n=t.slice(0,100),s=t.length>100?t.slice(-100):"";return`${e}:${r[0]}:${r[1]}:${t.length}:${n}:${s}`};async function Ic(t,e){return Cc(t)?Me[t]:await vc(t,e)||(console.warn(`[Streamdown] Theme "${t}" not found. Falling back to ${t.includes("dark")?"github-dark":"github-light"}.`),t.includes("dark")?Me["github-dark"]:Me["github-light"])}async function Nc(t,e){if(Xn(t))return Jn[t];let r=await Dn(t,e);return r||console.warn(`[Streamdown] Language "${t}" not found in bundled languages or CDN. Falling back to plain text.`),r}var $c=(t,e,r)=>{let n=Ec(t,e);if(yt.has(n))return yt.get(n);let s=(async()=>{let o=await Nc(t,r),a=o?[o]:["text"],c=await Promise.all(e.map(i=>Ic(i,r)));return await Ia({themes:c,langs:a,engine:xc})})();return yt.set(n,s),s},Gr=({code:t,language:e,shikiTheme:r,cdnUrl:n,callback:s})=>{let o=Ac(t,e,r);return wt.has(o)?wt.get(o):(s&&(ne.has(o)||ne.set(o,new Set),ne.get(o).add(s)),$c(e,r,n).then(a=>{let c=a.getLoadedLanguages().includes(e)?e:"text",i=a.codeToTokens(t,{lang:c,themes:{light:r[0],dark:r[1]}});wt.set(o,i);let l=ne.get(o);if(l){for(let u of l)u(i);ne.delete(o)}}).catch(a=>{console.error("Failed to highlight code:",a),ne.delete(o)}),null)},Lc=({code:t,language:e,className:r,children:n,...s})=>{let{shikiTheme:o,cdnUrl:a}=ae.useContext(Vn),c=ae.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:t.split(`
153
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[t]),[i,l]=ae.useState(c);return ae.useEffect(()=>{let u=Gr({code:t,language:e,shikiTheme:o,cdnUrl:a});if(u){l(u);return}l(c),Gr({code:t,language:e,shikiTheme:o,cdnUrl:a,callback:d=>{l(d)}})},[t,e,o,a,c]),L.jsx(Qn.Provider,{value:{code:t},children:L.jsxs(wc,{language:e,children:[L.jsx(kc,{language:e,children:n}),L.jsx(yc,{className:r,language:e,result:i,...s})]})})};export{Lc as CodeBlock};