@prismshadow/penguin-server 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/api/types.d.ts +393 -21
- package/dist/auth-token.d.ts +29 -0
- package/dist/auth-token.js +51 -0
- package/dist/auth-token.js.map +1 -0
- package/dist/{chunk-WKJ3ANJP.js → chunk-622KL7BQ.js} +92 -381
- package/dist/chunk-622KL7BQ.js.map +1 -0
- package/dist/chunk-K4ZSUT72.js +34 -0
- package/dist/chunk-K4ZSUT72.js.map +1 -0
- package/dist/chunk-UGAFPYVX.js +374 -0
- package/dist/chunk-UGAFPYVX.js.map +1 -0
- package/dist/extension/index.d.ts +212 -0
- package/dist/extension/index.js +1 -0
- package/dist/extension/index.js.map +1 -0
- package/dist/index.js +5758 -1310
- package/dist/index.js.map +1 -1
- package/dist/initial-password.d.ts +9 -12
- package/dist/initial-password.js +3 -7
- package/dist/install.ps1 +729 -0
- package/dist/install.sh +785 -0
- package/dist/reset-admin-password.d.ts +4 -7
- package/dist/reset-admin-password.js +11 -9
- package/dist/reset-admin-password.js.map +1 -1
- package/dist/secret-file.d.ts +3 -0
- package/dist/secret-file.js +17 -0
- package/dist/secret-file.js.map +1 -0
- package/package.json +19 -3
- package/web-dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/web-dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/web-dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/web-dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/web-dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/web-dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/web-dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/web-dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/web-dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/web-dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/web-dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/web-dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/web-dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/web-dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/web-dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/web-dist/assets/{addon-fit-CE-3eCvv.js → addon-fit-DHOzI3Ur.js} +1 -1
- package/web-dist/assets/{addon-web-links-DeODgawX.js → addon-web-links-DC7759H1.js} +1 -1
- package/web-dist/assets/{highlighter-DpnM5FfD.js → highlighter-CGPO6Q4b.js} +1 -1
- package/web-dist/assets/index-CaFDHl-w.js +451 -0
- package/web-dist/assets/index-D8Bk9LtJ.css +1 -0
- package/web-dist/assets/{xterm-BjU-ZsL5.js → xterm-DY5ko-BU.js} +1 -1
- package/web-dist/index.html +2 -2
- package/dist/chunk-UUJCF46V.js +0 -50
- package/dist/chunk-UUJCF46V.js.map +0 -1
- package/dist/chunk-WKJ3ANJP.js.map +0 -1
- package/web-dist/assets/index-aRsvImZt.css +0 -1
- package/web-dist/assets/index-gNzir_kH.js +0 -189
|
@@ -14,15 +14,12 @@ type ResetAdminPasswordResult =
|
|
|
14
14
|
/** Nothing to reset: the database exists but the admin was never seeded. */
|
|
15
15
|
| {
|
|
16
16
|
outcome: "no_admin";
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
/** Returned to the unclaimed state: start the server and open the first-login link it prints. */
|
|
19
|
+
| {
|
|
18
20
|
outcome: "reset";
|
|
19
|
-
password: string;
|
|
20
21
|
};
|
|
21
|
-
/**
|
|
22
|
-
* Resets the built-in admin to a fresh initial password. `dbPath` defaults to the
|
|
23
|
-
* root's `web.db`; callers honoring PENGUIN_WEB_DB pass the resolved path (the
|
|
24
|
-
* plaintext reminder file always lives in `root`, matching the server's own layout).
|
|
25
|
-
*/
|
|
22
|
+
/** `dbPath` may be elsewhere (PENGUIN_WEB_DB); `root` stays the root, which the sweep needs. */
|
|
26
23
|
declare function resetAdminPassword(root: string, dbPath?: string): Promise<ResetAdminPasswordResult>;
|
|
27
24
|
|
|
28
25
|
export { type ResetAdminPasswordResult, resetAdminPassword };
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ADMIN_USER_ID,
|
|
3
|
-
AuthSessionsRepo,
|
|
4
|
-
UsersRepo,
|
|
5
3
|
generateInitialAdminPassword,
|
|
6
|
-
hashPassword
|
|
7
|
-
|
|
8
|
-
} from "./chunk-WKJ3ANJP.js";
|
|
4
|
+
hashPassword
|
|
5
|
+
} from "./chunk-UGAFPYVX.js";
|
|
9
6
|
import {
|
|
10
7
|
liveServerLock
|
|
11
8
|
} from "./chunk-OMBFPEGQ.js";
|
|
12
9
|
import {
|
|
13
|
-
|
|
14
|
-
} from "./chunk-
|
|
10
|
+
clearInitialAdminPassword
|
|
11
|
+
} from "./chunk-K4ZSUT72.js";
|
|
12
|
+
import {
|
|
13
|
+
AuthSessionsRepo,
|
|
14
|
+
UsersRepo,
|
|
15
|
+
openDatabase
|
|
16
|
+
} from "./chunk-622KL7BQ.js";
|
|
15
17
|
|
|
16
18
|
// src/reset-admin-password.ts
|
|
17
19
|
import fs from "fs";
|
|
@@ -27,8 +29,8 @@ async function resetAdminPassword(root, dbPath = path.join(root, "web.db")) {
|
|
|
27
29
|
const password = generateInitialAdminPassword();
|
|
28
30
|
users.updatePassword(ADMIN_USER_ID, await hashPassword(password), true);
|
|
29
31
|
new AuthSessionsRepo(db).deleteByUser(ADMIN_USER_ID);
|
|
30
|
-
|
|
31
|
-
return { outcome: "reset"
|
|
32
|
+
clearInitialAdminPassword(root);
|
|
33
|
+
return { outcome: "reset" };
|
|
32
34
|
} finally {
|
|
33
35
|
db.close();
|
|
34
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reset-admin-password.ts"],"sourcesContent":["/**\n * Offline
|
|
1
|
+
{"version":3,"sources":["../src/reset-admin-password.ts"],"sourcesContent":["/**\n * Offline rescue for a forgotten admin password — nobody can reset the admin from the web UI,\n * so this does it from the machine that owns the data root (local filesystem access IS the\n * authorization). The account goes back to unclaimed and the next start prints a first-login\n * link, so no plaintext is produced for anyone to write down. Refuses while a server is live,\n * web.db being single-writer. Exported as `@prismshadow/penguin-server/reset-admin-password`\n * so the CLI need not import the package entry, which starts listening.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { hashPassword } from \"./auth/password.js\";\nimport { ADMIN_USER_ID, generateInitialAdminPassword } from \"./auth/service.js\";\nimport { openDatabase } from \"./db/database.js\";\nimport { UsersRepo } from \"./db/repos/users.js\";\nimport { AuthSessionsRepo } from \"./db/repos/auth-sessions.js\";\nimport { clearInitialAdminPassword } from \"./initial-password.js\";\nimport { liveServerLock } from \"./lock.js\";\nimport type { ServerLock } from \"./lock.js\";\n\nexport type ResetAdminPasswordResult =\n /** Refused: a live server owns this data root (stop it first — web.db is single-writer). */\n | { outcome: \"server_running\"; lock: ServerLock }\n /** Nothing to reset: the root has no Web database (the server has never run here). */\n | { outcome: \"no_database\"; dbPath: string }\n /** Nothing to reset: the database exists but the admin was never seeded. */\n | { outcome: \"no_admin\" }\n /** Returned to the unclaimed state: start the server and open the first-login link it prints. */\n | { outcome: \"reset\" };\n\n/** `dbPath` may be elsewhere (PENGUIN_WEB_DB); `root` stays the root, which the sweep needs. */\nexport async function resetAdminPassword(\n root: string,\n dbPath: string = path.join(root, \"web.db\"),\n): Promise<ResetAdminPasswordResult> {\n const lock = await liveServerLock(root);\n if (lock !== null) return { outcome: \"server_running\", lock };\n // Existence check before openDatabase, which would otherwise CREATE an empty database\n // (and the root directory) on a root the server has never used.\n if (!fs.existsSync(dbPath)) return { outcome: \"no_database\", dbPath };\n const db = openDatabase(dbPath);\n try {\n const users = new UsersRepo(db);\n if (users.findById(ADMIN_USER_ID) === null) return { outcome: \"no_admin\" };\n // Discarded unread: a value nobody holds cannot be typed, phished, or left in a buffer.\n const password = generateInitialAdminPassword();\n users.updatePassword(ADMIN_USER_ID, await hashPassword(password), true);\n new AuthSessionsRepo(db).deleteByUser(ADMIN_USER_ID);\n clearInitialAdminPassword(root);\n return { outcome: \"reset\" };\n } finally {\n db.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAQA,OAAO,QAAQ;AACf,OAAO,UAAU;AAqBjB,eAAsB,mBACpB,MACA,SAAiB,KAAK,KAAK,MAAM,QAAQ,GACN;AACnC,QAAM,OAAO,MAAM,eAAe,IAAI;AACtC,MAAI,SAAS,KAAM,QAAO,EAAE,SAAS,kBAAkB,KAAK;AAG5D,MAAI,CAAC,GAAG,WAAW,MAAM,EAAG,QAAO,EAAE,SAAS,eAAe,OAAO;AACpE,QAAM,KAAK,aAAa,MAAM;AAC9B,MAAI;AACF,UAAM,QAAQ,IAAI,UAAU,EAAE;AAC9B,QAAI,MAAM,SAAS,aAAa,MAAM,KAAM,QAAO,EAAE,SAAS,WAAW;AAEzE,UAAM,WAAW,6BAA6B;AAC9C,UAAM,eAAe,eAAe,MAAM,aAAa,QAAQ,GAAG,IAAI;AACtE,QAAI,iBAAiB,EAAE,EAAE,aAAa,aAAa;AACnD,8BAA0B,IAAI;AAC9B,WAAO,EAAE,SAAS,QAAQ;AAAA,EAC5B,UAAE;AACA,OAAG,MAAM;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/secret-file.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
function writeSecretFile(filePath, contents) {
|
|
4
|
+
fs.rmSync(filePath, { force: true });
|
|
5
|
+
const flags = fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | (fs.constants.O_NOFOLLOW ?? 0);
|
|
6
|
+
const fd = fs.openSync(filePath, flags, 384);
|
|
7
|
+
try {
|
|
8
|
+
fs.fchmodSync(fd, 384);
|
|
9
|
+
fs.writeSync(fd, contents);
|
|
10
|
+
} finally {
|
|
11
|
+
fs.closeSync(fd);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
writeSecretFile
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=secret-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/secret-file.ts"],"sourcesContent":["/**\n * Writes a bearer secret to a 0600 file, refusing to follow a symlink parked at the path:\n * someone who can write the directory but not read the file could otherwise redirect the write\n * into a file they CAN read. Hence unlink + exclusive create, and chmod on the fd rather than\n * the path. Exported as `@prismshadow/penguin-server/secret-file` so the CLI shares it.\n */\nimport fs from \"node:fs\";\n\nexport function writeSecretFile(filePath: string, contents: string): void {\n fs.rmSync(filePath, { force: true });\n const flags =\n fs.constants.O_WRONLY |\n fs.constants.O_CREAT |\n fs.constants.O_EXCL |\n (fs.constants.O_NOFOLLOW ?? 0);\n const fd = fs.openSync(filePath, flags, 0o600);\n try {\n fs.fchmodSync(fd, 0o600);\n fs.writeSync(fd, contents);\n } finally {\n fs.closeSync(fd);\n }\n}\n"],"mappings":";AAMA,OAAO,QAAQ;AAER,SAAS,gBAAgB,UAAkB,UAAwB;AACxE,KAAG,OAAO,UAAU,EAAE,OAAO,KAAK,CAAC;AACnC,QAAM,QACJ,GAAG,UAAU,WACb,GAAG,UAAU,UACb,GAAG,UAAU,UACZ,GAAG,UAAU,cAAc;AAC9B,QAAM,KAAK,GAAG,SAAS,UAAU,OAAO,GAAK;AAC7C,MAAI;AACF,OAAG,WAAW,IAAI,GAAK;AACvB,OAAG,UAAU,IAAI,QAAQ;AAAA,EAC3B,UAAE;AACA,OAAG,UAAU,EAAE;AAAA,EACjB;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismshadow/penguin-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "PenguinHarness web server: multi-user authentication and authorization, Session execution with SSE streaming, and usage accounting, built on @prismshadow/penguin-core.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,6 +37,18 @@
|
|
|
37
37
|
"./version-report": {
|
|
38
38
|
"types": "./dist/version-report.d.ts",
|
|
39
39
|
"import": "./dist/version-report.js"
|
|
40
|
+
},
|
|
41
|
+
"./auth-token": {
|
|
42
|
+
"types": "./dist/auth-token.d.ts",
|
|
43
|
+
"import": "./dist/auth-token.js"
|
|
44
|
+
},
|
|
45
|
+
"./secret-file": {
|
|
46
|
+
"types": "./dist/secret-file.d.ts",
|
|
47
|
+
"import": "./dist/secret-file.js"
|
|
48
|
+
},
|
|
49
|
+
"./extension": {
|
|
50
|
+
"types": "./dist/extension/index.d.ts",
|
|
51
|
+
"import": "./dist/extension/index.js"
|
|
40
52
|
}
|
|
41
53
|
},
|
|
42
54
|
"main": "./dist/index.js",
|
|
@@ -52,15 +64,19 @@
|
|
|
52
64
|
"fflate": "^0.8.3",
|
|
53
65
|
"hono": "^4.12.34",
|
|
54
66
|
"node-pty": "^1.1.0",
|
|
67
|
+
"remark-gfm": "^4.0.0",
|
|
68
|
+
"remark-parse": "^11.0.0",
|
|
55
69
|
"smol-toml": "^1.3.0",
|
|
56
70
|
"tar": "^7.5.21",
|
|
57
71
|
"undici": "^7.29.0",
|
|
72
|
+
"unified": "^11.0.5",
|
|
58
73
|
"ws": "^8.18.3",
|
|
59
74
|
"yaml": "^2.5.0",
|
|
60
|
-
"@prismshadow/penguin-
|
|
61
|
-
"@prismshadow/penguin-
|
|
75
|
+
"@prismshadow/penguin-core": "0.2.8",
|
|
76
|
+
"@prismshadow/penguin-skills": "0.2.8"
|
|
62
77
|
},
|
|
63
78
|
"devDependencies": {
|
|
79
|
+
"@types/mdast": "^4.0.4",
|
|
64
80
|
"@types/node": "^24.0.0",
|
|
65
81
|
"@types/ws": "^8.18.1",
|
|
66
82
|
"tsup": "^8.3.0",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g}from"./index-
|
|
1
|
+
import{g}from"./index-CaFDHl-w.js";function _(i,s){for(var o=0;o<s.length;o++){const t=s[o];if(typeof t!="string"&&!Array.isArray(t)){for(const e in t)if(e!=="default"&&!(e in i)){const r=Object.getOwnPropertyDescriptor(t,e);r&&Object.defineProperty(i,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var a={exports:{}},d;function y(){return d||(d=1,(function(i,s){(function(o,t){i.exports=t()})(self,(()=>(()=>{var o={};return(()=>{var t=o;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const r=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,r=e._renderService.dimensions;if(r.css.cell.width===0||r.css.cell.height===0)return;const c=this._terminal.options.scrollback===0?0:e.viewport.scrollBarWidth,l=window.getComputedStyle(this._terminal.element.parentElement),m=parseInt(l.getPropertyValue("height")),u=Math.max(0,parseInt(l.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),h=m-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),f=u-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-c;return{cols:Math.max(2,Math.floor(f/r.css.cell.width)),rows:Math.max(1,Math.floor(h/r.css.cell.height))}}}})(),o})()))})(a)),a.exports}var p=y();const w=g(p),x=_({__proto__:null,default:w},[p]);export{x as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as O}from"./index-
|
|
1
|
+
import{g as O}from"./index-CaFDHl-w.js";function j(b,k){for(var _=0;_<k.length;_++){const l=k[_];if(typeof l!="string"&&!Array.isArray(l)){for(const u in l)if(u!=="default"&&!(u in b)){const L=Object.getOwnPropertyDescriptor(l,u);L&&Object.defineProperty(b,u,L.get?L:{enumerable:!0,get:()=>l[u]})}}}return Object.freeze(Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}))}var w={exports:{}},C;function A(){return C||(C=1,(function(b,k){(function(_,l){b.exports=l()})(self,(()=>(()=>{var _={6:(p,d)=>{function h(s){try{const e=new URL(s),t=e.password&&e.username?`${e.protocol}//${e.username}:${e.password}@${e.host}`:e.username?`${e.protocol}//${e.username}@${e.host}`:`${e.protocol}//${e.host}`;return s.toLocaleLowerCase().startsWith(t.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(d,"__esModule",{value:!0}),d.LinkComputer=d.WebLinkProvider=void 0,d.WebLinkProvider=class{constructor(s,e,t,r={}){this._terminal=s,this._regex=e,this._handler=t,this._options=r}provideLinks(s,e){const t=f.computeLink(s,this._regex,this._terminal,this._handler);e(this._addCallbacks(t))}_addCallbacks(s){return s.map((e=>(e.leave=this._options.leave,e.hover=(t,r)=>{if(this._options.hover){const{range:c}=e;this._options.hover(t,r,c)}},e)))}};class f{static computeLink(e,t,r,c){const g=new RegExp(t.source,(t.flags||"")+"g"),[n,o]=f._getWindowedLineStrings(e-1,r),i=n.join("");let a;const x=[];for(;a=g.exec(i);){const v=a[0];if(!h(v))continue;const[m,W]=f._mapStrIdx(r,o,0,a.index),[y,P]=f._mapStrIdx(r,m,W,v.length);if(m===-1||W===-1||y===-1||P===-1)continue;const $={start:{x:W+1,y:m+1},end:{x:P,y:y+1}};x.push({range:$,text:v,activate:c})}return x}static _getWindowedLineStrings(e,t){let r,c=e,g=e,n=0,o="";const i=[];if(r=t.buffer.active.getLine(e)){const a=r.translateToString(!0);if(r.isWrapped&&a[0]!==" "){for(n=0;(r=t.buffer.active.getLine(--c))&&n<2048&&(o=r.translateToString(!0),n+=o.length,i.push(o),r.isWrapped&&o.indexOf(" ")===-1););i.reverse()}for(i.push(a),n=0;(r=t.buffer.active.getLine(++g))&&r.isWrapped&&n<2048&&(o=r.translateToString(!0),n+=o.length,i.push(o),o.indexOf(" ")===-1););}return[i,c]}static _mapStrIdx(e,t,r,c){const g=e.buffer.active,n=g.getNullCell();let o=r;for(;c;){const i=g.getLine(t);if(!i)return[-1,-1];for(let a=o;a<i.length;++a){i.getCell(a,n);const x=n.getChars();if(n.getWidth()&&(c-=x.length||1,a===i.length-1&&x==="")){const v=g.getLine(t+1);v&&v.isWrapped&&(v.getCell(0,n),n.getWidth()===2&&(c+=1))}if(c<0)return[t,a]}t++,o=0}return[t,o]}}d.LinkComputer=f}},l={};function u(p){var d=l[p];if(d!==void 0)return d.exports;var h=l[p]={exports:{}};return _[p](h,h.exports,u),h.exports}var L={};return(()=>{var p=L;Object.defineProperty(p,"__esModule",{value:!0}),p.WebLinksAddon=void 0;const d=u(6),h=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function f(s,e){const t=window.open();if(t){try{t.opener=null}catch{}t.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}p.WebLinksAddon=class{constructor(s=f,e={}){this._handler=s,this._options=e}activate(s){this._terminal=s;const e=this._options,t=e.urlRegex||h;this._linkProvider=this._terminal.registerLinkProvider(new d.WebLinkProvider(this._terminal,t,this._handler,e))}dispose(){this._linkProvider?.dispose()}}})(),L})()))})(w)),w.exports}var S=A();const T=O(S),E=j({__proto__:null,default:T},[S]);export{E as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as vt,s as Nn,f as $r,a as Lr,b as Pr,c as Dt,h as Tr,r as Gr,i as Mr,L as Or,_ as jt}from"./index-gNzir_kH.js";const Ut={}.hasOwnProperty;function Br(e,t){const n=t||{};function r(s,...o){let i=r.invalid;const a=r.handlers;if(s&&Ut.call(s,e)){const c=String(s[e]);i=Ut.call(a,c)?a[c]:r.unknown}if(i)return i.call(this,s,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var k=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Fr(e){return Nt(e)}function Nt(e){return Array.isArray(e)?Dr(e):e instanceof RegExp?e:typeof e=="object"?jr(e):e}function Dr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Nt(e[n]);return t}function jr(e){let t={};for(let n in e)t[n]=Nt(e[n]);return t}function Rn(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function $n(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?$n(e.substring(0,e.length-1)):e.substr(~t+1)}var Je=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(e){return e===null?!1:(Je.lastIndex=0,Je.test(e))}static replaceCaptures(e,t,n){return e.replace(Je,(r,s,o,i)=>{let a=n[parseInt(s||o,10)];if(a){let c=t.substring(a.start,a.end);for(;c[0]===".";)c=c.substring(1);switch(i){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function Ln(e,t){return e<t?-1:e>t?1:0}function Pn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let s=0;s<n;s++){let o=Ln(e[s],t[s]);if(o!==0)return o}return 0}return n-r}function Wt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Tn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Gn=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},Ne=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(zr(e),t)}static createFromParsedTheme(e,t){return qr(e,t)}_cachedMatchRoot=new Gn(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(s=>Ur(e.parent,s.parentScopes));return r?new Mn(r.fontStyle,r.foreground,r.background):null}},Ye=class Ee{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Ee(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Ee(n,t[r]);return n}push(t){return new Ee(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function Ur(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!Wr(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Wr(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Mn=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function zr(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let s=0,o=t.length;s<o;s++){let i=t[s];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let h=i.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let c=-1;if(typeof i.settings.fontStyle=="string"){c=0;let h=i.settings.fontStyle.split(" ");for(let f=0,d=h.length;f<d;f++)switch(h[f]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof i.settings.foreground=="string"&&Wt(i.settings.foreground)&&(l=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Wt(i.settings.background)&&(u=i.settings.background);for(let h=0,f=a.length;h<f;h++){let p=a[h].trim().split(" "),y=p[p.length-1],b=null;p.length>1&&(b=p.slice(0,p.length-1),b.reverse()),n[r++]=new Hr(y,b,s,c,l,u)}}return n}var Hr=class{constructor(e,t,n,r,s,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}},R=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(R||{});function qr(e,t){e.sort((c,l)=>{let u=Ln(c.scope,l.scope);return u!==0||(u=Pn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&e[0].scope==="";){let c=e.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let o=new Vr(t),i=new Mn(n,o.getId(r),o.getId(s)),a=new Qr(new ft(0,null,-1,0,0),[]);for(let c=0,l=e.length;c<l;c++){let u=e[c];a.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new Ne(o,i,a)}var Vr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Xr=Object.freeze([]),ft=class On{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,s,o){this.scopeDepth=t,this.parentScopes=n||Xr,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new On(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,s=t.length;r<s;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,s){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Qr=class dt{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,s=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=t.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-t.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),s,o;if(r===-1?(s=t,o=""):(s=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(dt._cmpBySpecificity),n}insert(t,n,r,s,o,i){if(n===""){this._doInsertHere(t,r,s,o,i);return}let a=n.indexOf("."),c,l;a===-1?(c=n,l=""):(c=n.substring(0,a),l=n.substring(a+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new dt(this._mainRule.clone(),ft.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,s,o,i)}_doInsertHere(t,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(t,r,s,o);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let c=this._rulesWithParentScopes[i];if(Pn(c.parentScopes,n)===0){c.acceptOverwrite(t,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new ft(t,n,r,s,o))}},J=class L{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=L.getLanguageId(t),r=L.getTokenType(t),s=L.getFontStyle(t),o=L.getForeground(t),i=L.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,s,o,i,a){let c=L.getLanguageId(t),l=L.getTokenType(t),u=L.containsBalancedBrackets(t)?1:0,h=L.getFontStyle(t),f=L.getForeground(t),d=L.getBackground(t);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),i!==0&&(f=i),a!==0&&(d=a),(c<<0|l<<8|u<<10|h<<11|f<<15|d<<24)>>>0}};function Re(e,t){const n=[],r=Kr(e);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=i();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const c=o();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=a();return s===")"&&(s=r.next()),c}if(zt(s)){const c=[];do c.push(s),s=r.next();while(zt(s));return l=>t(c,l)}return null}function i(){const c=[];let l=o();for(;l;)c.push(l),l=o();return u=>c.every(h=>h(u))}function a(){const c=[];let l=i();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=i()}return u=>c.some(h=>h(u))}}function zt(e){return!!e&&!!e.match(/[\w\.:]+/)}function Kr(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function Bn(e){typeof e.dispose=="function"&&e.dispose()}var de=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Zr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Jr=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Yr=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new de(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new Jr;for(const n of e)es(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof de){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function es(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const o=n.lookup(t);e instanceof de?Ie({baseGrammar:o,selfGrammar:s},r):pt(e.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const i=n.injections(e.scopeName);if(i)for(const a of i)r.add(new de(a))}function pt(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];$e([r],t,n)}}function Ie(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&$e(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&$e(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function $e(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?Rn({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&$e(r.patterns,{...t,repository:s},n);const o=r.include;if(!o)continue;const i=Fn(o);switch(i.kind){case 0:Ie({...t,selfGrammar:t.baseGrammar},n);break;case 1:Ie(t,n);break;case 2:pt(i.ruleName,{...t,repository:s},n);break;case 3:case 4:const a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){const c={baseGrammar:t.baseGrammar,selfGrammar:a,repository:s};i.kind===4?pt(i.ruleName,c,n):Ie(c,n)}else i.kind===4?n.add(new Zr(i.scopeName,i.ruleName)):n.add(new de(i.scopeName));break}}}var ts=class{kind=0},ns=class{kind=1},rs=class{constructor(e){this.ruleName=e}kind=2},ss=class{constructor(e){this.scopeName=e}kind=3},os=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Fn(e){if(e==="$base")return new ts;if(e==="$self")return new ns;const t=e.indexOf("#");if(t===-1)return new ss(e);if(t===0)return new rs(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new os(n,r)}}var is=/\\(\d+)/,Ht=/\\(\d+)/g,as=-1,Dn=-2;var be=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${$n(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:we.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,e,t)}},cs=class extends be{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},ls=class extends be{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new pe(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ge,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},qt=class extends be{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ge,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},gt=class extends be{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,o,i,a,c,l){super(e,t,n,r),this._begin=new pe(s,this.id),this.beginCaptures=o,this._end=new pe(i||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ge;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Le=class extends be{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,o,i,a,c){super(e,t,n,r),this._begin=new pe(s,this.id),this.beginCaptures=o,this.whileCaptures=a,this._while=new pe(i,Dn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ge;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new ge,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},jn=class N{static createCaptureRule(t,n,r,s,o){return t.registerRule(i=>new cs(n,i,r,s,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new ls(t.$vscodeTextmateLocation,t.id,t.name,t.match,N._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Rn({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new qt(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,N._compilePatterns(o,n,r))}return t.while?new Le(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,N._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,N._compileCaptures(t.whileCaptures||t.captures,n,r),N._compilePatterns(t.patterns,n,r)):new gt(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,N._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,N._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,N._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let o=0;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);a>o&&(o=a)}for(let i=0;i<=o;i++)s[i]=null;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);let c=0;t[i].patterns&&(c=N.getCompiledRuleId(t[i],n,r)),s[a]=N.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,c)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let o=0,i=t.length;o<i;o++){const a=t[o];let c=-1;if(a.include){const l=Fn(a.include);switch(l.kind){case 0:case 1:c=N.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=N.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,f=l.kind===4?l.ruleName:null,d=n.getExternalGrammar(h,r);if(d)if(f){let p=d.repository[f];p&&(c=N.getCompiledRuleId(p,n,d.repository))}else c=N.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else c=N.getCompiledRuleId(a,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof qt||l instanceof gt||l instanceof Le)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},pe=class Un{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){const r=t.length;let s=0,o=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){const l=t.charAt(a+1);l==="z"?(o.push(t.substring(s,a)),o.push("$(?!\\n)(?<!\\n)"),s=a+2):(l==="A"||l==="G")&&(i=!0),a++}this.hasAnchor=i,s===0?this.source=t:(o.push(t.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=is.test(this.source):this.hasBackReferences=!1}clone(){return new Un(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>t.substring(s.start,s.end));return Ht.lastIndex=0,this.source.replace(Ht,(s,o)=>Tn(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],s=[],o,i,a,c;for(o=0,i=this.source.length;o<i;o++)a=this.source.charAt(o),t[o]=a,n[o]=a,r[o]=a,s[o]=a,a==="\\"&&o+1<i&&(c=this.source.charAt(o+1),c==="A"?(t[o+1]="",n[o+1]="",r[o+1]="A",s[o+1]="A"):c==="G"?(t[o+1]="",n[o+1]="G",r[o+1]="",s[o+1]="G"):(t[o+1]=c,n[o+1]=c,r[o+1]=c,s[o+1]=c),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},ge=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Vt(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(s=>s.resolveAnchors(t,n));return new Vt(e,r,this._items.map(s=>s.ruleId))}},Vt=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
1
|
+
import{w as vt,s as Nn,f as $r,a as Lr,b as Pr,c as Dt,h as Tr,r as Gr,i as Mr,L as Or,_ as jt}from"./index-CaFDHl-w.js";const Ut={}.hasOwnProperty;function Br(e,t){const n=t||{};function r(s,...o){let i=r.invalid;const a=r.handlers;if(s&&Ut.call(s,e)){const c=String(s[e]);i=Ut.call(a,c)?a[c]:r.unknown}if(i)return i.call(this,s,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var k=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Fr(e){return Nt(e)}function Nt(e){return Array.isArray(e)?Dr(e):e instanceof RegExp?e:typeof e=="object"?jr(e):e}function Dr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Nt(e[n]);return t}function jr(e){let t={};for(let n in e)t[n]=Nt(e[n]);return t}function Rn(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function $n(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?$n(e.substring(0,e.length-1)):e.substr(~t+1)}var Je=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(e){return e===null?!1:(Je.lastIndex=0,Je.test(e))}static replaceCaptures(e,t,n){return e.replace(Je,(r,s,o,i)=>{let a=n[parseInt(s||o,10)];if(a){let c=t.substring(a.start,a.end);for(;c[0]===".";)c=c.substring(1);switch(i){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function Ln(e,t){return e<t?-1:e>t?1:0}function Pn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let s=0;s<n;s++){let o=Ln(e[s],t[s]);if(o!==0)return o}return 0}return n-r}function Wt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Tn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Gn=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},Ne=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(zr(e),t)}static createFromParsedTheme(e,t){return qr(e,t)}_cachedMatchRoot=new Gn(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(s=>Ur(e.parent,s.parentScopes));return r?new Mn(r.fontStyle,r.foreground,r.background):null}},Ye=class Ee{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Ee(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Ee(n,t[r]);return n}push(t){return new Ee(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function Ur(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!Wr(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Wr(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Mn=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function zr(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let s=0,o=t.length;s<o;s++){let i=t[s];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let h=i.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let c=-1;if(typeof i.settings.fontStyle=="string"){c=0;let h=i.settings.fontStyle.split(" ");for(let f=0,d=h.length;f<d;f++)switch(h[f]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof i.settings.foreground=="string"&&Wt(i.settings.foreground)&&(l=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Wt(i.settings.background)&&(u=i.settings.background);for(let h=0,f=a.length;h<f;h++){let p=a[h].trim().split(" "),y=p[p.length-1],b=null;p.length>1&&(b=p.slice(0,p.length-1),b.reverse()),n[r++]=new Hr(y,b,s,c,l,u)}}return n}var Hr=class{constructor(e,t,n,r,s,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}},R=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(R||{});function qr(e,t){e.sort((c,l)=>{let u=Ln(c.scope,l.scope);return u!==0||(u=Pn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&e[0].scope==="";){let c=e.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let o=new Vr(t),i=new Mn(n,o.getId(r),o.getId(s)),a=new Qr(new ft(0,null,-1,0,0),[]);for(let c=0,l=e.length;c<l;c++){let u=e[c];a.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new Ne(o,i,a)}var Vr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Xr=Object.freeze([]),ft=class On{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,s,o){this.scopeDepth=t,this.parentScopes=n||Xr,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new On(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,s=t.length;r<s;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,s){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Qr=class dt{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,s=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=t.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-t.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),s,o;if(r===-1?(s=t,o=""):(s=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(dt._cmpBySpecificity),n}insert(t,n,r,s,o,i){if(n===""){this._doInsertHere(t,r,s,o,i);return}let a=n.indexOf("."),c,l;a===-1?(c=n,l=""):(c=n.substring(0,a),l=n.substring(a+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new dt(this._mainRule.clone(),ft.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,s,o,i)}_doInsertHere(t,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(t,r,s,o);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let c=this._rulesWithParentScopes[i];if(Pn(c.parentScopes,n)===0){c.acceptOverwrite(t,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new ft(t,n,r,s,o))}},J=class L{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=L.getLanguageId(t),r=L.getTokenType(t),s=L.getFontStyle(t),o=L.getForeground(t),i=L.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,s,o,i,a){let c=L.getLanguageId(t),l=L.getTokenType(t),u=L.containsBalancedBrackets(t)?1:0,h=L.getFontStyle(t),f=L.getForeground(t),d=L.getBackground(t);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),i!==0&&(f=i),a!==0&&(d=a),(c<<0|l<<8|u<<10|h<<11|f<<15|d<<24)>>>0}};function Re(e,t){const n=[],r=Kr(e);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=i();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const c=o();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=a();return s===")"&&(s=r.next()),c}if(zt(s)){const c=[];do c.push(s),s=r.next();while(zt(s));return l=>t(c,l)}return null}function i(){const c=[];let l=o();for(;l;)c.push(l),l=o();return u=>c.every(h=>h(u))}function a(){const c=[];let l=i();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=i()}return u=>c.some(h=>h(u))}}function zt(e){return!!e&&!!e.match(/[\w\.:]+/)}function Kr(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function Bn(e){typeof e.dispose=="function"&&e.dispose()}var de=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Zr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Jr=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Yr=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new de(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new Jr;for(const n of e)es(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof de){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function es(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const o=n.lookup(t);e instanceof de?Ie({baseGrammar:o,selfGrammar:s},r):pt(e.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const i=n.injections(e.scopeName);if(i)for(const a of i)r.add(new de(a))}function pt(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];$e([r],t,n)}}function Ie(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&$e(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&$e(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function $e(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?Rn({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&$e(r.patterns,{...t,repository:s},n);const o=r.include;if(!o)continue;const i=Fn(o);switch(i.kind){case 0:Ie({...t,selfGrammar:t.baseGrammar},n);break;case 1:Ie(t,n);break;case 2:pt(i.ruleName,{...t,repository:s},n);break;case 3:case 4:const a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){const c={baseGrammar:t.baseGrammar,selfGrammar:a,repository:s};i.kind===4?pt(i.ruleName,c,n):Ie(c,n)}else i.kind===4?n.add(new Zr(i.scopeName,i.ruleName)):n.add(new de(i.scopeName));break}}}var ts=class{kind=0},ns=class{kind=1},rs=class{constructor(e){this.ruleName=e}kind=2},ss=class{constructor(e){this.scopeName=e}kind=3},os=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Fn(e){if(e==="$base")return new ts;if(e==="$self")return new ns;const t=e.indexOf("#");if(t===-1)return new ss(e);if(t===0)return new rs(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new os(n,r)}}var is=/\\(\d+)/,Ht=/\\(\d+)/g,as=-1,Dn=-2;var be=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${$n(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:we.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,e,t)}},cs=class extends be{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},ls=class extends be{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new pe(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ge,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},qt=class extends be{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ge,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},gt=class extends be{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,o,i,a,c,l){super(e,t,n,r),this._begin=new pe(s,this.id),this.beginCaptures=o,this._end=new pe(i||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ge;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Le=class extends be{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,o,i,a,c){super(e,t,n,r),this._begin=new pe(s,this.id),this.beginCaptures=o,this.whileCaptures=a,this._while=new pe(i,Dn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ge;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new ge,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},jn=class N{static createCaptureRule(t,n,r,s,o){return t.registerRule(i=>new cs(n,i,r,s,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new ls(t.$vscodeTextmateLocation,t.id,t.name,t.match,N._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Rn({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new qt(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,N._compilePatterns(o,n,r))}return t.while?new Le(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,N._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,N._compileCaptures(t.whileCaptures||t.captures,n,r),N._compilePatterns(t.patterns,n,r)):new gt(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,N._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,N._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,N._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let o=0;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);a>o&&(o=a)}for(let i=0;i<=o;i++)s[i]=null;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);let c=0;t[i].patterns&&(c=N.getCompiledRuleId(t[i],n,r)),s[a]=N.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,c)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let o=0,i=t.length;o<i;o++){const a=t[o];let c=-1;if(a.include){const l=Fn(a.include);switch(l.kind){case 0:case 1:c=N.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=N.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,f=l.kind===4?l.ruleName:null,d=n.getExternalGrammar(h,r);if(d)if(f){let p=d.repository[f];p&&(c=N.getCompiledRuleId(p,n,d.repository))}else c=N.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else c=N.getCompiledRuleId(a,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof qt||l instanceof gt||l instanceof Le)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},pe=class Un{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){const r=t.length;let s=0,o=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){const l=t.charAt(a+1);l==="z"?(o.push(t.substring(s,a)),o.push("$(?!\\n)(?<!\\n)"),s=a+2):(l==="A"||l==="G")&&(i=!0),a++}this.hasAnchor=i,s===0?this.source=t:(o.push(t.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=is.test(this.source):this.hasBackReferences=!1}clone(){return new Un(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>t.substring(s.start,s.end));return Ht.lastIndex=0,this.source.replace(Ht,(s,o)=>Tn(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],s=[],o,i,a,c;for(o=0,i=this.source.length;o<i;o++)a=this.source.charAt(o),t[o]=a,n[o]=a,r[o]=a,s[o]=a,a==="\\"&&o+1<i&&(c=this.source.charAt(o+1),c==="A"?(t[o+1]="",n[o+1]="",r[o+1]="A",s[o+1]="A"):c==="G"?(t[o+1]="",n[o+1]="G",r[o+1]="",s[o+1]="G"):(t[o+1]=c,n[o+1]=c,r[o+1]=c,s[o+1]=c),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},ge=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Vt(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(s=>s.resolveAnchors(t,n));return new Vt(e,r,this._items.map(s=>s.ruleId))}},Vt=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
2
2
|
`)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},et=class{constructor(e,t){this.languageId=e,this.tokenType=t}},us=class mt{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new et(t,8),this._embeddedLanguagesMatcher=new hs(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?mt._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new et(0,0);_getBasicScopeAttributes=new Gn(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new et(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(mt.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},hs=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>Tn(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Xt=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Wn(e,t,n,r,s,o,i,a){const c=t.content.length;let l=!1,u=-1;if(i){const d=fs(e,t,n,r,s,o);s=d.stack,r=d.linePos,n=d.isFirstLine,u=d.anchorPosition}const h=Date.now();for(;!l;){if(a!==0&&Date.now()-h>a)return new Xt(s,!0);f()}return new Xt(s,!1);function f(){const d=ds(e,t,n,r,s,u);if(!d){o.produce(s,c),l=!0;return}const p=d.captureIndices,y=d.matchedRuleId,b=p&&p.length>0?p[0].end>r:!1;if(y===as){const g=s.getRule(e);o.produce(s,p[0].start),s=s.withContentNameScopesList(s.nameScopesList),ue(e,t,n,s,o,g.endCaptures,p),o.produce(s,p[0].end);const m=s;if(s=s.parent,u=m.getAnchorPos(),!b&&m.getEnterPos()===r){s=m,o.produce(s,c),l=!0;return}}else{const g=e.getRule(y);o.produce(s,p[0].start);const m=s,_=g.getName(t.content,p),C=s.contentNameScopesList.pushAttributed(_,e);if(s=s.push(y,r,u,p[0].end===c,null,C,C),g instanceof gt){const S=g;ue(e,t,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const v=S.getContentName(t.content,p),$=C.pushAttributed(v,e);if(s=s.withContentNameScopesList($),S.endHasBackReferences&&(s=s.withEndRule(S.getEndWithResolvedBackReferences(t.content,p))),!b&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,c),l=!0;return}}else if(g instanceof Le){const S=g;ue(e,t,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const v=S.getContentName(t.content,p),$=C.pushAttributed(v,e);if(s=s.withContentNameScopesList($),S.whileHasBackReferences&&(s=s.withEndRule(S.getWhileWithResolvedBackReferences(t.content,p))),!b&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,c),l=!0;return}}else if(ue(e,t,n,s,o,g.captures,p),o.produce(s,p[0].end),s=s.pop(),!b){s=s.safePop(),o.produce(s,c),l=!0;return}}p[0].end>r&&(r=p[0].end,n=!1)}}function fs(e,t,n,r,s,o){let i=s.beginRuleCapturedEOL?0:-1;const a=[];for(let c=s;c;c=c.pop()){const l=c.getRule(e);l instanceof Le&&a.push({rule:l,stack:c})}for(let c=a.pop();c;c=a.pop()){const{ruleScanner:l,findOptions:u}=ms(c.rule,e,c.stack.endRule,n,r===i),h=l.findNextMatchSync(t,r,u);if(h){if(h.ruleId!==Dn){s=c.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(o.produce(c.stack,h.captureIndices[0].start),ue(e,t,n,c.stack,o,c.rule.whileCaptures,h.captureIndices),o.produce(c.stack,h.captureIndices[0].end),i=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=c.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:i,isFirstLine:n}}function ds(e,t,n,r,s,o){const i=ps(e,t,n,r,s,o),a=e.getInjections();if(a.length===0)return i;const c=gs(a,e,t,n,r,s,o);if(!c)return i;if(!i)return c;const l=i.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:i}function ps(e,t,n,r,s,o){const i=s.getRule(e),{ruleScanner:a,findOptions:c}=zn(i,e,s.endRule,n,r===o),l=a.findNextMatchSync(t,r,c);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}function gs(e,t,n,r,s,o,i){let a=Number.MAX_VALUE,c=null,l,u=0;const h=o.contentNameScopesList.getScopeNames();for(let f=0,d=e.length;f<d;f++){const p=e[f];if(!p.matcher(h))continue;const y=t.getRule(p.ruleId),{ruleScanner:b,findOptions:g}=zn(y,t,null,r,s===i),m=b.findNextMatchSync(n,s,g);if(!m)continue;const _=m.captureIndices[0].start;if(!(_>=a)&&(a=_,c=m.captureIndices,l=m.ruleId,u=p.priority,a===s))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function zn(e,t,n,r,s){return{ruleScanner:e.compileAG(t,n,r,s),findOptions:0}}function ms(e,t,n,r,s){return{ruleScanner:e.compileWhileAG(t,n,r,s),findOptions:0}}function ue(e,t,n,r,s,o,i){if(o.length===0)return;const a=t.content,c=Math.min(o.length,i.length),l=[],u=i[0].end;for(let h=0;h<c;h++){const f=o[h];if(f===null)continue;const d=i[h];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?s.produceFromScopes(l[l.length-1].scopes,d.start):s.produce(r,d.start),f.retokenizeCapturedWithRuleId){const y=f.getName(a,i),b=r.contentNameScopesList.pushAttributed(y,e),g=f.getContentName(a,i),m=b.pushAttributed(g,e),_=r.push(f.retokenizeCapturedWithRuleId,d.start,-1,!1,null,b,m),C=e.createOnigString(a.substring(0,d.end));Wn(e,C,n&&d.start===0,d.start,_,s,!1,0),Bn(C);continue}const p=f.getName(a,i);if(p!==null){const b=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(p,e);l.push(new ys(b,d.end))}}for(;l.length>0;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var ys=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function bs(e,t,n,r,s,o,i,a){return new ws(e,t,n,r,s,o,i,a)}function Qt(e,t,n,r,s){const o=Re(t,Pe),i=jn.getCompiledRuleId(n,r,s.repository);for(const a of o)e.push({debugSelector:t,matcher:a.matcher,ruleId:i,grammar:s,priority:a.priority})}function Pe(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let s=n;s<t.length;s++)if(_s(t[s],r))return n=s+1,!0;return!1})}function _s(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var ws=class{constructor(e,t,n,r,s,o,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=a,this._basicScopeAttributesProvider=new us(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Kt(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const c of Object.keys(s)){const l=Re(c,Pe);for(const u of l)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[c]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const s=r.injections;if(s)for(let i in s)Qt(t,i,s[i],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(i=>{const a=this.getExternalGrammar(i);if(a){const c=a.injectionSelector;c&&Qt(t,c,a,this,a)}})}return t.sort((s,o)=>s.priority-o.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Kt(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=jn.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!t||t===yt.NULL){s=!0;const l=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=J.set(0,l.languageId,l.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null);let d;f?d=he.createRootAndLookUpScopeName(f,h,this):d=he.createRoot("unknown",h),t=new yt(null,this._rootId,-1,-1,!1,null,d,d)}else s=!1,t.reset();e=e+`
|
|
3
3
|
`;const o=this.createOnigString(e),i=o.content.length,a=new Ss(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Wn(this,o,s,0,t,a,!0,r);return Bn(o),{lineLength:i,lineTokens:a,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Kt(e,t){return e=Fr(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var he=class F{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,s=t?.scopePath??null;for(const o of n)s=Ye.push(s,o.scopeNames),r=new F(r,s,o.encodedTokenAttributes);return r}static createRoot(t,n){return new F(null,new Ye(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const s=r.getMetadataForScope(t),o=new Ye(null,t),i=r.themeProvider.themeMatch(o),a=F.mergeAttributes(n,s,i);return new F(null,o,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return F.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let s=-1,o=0,i=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,i=r.backgroundId),J.set(t,n.languageId,n.tokenType,null,s,o,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return F._pushAttributed(this,t,n);const r=t.split(/ /g);let s=this;for(const o of r)s=F._pushAttributed(s,o,n);return s}static _pushAttributed(t,n,r){const s=r.getMetadataForScope(n),o=t.scopePath.push(n),i=r.themeProvider.themeMatch(o),a=F.mergeAttributes(t.tokenAttributes,s,i);return new F(t,o,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?n.reverse():void 0}},yt=class X{constructor(t,n,r,s,o,i,a,c){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new X(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:X._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?he.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){X._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,s,o,i,a){return new X(this,t,n,r,s,o,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new X(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){const r=he.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new X(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,he.fromExtension(r,n.contentNameScopesList))}},Cs=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Re(n,Pe).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Re(n,Pe).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Ss=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=e?.getScopeNames()??[];for(const i of this._tokenTypeOverrides)i.matcher(o)&&(r=J.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=J.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}const n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},ks=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,s){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,bs(e,o,t,n,r,s,this,this._onigLib))}return this._grammars.get(e)}},xs=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new ks(Ne.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Ne.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,r){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(t,n,r){return this._loadGrammar(t,n,r.embeddedLanguages,r.tokenTypes,new Cs(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,s,o){const i=new Yr(this._syncRegistry,t);for(;i.Q.length>0;)i.Q.map(a=>this._loadSingleGrammar(a.scopeName)),i.processQueue();return this._grammarForScopeName(t,n,r,s,o)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,s=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,s)}_grammarForScopeName(t,n=0,r=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(t,n,r,s,o)}},bt=yt.NULL;function Te(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[s,o]of Object.entries(t?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function q(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function As(e){return Array.isArray(e)?e:[e]}async function Hn(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function De(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Es(e){return e==="ansi"||De(e)}function je(e){return e==="none"}function Is(e){return je(e)}const vs=/(\r?\n)/g;function Ue(e,t=!1){if(e.length===0)return[["",0]];const n=e.split(vs);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const i=t?n[o]+(n[o+1]||""):n[o];s.push([i,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}const Zt={light:"#333333",dark:"#bbbbbb"},Jt={light:"#fffffe",dark:"#1e1e1e"},Yt="__shiki_resolved";function Rt(e){if(e?.[Yt])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){const a=t.settings?t.settings.find(c=>!c.name&&!c.scope):void 0;a?.settings?.foreground&&(r=a.settings.foreground),a?.settings?.background&&(n=a.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Zt.light:Zt.dark),n||(n=t.type==="light"?Jt.light:Jt.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let s=0;const o=new Map;function i(a){if(o.has(a))return o.get(a);s+=1;const c=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${c}`]?i(a):(o.set(a,c),c)}t.settings=t.settings.map(a=>{const c=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),l=a.settings?.background&&!a.settings.background.startsWith("#");if(!c&&!l)return a;const u={...a,settings:{...a.settings}};if(c){const h=i(a.settings.foreground);t.colorReplacements[h]=a.settings.foreground,u.settings.foreground=h}if(l){const h=i(a.settings.background);t.colorReplacements[h]=a.settings.background,u.settings.background=h}return u});for(const a of Object.keys(t.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!t.colors[a]?.startsWith("#")){const c=i(t.colors[a]);t.colorReplacements[c]=t.colors[a],t.colors[a]=c}return Object.defineProperty(t,Yt,{enumerable:!1,writable:!1,value:!0}),t}async function qn(e){return[...new Set((await Promise.all(e.filter(t=>!Es(t)).map(async t=>await Hn(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Vn(e){return(await Promise.all(e.map(async t=>Is(t)?null:Rt(await Hn(t))))).filter(t=>!!t)}function Xn(e,t){if(!t)return e;if(t[e]){const n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new k(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Ns=class extends xs{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const t=Rt(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Ne.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Xn(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const t=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(s=>{this._alias[s]=e.name}),this._loadedLanguagesCache=null,t.size)for(const s of t)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const r of e)this.resolveEmbeddedLanguages(r);const t=[...this._langGraph.entries()],n=t.filter(([r,s])=>!s);if(n.length){const r=t.filter(([s,o])=>o?(o.embeddedLanguages||o.embeddedLangs)?.some(i=>n.map(([a])=>a).includes(i)):!1).filter(s=>!n.includes(s));throw new k(`Missing languages ${n.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(const[r,s]of t)this._resolver.addLanguage(s);for(const[r,s]of t)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const t=e.embeddedLanguages??e.embeddedLangs;if(t)for(const n of t)this._langGraph.set(n,this._langMap.get(n))}},Rs=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const s=t.slice(0,r).join(".");n=[...n,...this._injections.get(s)||[]]}return n}};let le=0;function $s(e){le+=1,e.warnings!==!1&&le>=10&&le%10===0&&console.warn(`[Shiki] ${le} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new k("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Rt),s=new Ns(new Rs(e.engine,n),r,n,e.langAlias);let o;function i(m){return Xn(m,e.langAlias)}function a(m){b();const _=s.getGrammar(typeof m=="string"?m:m.name);if(!_)throw new k(`Language \`${m}\` not found, you may need to load it first`);return _}function c(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};b();const _=s.getTheme(m);if(!_)throw new k(`Theme \`${m}\` not found, you may need to load it first`);return _}function l(m){b();const _=c(m);return o!==m&&(s.setTheme(_),o=m),{theme:_,colorMap:s.getColorMap()}}function u(){return b(),s.getLoadedThemes()}function h(){return b(),s.getLoadedLanguages()}function f(...m){b(),s.loadLanguages(m.flat(1))}async function d(...m){return f(await qn(m))}function p(...m){b();for(const _ of m.flat(1))s.loadTheme(_)}async function y(...m){return b(),p(await Vn(m))}function b(){if(t)throw new k("Shiki instance has been disposed")}function g(){t||(t=!0,s.dispose(),le-=1)}return{setTheme:l,getTheme:c,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:h,resolveLangAlias:i,loadLanguage:d,loadLanguageSync:f,loadTheme:y,loadThemeSync:p,dispose:g,[Symbol.dispose]:g}}async function Ls(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([Vn(e.themes||[]),qn(e.langs||[]),e.engine]);return $s({...e,themes:t,langs:n,engine:r})}const Qn=new WeakMap;function We(e,t){Qn.set(e,t)}function me(e){return Qn.get(e)}var ze=class Kn{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new Kn(Object.fromEntries(As(n).map(r=>[r,bt])),t)}constructor(...t){if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,s]=t;this.lang=r,this._stacks={[s]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Ps(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Ps(e){const t=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&t.push(o),s.parent&&r(s.parent)}return r(e),t}function Ts(e,t){if(!(e instanceof ze))throw new k("Invalid grammar state");return e.getInternalStack(t)}const Gs=/,/,Ms=/ /;function Zn(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(De(e.resolveLangAlias(n.lang||"text"))||je(r))return Ue(t).map(a=>[{content:a[0],offset:a[1]}]);const{theme:s,colorMap:o}=e.setTheme(r),i=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new k(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(s.name))throw new k(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Bs(t,i,s,o,n)}function Os(...e){if(e.length===2)return me(e[1]);const[t,n,r={}]=e,{lang:s="text",theme:o=t.getLoadedThemes()[0]}=r;if(De(s)||je(o))throw new k("Plain language does not have grammar state");if(s==="ansi")throw new k("ANSI language does not have grammar state");const{theme:i,colorMap:a}=t.setTheme(o),c=t.getLanguage(s);return new ze($t(n,c,i,a,r).stateStack,c.name,i.name)}function Bs(e,t,n,r,s){const o=$t(e,t,n,r,s),i=new ze(o.stateStack,t.name,n.name);return We(o.tokens,i),o.tokens}function $t(e,t,n,r,s){const o=Te(n,s),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:c=!1}=s,l=Ue(e);let u=s.grammarState?Ts(s.grammarState,n.name)??bt:s.grammarContextCode!=null?$t(s.grammarContextCode,t,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:bt,h=[];const f=[];for(let d=0,p=l.length;d<p;d++){const[y,b]=l[d];if(y===""){h=[],f.push([]);continue}if(i>0&&y.length>=i){h=[],f.push([{content:y,offset:b,color:"",fontStyle:0}]);continue}let g,m,_;c&&c!=="tokenType"&&(g=t.tokenizeLine(y,u,a),m=g.tokens,_=0);const C=t.tokenizeLine2(y,u,a),S=C.tokens.length/2;for(let v=0;v<S;v++){const $=C.tokens[2*v],O=v+1<S?C.tokens[2*v+2]:y.length;if($===O)continue;const ee=C.tokens[2*v+1],Qe=q(r[J.getForeground(ee)],o),Ke=J.getFontStyle(ee),B={content:y.substring($,O),offset:b+$,color:Qe,fontStyle:Ke};if(c==="tokenType")B.type=J.getTokenType(ee);else if(c){const Bt=[];if(c!=="scopeName")for(const D of n.settings){let te;switch(typeof D.scope){case"string":te=D.scope.split(Gs).map(Ze=>Ze.trim());break;case"object":te=D.scope;break;default:continue}Bt.push({settings:D,selectors:te.map(Ze=>Ze.split(Ms))})}B.explanation=[];let Ft=0;for(;$+Ft<O;){const D=m[_],te=y.substring(D.startIndex,D.endIndex);Ft+=te.length,B.explanation.push({content:te,scopes:c==="scopeName"?Fs(D.scopes):Ds(Bt,D.scopes)}),_+=1}}h.push(B)}f.push(h),h=[],u=C.ruleStack}return{tokens:f,stateStack:u}}function Fs(e){return e.map(t=>({scopeName:t}))}function Ds(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const o=t[r];n[r]={scopeName:o,themeMatches:Us(e,o,t.slice(0,r))}}return n}function en(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function js(e,t,n){if(!en(e.at(-1),t))return!1;let r=e.length-2,s=n.length-1;for(;r>=0&&s>=0;)en(e[r],n[s])&&(r-=1),s-=1;return r===-1}function Us(e,t,n){const r=[];for(const{selectors:s,settings:o}of e)for(const i of s)if(js(i,t,n)){r.push(o);break}return r}function Jn(e,t,n,r=Zn){const s=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),o=s.map(l=>{const u=r(e,t,{...n,theme:l.theme});return{tokens:u,state:me(u),theme:typeof l.theme=="string"?l.theme:l.theme.name}}),i=Ws(...o.map(l=>l.tokens)),a=i[0].map((l,u)=>l.map((h,f)=>{const d={content:h.content,variants:{},offset:h.offset};return"includeExplanation"in n&&n.includeExplanation&&(d.explanation=h.explanation),i.forEach((p,y)=>{const{content:b,explanation:g,offset:m,..._}=p[u][f];d.variants[s[y].color]=_}),d})),c=o[0].state?new ze(Object.fromEntries(o.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),o[0].state.lang):void 0;return c&&We(a,c),a}function Ws(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const s=e.map(c=>c[r]),o=t.map(()=>[]);t.forEach((c,l)=>c.push(o[l]));const i=s.map(()=>0),a=s.map(c=>c[0]);for(;a.every(c=>c);){const c=Math.min(...a.map(l=>l.content.length));for(let l=0;l<n;l++){const u=a[l];u.content.length===c?(o[l].push(u),i[l]+=1,a[l]=s[l][i[l]]):(o[l].push({...u,content:u.content.slice(0,c)}),a[l]={...u,content:u.content.slice(c),offset:u.offset+c})}}}return t}const zs=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],Hs=/["&'<>`]/g,qs=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Vs=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Xs=/[|\\{}()[\]^$+*?.]/g,tn=new WeakMap;function Qs(e,t){if(e=e.replace(t.subset?Ks(t.subset):Hs,r),t.subset||t.escapeOnly)return e;return e.replace(qs,n).replace(Vs,r);function n(s,o,i){return t.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,i.charCodeAt(o+2),t)}function r(s,o,i){return t.format(s.charCodeAt(0),i.charCodeAt(o+1),t)}}function Ks(e){let t=tn.get(e);return t||(t=Zs(e),tn.set(e,t)),t}function Zs(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(Xs,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const Js=/[\dA-Fa-f]/;function Ys(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!Js.test(String.fromCharCode(t))?r:r+";"}const eo=/\d/;function to(e,t,n){const r="&#"+String(e);return n&&t&&!eo.test(String.fromCharCode(t))?r:r+";"}const no=["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"],tt={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:"€"},ro=["cent","copy","divide","gt","lt","not","para","times"],Yn={}.hasOwnProperty,_t={};let Ce;for(Ce in tt)Yn.call(tt,Ce)&&(_t[tt[Ce]]=Ce);const so=/[^\dA-Za-z]/;function oo(e,t,n,r){const s=String.fromCharCode(e);if(Yn.call(_t,s)){const o=_t[s],i="&"+o;return n&&no.includes(o)&&!ro.includes(o)&&(!r||t&&t!==61&&so.test(String.fromCharCode(t)))?i:i+";"}return""}function io(e,t,n){let r=Ys(e,t,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=oo(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const o=to(e,t,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function ie(e,t){return Qs(e,Object.assign({format:io},t))}const ao=/^>|^->|<!--|-->|--!>|<!-$/g,co=[">"],lo=["<",">"];function uo(e,t,n,r){return r.settings.bogusComments?"<?"+ie(e.value,Object.assign({},r.settings.characterReferences,{subset:co}))+">":"<!--"+e.value.replace(ao,s)+"-->";function s(o){return ie(o,Object.assign({},r.settings.characterReferences,{subset:lo}))}}function ho(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const E=tr(1),er=tr(-1),fo=[];function tr(e){return t;function t(n,r,s){const o=n?n.children:fo;let i=(r||0)+e,a=o[i];if(!s)for(;a&&vt(a);)i+=e,a=o[i];return a}}const po={}.hasOwnProperty;function nr(e){return t;function t(n,r,s){return po.call(e,n.tagName)&&e[n.tagName](n,r,s)}}const Lt=nr({body:mo,caption:nt,colgroup:nt,dd:wo,dt:_o,head:nt,html:go,li:bo,optgroup:Co,option:So,p:yo,rp:nn,rt:nn,tbody:xo,td:rn,tfoot:Ao,th:rn,thead:ko,tr:Eo});function nt(e,t,n){const r=E(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&vt(r.value.charAt(0)))}function go(e,t,n){const r=E(n,t);return!r||r.type!=="comment"}function mo(e,t,n){const r=E(n,t);return!r||r.type!=="comment"}function yo(e,t,n){const r=E(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function bo(e,t,n){const r=E(n,t);return!r||r.type==="element"&&r.tagName==="li"}function _o(e,t,n){const r=E(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function wo(e,t,n){const r=E(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function nn(e,t,n){const r=E(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Co(e,t,n){const r=E(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function So(e,t,n){const r=E(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function ko(e,t,n){const r=E(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function xo(e,t,n){const r=E(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Ao(e,t,n){return!E(n,t)}function Eo(e,t,n){const r=E(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function rn(e,t,n){const r=E(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const Io=nr({body:Ro,colgroup:$o,head:No,html:vo,tbody:Lo});function vo(e){const t=E(e,-1);return!t||t.type!=="comment"}function No(e){const t=new Set;for(const r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}const n=e.children[0];return!n||n.type==="element"}function Ro(e){const t=E(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&vt(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function $o(e,t,n){const r=er(n,t),s=E(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Lt(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function Lo(e,t,n){const r=er(n,t),s=E(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Lt(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const Se={name:[[`
|
|
4
4
|
\f\r &/=>`.split(""),`
|