dskcode 0.1.47 → 0.1.48
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 +21 -24
- package/dist/{angular-ts-XKF3LV22.js → angular-ts-UGSD62EB.js} +2 -2
- package/dist/chunk-LG2AWYGC.js +12 -0
- package/dist/chunk-XAWVLVWL.js +2 -0
- package/dist/config-ui-LWC4GWEV.js +4 -0
- package/dist/{gdresource-4NUZ6YCX.js → gdresource-A6NTYFLM.js} +2 -2
- package/dist/index.js +117 -122
- package/dist/{mdc-ZOKCGRSD.js → mdc-BVI2JKDR.js} +2 -2
- package/dist/session-registry-HSCHBXFO.js +2 -0
- package/package.json +1 -5
- package/dist/chunk-V5VB2WRZ.js +0 -5
- package/dist/config-ui-JE4ZQLPC.js +0 -4
package/dist/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
3
|
-
`)?u.replace(/(\r?\n)/g,s+"$1"+o):u)+s};return
|
|
4
|
-
`,"utf8")}async function
|
|
5
|
-
`)}p();import{createInterface as
|
|
6
|
-
\u26A0 \u672A\u68C0\u6D4B\u5230 API Key \u914D\u7F6E`)),console.log(
|
|
7
|
-
`));let e=
|
|
8
|
-
\u26A0 \u672A\u68C0\u6D4B\u5230\u706B\u5C71 ASR \u51ED\u636E`)),console.log(
|
|
9
|
-
`)),console.log(
|
|
10
|
-
`));let e=
|
|
11
|
-
`));return}if(await
|
|
12
|
-
\u2726 \u68C0\u6D4B\u5230\u4F60\u5728 Claude Code \u4E2D\u5B89\u88C5\u4E86 ${String(n.length)} \u4E2A skill\uFF1A`));let r=n.slice(0,5).map(s=>
|
|
13
|
-
`);if(console.log(r),n.length>5&&console.log(
|
|
14
|
-
`)),!await
|
|
15
|
-
`));return}try{let{imported:s,skipped:i}=await
|
|
16
|
-
`))}}async function
|
|
17
|
-
`)}function
|
|
18
|
-
`)){if(r.length===0){n.push("");continue}let o=
|
|
19
|
-
`).filter(
|
|
20
|
-
`),n=[],r="";function o(){r&&(n.push({text:r,type:"plain"}),r="")}for(let s=0;s<t.length;s++){let i=t[s]??"";if(
|
|
2
|
+
import{a as kn,b as ka,c as tn,d as Yn,e as kt,f as Sa,h as Ta}from"./chunk-V3LN4R4P.js";import{a as nd}from"./chunk-KMMG6QC6.js";import{a as Oe,b as Qn,c as Ca}from"./chunk-5Z3DMHRQ.js";import{a as td}from"./chunk-MDFCAIOB.js";import{a as ga,b as ya,c as Lt,d as xa,e as Yu,f as ba,g as wa,i as en}from"./chunk-LG2AWYGC.js";import{a as Qu,b as ed,c as as,f as ls}from"./chunk-O3L436MU.js";import{a as is}from"./chunk-XAWVLVWL.js";import{a as Ag,b as Zu,c as Eg,d as p}from"./chunk-LPD7BHH5.js";var ip=Ag((XR,sp)=>{"use strict";p();var nl,{defineProperty:wx,getPrototypeOf:kx,setPrototypeOf:op,create:Sx,keys:Tx}=Object,st="",{round:Ts,max:Cx}=Math,rl=e=>{let t=/([a-f\d]{3,6})/i.exec(e)?.[0],n=t?.length,r="0x"+(6^n?3^n?"0":t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t)|0;return[r>>16,r>>8&255,255&r]},ep=e=>{if(8>e)return 30+e;if(16>e)return 82+e;if(e>231)return e>243?37:30;let t=(e-=16)%36,n=e/36|0,r=t/6|0,o=t%6;return 30+(n>2|(r>2)<<1|(o>2)<<2)+(Cx(n,r,o)>4?60:0)},tp={open:st,close:st},np=(e,{open:t="",close:n="",f:r})=>{let o=(e.open||st)+t,s=n+(e.close||st),i=(a,...l)=>{if(!a){if(!n)return t;if((a??st)===st)return st}let c,u=r?r(a,...l):a.raw?String.raw({raw:a},...l):st+a,d=i;if(u.includes("\x1B"))for(;d=d.p;){let{t:m,o:h}=d,f=h.length,g=st,b=0;if(f)for(;~(c=u.indexOf(h,b));b=c+f)g+=u.slice(b,c)+m;u=g+u.slice(b)}return o+(u.includes(`
|
|
3
|
+
`)?u.replace(/(\r?\n)/g,s+"$1"+o):u)+s};return op(i,kx(e)).p={t,o:n,p:e.p},i.open=o,i.close=s,i},rp=new function e(t=globalThis){let n=typeof t=="number"?t:(_=>{let E=_.process??{},M=E.argv??[],U=E.env??{},T=0;try{T=((le,ee,W)=>(nl=ee.TERM,{"24bit":3,truecolor:3,ansi256:2,ansi:1}[ee.COLORTERM]||(ee.CI?/,GITHUB/.test(W)?3:1:(ee.PM2_HOME||/edge/.test(ee.NEXT_RUNTIME)||le.stdout?.isTTY)&&nl!=="dumb"?le.platform==="win32"?3:/-256/.test(nl)?2:1:0)))(E,U,","+Tx(U).join(","))}catch{U={}}let N,F=T||1,q="FORCE_COLOR",$={false:0,0:0,1:1,2:2,3:3}[U[q]]??F,oe=-1;for(N of M)/^--color=?(true|always)?$/.test(N)&&(oe=F),/^--(no-color|color=(false|never))$/.test(N)&&(oe=0);return _.window?.chrome?3:q in U?$:~oe?oe:U.NO_COLOR?0:T})(t),r={},o={Ansis:e,level:n,isSupported:()=>l,strip:_=>_.replace(/][^]*|[][[()#;?]*(?:\d+(?:;\d*)*)?[\dA-ORZcf-nqry=><]/g,st),extend(_){for(let E in _){let M=_[E];(typeof M)[0]==="s"&&(s(u(E),w(...rl(M))),M=b(...rl(M))),s(E,M)}return op(o,Sx({},r))}},s=(_,E)=>{r[_]={get(){return wx(this,_,{value:E.call?(...M)=>np(this,E(...M)):np(this,E)})[_]}}},i=1^n,a=n>2,l=n>0,c=(_,E)=>l?{open:`\x1B[${_}m`,close:E?`\x1B[${E}m`:st}:tp,u=_=>"bg"+_[0].toUpperCase()+_.slice(1),d=_=>E=>_(...rl(E)),m=(_,E)=>(M,U,T)=>c(`${_}8;2;${M};${U};${T}`,E),h=_=>(E,M,U)=>_(((T,N,F)=>T^N|N^F?16+36*Ts(T/51)+6*Ts(N/51)+Ts(F/51):8>T?16:T>248?231:Ts(24*(T-8)/247)+232)(E,M,U)),f=_=>c(i?"38;5;"+_:ep(_),39),g=_=>c(i?"48;5;"+_:ep(_)+10,49),b=a?m(3,39):h(f),w=a?m(4,49):h(g),S={fg:f,bg:g,rgb:b,bgRgb:w,hex:d(b),bgHex:d(w),visible:tp,reset:c(0,st),bold:c(1,22),dim:c(2,22),italic:c(3,23),underline:c(4,24),inverse:c(7,27),hidden:c(8,28),strikethrough:c(9,29),link:{f:(_,E=_)=>l?`\x1B]8;;${_}\x07${E}\x1B]8;;\x07`:E!=_?E+` (\u200B${_}\u200B)`:_}},v=(_,E)=>{S[_]=c(E,39),S[u(_)]=c(E+10,49)};return"gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((_,E)=>{E?v(_+"Bright",89+E):E=61,v(_,29+E)})),o.extend(S)};sp.exports=rp.default=rp});p();p();import{Command as KC}from"commander";import{useEffect as XC,useState as cg}from"react";p();p();p();import{mkdir as Ig,readFile as Pg,writeFile as Lg}from"fs/promises";import{dirname as $g}from"path";function cs(e){let t=process.env.VOLC_ASR_APP_ID?.trim(),n=process.env.VOLC_ASR_ACCESS_KEY?.trim(),r=t||e?.appId||"",o=n||e?.accessKey||"",s={appId:t?"env":e?.appId?"settings":"missing",accessKey:n?"env":e?.accessKey?"settings":"missing"},i=[];return r||i.push("appId"),o||i.push("accessKey"),{resolved:i.length===0,missing:i.length>0?i:void 0,source:s,config:{appId:r,accessKey:o,resourceId:e?.resourceId??"volc.bigasr.sauc.duration",language:e?.language??"zh-CN",sampleRate:e?.sampleRate??16e3,enabled:e?.enabled??!0}}}async function _a(e,t,n,r){let o={};try{let i=await Pg(e,"utf8"),a=JSON.parse(i);a&&typeof a=="object"&&(o=a)}catch(i){if(i.code!=="ENOENT")throw i}let s=o.voice??{appId:"",accessKey:""};o.voice={...s,appId:t,accessKey:n,resourceId:r?.resourceId??s.resourceId??"volc.bigasr.sauc.duration",language:r?.language??s.language??"zh-CN",enabled:s.enabled??!0},await Ig($g(e),{recursive:!0}),await Lg(e,JSON.stringify(o,null,2)+`
|
|
4
|
+
`,"utf8")}async function rd(){let e=this.optsWithGlobals(),t=e.verbose??!1,n,r=[];try{let o=await Lt(e.config);if(n=o.config,o.errors.length>0)for(let s of o.errors)r.push(s.message)}catch{n=structuredClone(ga)}if(n=ya(n,{verbose:t,model:e.model}),r.length>0&&t)for(let o of r)console.error(` \u26A0 ${o}`);return{config:n,verbose:t}}p();import ve from"chalk";function od(e){let t=[];t.push(""),t.push(ve.bold("\u7528\u6CD5:")),t.push(` ${ve.cyan("dskcode")} ${ve.dim("[global-options]")} ${ve.green("<command>")} ${ve.dim("[options]")}`),t.push("");let n=e.options.filter(o=>o.long!=="--help"&&o.long!=="--version"&&o.long!=="--config");if(n.length>0){t.push(ve.bold("\u5168\u5C40\u9009\u9879:"));for(let o of n){let s=[o.short,o.long].filter(Boolean).join(", ");t.push(` ${ve.cyan(s.padEnd(24))} ${o.description??""}`)}t.push("")}t.push(ve.bold("\u5185\u7F6E\u9009\u9879:"));for(let o of["-h, --help","-V, --version"]){let s=e.options.find(i=>i.long===(o.includes("help")?"--help":"--version"));s&&t.push(` ${ve.cyan(o.padEnd(24))} ${s.description??""}`)}t.push("");let r=e.commands.filter(o=>!o.name().startsWith("help"));if(r.length>0){t.push(ve.bold("\u547D\u4EE4:"));for(let o of r)t.push(` ${ve.green(o.name().padEnd(24))} ${o.description()}`);t.push("")}return t.push(ve.bold("\u793A\u4F8B:")),t.push(` ${ve.dim("# \u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD(\u65E0\u53C2\u9ED8\u8BA4\u884C\u4E3A)")}`),t.push(" dskcode"),t.push(` ${ve.dim("# \u8BA9 AI \u6267\u884C\u4E00\u4E2A\u4EFB\u52A1")}`),t.push(" dskcode run \u4FEE\u6539\u6240\u6709 TODO \u6CE8\u91CA"),t.push(` ${ve.dim("# \u8FD0\u884C\u914D\u7F6E\u5411\u5BFC")}`),t.push(" dskcode setup"),t.push(` ${ve.dim("# \u751F\u6210 shell \u81EA\u52A8\u8865\u5168")}`),t.push(" dskcode completion"),t.push(` ${ve.dim("# \u67E5\u770B\u81EA\u9009\u80A1\u884C\u60C5")}`),t.push(" dskcode stock"),t.push(` ${ve.dim("# \u67E5\u770B\u6307\u5B9A\u80A1\u7968\u884C\u60C5")}`),t.push(" dskcode stock sh513090 sz000001"),t.push(""),t.join(`
|
|
5
|
+
`)}p();import{createInterface as sd}from"readline";import me from"chalk";function id(e){return!!(e.some(t=>t.apiKey)||process.env.DEEPSEEK_API_KEY)}var va=10;async function ad(){console.log(me.yellow(`
|
|
6
|
+
\u26A0 \u672A\u68C0\u6D4B\u5230 API Key \u914D\u7F6E`)),console.log(me.dim(" \u4F60\u53EF\u4EE5\u901A\u8FC7\u4EE5\u4E0B\u4EFB\u4E00\u65B9\u5F0F\u914D\u7F6E\uFF1A")),console.log(me.dim(" \xB7 \u73AF\u5883\u53D8\u91CF: export DEEPSEEK_API_KEY=sk-xxx")),console.log(me.dim(" \xB7 \u914D\u7F6E\u6587\u4EF6: ~/.dskcode/settings.json")),console.log(me.dim(` \xB7 \u4E0B\u9762\u76F4\u63A5\u8F93\u5165\uFF0C\u81EA\u52A8\u4FDD\u5B58\u5230\u5168\u5C40\u914D\u7F6E
|
|
7
|
+
`));let e=sd({input:process.stdin,output:process.stdout});return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,process.stdin.removeListener("keypress",o),e.close())},o=(s,i)=>{i.ctrl&&i.name==="c"&&(r(),t(null))};process.stdin.on("keypress",o),e.question(` ${me.cyan("\u{1F511}")} ${me.bold("\u8BF7\u8F93\u5165\u4F60\u7684 DeepSeek API Key:")} `,s=>{r();let i=s.trim();if(!i){console.log(me.red(" \u2716 API Key \u4E0D\u80FD\u4E3A\u7A7A")),t(null);return}if(i.length<va){console.log(me.red(" \u2716 API Key \u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u957F\u5EA6\u81F3\u5C11 10 \u4F4D")),t(null);return}t(i)})})}async function ld(){console.log(me.yellow(`
|
|
8
|
+
\u26A0 \u672A\u68C0\u6D4B\u5230\u706B\u5C71 ASR \u51ED\u636E`)),console.log(me.dim(" \u4F60\u53EF\u4EE5\u901A\u8FC7\u4EE5\u4E0B\u4EFB\u4E00\u65B9\u5F0F\u914D\u7F6E\uFF1A")),console.log(me.dim(" \xB7 \u73AF\u5883\u53D8\u91CF: export VOLC_ASR_APP_ID=... VOLC_ASR_ACCESS_KEY=...")),console.log(me.dim(" \xB7 \u914D\u7F6E\u6587\u4EF6: ~/.dskcode/settings.json \u7684 voice \u6BB5")),console.log(me.dim(` \xB7 \u4E0B\u9762\u76F4\u63A5\u8F93\u5165\uFF0C\u81EA\u52A8\u4FDD\u5B58\u5230\u5168\u5C40\u914D\u7F6E
|
|
9
|
+
`)),console.log(me.dim(` \u51ED\u636E\u83B7\u53D6\u8DEF\u5F84\uFF1A\u706B\u5C71\u63A7\u5236\u53F0 \u2192 \u8BED\u97F3\u6280\u672F \u2192 \u6211\u7684\u5E94\u7528
|
|
10
|
+
`));let e=sd({input:process.stdin,output:process.stdout});return new Promise(t=>{let n=!1,r=()=>{n||(n=!0,process.stdin.removeListener("keypress",o),e.close())},o=(s,i)=>{i.ctrl&&i.name==="c"&&(r(),t(null))};process.stdin.on("keypress",o),e.question(` ${me.cyan("\u{1F194}")} ${me.bold("\u8BF7\u8F93\u5165 APP ID\uFF08\u7EAF\u6570\u5B57\uFF09:")} `,s=>{let i=s.trim();if(!/^\d+$/.test(i)){r(),console.log(me.red(" \u2716 APP ID \u5FC5\u987B\u662F\u7EAF\u6570\u5B57")),t(null);return}e.question(` ${me.cyan("\u{1F511}")} ${me.bold("\u8BF7\u8F93\u5165 Access Key:")} `,a=>{r();let l=a.trim();if(l.length<va){console.log(me.red(` \u2716 Access Key \u957F\u5EA6\u81F3\u5C11 ${va} \u4F4D`)),t(null);return}t({appId:i,accessKey:l})})})})}p();import{createInterface as Og}from"readline";import{existsSync as $t,statSync as er,lstatSync as Dg}from"fs";import{mkdir as Ng,readdir as tr,cp as Mg,access as Bg,realpath as Fg,readFile as Gg}from"fs/promises";import{join as Ke}from"path";import qe from"chalk";function Ra(){let e=process.env.HOME??process.env.USERPROFILE??"~";return Ke(e,".claude","skills")}function nr(){return Qu()}async function rr(e){try{return await Bg(Ke(e,"SKILL.md")),!0}catch{return!1}}async function jg(){let e=Ra();if(!$t(e))return[];let t;try{t=await tr(e)}catch{return[]}let n=[];for(let r of t){let o=Ke(e,r);er(o).isDirectory()&&await rr(o)&&n.push(r)}return n}function Ug(e){let t=Og({input:process.stdin,output:process.stdout});return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,process.stdin.removeListener("keypress",s),t.close())},s=(i,a)=>{a.ctrl&&a.name==="c"&&(o(),n(!1))};process.stdin.on("keypress",s),t.question(e,i=>{o();let a=i.trim().toLowerCase();n(a==="y"||a==="yes")})})}async function Wg(e){let t=Ra(),n=nr();await Ng(n,{recursive:!0});let r=[],o=[];for(let s of e){let i=Ke(t,s),a=Ke(n,s);if($t(a)){o.push(s);continue}let l=Dg(i).isSymbolicLink()?await Fg(i):i;await Mg(l,a,{recursive:!0,dereference:!0}),r.push(s)}return{imported:r,skipped:o}}async function ud(){let e=nr();if(!$t(e))return 0;let t;try{t=await tr(e)}catch{return 0}let n=0;for(let r of t){let o=Ke(e,r);er(o).isDirectory()&&await rr(o)&&n++}return n}function Aa(e){return ed(e)}async function Hg(e){return await Ea(e)>0}async function Ea(e){let t=Aa(e);if(!$t(t))return 0;let n;try{n=await tr(t)}catch{return 0}let r=0;for(let o of n){let s=Ke(t,o);er(s).isDirectory()&&await rr(s)&&r++}return r}async function Vg(){let e=nr();if(!$t(e))return!1;let t;try{t=await tr(e)}catch{return!1}for(let n of t){let r=Ke(e,n);if(er(r).isDirectory()&&await rr(r))return!0}return!1}async function dd(e){if(e&&await Hg(e)){console.log(qe.dim(` \u68C0\u6D4B\u5230\u9879\u76EE\u672C\u5730 .dskcode/skill\uFF0C\u8DF3\u8FC7\u5BFC\u5165 Claude Code skill
|
|
11
|
+
`));return}if(await Vg())return;let n=await jg();if(n.length===0)return;console.log(qe.cyan(`
|
|
12
|
+
\u2726 \u68C0\u6D4B\u5230\u4F60\u5728 Claude Code \u4E2D\u5B89\u88C5\u4E86 ${String(n.length)} \u4E2A skill\uFF1A`));let r=n.slice(0,5).map(s=>qe.dim(` \xB7 ${s}`)).join(`
|
|
13
|
+
`);if(console.log(r),n.length>5&&console.log(qe.dim(` \xB7 ...\u7B49 ${String(n.length)} \u4E2A`)),console.log(qe.dim(` \u6E90\u76EE\u5F55: ${Ra()}`)),console.log(qe.dim(` \u76EE\u6807\u76EE\u5F55: ${nr()}
|
|
14
|
+
`)),!await Ug(` ${qe.cyan("\u{1F4E6}")} \u662F\u5426\u5C06\u8FD9\u4E9B skill \u5BFC\u5165\u5230 dskcode\uFF1F${qe.dim("[y/N] ")} `)){console.log(qe.dim(` \u5DF2\u8DF3\u8FC7 skill \u5BFC\u5165
|
|
15
|
+
`));return}try{let{imported:s,skipped:i}=await Wg(n);s.length>0&&console.log(qe.green(` \u2714 \u5DF2\u5BFC\u5165 ${String(s.length)} \u4E2A skill \u5230 ~/.dskcode/skills`)),i.length>0&&console.log(qe.yellow(` \u26A0 ${String(i.length)} \u4E2A skill \u5DF2\u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${i.join(", ")}`)),console.log("")}catch(s){console.log(qe.red(` \u2716 \u5BFC\u5165 skill \u5931\u8D25: ${s instanceof Error?s.message:String(s)}`)),console.log(qe.dim(` \u4F60\u53EF\u4EE5\u7A0D\u540E\u624B\u52A8\u590D\u5236 ~/.claude/skills \u5230 ~/.dskcode/skills
|
|
16
|
+
`))}}async function zg(){let e=nr();if(!$t(e))return[];let t;try{t=await tr(e)}catch{return[]}let n=[];for(let r of t){let o=Ke(e,r);er(o).isDirectory()&&await rr(o)&&n.push(r)}return n}async function qg(e){let t=Aa(e);if(!$t(t))return[];let n;try{n=await tr(t)}catch{return[]}let r=[];for(let o of n){let s=Ke(t,o);er(s).isDirectory()&&await rr(s)&&r.push(o)}return r}async function cd(e){try{let n=(await Gg(Ke(e,"SKILL.md"),"utf-8")).match(/^---\n([\s\S]*?)\n---/);if(!n)return null;let r=n[1],o=r.match(/^name:\s*(.+)$/m),s=r.match(/^description:\s*(.+)$/m);return{name:o?.[1]?.trim()??"",description:s?.[1]?.trim()??""}}catch{return null}}async function pd(e){let[t,n]=await Promise.all([zg(),qg(e)]),r=new Set,o=[];for(let l of[...n,...t])r.has(l)||(r.add(l),o.push(l));let s=nr(),i=Aa(e),a=[];for(let l of o){let c=Ke(i,l),u=null;if($t(c)&&(u=await cd(c)),!u){let d=Ke(s,l);$t(d)&&(u=await cd(d))}a.push(u??{name:l,description:""})}return a}import{readFile as JC}from"fs/promises";import{join as dg}from"path";p();p();import{render as Kg}from"ink";function Fr(e){let{waitUntilExit:t,clear:n,unmount:r}=Kg(e,{exitOnCtrlC:!1});return{waitUntilExit:t(),clear:n,unmount:r}}p();import{Text as nv}from"ink";import ov from"ink-spinner";import{jsx as av,jsxs as lv}from"react/jsx-runtime";p();import{Box as dv,Text as pv}from"ink";import{jsxs as hv}from"react/jsx-runtime";p();import{Box as xv,Text as bv}from"ink";import{useEffect as kv,useState as Sv}from"react";import{jsx as _v}from"react/jsx-runtime";var Gr=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Ia=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557"," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D"," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2554\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557 "," \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D"];p();import{Box as H,Text as G,useInput as WT,Static as HT}from"ink";import{useEffect as Se,useState as z,useCallback as ct,useMemo as Th,useRef as ae}from"react";p();import{useState as Xg,useCallback as Jg,useEffect as Zg,useRef as fd}from"react";var Yg=1500;function Sn(e){let[t,n]=Xg(!1),r=fd(null),o=fd(e);o.current=e,Zg(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Jg(()=>{if(t){o.current();return}n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},Yg)},[t]);return{doubleCtrlC:t,handleCtrlC:s}}import VT from"ink-spinner";p();import{Box as Tt,Text as Ot}from"ink";import{useEffect as Ey,useRef as _d,useState as vd}from"react";p();import{mkdir as Qg,readFile as ey,writeFile as ty}from"fs/promises";import{join as Pa}from"path";var Me=class e{static#e=new Set;static async flushAll(){await Promise.allSettled([...e.#e].map(t=>t.flush()))}#n;#r;#s;#t;#c;#p;#i=[];#d;#o;#a=!1;#m=!1;constructor(t={}){let n=process.env.HOME??process.env.USERPROFILE??"~";this.#n=t.costDir??Pa(n,".dskcode","costs"),this.#r=t.budgetLimit??0,this.#s=t.tokenBudgetLimit??0,this.#t=t.onBudgetExceeded,this.#c=md(),this.#p=new Date().toISOString();let r=La();this.#d=r,this.#o=hd(r),e.#e.add(this)}record(t,n){let r=kt(t,n),o={timestamp:new Date().toISOString(),model:n,usage:{...t},cost:{...r}};return this.#i.push(o),this.#f(),this.#u(o),this.#a=!0,this.#x(),r}get sessionId(){return this.#c}get records(){return this.#i}get sessionSummary(){let t=0,n=0,r=0,o=0;for(let s of this.#i)t+=s.usage.promptTokens,n+=s.usage.completionTokens,r+=s.usage.cachedPromptTokens??0,o+=s.cost.totalCost;return{sessionId:this.#c,startedAt:this.#p,totalPromptTokens:t,totalCompletionTokens:n,totalCachedTokens:r,totalCost:o,records:[...this.#i]}}get sessionTotalCost(){return this.#i.reduce((t,n)=>t+n.cost.totalCost,0)}get sessionPromptTokens(){return this.#i.reduce((t,n)=>t+n.usage.promptTokens,0)}get sessionCompletionTokens(){return this.#i.reduce((t,n)=>t+n.usage.completionTokens,0)}get sessionCallCount(){return this.#i.length}get todaySummary(){return this.#f(),{...this.#o}}get todayTotalCost(){return this.#f(),this.#o.totalCost}get todayCallCount(){return this.#f(),this.#o.totalCalls}get isBudgetExceeded(){return this.#r>0&&this.todayTotalCost>=this.#r||this.#s>0&&this.#o.totalPromptTokens+this.#o.totalCompletionTokens>=this.#s}get remainingBudget(){return this.#r<=0?1/0:Math.max(0,this.#r-this.todayTotalCost)}async load(){await this.#g();let t=await this.#h(),n=La();t.daily[n]&&(this.#o=t.daily[n],this.#d=n)}async flush(){if(!(!this.#a||this.#m)){this.#m=!0,this.#a=!1;try{await this.#g(),await this.#l()}catch(t){this.#a=!0,console.error("[CostTracker] flush \u5931\u8D25:",t)}finally{this.#m=!1}}}async queryRange(t,n){let r=await this.#h(),o=n??t,s=[];for(let[i,a]of Object.entries(r.daily))i>=t&&i<=o&&s.push(a);return s.sort((i,a)=>i.date.localeCompare(a.date)),s}resetSession(){this.#c=md(),this.#p=new Date().toISOString(),this.#i.length=0}async dispose(){e.#e.delete(this),await this.flush()}#f(){let t=La();t!==this.#d&&(this.#d=t,this.#o=hd(t),this.#a=!0)}#u(t){this.#o.totalPromptTokens+=t.usage.promptTokens,this.#o.totalCompletionTokens+=t.usage.completionTokens,this.#o.totalCachedTokens+=t.usage.cachedPromptTokens??0,this.#o.totalCost+=t.cost.totalCost,this.#o.totalCalls+=1;let n=t.model;this.#o.byModel[n]||(this.#o.byModel[n]={model:t.model,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0});let r=this.#o.byModel[n];r.totalPromptTokens+=t.usage.promptTokens,r.totalCompletionTokens+=t.usage.completionTokens,r.totalCachedTokens+=t.usage.cachedPromptTokens??0,r.totalCost+=t.cost.totalCost,r.totalCalls+=1}#x(){this.isBudgetExceeded&&this.#t?.(this)}async#h(){let t=Pa(this.#n,"history.json");try{let n=await ey(t,"utf-8");return JSON.parse(n)}catch{return{version:1,daily:{}}}}async#g(){await Qg(this.#n,{recursive:!0})}async#l(){let t=await this.#h();t.daily[this.#d]=this.#o;let n=ny(90),r=Object.keys(t.daily).filter(s=>s<n);for(let s of r)delete t.daily[s];let o=Pa(this.#n,"history.json");await ty(o,JSON.stringify(t,null,2),"utf-8")}};function md(){let e=Date.now().toString(36),t=Math.random().toString(36).slice(2,8);return`${e}-${t}`}function La(){return new Date().toISOString().slice(0,10)}function ny(e){let t=new Date;return t.setDate(t.getDate()-e),t.toISOString().slice(0,10)}function hd(e){return{date:e,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0,byModel:{}}}function $a(e){return`\xA5${e.toFixed(4)}`}p();import{Box as Ur,Text as St}from"ink";p();var ry=new Set(["password","token","apikey","api_key","secret","authorization","auth","credential","credentials","private_key","privatekey"]);function us(e,t){if(!yd(t))return`${e}()`;switch(e){case"read_file":return`${e}(path=${rt(t.path)})`;case"write_file":return`${e}(path=${rt(t.path)})`;case"edit_file":return`${e}(path=${rt(t.path)}, old_text=${rt(t.old_text,30)})`;case"multi_edit":{let s=Array.isArray(t.edits)?t.edits.length:0;return`${e}(path=${rt(t.path)}, edits=${s})`}case"delete_range":return`${e}(path=${rt(t.path)})`;case"bash":return`${e}(command=${rt(t.command,60)})`;case"ls":return`${e}(path=${rt(t.path??".")})`;case"glob":return`${e}(pattern=${rt(t.pattern)})`;case"grep":return`${e}(pattern=${rt(t.pattern)}, path=${rt(t.path??".")})`;case"fetch":return`${e}(url=${rt(t.url,60)})`;default:let n=Object.keys(t);if(n.length===0)return`${e}()`;let r=n.slice(0,4).map(s=>`${s}=\u2026`).join(", "),o=n.length>4?`, +${n.length-4}`:"";return`${e}(${r}${o})`}}function jr(e){return Oa(e,new WeakSet)}function Oa(e,t){if(e==null||typeof e!="object")return e;let n=e;if(t.has(n))return"****";if(t.add(n),Array.isArray(e))return e.map(o=>Oa(o,t));let r={};for(let[o,s]of Object.entries(n))ry.has(o.toLowerCase())?r[o]="****":r[o]=Oa(s,t);return r}function gd(e,t={}){let n=t.valueMaxLen??80,r=t.maskSensitive!==!1,o=t.maxKeys??6;if(!yd(e))return Da(e,n);let s=r?jr(e):e,i=Object.entries(s),l=i.slice(0,o).map(([c,u])=>`${c}: ${Da(u,n)}`);return i.length>o&&l.push(`+${i.length-o} more`),l.join(`
|
|
17
|
+
`)}function Da(e,t=80){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"\u2026":e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length<=3?JSON.stringify(e):`[\u2026${e.length} items\u2026]`;if(typeof e=="object"){let n=e,r=Object.keys(n);return r.length<=3?JSON.stringify(n):`{\u2026${r.length} keys\u2026}`}return JSON.stringify(e)}function rt(e,t=40){return e==null?String(e):typeof e!="string"?Da(e,t):e.length===0?"(\u7A7A)":e.length>t?e.slice(0,t-1)+"\u2026":e}function yd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}p();function or(e){if(e===""||e===void 0||e===null)return{ok:!0,args:{},fixed:""};try{return{ok:!0,args:JSON.parse(e),fixed:e}}catch(t){let n=oy(e);try{return{ok:!0,args:JSON.parse(n),fixed:n}}catch{let o=t instanceof Error?t.message:String(t);return sy(o,e)?{ok:!1,reason:"PARTIAL",partial:e,hint:"\u53C2\u6570 JSON \u5C1A\u672A\u6536\u5168\uFF0C\u6D41\u5F0F\u62FC\u63A5\u4E2D\uFF1B\u53EF\u80FD\u662F\u7F51\u7EDC/\u5FC3\u8DF3\u5BFC\u81F4\u534A\u622A"}:{ok:!1,reason:"INVALID_JSON",raw:e,error:o}}}}function oy(e){let t=e.length,n=0;for(let a=e.length-1;a>=0&&e[a]==="\\";a--)n++;n%2===1&&t--;let r=e.slice(0,t),o=[],s=!1,i=!1;for(let a=0;a<r.length;a++){let l=r[a];if(i){i=!1;continue}if(l==="\\"){i=!0;continue}if(l==='"'){s=!s;continue}s||(l==="{"?o.push("}"):l==="["?o.push("]"):(l==="}"||l==="]")&&o.pop())}for(s&&(r+='"');o.length>0;)r+=o.pop();return r}function sy(e,t){return!!(e.includes("Unexpected end of JSON")||e.includes("Unterminated string")||t.length<5)}import{jsx as Na,jsxs as Xe}from"react/jsx-runtime";function Ma({call:e,parsedArgs:t,schemaIssues:n,denial:r}){let o=t??ly(e.arguments),s=jr(o),i=us(e.name,s),a=gd(s);return Xe(Ur,{flexDirection:"column",marginLeft:3,marginTop:1,children:[Xe(Ur,{children:[Xe(St,{dimColor:!0,children:["\u{1F4E6} ",e.name]}),Xe(St,{dimColor:!0,children:[" ","\u2500".repeat(Math.max(1,30-e.name.length))]})]}),Xe(Ur,{flexDirection:"column",marginLeft:2,children:[Na(St,{dimColor:!0,children:i}),Na(St,{dimColor:!0,children:a})]}),n&&n.length>0&&Xe(Ur,{flexDirection:"column",marginLeft:2,children:[Xe(St,{color:"yellow",children:["\u26A0 schema \u95EE\u9898\uFF08",n.length,"\uFF09"]}),n.slice(0,3).map((l,c)=>Xe(St,{color:"yellow",children:[" - ",l.message]},c)),n.length>3&&Xe(St,{color:"yellow",children:[" ...\u8FD8\u6709 ",n.length-3," \u6761"]})]}),r&&Na(iy,{denial:r})]})}function iy({denial:e}){let t=ay[e.source]??e.source,n=e.source==="hardcoded_blacklist"?"\u{1F6AB}":"\u{1F6D1}";return Xe(Ur,{flexDirection:"column",marginLeft:2,marginTop:1,borderStyle:"round",borderColor:"red",paddingX:1,children:[Xe(St,{color:"red",bold:!0,children:[n," \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\uFF08",t,"\uFF09"]}),Xe(St,{color:"red",children:[" \u539F\u56E0\uFF1A",e.reason]}),e.hint&&Xe(St,{color:"yellow",children:[" \u63D0\u793A\uFF1A",e.hint]})]})}var ay={hardcoded_blacklist:"\u786C\u7F16\u7801\u5B89\u5168\u89C4\u5219",permission_rule:"\u7528\u6237\u914D\u7F6E\u89C4\u5219",user_prompt:"\u7528\u6237\u624B\u52A8\u62D2\u7EDD"};function ly(e){if(!e)return{};let t=or(e);return t.ok?t.args:{}}p();import{Box as ds,Text as Le}from"ink";p();function xd(e){return e>=4352&&e<=4447||e===9001||e===9002||e>=11904&&e<=42191||e>=43360&&e<=43391||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65040&&e<=65055||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126976&&e<=131071||e>=12288&&e<=12351||e>=131072&&e<=196607?2:e<32||e>=127&&e<160?0:1}function Wr(e){let t=0;for(let n of e){let r=n.codePointAt(0);r!==void 0&&r!==8205&&(r>=65024&&r<=65039||(t+=xd(r)))}return t}function*cy(e){for(let t of e){let n=t.codePointAt(0);n!==void 0&&n!==8205&&(n>=65024&&n<=65039||(yield{ch:t,width:xd(n)}))}}function uy(e,t){if(t<=0)return[e];let n=[];for(let r of e.split(`
|
|
18
|
+
`)){if(r.length===0){n.push("");continue}let o=dy(r,t);for(let s of o)n.push(s)}return n.length===0?[""]:n}function dy(e,t){if(Wr(e)<=t)return[e];let n=[],r="",o=0,s=-1,i=0;for(let{ch:a,width:l}of cy(e)){if(a===" "||a===" "){s=r.length,i=o+l,r+=a,o+=l;continue}if(o+l>t)if(s>0){let c=r.slice(0,s).replace(/[ \t]+$/,"");n.push(c),r=r.slice(s).replace(/^[ \t]+/,"")+a,o=Wr(r),s=-1,i=0}else n.push(r),r=a,o=l;else r+=a,o+=l}return r.length>0&&n.push(r),n}function py(e,t,n){return e.map((r,o)=>{let s=t[o]??3;return uy(r,s).map(a=>fy(a,s,n[o]??"left"))})}function fy(e,t,n="left"){let r=Wr(e),o=t-r;if(o<=0)return e;let s=n==="right"?o:n==="center"?Math.floor(o/2):0,i=o-s;return" ".repeat(s)+e+" ".repeat(i)}function Ba(e){let t=e.trim();return!t.startsWith("|")||!t.endsWith("|")?[]:t.slice(1,t.length-1).split("|").map(r=>r.trim())}function my(e){return Ba(e).map(t=>{let n=t.startsWith(":"),r=t.endsWith(":");return n&&r?"center":r?"right":"left"})}function bd(e,t={}){let n=t.termWidth??80,r=t.outerMargin??0,o=Math.max(n-r,20),s=e.split(`
|
|
19
|
+
`).filter(T=>T.trim().length>0);if(s.length<2)return{lines:s,colWidths:[],totalWidth:0};let i=-1;for(let T=0;T<s.length;T++){let N=(s[T]??"").trim();if(/^\|[-: |]+\|$/.test(N)&&N.includes("-")){i=T;break}}if(i===-1)return{lines:s,colWidths:[],totalWidth:0};let a=Ba(s.slice(0,i).join("")),l=my(s[i]??""),c=s.slice(i+1).map(Ba),u=a.length;if(u===0)return{lines:s,colWidths:[],totalWidth:0};let d=[];for(let T=0;T<u;T++){let N=Wr(a[T]??"");for(let F of c){let q=Wr(F[T]??"");q>N&&(N=q)}d.push(Math.max(N,3))}let m=2,h=d.reduce((T,N)=>T+N+m,1),f;if(h<=o)f=d;else{let T=o-1-m*u,N=d.reduce((q,$)=>q+$,0);f=d.map(q=>Math.max(3,Math.floor(q/N*T)));let F=f.reduce((q,$)=>q+$+m,1);for(;F>o&&f.length>0;){let q=f.length-1,$=f[q]??3;if($<=3)break;f[q]=$-1,F=f.reduce((oe,le)=>oe+le+m,1)}}let g="\u2500",b=(T,N,F)=>T+f.map(q=>g.repeat(q+m)).join(N)+F,w=b("\u250C","\u252C","\u2510"),S=b("\u251C","\u253C","\u2524"),v=b("\u2514","\u2534","\u2518");function _(T){let N=py(T,f,l),F=Math.max(1,...N.map($=>$.length)),q=[];for(let $=0;$<F;$++){let oe="\u2502";for(let le=0;le<u;le++){let W=(N[le]??[])[$]??" ".repeat(f[le]??3);oe+=" "+W+" ",le<u-1&&(oe+="\u2502")}oe+="\u2502",q.push(oe)}return q}let E=_(a),M=c.map(_),U=f.reduce((T,N)=>T+N+m,1);return{lines:[w,...E,S,...M.flat(),v],colWidths:f,totalWidth:U}}function wd(){let e=process.stdout?.columns;return typeof e=="number"&&e>0?e:void 0}import{jsx as be,jsxs as Ga}from"react/jsx-runtime";function hy(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("```",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=e.indexOf("```",r+3);if(o===-1){t.push({text:e.slice(r),type:"plain"});break}let s=e.slice(r+3,o);t.push({text:s,type:"code_block"}),n=o+3}return t}function Fa(e){let t=e.trim();return/^\|.+\|$/.test(t)}function gy(e){let t=e.trim();return/^\|[-: |]+\|$/.test(t)&&t.includes("-")}function yy(e){let t=e.split(`
|
|
20
|
+
`),n=[],r="";function o(){r&&(n.push({text:r,type:"plain"}),r="")}for(let s=0;s<t.length;s++){let i=t[s]??"";if(Fa(i)&&s+1<t.length&&gy(t[s+1]??"")&&s+2<t.length&&Fa(t[s+2]??"")){o();let a=[],l=s;for(;l<t.length&&Fa(t[l]??"");)a.push(t[l]),l++;n.push({text:a.join(`
|
|
21
21
|
`),type:"table"}),s=l-1}else r?r+=`
|
|
22
|
-
`+i:r=i}return o(),n}function
|
|
23
|
-
`),n=t[0]??"",r=n.trim().length>0&&!n.startsWith("+")&&!n.startsWith("-")&&!n.startsWith("@@")&&!n.startsWith(" "),o=r?n:void 0,s=r?t.slice(1):t;return s.length===0?r?
|
|
24
|
-
`),a=s.replace(/\\/g,"/").split("/").pop()??s;return ps(Fa,{flexDirection:"column",marginTop:1,children:[ps(Fa,{flexDirection:"row",gap:1,children:[ps(Cn,{bold:!0,color:"#00ffff",children:["\u{1F4DD} ",o?"\u4FEE\u6539":"\u65B0\u5EFA",":"]}),_n(Cn,{bold:!0,children:a}),ps(Cn,{color:"#555555",children:["(+",n," -",r,")"]})]}),_n(Fa,{flexDirection:"column",marginLeft:2,children:i.filter(l=>!l.startsWith("---")&&!l.startsWith("+++")).map((l,c)=>_n(Ny,{line:l},c))})]})}function Ny({line:e}){return e.startsWith("---")||e.startsWith("+++")?null:e.startsWith("@@")?_n(Cn,{color:"#00cccc",children:e}):e.startsWith("+")?_n(Cn,{color:"#22c55e",children:e}):e.startsWith("-")?_n(Cn,{color:"#ef4444",children:e}):_n(Cn,{color:"#6b7280",children:e})}p();import{Box as ja,Text as Ua}from"ink";import{jsx as fs,jsxs as vd}from"react/jsx-runtime";var My="#00bfff";function Wa({skills:e,input:t,selectedIndex:n}){let r=t.match(/(?:^|\s)\/([^/]*)$/);if(!r)return null;let o=r[1].toLowerCase().trim();if(e.length===0)return null;let s=!o&&t.startsWith("/")?e.slice(0,3):e.filter(i=>i.name.toLowerCase().includes(o)).slice(0,3);return o&&s.some(i=>i.name.toLowerCase()===o)||s.length===0?null:vd(ja,{flexDirection:"column",marginLeft:4,marginTop:1,children:[fs(Ua,{color:"#808080",dimColor:!0,children:"\u652F\u6301\u7684 Skill\uFF1A"}),s.map((i,a)=>fs(ja,{children:vd(Ua,{color:a===n?My:"#808080",children:[a===n?" \u203A ":" ",i.name]})},i.name)),fs(ja,{marginTop:1,children:fs(Ua,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as cn,Text as hr}from"ink";import{useEffect as pk,useState as fk}from"react";p();import{Box as mr,Text as Dn}from"ink";import{useEffect as ak,useState as lk}from"react";p();p();p();function By(e){return Qa(e)}function Qa(e){return Array.isArray(e)?Fy(e):e instanceof RegExp?e:typeof e=="object"?Gy(e):e}function Fy(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Qa(e[n]);return t}function Gy(e){let t={};for(let n in e)t[n]=Qa(e[n]);return t}function Dd(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function Nd(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Nd(e.substring(0,e.length-1)):e.substr(~t+1)}var Ha=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ms=class{static hasCaptures(e){return e===null?!1:(Ha.lastIndex=0,Ha.test(e))}static replaceCaptures(e,t,n){return e.replace(Ha,(r,o,s,i)=>{let a=n[parseInt(o||s,10)];if(a){let l=t.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(i){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Md(e,t){return e<t?-1:e>t?1:0}function Bd(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 o=0;o<n;o++){let s=Md(e[o],t[o]);if(s!==0)return s}return 0}return n-r}function Rd(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 Fd(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Gd=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Vr=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(Wy(e),t)}static createFromParsedTheme(e,t){return Vy(e,t)}_cachedMatchRoot=new Gd(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(o=>jy(e.parent,o.parentScopes));return r?new jd(r.fontStyle,r.foreground,r.background):null}},Va=class hs{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(let r of n)t=new hs(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new hs(n,t[r]);return n}push(t){return new hs(this,t)}getSegments(){let t=this,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){let n=[],r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function jy(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],o=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],o=!0}for(;e&&!Uy(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Uy(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var jd=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function Wy(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let o=0,s=t.length;o<s;o++){let i=t[o];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let d=i.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),a=d.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let l=-1;if(typeof i.settings.fontStyle=="string"){l=0;let d=i.settings.fontStyle.split(" ");for(let m=0,h=d.length;m<h;m++)switch(d[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof i.settings.foreground=="string"&&Rd(i.settings.foreground)&&(c=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Rd(i.settings.background)&&(u=i.settings.background);for(let d=0,m=a.length;d<m;d++){let f=a[d].trim().split(" "),g=f[f.length-1],w=null;f.length>1&&(w=f.slice(0,f.length-1),w.reverse()),n[r++]=new Hy(g,w,o,l,c,u)}}return n}var Hy=class{constructor(e,t,n,r,o,s){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=o,this.background=s}},pe=(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))(pe||{});function Vy(e,t){e.sort((l,c)=>{let u=Md(l.scope,c.scope);return u!==0||(u=Bd(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",o="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(o=l.background)}let s=new zy(t),i=new jd(n,s.getId(r),s.getId(o)),a=new Ky(new qa(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let u=e[l];a.insert(0,u.scope,u.parentScopes,u.fontStyle,s.getId(u.foreground),s.getId(u.background))}return new Vr(s,i,a)}var zy=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)}},qy=Object.freeze([]),qa=class Ud{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,o,s){this.scopeDepth=t,this.parentScopes=n||qy,this.fontStyle=r,this.foreground=o,this.background=s}clone(){return new Ud(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,o=t.length;r<o;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,o){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},Ky=class Ka{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,o=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[o]===">"&&o++,!(r>=t.parentScopes.length||o>=n.parentScopes.length);){let s=n.parentScopes[o].length-t.parentScopes[r].length;if(s!==0)return s;r++,o++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),o,s;if(r===-1?(o=t,s=""):(o=t.substring(0,r),s=t.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(s)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Ka._cmpBySpecificity),n}insert(t,n,r,o,s,i){if(n===""){this._doInsertHere(t,r,o,s,i);return}let a=n.indexOf("."),l,c;a===-1?(l=n,c=""):(l=n.substring(0,a),c=n.substring(a+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new Ka(this._mainRule.clone(),qa.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(t+1,c,r,o,s,i)}_doInsertHere(t,n,r,o,s){if(n===null){this._mainRule.acceptOverwrite(t,r,o,s);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let l=this._rulesWithParentScopes[i];if(Bd(l.parentScopes,n)===0){l.acceptOverwrite(t,r,o,s);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new qa(t,n,r,o,s))}},rn=class it{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let n=it.getLanguageId(t),r=it.getTokenType(t),o=it.getFontStyle(t),s=it.getForeground(t),i=it.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:o,foreground:s,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,o,s,i,a){let l=it.getLanguageId(t),c=it.getTokenType(t),u=it.containsBalancedBrackets(t)?1:0,d=it.getFontStyle(t),m=it.getForeground(t),h=it.getBackground(t);return n!==0&&(l=n),r!==8&&(c=r),o!==null&&(u=o?1:0),s!==-1&&(d=s),i!==0&&(m=i),a!==0&&(h=a),(l<<0|c<<8|u<<10|d<<11|m<<15|h<<24)>>>0}};function ys(e,t){let n=[],r=Xy(e),o=r.next();for(;o!==null;){let l=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let c=i();if(n.push({matcher:c,priority:l}),o!==",")break;o=r.next()}return n;function s(){if(o==="-"){o=r.next();let l=s();return c=>!!l&&!l(c)}if(o==="("){o=r.next();let l=a();return o===")"&&(o=r.next()),l}if(Ad(o)){let l=[];do l.push(o),o=r.next();while(Ad(o));return c=>t(l,c)}return null}function i(){let l=[],c=s();for(;c;)l.push(c),c=s();return u=>l.every(d=>d(u))}function a(){let l=[],c=i();for(;c&&(l.push(c),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");c=i()}return u=>l.some(d=>d(u))}}function Ad(e){return!!e&&!!e.match(/[\w\.:]+/)}function Xy(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Wd(e){typeof e.dispose=="function"&&e.dispose()}var zr=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Jy=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Zy=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Yy=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new zr(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Zy;for(let n of e)Qy(n,this.initialScopeName,this.repo,t);for(let n of t.references)if(n instanceof zr){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 Qy(e,t,n,r){let o=n.lookup(e.scopeName);if(!o){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let s=n.lookup(t);e instanceof zr?gs({baseGrammar:s,selfGrammar:o},r):Xa(e.ruleName,{baseGrammar:s,selfGrammar:o,repository:o.repository},r);let i=n.injections(e.scopeName);if(i)for(let a of i)r.add(new zr(a))}function Xa(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];bs([r],t,n)}}function gs(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&bs(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&bs(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function bs(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let o=r.repository?Dd({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&bs(r.patterns,{...t,repository:o},n);let s=r.include;if(!s)continue;let i=Hd(s);switch(i.kind){case 0:gs({...t,selfGrammar:t.baseGrammar},n);break;case 1:gs(t,n);break;case 2:Xa(i.ruleName,{...t,repository:o},n);break;case 3:case 4:let a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){let l={baseGrammar:t.baseGrammar,selfGrammar:a,repository:o};i.kind===4?Xa(i.ruleName,l,n):gs(l,n)}else i.kind===4?n.add(new Jy(i.scopeName,i.ruleName)):n.add(new zr(i.scopeName));break}}}var eb=class{kind=0},tb=class{kind=1},nb=class{constructor(e){this.ruleName=e}kind=2},rb=class{constructor(e){this.scopeName=e}kind=3},ob=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Hd(e){if(e==="$base")return new eb;if(e==="$self")return new tb;let t=e.indexOf("#");if(t===-1)return new rb(e);if(t===0)return new nb(e.substring(1));{let n=e.substring(0,t),r=e.substring(t+1);return new ob(n,r)}}var sb=/\\(\d+)/,Ed=/\\(\d+)/g;var ib=-1,Vd=-2;var Xr=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=ms.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=ms.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Nd(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:ms.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ms.replaceCaptures(this._contentName,e,t)}},ab=class extends Xr{retokenizeCapturedWithRuleId;constructor(e,t,n,r,o){super(e,t,n,r),this.retokenizeCapturedWithRuleId=o}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!")}},lb=class extends Xr{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,null),this._match=new qr(r,this.id),this.captures=o,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 Kr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Id=class extends Xr{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,r),this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let 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 Kr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ja=class extends Xr{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o,s,i,a,l,c){super(e,t,n,r),this._begin=new qr(o,this.id),this.beginCaptures=s,this._end=new qr(i||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kr;for(let 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}},xs=class extends Xr{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,o,s,i,a,l){super(e,t,n,r),this._begin=new qr(o,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new qr(i,Vd),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Kr;for(let 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 Kr,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},zd=class De{static createCaptureRule(t,n,r,o,s){return t.registerRule(i=>new ab(n,i,r,o,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(o=>{if(t.id=o,t.match)return new lb(t.$vscodeTextmateLocation,t.id,t.name,t.match,De._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Dd({},r,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Id(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,De._compilePatterns(s,n,r))}return t.while?new xs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,De._compileCaptures(t.whileCaptures||t.captures,n,r),De._compilePatterns(t.patterns,n,r)):new Ja(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,De._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,De._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let o=[];if(t){let s=0;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10);a>s&&(s=a)}for(let i=0;i<=s;i++)o[i]=null;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10),l=0;t[i].patterns&&(l=De.getCompiledRuleId(t[i],n,r)),o[a]=De.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,l)}}return o}static _compilePatterns(t,n,r){let o=[];if(t)for(let s=0,i=t.length;s<i;s++){let a=t[s],l=-1;if(a.include){let c=Hd(a.include);switch(c.kind){case 0:case 1:l=De.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=De.getCompiledRuleId(u,n,r));break;case 3:case 4:let d=c.scopeName,m=c.kind===4?c.ruleName:null,h=n.getExternalGrammar(d,r);if(h)if(m){let f=h.repository[m];f&&(l=De.getCompiledRuleId(f,n,h.repository))}else l=De.getCompiledRuleId(h.repository.$self,n,h.repository);break}}else l=De.getCompiledRuleId(a,n,r);if(l!==-1){let c=n.getRule(l),u=!1;if((c instanceof Id||c instanceof Ja||c instanceof xs)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;o.push(l)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},qr=class qd{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){let r=t.length,o=0,s=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){let c=t.charAt(a+1);c==="z"?(s.push(t.substring(o,a)),s.push("$(?!\\n)(?<!\\n)"),o=a+2):(c==="A"||c==="G")&&(i=!0),a++}this.hasAnchor=i,o===0?this.source=t:(s.push(t.substring(o,r)),this.source=s.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=sb.test(this.source):this.hasBackReferences=!1}clone(){return new qd(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(o=>t.substring(o.start,o.end));return Ed.lastIndex=0,this.source.replace(Ed,(o,s)=>Fd(r[parseInt(s,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=[],o=[],s,i,a,l;for(s=0,i=this.source.length;s<i;s++)a=this.source.charAt(s),t[s]=a,n[s]=a,r[s]=a,o[s]=a,a==="\\"&&s+1<i&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",n[s+1]="\uFFFF",r[s+1]="A",o[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",n[s+1]="G",r[s+1]="\uFFFF",o[s+1]="G"):(t[s+1]=l,n[s+1]=l,r[s+1]=l,o[s+1]=l),s++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:o.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}},Kr=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 Pd(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(o=>o.resolveAnchors(t,n));return new Pd(e,r,this._items.map(o=>o.ruleId))}},Pd=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(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
25
|
-
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},
|
|
26
|
-
`;let s=this.createOnigString(e),i=s.content.length,a=new kb(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Xd(this,s,o,0,t,a,!0,r);return Wd(s),{lineLength:i,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Od(e,t){return e=By(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 Hr=class Rt{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,o=t?.scopePath??null;for(let s of n)o=Va.push(o,s.scopeNames),r=new Rt(r,o,s.encodedTokenAttributes);return r}static createRoot(t,n){return new Rt(null,new Va(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let o=r.getMetadataForScope(t),s=new Va(null,t),i=r.themeProvider.themeMatch(s),a=Rt.mergeAttributes(n,o,i);return new Rt(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Rt.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 o=-1,s=0,i=0;return r!==null&&(o=r.fontStyle,s=r.foregroundId,i=r.backgroundId),rn.set(t,n.languageId,n.tokenType,null,o,s,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Rt._pushAttributed(this,t,n);let r=t.split(/ /g),o=this;for(let s of r)o=Rt._pushAttributed(o,s,n);return o}static _pushAttributed(t,n,r){let o=r.getMetadataForScope(n),s=t.scopePath.push(n),i=r.themeProvider.themeMatch(s),a=Rt.mergeAttributes(t.tokenAttributes,o,i);return new Rt(t,s,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let n=[],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}},Ya=class vn{constructor(t,n,r,o,s,i,a,l){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=o}_stackElementBrand=void 0;static NULL=new vn(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:vn._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Hr.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(){vn._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,o,s,i,a){return new vn(this,t,n,r,o,s,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let 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 vn(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){let r=Hr.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new vn(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Hr.fromExtension(r,n.contentNameScopesList))}},wb=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):ys(n,ws).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>ys(n,ws).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(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},kb=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,o=!1;if(this.balancedBracketSelectors?.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let s=e?.getScopeNames()??[];for(let i of this._tokenTypeOverrides)i.matcher(s)&&(r=rn.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(s))}if(o&&(r=rn.set(r,0,8,o,-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}let 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);let n=new Uint32Array(this._binaryTokens.length);for(let r=0,o=this._binaryTokens.length;r<o;r++)n[r]=this._binaryTokens[r];return n}},Sb=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let 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,o){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,yb(e,s,t,n,r,o,this,this._onigLib))}return this._grammars.get(e)}},Yd=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Sb(Vr.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Vr.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new wb(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,o){let s=new Yy(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(i=>this._loadSingleGrammar(i.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,n,r,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,o=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,o)}},ks=Ya.NULL;p();var nl=Lg(sp(),1),or=nl.default,{Ansis:fA,fg:mA,bg:hA,rgb:gA,bgRgb:yA,hex:bA,bgHex:xA,reset:wA,inverse:kA,hidden:SA,visible:TA,link:CA,bold:_A,dim:vA,italic:RA,underline:AA,strikethrough:EA,black:IA,red:PA,green:LA,yellow:$A,blue:OA,magenta:DA,cyan:NA,white:MA,gray:BA,redBright:FA,greenBright:GA,yellowBright:jA,blueBright:UA,magentaBright:WA,cyanBright:HA,whiteBright:VA,bgBlack:zA,bgRed:qA,bgGreen:KA,bgYellow:XA,bgBlue:JA,bgMagenta:ZA,bgCyan:YA,bgWhite:QA,bgGray:eE,bgRedBright:tE,bgGreenBright:nE,bgYellowBright:rE,bgBlueBright:oE,bgMagentaBright:sE,bgCyanBright:iE,bgWhiteBright:aE}=nl.default;p();p();var rl=Object.defineProperty,Ab=Object.getOwnPropertyDescriptor,Eb=Object.getOwnPropertyNames,Ib=Object.prototype.hasOwnProperty,sr=(e,t)=>{let n={};for(var r in e)rl(n,r,{get:e[r],enumerable:!0});return t||rl(n,Symbol.toStringTag,{value:"Module"}),n},ip=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=Eb(t),s=0,i=o.length,a;s<i;s++)a=o[s],!Ib.call(e,a)&&a!==n&&rl(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=Ab(t,a))||r.enumerable});return e},Ts=(e,t,n)=>(ip(e,t,"default"),n&&ip(n,t,"default"));p();var ir=[{id:"abap",name:"ABAP",import:(()=>import("./abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("./actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("./ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("./angular-html-FD45HTTF.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("./angular-ts-XKF3LV22.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("./apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("./apex-27CRTE2E.js"))},{id:"apl",name:"APL",import:(()=>import("./apl-DZEE5XRN.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("./applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("./ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("./asciidoc-6DTTKQ3A.js"))},{id:"asm",name:"Assembly",import:(()=>import("./asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("./astro-AZ66H24C.js"))},{id:"awk",name:"AWK",import:(()=>import("./awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("./ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("./bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("./beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("./berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("./bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("./bicep-EOACOM4G.js"))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>import("./bird2-ZG3DO533.js"))},{id:"blade",name:"Blade",import:(()=>import("./blade-6Y7SALML.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("./bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("./c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("./c3-4Z2YI6YO.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("./cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("./cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("./clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("./clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("./cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("./cobol-KCXH3T3Q.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("./codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("./codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("./coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("./common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("./coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("./cpp-B4ITA36J.js"))},{id:"crystal",name:"Crystal",import:(()=>import("./crystal-DVILAEWU.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("./csharp-VNJLKKRO.js"))},{id:"css",name:"CSS",import:(()=>import("./css-NLVM2B53.js"))},{id:"csv",name:"CSV",import:(()=>import("./csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("./cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("./cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("./d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("./dart-KG257MMB.js"))},{id:"dax",name:"DAX",import:(()=>import("./dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("./desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("./diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("./docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("./dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("./dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("./edge-75EAMBUG.js"))},{id:"elixir",name:"Elixir",import:(()=>import("./elixir-NWFINHZW.js"))},{id:"elm",name:"Elm",import:(()=>import("./elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("./emacs-lisp-NRIAYFLD.js"))},{id:"erb",name:"ERB",import:(()=>import("./erb-L6I32JVH.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("./erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("./fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("./fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("./fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("./fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("./fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("./fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("./gdresource-4NUZ6YCX.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("./gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("./gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("./genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("./gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("./git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("./git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("./gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("./glimmer-js-EJYO25PG.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("./glimmer-ts-Q2ZC2IIP.js"))},{id:"glsl",name:"GLSL",import:(()=>import("./glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("./gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("./gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("./go-WER5FUYJ.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("./graphql-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("./groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("./hack-FLOLYEQ5.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("./haml-SCHIB33Y.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("./handlebars-BNURLECZ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("./haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("./haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("./hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("./hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("./hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("./html-DXDULU5G.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("./html-derivative-QD4CE6YQ.js"))},{id:"http",name:"HTTP",import:(()=>import("./http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("./hurl-BZB5LDD5.js"))},{id:"hxml",name:"HXML",import:(()=>import("./hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("./hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("./imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("./ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("./java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("./javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("./jinja-DC3WU6ZJ.js"))},{id:"jison",name:"Jison",import:(()=>import("./jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("./json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("./json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("./jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("./jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("./jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("./jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("./jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("./julia-CHGX5VFI.js"))},{id:"just",name:"Just",import:(()=>import("./just-XO4JBQP4.js"))},{id:"kdl",name:"KDL",import:(()=>import("./kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("./kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("./kusto-55BKOIH6.js"))},{id:"latex",name:"LaTeX",import:(()=>import("./latex-7PE6CJI5.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("./lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("./less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("./liquid-OUYRJBEI.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("./llvm-F6576PPM.js"))},{id:"log",name:"Log file",import:(()=>import("./log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("./logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("./lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("./luau-7VRLQHZS.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("./make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("./markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("./marko-TQJFHH5J.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("./matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("./mdc-ZOKCGRSD.js"))},{id:"mdx",name:"MDX",import:(()=>import("./mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("./mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("./mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("./mojo-NUFJUGRT.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("./moonbit-IQKVCQX6.js"))},{id:"move",name:"Move",import:(()=>import("./move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("./narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("./nextflow-OTA6EZBU.js"))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>import("./nextflow-groovy-434C6PKN.js"))},{id:"nginx",name:"Nginx",import:(()=>import("./nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("./nim-LBV5OEXG.js"))},{id:"nix",name:"Nix",import:(()=>import("./nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("./nushell-WFCCYAUY.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("./objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("./objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("./ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("./odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("./openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("./pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("./perl-N2JOL2L5.js"))},{id:"php",name:"PHP",import:(()=>import("./php-OXA56EZC.js"))},{id:"pkl",name:"Pkl",import:(()=>import("./pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("./plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("./po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("./polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("./postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("./powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("./powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("./prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("./prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("./proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("./pug-CWA4QCVE.js"))},{id:"puppet",name:"Puppet",import:(()=>import("./puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("./purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("./python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("./qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("./qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("./qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("./r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("./racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("./raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("./razor-B3X33ONZ.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("./reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("./regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("./rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("./riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("./ron-G4N7ZKMH.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("./rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("./rst-D5R5URHP.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("./ruby-DWCE4YYU.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("./rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("./sas-T7S4QIRM.js"))},{id:"sass",name:"Sass",import:(()=>import("./sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("./scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("./scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("./scss-RIXXNXKR.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("./sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("./shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("./shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("./shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("./smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("./solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("./soy-4TQM2FCJ.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("./sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("./splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("./sql-52F5XK5C.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("./ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("./stata-6C4TLAPQ.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("./stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("./surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("./svelte-NTV6SKXK.js"))},{id:"swift",name:"Swift",import:(()=>import("./swift-KMR3DOSF.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("./system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("./systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("./talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("./tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("./tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("./templ-U5PIZYER.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("./terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("./tex-MVHXDK4A.js"))},{id:"toml",name:"TOML",import:(()=>import("./toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("./ts-tags-K7BWB4VX.js"))},{id:"tsv",name:"TSV",import:(()=>import("./tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("./tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("./turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("./twig-7UZRHYW3.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("./typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("./typespec-535S7LOL.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("./typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("./v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("./vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("./vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("./verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("./vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("./viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("./vue-CKPBQTY7.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("./vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("./vue-vine-Q32TIQRB.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("./vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("./wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("./wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("./wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("./wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("./wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("./wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("./xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("./xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("./yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("./zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("./zig-6LJUAPBA.js"))}],Jr=Object.fromEntries(ir.map(e=>[e.id,e.import])),Zr=Object.fromEntries(ir.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Yr={...Jr,...Zr};p();var Qr=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("./andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("./aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("./ayu-dark-55BH6GCR.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("./ayu-light-IPNR4FEJ.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("./ayu-mirage-MOSAI7A2.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("./catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("./catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("./catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("./catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("./dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("./dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("./dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("./everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("./everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("./github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("./github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("./github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("./github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("./github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("./github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("./github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("./gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("./gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("./gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("./gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("./gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("./gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("./horizon-EAAZ4KVN.js"))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>import("./horizon-bright-CGMA7ELN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("./houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("./kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("./kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("./kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("./laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("./light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("./material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("./material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("./material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("./material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("./material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("./min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("./min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("./monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("./night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("./night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("./nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("./one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("./one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("./plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("./poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("./red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("./rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("./rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("./rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("./slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("./slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("./snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("./solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("./solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("./synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("./tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("./vesper-DY3BCX5Y.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("./vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("./vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("./vitesse-light-RICZI4IG.js"))}],eo=Object.fromEntries(Qr.map(e=>[e.id,e.import]));p();p();var ll={};Ju(ll,{createOnigurumaEngine:()=>al,getDefaultWasmLoader:()=>zb,loadWasm:()=>Rs,setDefaultWasmLoader:()=>Vb});p();var il=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Pb(){return 2147483648}function Lb(){return typeof performance<"u"?performance.now():Date.now()}var $b=(e,t)=>e+(t-e%t)%t;async function Ob(e){let t,n,r={};function o(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function s(h,f,g){r.HEAPU8.copyWithin(h,f,f+g)}function i(h){try{return t.grow(h-n.byteLength+65535>>>16),o(t.buffer),1}catch{}}function a(h){let f=r.HEAPU8.length;h=h>>>0;let g=Pb();if(h>g)return!1;for(let w=1;w<=4;w*=2){let x=f*(1+.2/w);x=Math.min(x,h+100663296);let T=Math.min(g,$b(Math.max(h,x),65536));if(i(T))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function c(h,f,g=1024){let w=f+g,x=f;for(;h[x]&&!(x>=w);)++x;if(x-f>16&&h.buffer&&l)return l.decode(h.subarray(f,x));let T="";for(;f<x;){let v=h[f++];if(!(v&128)){T+=String.fromCharCode(v);continue}let _=h[f++]&63;if((v&224)===192){T+=String.fromCharCode((v&31)<<6|_);continue}let S=h[f++]&63;if((v&240)===224?v=(v&15)<<12|_<<6|S:v=(v&7)<<18|_<<12|S<<6|h[f++]&63,v<65536)T+=String.fromCharCode(v);else{let D=v-65536;T+=String.fromCharCode(55296|D>>10,56320|D&1023)}}return T}function u(h,f){return h?c(r.HEAPU8,h,f):""}let d={emscripten_get_now:Lb,emscripten_memcpy_big:s,emscripten_resize_heap:a,fd_write:()=>0};async function m(){let f=await e({env:d,wasi_snapshot_preview1:d});t=f.memory,o(t.buffer),Object.assign(r,f),r.UTF8ToString=u}return await m(),r}var Db=Object.defineProperty,Nb=(e,t,n)=>t in e?Db(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ce=(e,t,n)=>Nb(e,typeof t!="symbol"?t+"":t,n),Ae=null;function Mb(e){throw new il(e.UTF8ToString(e.getLastOnigError()))}var _s=class e{constructor(t){Ce(this,"utf16Length"),Ce(this,"utf8Length"),Ce(this,"utf16Value"),Ce(this,"utf8Value"),Ce(this,"utf16OffsetToUtf8"),Ce(this,"utf8OffsetToUtf16");let n=t.length,r=e._utf8ByteLength(t),o=r!==n,s=o?new Uint32Array(n+1):null;o&&(s[n]=r);let i=o?new Uint32Array(r+1):null;o&&(i[r]=n);let a=new Uint8Array(r),l=0;for(let c=0;c<n;c++){let u=t.charCodeAt(c),d=u,m=!1;if(u>=55296&&u<=56319&&c+1<n){let h=t.charCodeAt(c+1);h>=56320&&h<=57343&&(d=(u-55296<<10)+65536|h-56320,m=!0)}o&&(s[c]=l,m&&(s[c+1]=l),d<=127?i[l+0]=c:d<=2047?(i[l+0]=c,i[l+1]=c):d<=65535?(i[l+0]=c,i[l+1]=c,i[l+2]=c):(i[l+0]=c,i[l+1]=c,i[l+2]=c,i[l+3]=c)),d<=127?a[l++]=d:d<=2047?(a[l++]=192|(d&1984)>>>6,a[l++]=128|(d&63)>>>0):d<=65535?(a[l++]=224|(d&61440)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0):(a[l++]=240|(d&1835008)>>>18,a[l++]=128|(d&258048)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0),m&&c++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=a,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=i}static _utf8ByteLength(t){let n=0;for(let r=0,o=t.length;r<o;r++){let s=t.charCodeAt(r),i=s,a=!1;if(s>=55296&&s<=56319&&r+1<o){let l=t.charCodeAt(r+1);l>=56320&&l<=57343&&(i=(s-55296<<10)+65536|l-56320,a=!0)}i<=127?n+=1:i<=2047?n+=2:i<=65535?n+=3:n+=4,a&&r++}return n}createString(t){let n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}},vs=class At{constructor(t){if(Ce(this,"id",++At.LAST_ID),Ce(this,"_onigBinding"),Ce(this,"content"),Ce(this,"utf16Length"),Ce(this,"utf8Length"),Ce(this,"utf16OffsetToUtf8"),Ce(this,"utf8OffsetToUtf16"),Ce(this,"ptr"),!Ae)throw new il("Must invoke loadWasm first.");this._onigBinding=Ae,this.content=t;let n=new _s(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!At._sharedPtrInUse?(At._sharedPtr||(At._sharedPtr=Ae.omalloc(1e4)),At._sharedPtrInUse=!0,Ae.HEAPU8.set(n.utf8Value,At._sharedPtr),this.ptr=At._sharedPtr):this.ptr=n.createString(Ae)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===At._sharedPtr?At._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Ce(vs,"LAST_ID",0);Ce(vs,"_sharedPtr",0);Ce(vs,"_sharedPtrInUse",!1);var ap=vs,sl=class{constructor(t){if(Ce(this,"_onigBinding"),Ce(this,"_ptr"),!Ae)throw new il("Must invoke loadWasm first.");let n=[],r=[];for(let a=0,l=t.length;a<l;a++){let c=new _s(t[a]);n[a]=c.createString(Ae),r[a]=c.utf8Length}let o=Ae.omalloc(4*t.length);Ae.HEAPU32.set(n,o/4);let s=Ae.omalloc(4*t.length);Ae.HEAPU32.set(r,s/4);let i=Ae.createOnigScanner(o,s,t.length);for(let a=0,l=t.length;a<l;a++)Ae.ofree(n[a]);Ae.ofree(s),Ae.ofree(o),i===0&&Mb(Ae),this._onigBinding=Ae,this._ptr=i}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let o=0;if(typeof r=="number"&&(o=r),typeof t=="string"){t=new ap(t);let s=this._findNextMatchSync(t,n,!1,o);return t.dispose(),s}return this._findNextMatchSync(t,n,!1,o)}_findNextMatchSync(t,n,r,o){let s=this._onigBinding,i=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),o);if(i===0)return null;let a=s.HEAPU32,l=i/4,c=a[l++],u=a[l++],d=[];for(let m=0;m<u;m++){let h=t.convertUtf8OffsetToUtf16(a[l++]),f=t.convertUtf8OffsetToUtf16(a[l++]);d[m]={start:h,end:f,length:f-h}}return{index:c,captureIndices:d}}};function Bb(e){return typeof e.instantiator=="function"}function Fb(e){return typeof e.default=="function"}function Gb(e){return typeof e.data<"u"}function jb(e){return typeof Response<"u"&&e instanceof Response}function Ub(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var Cs;function Rs(e){if(Cs)return Cs;async function t(){Ae=await Ob(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),Bb(r)?r=await r.instantiator(n):Fb(r)?r=await r.default(n):(Gb(r)&&(r=r.data),jb(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await Wb(r)(n):r=await Hb(r)(n):Ub(r)?r=await ol(r)(n):r instanceof WebAssembly.Module?r=await ol(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await ol(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Cs=t(),Cs}function ol(e){return t=>WebAssembly.instantiate(e,t)}function Wb(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Hb(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var lp;function Vb(e){lp=e}function zb(){return lp}async function al(e){return e&&await Rs(e),{createScanner(t){return new sl(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new ap(t)}}}var cl=sr({});Ts(cl,ll);p();p();var te=class extends Error{constructor(e){super(e),this.name="ShikiError"}};p();function no(e,t){let n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(let[o,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?n[o]=s:o===r&&Object.assign(n,s);return n}function Mt(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function fp(e){return Array.isArray(e)?e:[e]}async function ul(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function ro(e){return!e||["plaintext","txt","text","plain"].includes(e)}function dl(e){return e==="ansi"||ro(e)}function oo(e){return e==="none"}function pl(e){return oo(e)}var qb=/(\r?\n)/g;function ar(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(qb),r=0,o=[];for(let s=0;s<n.length;s+=2){let i=t?n[s]+(n[s+1]||""):n[s];o.push([i,r]),r+=n[s].length,r+=n[s+1]?.length||0}return o}var cp={light:"#333333",dark:"#bbbbbb"},up={light:"#fffffe",dark:"#1e1e1e"},dp="__shiki_resolved";function As(e){if(e?.[dp])return e;let 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){let a=t.settings?t.settings.find(l=>!l.name&&!l.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"?cp.light:cp.dark),n||(n=t.type==="light"?up.light:up.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 o=0,s=new Map;function i(a){if(s.has(a))return s.get(a);o+=1;let l=`#${o.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?i(a):(s.set(a,l),l)}t.settings=t.settings.map(a=>{let l=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),c=a.settings?.background&&!a.settings.background.startsWith("#");if(!l&&!c)return a;let u={...a,settings:{...a.settings}};if(l){let d=i(a.settings.foreground);t.colorReplacements[d]=a.settings.foreground,u.settings.foreground=d}if(c){let d=i(a.settings.background);t.colorReplacements[d]=a.settings.background,u.settings.background=d}return u});for(let a of Object.keys(t.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!t.colors[a]?.startsWith("#")){let l=i(t.colors[a]);t.colorReplacements[l]=t.colors[a],t.colors[a]=l}return Object.defineProperty(t,dp,{enumerable:!1,writable:!1,value:!0}),t}async function mp(e){return[...new Set((await Promise.all(e.filter(t=>!dl(t)).map(async t=>await ul(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function hp(e){return(await Promise.all(e.map(async t=>pl(t)?null:As(await ul(t))))).filter(t=>!!t)}function gp(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new te(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Kb=class extends Yd{_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(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=As(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=Vr.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=gp(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,t.size)for(let o of t)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],n=t.filter(([r,o])=>!o);if(n.length){let r=t.filter(([o,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(i=>n.map(([a])=>a).includes(i)):!1).filter(o=>!n.includes(o));throw new te(`Missing languages ${n.map(([o])=>`\`${o}\``).join(", ")}, required by ${r.map(([o])=>`\`${o}\``).join(", ")}`)}for(let[r,o]of t)this._resolver.addLanguage(o);for(let[r,o]of t)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let n of t)this._langGraph.set(n,this._langMap.get(n))}},Xb=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){let t=e.split("."),n=[];for(let r=1;r<=t.length;r++){let o=t.slice(0,r).join(".");n=[...n,...this._injections.get(o)||[]]}return n}},to=0;function fl(e){to+=1,e.warnings!==!1&&to>=10&&to%10===0&&console.warn(`[Shiki] ${to} 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 te("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(As),o=new Kb(new Xb(e.engine,n),r,n,e.langAlias),s;function i(T){return gp(T,e.langAlias)}function a(T){w();let v=o.getGrammar(typeof T=="string"?T:T.name);if(!v)throw new te(`Language \`${T}\` not found, you may need to load it first`);return v}function l(T){if(T==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};w();let v=o.getTheme(T);if(!v)throw new te(`Theme \`${T}\` not found, you may need to load it first`);return v}function c(T){w();let v=l(T);return s!==T&&(o.setTheme(v),s=T),{theme:v,colorMap:o.getColorMap()}}function u(){return w(),o.getLoadedThemes()}function d(){return w(),o.getLoadedLanguages()}function m(...T){w(),o.loadLanguages(T.flat(1))}async function h(...T){return m(await mp(T))}function f(...T){w();for(let v of T.flat(1))o.loadTheme(v)}async function g(...T){return w(),f(await hp(T))}function w(){if(t)throw new te("Shiki instance has been disposed")}function x(){t||(t=!0,o.dispose(),to-=1)}return{setTheme:c,getTheme:l,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:g,loadThemeSync:f,dispose:x,[Symbol.dispose]:x}}async function ml(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([hp(e.themes||[]),mp(e.langs||[]),e.engine]);return fl({...e,themes:t,langs:n,engine:r})}var yp=new WeakMap;function so(e,t){yp.set(e,t)}function lr(e){return yp.get(e)}var Es=class bp{_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 bp(Object.fromEntries(fp(n).map(r=>[r,ks])),t)}constructor(...t){if(t.length===2){let[n,r]=t;this.lang=r,this._stacks=n}else{let[n,r,o]=t;this.lang=r,this._stacks={[o]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Jb(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Jb(e){let t=[],n=new Set;function r(o){if(n.has(o))return;n.add(o);let s=o?.nameScopesList?.scopeName;s&&t.push(s),o.parent&&r(o.parent)}return r(e),t}function Zb(e,t){if(!(e instanceof Es))throw new te("Invalid grammar state");return e.getInternalStack(t)}var Yb=/,/,Qb=/ /;function hl(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(ro(e.resolveLangAlias(n.lang||"text"))||oo(r))return ar(t).map(a=>[{content:a[0],offset:a[1]}]);let{theme:o,colorMap:s}=e.setTheme(r),i=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new te(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new te(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return wp(t,i,o,s,n)}function xp(...e){if(e.length===2)return lr(e[1]);let[t,n,r={}]=e,{lang:o="text",theme:s=t.getLoadedThemes()[0]}=r;if(ro(o)||oo(s))throw new te("Plain language does not have grammar state");if(o==="ansi")throw new te("ANSI language does not have grammar state");let{theme:i,colorMap:a}=t.setTheme(s),l=t.getLanguage(o);return new Es(gl(n,l,i,a,r).stateStack,l.name,i.name)}function wp(e,t,n,r,o){let s=gl(e,t,n,r,o),i=new Es(s.stateStack,t.name,n.name);return so(s.tokens,i),s.tokens}function gl(e,t,n,r,o){let s=no(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=o,c=ar(e),u=o.grammarState?Zb(o.grammarState,n.name)??ks:o.grammarContextCode!=null?gl(o.grammarContextCode,t,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:ks,d=[],m=[];for(let h=0,f=c.length;h<f;h++){let[g,w]=c[h];if(g===""){d=[],m.push([]);continue}if(i>0&&g.length>=i){d=[],m.push([{content:g,offset:w,color:"",fontStyle:0}]);continue}let x,T,v;l&&l!=="tokenType"&&(x=t.tokenizeLine(g,u,a),T=x.tokens,v=0);let _=t.tokenizeLine2(g,u,a),S=_.tokens.length/2;for(let D=0;D<S;D++){let H=_.tokens[2*D],E=D+1<S?_.tokens[2*D+2]:g.length;if(H===E)continue;let I=_.tokens[2*D+1],B=Mt(r[rn.getForeground(I)],s),Y=rn.getFontStyle(I),q={content:g.substring(H,E),offset:w+H,color:B,fontStyle:Y};if(l==="tokenType")q.type=rn.getTokenType(I);else if(l){let ae=[];if(l!=="scopeName")for(let Q of n.settings){let j;switch(typeof Q.scope){case"string":j=Q.scope.split(Yb).map(re=>re.trim());break;case"object":j=Q.scope;break;default:continue}ae.push({settings:Q,selectors:j.map(re=>re.split(Qb))})}q.explanation=[];let ce=0;for(;H+ce<E;){let Q=T[v],j=g.substring(Q.startIndex,Q.endIndex);ce+=j.length,q.explanation.push({content:j,scopes:l==="scopeName"?ex(Q.scopes):tx(ae,Q.scopes)}),v+=1}}d.push(q)}m.push(d),d=[],u=_.ruleStack}return{tokens:m,stateStack:u}}function ex(e){return e.map(t=>({scopeName:t}))}function tx(e,t){let n=[];for(let r=0,o=t.length;r<o;r++){let s=t[r];n[r]={scopeName:s,themeMatches:rx(e,s,t.slice(0,r))}}return n}function pp(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function nx(e,t,n){if(!pp(e.at(-1),t))return!1;let r=e.length-2,o=n.length-1;for(;r>=0&&o>=0;)pp(e[r],n[o])&&(r-=1),o-=1;return r===-1}function rx(e,t,n){let r=[];for(let{selectors:o,settings:s}of e)for(let i of o)if(nx(i,t,n)){r.push(s);break}return r}function Is(e,t,n,r=hl){let o=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),s=o.map(c=>{let u=r(e,t,{...n,theme:c.theme});return{tokens:u,state:lr(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=ox(...s.map(c=>c.tokens)),a=i[0].map((c,u)=>c.map((d,m)=>{let h={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=d.explanation),i.forEach((f,g)=>{let{content:w,explanation:x,offset:T,...v}=f[u][m];h.variants[o[g].color]=v}),h})),l=s[0].state?new Es(Object.fromEntries(s.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),s[0].state.lang):void 0;return l&&so(a,l),a}function ox(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let o=e.map(l=>l[r]),s=t.map(()=>[]);t.forEach((l,c)=>l.push(s[c]));let i=o.map(()=>0),a=o.map(l=>l[0]);for(;a.every(l=>l);){let l=Math.min(...a.map(c=>c.content.length));for(let c=0;c<n;c++){let u=a[c];u.content.length===l?(s[c].push(u),i[c]+=1,a[c]=o[c][i[c]]):(s[c].push({...u,content:u.content.slice(0,l)}),a[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return t}p();p();p();var kp=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];p();p();p();var Bt=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Bt.prototype.normal={};Bt.prototype.property={};Bt.prototype.space=void 0;function yl(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Bt(n,r,t)}p();p();p();function io(e){return e.toLowerCase()}p();p();var Ee=class{constructor(t,n){this.attribute=n,this.property=t}};Ee.prototype.attribute="";Ee.prototype.booleanish=!1;Ee.prototype.boolean=!1;Ee.prototype.commaOrSpaceSeparated=!1;Ee.prototype.commaSeparated=!1;Ee.prototype.defined=!1;Ee.prototype.mustUseProperty=!1;Ee.prototype.number=!1;Ee.prototype.overloadedBoolean=!1;Ee.prototype.property="";Ee.prototype.spaceSeparated=!1;Ee.prototype.space=void 0;var ao={};Ju(ao,{boolean:()=>z,booleanish:()=>fe,commaOrSpaceSeparated:()=>We,commaSeparated:()=>Ft,number:()=>A,overloadedBoolean:()=>Ps,spaceSeparated:()=>ee});p();var sx=0,z=Rn(),fe=Rn(),Ps=Rn(),A=Rn(),ee=Rn(),Ft=Rn(),We=Rn();function Rn(){return 2**++sx}var bl=Object.keys(ao),An=class extends Ee{constructor(t,n,r,o){let s=-1;if(super(t,n),Sp(this,"space",o),typeof r=="number")for(;++s<bl.length;){let i=bl[s];Sp(this,bl[s],(r&ao[i])===ao[i])}}};An.prototype.defined=!0;function Sp(e,t,n){n&&(e[t]=n)}function lt(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let s=new An(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[io(r)]=r,n[io(s.attribute)]=r}return new Bt(t,n,e.space)}var xl=lt({properties:{ariaActiveDescendant:null,ariaAtomic:fe,ariaAutoComplete:null,ariaBusy:fe,ariaChecked:fe,ariaColCount:A,ariaColIndex:A,ariaColSpan:A,ariaControls:ee,ariaCurrent:null,ariaDescribedBy:ee,ariaDetails:null,ariaDisabled:fe,ariaDropEffect:ee,ariaErrorMessage:null,ariaExpanded:fe,ariaFlowTo:ee,ariaGrabbed:fe,ariaHasPopup:null,ariaHidden:fe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ee,ariaLevel:A,ariaLive:null,ariaModal:fe,ariaMultiLine:fe,ariaMultiSelectable:fe,ariaOrientation:null,ariaOwns:ee,ariaPlaceholder:null,ariaPosInSet:A,ariaPressed:fe,ariaReadOnly:fe,ariaRelevant:null,ariaRequired:fe,ariaRoleDescription:ee,ariaRowCount:A,ariaRowIndex:A,ariaRowSpan:A,ariaSelected:fe,ariaSetSize:A,ariaSort:null,ariaValueMax:A,ariaValueMin:A,ariaValueNow:A,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});p();p();p();function Ls(e,t){return t in e?e[t]:t}function $s(e,t){return Ls(e,t.toLowerCase())}var Tp=lt({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ft,acceptCharset:ee,accessKey:ee,action:null,allow:null,allowFullScreen:z,allowPaymentRequest:z,allowUserMedia:z,alpha:z,alt:null,as:null,async:z,autoCapitalize:null,autoComplete:ee,autoFocus:z,autoPlay:z,blocking:ee,capture:null,charSet:null,checked:z,cite:null,className:ee,closedBy:null,colorSpace:null,cols:A,colSpan:A,command:null,commandFor:null,content:null,contentEditable:fe,controls:z,controlsList:ee,coords:A|Ft,crossOrigin:null,data:null,dateTime:null,decoding:null,default:z,defer:z,dir:null,dirName:null,disabled:z,download:Ps,draggable:fe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:z,formTarget:null,headers:ee,height:A,hidden:Ps,high:A,href:null,hrefLang:null,htmlFor:ee,httpEquiv:ee,id:null,imageSizes:null,imageSrcSet:null,inert:z,inputMode:null,integrity:null,is:null,isMap:z,itemId:null,itemProp:ee,itemRef:ee,itemScope:z,itemType:ee,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:z,low:A,manifest:null,max:null,maxLength:A,media:null,method:null,min:null,minLength:A,multiple:z,muted:z,name:null,nonce:null,noModule:z,noValidate:z,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:z,optimum:A,pattern:null,ping:ee,placeholder:null,playsInline:z,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:z,referrerPolicy:null,rel:ee,required:z,reversed:z,rows:A,rowSpan:A,sandbox:ee,scope:null,scoped:z,seamless:z,selected:z,shadowRootClonable:z,shadowRootCustomElementRegistry:z,shadowRootDelegatesFocus:z,shadowRootMode:null,shadowRootSerializable:z,shape:null,size:A,sizes:null,slot:null,span:A,spellCheck:fe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:A,step:null,style:null,tabIndex:A,target:null,title:null,translate:null,type:null,typeMustMatch:z,useMap:null,value:fe,width:A,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ee,axis:null,background:null,bgColor:null,border:A,borderColor:null,bottomMargin:A,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:z,declare:z,event:null,face:null,frame:null,frameBorder:null,hSpace:A,leftMargin:A,link:null,longDesc:null,lowSrc:null,marginHeight:A,marginWidth:A,noResize:z,noHref:z,noShade:z,noWrap:z,object:null,profile:null,prompt:null,rev:null,rightMargin:A,rules:null,scheme:null,scrolling:fe,standby:null,summary:null,text:null,topMargin:A,valueType:null,version:null,vAlign:null,vLink:null,vSpace:A,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:z,disablePictureInPicture:z,disableRemotePlayback:z,exportParts:Ft,part:ee,prefix:null,property:null,results:A,security:null,unselectable:null},space:"html",transform:$s});p();var Cp=lt({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:We,accentHeight:A,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:A,amplitude:A,arabicForm:null,ascent:A,attributeName:null,attributeType:null,azimuth:A,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:A,by:null,calcMode:null,capHeight:A,className:ee,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:A,diffuseConstant:A,direction:null,display:null,dur:null,divisor:A,dominantBaseline:null,download:z,dx:null,dy:null,edgeMode:null,editable:null,elevation:A,enableBackground:null,end:null,event:null,exponent:A,externalResourcesRequired:null,fill:null,fillOpacity:A,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ft,g2:Ft,glyphName:Ft,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:A,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:A,horizOriginX:A,horizOriginY:A,id:null,ideographic:A,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:A,k:A,k1:A,k2:A,k3:A,k4:A,kernelMatrix:We,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:A,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:A,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:A,overlineThickness:A,paintOrder:null,panose1:null,path:null,pathLength:A,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ee,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:A,pointsAtY:A,pointsAtZ:A,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:We,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:We,rev:We,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:We,requiredFeatures:We,requiredFonts:We,requiredFormats:We,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:A,specularExponent:A,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:A,strikethroughThickness:A,string:null,stroke:null,strokeDashArray:We,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:A,strokeOpacity:A,strokeWidth:null,style:null,surfaceScale:A,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:We,tabIndex:A,tableValues:null,target:null,targetX:A,targetY:A,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:We,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:A,underlineThickness:A,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:A,values:null,vAlphabetic:A,vMathematical:A,vectorEffect:null,vHanging:A,vIdeographic:A,version:null,vertAdvY:A,vertOriginX:A,vertOriginY:A,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ls});p();var wl=lt({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});p();var kl=lt({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:$s});p();var Sl=lt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});p();var ix=/[A-Z]/g,_p=/-[a-z]/g,ax=/^data[-\w.:]+$/i;function Tl(e,t){let n=io(t),r=t,o=Ee;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ax.test(t)){if(t.charAt(4)==="-"){let s=t.slice(5).replace(_p,cx);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{let s=t.slice(4);if(!_p.test(s)){let i=s.replace(ix,lx);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=An}return new o(r,t)}function lx(e){return"-"+e.toLowerCase()}function cx(e){return e.charAt(1).toUpperCase()}var vp=yl([xl,Tp,wl,kl,Sl],"html"),Os=yl([xl,Cp,wl,kl,Sl],"svg");p();p();var Rp={}.hasOwnProperty;function Ap(e,t){let n=t||{};function r(o,...s){let i=r.invalid,a=r.handlers;if(o&&Rp.call(o,e)){let l=String(o[e]);i=Rp.call(a,l)?a[l]:r.unknown}if(i)return i.call(this,o,...s)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}p();p();p();var ux=/["&'<>`]/g,dx=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,px=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,fx=/[|\\{}()[\]^$+*?.]/g,Ep=new WeakMap;function Ip(e,t){if(e=e.replace(t.subset?mx(t.subset):ux,r),t.subset||t.escapeOnly)return e;return e.replace(dx,n).replace(px,r);function n(o,s,i){return t.format((o.charCodeAt(0)-55296)*1024+o.charCodeAt(1)-56320+65536,i.charCodeAt(s+2),t)}function r(o,s,i){return t.format(o.charCodeAt(0),i.charCodeAt(s+1),t)}}function mx(e){let t=Ep.get(e);return t||(t=hx(e),Ep.set(e,t)),t}function hx(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(fx,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}p();p();var gx=/[\dA-Fa-f]/;function Pp(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!gx.test(String.fromCharCode(t))?r:r+";"}p();var yx=/\d/;function Lp(e,t,n){let r="&#"+String(e);return n&&t&&!yx.test(String.fromCharCode(t))?r:r+";"}p();p();var $p=["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"];p();var Ds={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};p();var Op=["cent","copy","divide","gt","lt","not","para","times"];var Dp={}.hasOwnProperty,Cl={},Ns;for(Ns in Ds)Dp.call(Ds,Ns)&&(Cl[Ds[Ns]]=Ns);var bx=/[^\dA-Za-z]/;function Np(e,t,n,r){let o=String.fromCharCode(e);if(Dp.call(Cl,o)){let s=Cl[o],i="&"+s;return n&&$p.includes(s)&&!Op.includes(s)&&(!r||t&&t!==61&&bx.test(String.fromCharCode(t)))?i:i+";"}return""}function Mp(e,t,n){let r=Pp(e,t,n.omitOptionalSemicolons),o;if((n.useNamedReferences||n.useShortestReferences)&&(o=Np(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!o)&&n.useShortestReferences){let s=Lp(e,t,n.omitOptionalSemicolons);s.length<r.length&&(r=s)}return o&&(!n.useShortestReferences||o.length<r.length)?o:r}function Gt(e,t){return Ip(e,Object.assign({format:Mp},t))}var xx=/^>|^->|<!--|-->|--!>|<!-$/g,wx=[">"],kx=["<",">"];function Bp(e,t,n,r){return r.settings.bogusComments?"<?"+Gt(e.value,Object.assign({},r.settings.characterReferences,{subset:wx}))+">":"<!--"+e.value.replace(xx,o)+"-->";function o(s){return Gt(s,Object.assign({},r.settings.characterReferences,{subset:kx}))}}p();function Fp(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}p();p();function _l(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;o!==-1;)r++,o=n.indexOf(t,o+t.length);return r}p();function Gp(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}p();function jp(e){return e.join(" ").trim()}p();p();p();var Sx=/[ \t\n\f\r]/g;function En(e){return typeof e=="object"?e.type==="text"?Up(e.value):!1:Up(e)}function Up(e){return e.replace(Sx,"")===""}p();var ye=Wp(1),vl=Wp(-1),Tx=[];function Wp(e){return t;function t(n,r,o){let s=n?n.children:Tx,i=(r||0)+e,a=s[i];if(!o)for(;a&&En(a);)i+=e,a=s[i];return a}}p();var Cx={}.hasOwnProperty;function Ms(e){return t;function t(n,r,o){return Cx.call(e,n.tagName)&&e[n.tagName](n,r,o)}}var lo=Ms({body:vx,caption:Rl,colgroup:Rl,dd:Ix,dt:Ex,head:Rl,html:_x,li:Ax,optgroup:Px,option:Lx,p:Rx,rp:Hp,rt:Hp,tbody:Ox,td:Vp,tfoot:Dx,th:Vp,thead:$x,tr:Nx});function Rl(e,t,n){let r=ye(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&En(r.value.charAt(0)))}function _x(e,t,n){let r=ye(n,t);return!r||r.type!=="comment"}function vx(e,t,n){let r=ye(n,t);return!r||r.type!=="comment"}function Rx(e,t,n){let r=ye(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 Ax(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&r.tagName==="li"}function Ex(e,t,n){let r=ye(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Ix(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Hp(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Px(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function Lx(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function $x(e,t,n){let r=ye(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Ox(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Dx(e,t,n){return!ye(n,t)}function Nx(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Vp(e,t,n){let r=ye(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}p();var zp=Ms({body:Fx,colgroup:Gx,head:Bx,html:Mx,tbody:jx});function Mx(e){let t=ye(e,-1);return!t||t.type!=="comment"}function Bx(e){let t=new Set;for(let 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)}let n=e.children[0];return!n||n.type==="element"}function Fx(e){let t=ye(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&En(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Gx(e,t,n){let r=vl(n,t),o=ye(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&lo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function jx(e,t,n){let r=vl(n,t),o=ye(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&lo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}var Bs={name:[[`
|
|
22
|
+
`+i:r=i}return o(),n}function xy(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("**",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=e.indexOf("**",r+2);if(o===-1){t.push({text:e.slice(r),type:"plain"});break}t.push({text:e.slice(r+2,o),type:"bold"}),n=o+2}return t}function by(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf("`",n);if(r===-1){t.push({text:e.slice(n),type:"plain"});break}r>n&&t.push({text:e.slice(n,r),type:"plain"});let o=1;for(;r+o<e.length&&e[r+o]==="`";)o++;if(o===1){let s=e.indexOf("`",r+1);if(s===-1){t.push({text:e.slice(r),type:"plain"});break}t.push({text:e.slice(r+1,s),type:"code"}),n=s+1}else t.push({text:e.slice(r,r+o),type:"plain"}),n=r+o}return t}function wy(e){let t=[];for(let n of e){if(n.type==="code_block"||n.type==="table"){t.push(n);continue}let r=by(n.text);for(let o of r)o.type==="code"?t.push(o):n.type==="bold"?t.push({text:o.text,type:"bold"}):t.push(o)}return t}var ky="#22c55e",Sy="#ef4444",Ty="#00cccc";function Cy({code:e}){let t=e.split(`
|
|
23
|
+
`),n=t[0]??"",r=n.trim().length>0&&!n.startsWith("+")&&!n.startsWith("-")&&!n.startsWith("@@")&&!n.startsWith(" "),o=r?n:void 0,s=r?t.slice(1):t;return s.length===0?r?be(ds,{marginLeft:2,children:Ga(Le,{color:"#888888",children:["\u250C ",o]})}):null:Ga(ds,{flexDirection:"column",marginLeft:2,marginTop:1,children:[o&&Ga(Le,{color:"#888888",children:["\u250C ",o]}),s.map((i,a)=>i.startsWith("+")?be(Le,{color:ky,children:i},a):i.startsWith("-")?be(Le,{color:Sy,children:i},a):i.startsWith("@@")?be(Le,{color:Ty,children:i},a):be(Le,{children:i},a))]})}function _y({text:e}){let t=wd(),n=bd(e,{termWidth:t});return n.colWidths.length===0?be(Le,{children:e}):be(ds,{flexDirection:"column",marginTop:1,children:n.lines.map((r,o)=>{let s=o===0,i=o===n.lines.length-1,a=!s&&!i&&r.startsWith("\u251C");return be(Le,{color:s||i||a?"#888888":void 0,children:r},o)})})}var vy=/[\u{1F000}-\u{1FFFF}\u{FE00}-\u{FE0F}\u{200D}\u{20E3}\u{2600}-\u{27BF}\u{231A}-\u{23FF}\u{2934}\u{2935}\u{25AA}-\u{25FE}\u{2B50}\u{2B55}\u{00A9}\u{00AE}\u{2122}\u{3030}\u{303D}\u{3297}\u{3299}]/u;function Ry(e){return vy.test(e)}function Ay(e){try{return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(e)].map(r=>({text:r.segment,isEmoji:Ry(r.segment)}))}catch{return[{text:e,isEmoji:!1}]}}function kd(e,t){let n=Ay(e);if(n.length===1&&!n[0].isEmoji)return be(Le,{color:Td,children:e},t);let r=[];for(let o of n){let s=r[r.length-1];s&&s.isEmoji===o.isEmoji?s.text+=o.text:r.push({text:o.text,isEmoji:o.isEmoji})}return be(Le,{children:r.map((o,s)=>o.isEmoji?o.text:be(Le,{color:Td,children:o.text},s))},t)}var Sd="#00BFFF",Td="#A855F7";function Cd({children:e}){let t=hy(e),n=[];for(let c of t)c.type==="code_block"?n.push(c):n.push(...yy(c.text));let r=[];for(let c of n)c.type==="code_block"||c.type==="table"?r.push(c):r.push(...xy(c.text));let o=wy(r);if(!o.some(c=>c.type==="code_block"||c.type==="table"))return o.length===1&&o[0].type==="plain"?be(Le,{wrap:"wrap",children:e}):be(Le,{wrap:"wrap",children:o.map((u,d)=>u.type==="code"?be(Le,{color:Sd,children:u.text},d):u.type==="bold"?kd(u.text,d):u.text)});let i=[],a=[];function l(c){if(a.length===0)return;a.length===1&&a[0].type==="plain"?i.push(be(Le,{wrap:"wrap",children:a[0].text},c)):i.push(be(Le,{wrap:"wrap",children:a.map((d,m)=>d.type==="code"?be(Le,{color:Sd,children:d.text},m):d.type==="bold"?kd(d.text,m):d.text)},c)),a=[]}for(let c of o)c.type==="code_block"?(l(i.length),i.push(be(Cy,{code:c.text},`b${i.length}`))):c.type==="table"?(l(i.length),i.push(be(_y,{text:c.text},`t${i.length}`))):a.push(c);return l(i.length),be(ds,{flexDirection:"column",children:i})}import{Fragment as Ly,jsx as Ct,jsxs as Je}from"react/jsx-runtime";function Iy(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Py({usage:e,cost:t}){let n=e?e.promptTokens+e.completionTokens:0,r=t??0,[o,s]=vd(n),[i,a]=vd(r),l=_d(null),c=_d(null);return Ey(()=>{if(l.current&&l.current.toTokens===n&&l.current.toCost===r)return;if(n<=o&&r<=i){s(n),a(r),l.current={fromTokens:n,fromCost:r,toTokens:n,toCost:r,startMs:Date.now(),durationMs:0};return}let u=n-o,d=r-i,m=Math.min(600,Math.max(220,Math.max(u,0)*1.2+220));return l.current={fromTokens:o,fromCost:i,toTokens:n,toCost:r,startMs:Date.now(),durationMs:m},c.current&&clearInterval(c.current),c.current=setInterval(()=>{let h=l.current;if(!h)return;let f=Date.now()-h.startMs;if(f>=h.durationMs){s(h.toTokens),a(h.toCost),c.current&&(clearInterval(c.current),c.current=null);return}let g=f/h.durationMs,b=1-Math.pow(1-g,3),w=h.fromTokens+(h.toTokens-h.fromTokens)*b,S=h.fromCost+(h.toCost-h.fromCost)*b;s(w),a(S)},33),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[n,r]),Je(Ly,{children:[e&&Je(Ot,{color:"#888888",children:[Math.round(o).toLocaleString()," tokens"]}),t!==void 0&&t>0&&Je(Ot,{color:"#888888",children:[" \xB7 ","\xA5",i.toFixed(4)]})]})}function ps({content:e,toolCalls:t,isStreaming:n=!1,usage:r,elapsed:o,cost:s,model:i,toolResults:a}){return!e&&(!t||t.length===0)&&!n?null:Je(Tt,{flexDirection:"row",marginTop:1,children:[Ct(Tt,{width:1,backgroundColor:"#E040FB",flexShrink:0}),Je(Tt,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[Je(Tt,{flexDirection:"row",children:[Ct(Tt,{width:4,flexShrink:0,children:Ct(Ot,{bold:!0,color:"#ff00ff",children:"\u{1F916}"})}),Je(Tt,{flexGrow:1,flexDirection:"column",children:[e&&Ct(Cd,{children:e}),n&&!e&&Ct(Ot,{color:"#888888",children:"..."})]})]}),t&&t.length>0&&Ct(Tt,{flexDirection:"column",children:t.map((l,c)=>Ct(Ma,{call:l,denial:a?.get(l.id??"")?.denial},l.id??c))}),n&&(r||s!==void 0)&&Ct(Tt,{flexDirection:"row",marginTop:1,marginLeft:3,children:Je(Ot,{color:"#666666",dimColor:!0,children:["\u23F3 \u5DF2\u6D88\u8017 ",Ct(Py,{usage:r,cost:s})]})}),!n&&(r||o!==void 0)&&Je(Tt,{flexDirection:"column",marginTop:1,marginLeft:3,children:[Ct(Ot,{color:"#555555",children:"\u2500".repeat(36)}),Je(Tt,{flexDirection:"row",gap:2,children:[s!==void 0&&s>0&&Je(Ot,{color:"yellow",children:["\u{1F4B0} \u672C\u6B21 ",$a(s)]}),o!==void 0&&Je(Ot,{color:"cyan",children:["\u{1F550} ",Iy(o)]}),r&&Je(Ot,{color:"#888888",children:["\u{1F4E6} ",(r.promptTokens+r.completionTokens).toLocaleString()," tokens"]})]})]})]})]})}p();import{Box as ja,Text as Tn}from"ink";import{jsx as Cn,jsxs as fs}from"react/jsx-runtime";function Ua({diff:e}){let{patch:t,additions:n,deletions:r,existedBefore:o,filePath:s}=e;if(!t||t.length===0)return null;let i=t.split(`
|
|
24
|
+
`),a=s.replace(/\\/g,"/").split("/").pop()??s;return fs(ja,{flexDirection:"column",marginTop:1,children:[fs(ja,{flexDirection:"row",gap:1,children:[fs(Tn,{bold:!0,color:"#00ffff",children:["\u{1F4DD} ",o?"\u4FEE\u6539":"\u65B0\u5EFA",":"]}),Cn(Tn,{bold:!0,children:a}),fs(Tn,{color:"#555555",children:["(+",n," -",r,")"]})]}),Cn(ja,{flexDirection:"column",marginLeft:2,children:i.filter(l=>!l.startsWith("---")&&!l.startsWith("+++")).map((l,c)=>Cn($y,{line:l},c))})]})}function $y({line:e}){return e.startsWith("---")||e.startsWith("+++")?null:e.startsWith("@@")?Cn(Tn,{color:"#00cccc",children:e}):e.startsWith("+")?Cn(Tn,{color:"#22c55e",children:e}):e.startsWith("-")?Cn(Tn,{color:"#ef4444",children:e}):Cn(Tn,{color:"#6b7280",children:e})}p();import{Box as Wa,Text as Ha}from"ink";import{jsx as ms,jsxs as Rd}from"react/jsx-runtime";var Oy="#00bfff";function Va({skills:e,input:t,selectedIndex:n}){let r=t.match(/(?:^|\s)\/([^/]*)$/);if(!r)return null;let o=r[1].toLowerCase().trim();if(e.length===0)return null;let s=!o&&t.startsWith("/")?e.slice(0,3):e.filter(i=>i.name.toLowerCase().includes(o)).slice(0,3);return o&&s.some(i=>i.name.toLowerCase()===o)||s.length===0?null:Rd(Wa,{flexDirection:"column",marginLeft:4,marginTop:1,children:[ms(Ha,{color:"#808080",dimColor:!0,children:"\u652F\u6301\u7684 Skill\uFF1A"}),s.map((i,a)=>ms(Wa,{children:Rd(Ha,{color:a===n?Oy:"#808080",children:[a===n?" \u203A ":" ",i.name]})},i.name)),ms(Wa,{marginTop:1,children:ms(Ha,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as ln,Text as gr}from"ink";import{useEffect as c0,useState as u0}from"react";p();import{Box as hr,Text as On}from"ink";import{useEffect as o0,useState as s0}from"react";p();p();p();function Dy(e){return tl(e)}function tl(e){return Array.isArray(e)?Ny(e):e instanceof RegExp?e:typeof e=="object"?My(e):e}function Ny(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=tl(e[n]);return t}function My(e){let t={};for(let n in e)t[n]=tl(e[n]);return t}function Nd(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function Md(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Md(e.substring(0,e.length-1)):e.substr(~t+1)}var za=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,hs=class{static hasCaptures(e){return e===null?!1:(za.lastIndex=0,za.test(e))}static replaceCaptures(e,t,n){return e.replace(za,(r,o,s,i)=>{let a=n[parseInt(o||s,10)];if(a){let l=t.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(i){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Bd(e,t){return e<t?-1:e>t?1:0}function Fd(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 o=0;o<n;o++){let s=Bd(e[o],t[o]);if(s!==0)return s}return 0}return n-r}function Ad(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 Gd(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var jd=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},zr=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(Gy(e),t)}static createFromParsedTheme(e,t){return Uy(e,t)}_cachedMatchRoot=new jd(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(o=>By(e.parent,o.parentScopes));return r?new Ud(r.fontStyle,r.foreground,r.background):null}},qa=class gs{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(let r of n)t=new gs(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new gs(n,t[r]);return n}push(t){return new gs(this,t)}getSegments(){let t=this,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){let n=[],r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function By(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],o=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],o=!0}for(;e&&!Fy(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Fy(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Ud=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function Gy(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let o=0,s=t.length;o<s;o++){let i=t[o];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let d=i.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),a=d.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let l=-1;if(typeof i.settings.fontStyle=="string"){l=0;let d=i.settings.fontStyle.split(" ");for(let m=0,h=d.length;m<h;m++)switch(d[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof i.settings.foreground=="string"&&Ad(i.settings.foreground)&&(c=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Ad(i.settings.background)&&(u=i.settings.background);for(let d=0,m=a.length;d<m;d++){let f=a[d].trim().split(" "),g=f[f.length-1],b=null;f.length>1&&(b=f.slice(0,f.length-1),b.reverse()),n[r++]=new jy(g,b,o,l,c,u)}}return n}var jy=class{constructor(e,t,n,r,o,s){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=o,this.background=s}},de=(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))(de||{});function Uy(e,t){e.sort((l,c)=>{let u=Bd(l.scope,c.scope);return u!==0||(u=Fd(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",o="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(o=l.background)}let s=new Wy(t),i=new Ud(n,s.getId(r),s.getId(o)),a=new Vy(new Xa(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let u=e[l];a.insert(0,u.scope,u.parentScopes,u.fontStyle,s.getId(u.foreground),s.getId(u.background))}return new zr(s,i,a)}var Wy=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)}},Hy=Object.freeze([]),Xa=class Wd{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,o,s){this.scopeDepth=t,this.parentScopes=n||Hy,this.fontStyle=r,this.foreground=o,this.background=s}clone(){return new Wd(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,o=t.length;r<o;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,o){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},Vy=class Ja{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,o=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[o]===">"&&o++,!(r>=t.parentScopes.length||o>=n.parentScopes.length);){let s=n.parentScopes[o].length-t.parentScopes[r].length;if(s!==0)return s;r++,o++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),o,s;if(r===-1?(o=t,s=""):(o=t.substring(0,r),s=t.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(s)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Ja._cmpBySpecificity),n}insert(t,n,r,o,s,i){if(n===""){this._doInsertHere(t,r,o,s,i);return}let a=n.indexOf("."),l,c;a===-1?(l=n,c=""):(l=n.substring(0,a),c=n.substring(a+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new Ja(this._mainRule.clone(),Xa.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(t+1,c,r,o,s,i)}_doInsertHere(t,n,r,o,s){if(n===null){this._mainRule.acceptOverwrite(t,r,o,s);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let l=this._rulesWithParentScopes[i];if(Fd(l.parentScopes,n)===0){l.acceptOverwrite(t,r,o,s);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Xa(t,n,r,o,s))}},nn=class ot{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let n=ot.getLanguageId(t),r=ot.getTokenType(t),o=ot.getFontStyle(t),s=ot.getForeground(t),i=ot.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:o,foreground:s,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,o,s,i,a){let l=ot.getLanguageId(t),c=ot.getTokenType(t),u=ot.containsBalancedBrackets(t)?1:0,d=ot.getFontStyle(t),m=ot.getForeground(t),h=ot.getBackground(t);return n!==0&&(l=n),r!==8&&(c=r),o!==null&&(u=o?1:0),s!==-1&&(d=s),i!==0&&(m=i),a!==0&&(h=a),(l<<0|c<<8|u<<10|d<<11|m<<15|h<<24)>>>0}};function xs(e,t){let n=[],r=zy(e),o=r.next();for(;o!==null;){let l=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let c=i();if(n.push({matcher:c,priority:l}),o!==",")break;o=r.next()}return n;function s(){if(o==="-"){o=r.next();let l=s();return c=>!!l&&!l(c)}if(o==="("){o=r.next();let l=a();return o===")"&&(o=r.next()),l}if(Ed(o)){let l=[];do l.push(o),o=r.next();while(Ed(o));return c=>t(l,c)}return null}function i(){let l=[],c=s();for(;c;)l.push(c),c=s();return u=>l.every(d=>d(u))}function a(){let l=[],c=i();for(;c&&(l.push(c),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");c=i()}return u=>l.some(d=>d(u))}}function Ed(e){return!!e&&!!e.match(/[\w\.:]+/)}function zy(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Hd(e){typeof e.dispose=="function"&&e.dispose()}var qr=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},qy=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Ky=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Xy=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new qr(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ky;for(let n of e)Jy(n,this.initialScopeName,this.repo,t);for(let n of t.references)if(n instanceof qr){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 Jy(e,t,n,r){let o=n.lookup(e.scopeName);if(!o){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let s=n.lookup(t);e instanceof qr?ys({baseGrammar:s,selfGrammar:o},r):Za(e.ruleName,{baseGrammar:s,selfGrammar:o,repository:o.repository},r);let i=n.injections(e.scopeName);if(i)for(let a of i)r.add(new qr(a))}function Za(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];bs([r],t,n)}}function ys(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&bs(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&bs(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function bs(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let o=r.repository?Nd({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&bs(r.patterns,{...t,repository:o},n);let s=r.include;if(!s)continue;let i=Vd(s);switch(i.kind){case 0:ys({...t,selfGrammar:t.baseGrammar},n);break;case 1:ys(t,n);break;case 2:Za(i.ruleName,{...t,repository:o},n);break;case 3:case 4:let a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){let l={baseGrammar:t.baseGrammar,selfGrammar:a,repository:o};i.kind===4?Za(i.ruleName,l,n):ys(l,n)}else i.kind===4?n.add(new qy(i.scopeName,i.ruleName)):n.add(new qr(i.scopeName));break}}}var Zy=class{kind=0},Yy=class{kind=1},Qy=class{constructor(e){this.ruleName=e}kind=2},ex=class{constructor(e){this.scopeName=e}kind=3},tx=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Vd(e){if(e==="$base")return new Zy;if(e==="$self")return new Yy;let t=e.indexOf("#");if(t===-1)return new ex(e);if(t===0)return new Qy(e.substring(1));{let n=e.substring(0,t),r=e.substring(t+1);return new tx(n,r)}}var nx=/\\(\d+)/,Id=/\\(\d+)/g;var rx=-1,zd=-2;var Jr=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=hs.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=hs.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Md(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:hs.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:hs.replaceCaptures(this._contentName,e,t)}},ox=class extends Jr{retokenizeCapturedWithRuleId;constructor(e,t,n,r,o){super(e,t,n,r),this.retokenizeCapturedWithRuleId=o}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!")}},sx=class extends Jr{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,null),this._match=new Kr(r,this.id),this.captures=o,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 Xr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Pd=class extends Jr{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,r),this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let 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 Xr,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ya=class extends Jr{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,o,s,i,a,l,c){super(e,t,n,r),this._begin=new Kr(o,this.id),this.beginCaptures=s,this._end=new Kr(i||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Xr;for(let 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}},ws=class extends Jr{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,o,s,i,a,l){super(e,t,n,r),this._begin=new Kr(o,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new Kr(i,zd),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Xr;for(let 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 Xr,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},qd=class De{static createCaptureRule(t,n,r,o,s){return t.registerRule(i=>new ox(n,i,r,o,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(o=>{if(t.id=o,t.match)return new sx(t.$vscodeTextmateLocation,t.id,t.name,t.match,De._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Nd({},r,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Pd(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,De._compilePatterns(s,n,r))}return t.while?new ws(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,De._compileCaptures(t.whileCaptures||t.captures,n,r),De._compilePatterns(t.patterns,n,r)):new Ya(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,De._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,De._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,De._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let o=[];if(t){let s=0;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10);a>s&&(s=a)}for(let i=0;i<=s;i++)o[i]=null;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let a=parseInt(i,10),l=0;t[i].patterns&&(l=De.getCompiledRuleId(t[i],n,r)),o[a]=De.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,l)}}return o}static _compilePatterns(t,n,r){let o=[];if(t)for(let s=0,i=t.length;s<i;s++){let a=t[s],l=-1;if(a.include){let c=Vd(a.include);switch(c.kind){case 0:case 1:l=De.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=De.getCompiledRuleId(u,n,r));break;case 3:case 4:let d=c.scopeName,m=c.kind===4?c.ruleName:null,h=n.getExternalGrammar(d,r);if(h)if(m){let f=h.repository[m];f&&(l=De.getCompiledRuleId(f,n,h.repository))}else l=De.getCompiledRuleId(h.repository.$self,n,h.repository);break}}else l=De.getCompiledRuleId(a,n,r);if(l!==-1){let c=n.getRule(l),u=!1;if((c instanceof Pd||c instanceof Ya||c instanceof ws)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;o.push(l)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},Kr=class Kd{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){let r=t.length,o=0,s=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){let c=t.charAt(a+1);c==="z"?(s.push(t.substring(o,a)),s.push("$(?!\\n)(?<!\\n)"),o=a+2):(c==="A"||c==="G")&&(i=!0),a++}this.hasAnchor=i,o===0?this.source=t:(s.push(t.substring(o,r)),this.source=s.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=nx.test(this.source):this.hasBackReferences=!1}clone(){return new Kd(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(o=>t.substring(o.start,o.end));return Id.lastIndex=0,this.source.replace(Id,(o,s)=>Gd(r[parseInt(s,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=[],o=[],s,i,a,l;for(s=0,i=this.source.length;s<i;s++)a=this.source.charAt(s),t[s]=a,n[s]=a,r[s]=a,o[s]=a,a==="\\"&&s+1<i&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",n[s+1]="\uFFFF",r[s+1]="A",o[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",n[s+1]="G",r[s+1]="\uFFFF",o[s+1]="G"):(t[s+1]=l,n[s+1]=l,r[s+1]=l,o[s+1]=l),s++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:o.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}},Xr=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 Ld(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(o=>o.resolveAnchors(t,n));return new Ld(e,r,this._items.map(o=>o.ruleId))}},Ld=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(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
25
|
+
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Ka=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ix=class Qa{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Ka(t,8),this._embeddedLanguagesMatcher=new ax(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Qa._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Ka(0,0);_getBasicScopeAttributes=new jd(t=>{let n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Ka(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let n=t.match(Qa.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/},ax=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([n,r])=>Gd(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},mR={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Xd=!1,$d=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Jd(e,t,n,r,o,s,i,a){let l=t.content.length,c=!1,u=-1;if(i){let h=lx(e,t,n,r,o,s);o=h.stack,r=h.linePos,n=h.isFirstLine,u=h.anchorPosition}let d=Date.now();for(;!c;){if(a!==0&&Date.now()-d>a)return new $d(o,!0);m()}return new $d(o,!1);function m(){let h=cx(e,t,n,r,o,u);if(!h){s.produce(o,l),c=!0;return}let f=h.captureIndices,g=h.matchedRuleId,b=f&&f.length>0?f[0].end>r:!1;if(g===rx){let w=o.getRule(e);s.produce(o,f[0].start),o=o.withContentNameScopesList(o.nameScopesList),Hr(e,t,n,o,s,w.endCaptures,f),s.produce(o,f[0].end);let S=o;if(o=o.parent,u=S.getAnchorPos(),!b&&S.getEnterPos()===r){o=S,s.produce(o,l),c=!0;return}}else{let w=e.getRule(g);s.produce(o,f[0].start);let S=o,v=w.getName(t.content,f),_=o.contentNameScopesList.pushAttributed(v,e);if(o=o.push(g,r,u,f[0].end===l,null,_,_),w instanceof Ya){let E=w;Hr(e,t,n,o,s,E.beginCaptures,f),s.produce(o,f[0].end),u=f[0].end;let M=E.getContentName(t.content,f),U=_.pushAttributed(M,e);if(o=o.withContentNameScopesList(U),E.endHasBackReferences&&(o=o.withEndRule(E.getEndWithResolvedBackReferences(t.content,f))),!b&&S.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(w instanceof ws){let E=w;Hr(e,t,n,o,s,E.beginCaptures,f),s.produce(o,f[0].end),u=f[0].end;let M=E.getContentName(t.content,f),U=_.pushAttributed(M,e);if(o=o.withContentNameScopesList(U),E.whileHasBackReferences&&(o=o.withEndRule(E.getWhileWithResolvedBackReferences(t.content,f))),!b&&S.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(Hr(e,t,n,o,s,w.captures,f),s.produce(o,f[0].end),o=o.pop(),!b){o=o.safePop(),s.produce(o,l),c=!0;return}}f[0].end>r&&(r=f[0].end,n=!1)}}function lx(e,t,n,r,o,s){let i=o.beginRuleCapturedEOL?0:-1,a=[];for(let l=o;l;l=l.pop()){let c=l.getRule(e);c instanceof ws&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){let{ruleScanner:c,findOptions:u}=px(l.rule,e,l.stack.endRule,n,r===i),d=c.findNextMatchSync(t,r,u);if(d){if(d.ruleId!==zd){o=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),Hr(e,t,n,l.stack,s,l.rule.whileCaptures,d.captureIndices),s.produce(l.stack,d.captureIndices[0].end),i=d.captureIndices[0].end,d.captureIndices[0].end>r&&(r=d.captureIndices[0].end,n=!1))}else{o=l.stack.pop();break}}return{stack:o,linePos:r,anchorPosition:i,isFirstLine:n}}function cx(e,t,n,r,o,s){let i=ux(e,t,n,r,o,s),a=e.getInjections();if(a.length===0)return i;let l=dx(a,e,t,n,r,o,s);if(!l)return i;if(!i)return l;let c=i.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:i}function ux(e,t,n,r,o,s){let i=o.getRule(e),{ruleScanner:a,findOptions:l}=Zd(i,e,o.endRule,n,r===s),c=a.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function dx(e,t,n,r,o,s,i){let a=Number.MAX_VALUE,l=null,c,u=0,d=s.contentNameScopesList.getScopeNames();for(let m=0,h=e.length;m<h;m++){let f=e[m];if(!f.matcher(d))continue;let g=t.getRule(f.ruleId),{ruleScanner:b,findOptions:w}=Zd(g,t,null,r,o===i),S=b.findNextMatchSync(n,o,w);if(!S)continue;let v=S.captureIndices[0].start;if(!(v>=a)&&(a=v,l=S.captureIndices,c=S.ruleId,u=f.priority,a===o))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function Zd(e,t,n,r,o){if(Xd){let i=e.compile(t,n),a=Yd(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileAG(t,n,r,o),findOptions:0}}function px(e,t,n,r,o){if(Xd){let i=e.compileWhile(t,n),a=Yd(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileWhileAG(t,n,r,o),findOptions:0}}function Yd(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function Hr(e,t,n,r,o,s,i){if(s.length===0)return;let a=t.content,l=Math.min(s.length,i.length),c=[],u=i[0].end;for(let d=0;d<l;d++){let m=s[d];if(m===null)continue;let h=i[d];if(h.length===0)continue;if(h.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=h.start;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?o.produceFromScopes(c[c.length-1].scopes,h.start):o.produce(r,h.start),m.retokenizeCapturedWithRuleId){let g=m.getName(a,i),b=r.contentNameScopesList.pushAttributed(g,e),w=m.getContentName(a,i),S=b.pushAttributed(w,e),v=r.push(m.retokenizeCapturedWithRuleId,h.start,-1,!1,null,b,S),_=e.createOnigString(a.substring(0,h.end));Jd(e,_,n&&h.start===0,h.start,v,o,!1,0),Hd(_);continue}let f=m.getName(a,i);if(f!==null){let b=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);c.push(new fx(b,h.end))}}for(;c.length>0;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var fx=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function mx(e,t,n,r,o,s,i,a){return new gx(e,t,n,r,o,s,i,a)}function Od(e,t,n,r,o){let s=xs(t,ks),i=qd.getCompiledRuleId(n,r,o.repository);for(let a of s)e.push({debugSelector:t,matcher:a.matcher,ruleId:i,grammar:o,priority:a.priority})}function ks(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let o=n;o<t.length;o++)if(hx(t[o],r))return n=o+1,!0;return!1})}function hx(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var gx=class{constructor(e,t,n,r,o,s,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new ix(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Dd(t,null),this._injections=null,this._tokenTypeMatchers=[],o)for(let l of Object.keys(o)){let c=xs(l,ks);for(let u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:o[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let 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(){let e={lookup:o=>o===this._rootScopeName?this._grammar:this.getExternalGrammar(o),injections:o=>this._grammarRepository.injections(o)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let o=r.injections;if(o)for(let i in o)Od(t,i,o[i],this,r);let s=this._grammarRepository.injections(n);s&&s.forEach(i=>{let a=this.getExternalGrammar(i);if(a){let l=a.injectionSelector;l&&Od(t,l,a,this,a)}})}return t.sort((o,s)=>o.priority-s.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let 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){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Dd(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let 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){let 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=qd.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!t||t===el.NULL){o=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),d=nn.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),m=this.getRule(this._rootId).getName(null,null),h;m?h=Vr.createRootAndLookUpScopeName(m,d,this):h=Vr.createRoot("unknown",d),t=new el(null,this._rootId,-1,-1,!1,null,h,h)}else o=!1,t.reset();e=e+`
|
|
26
|
+
`;let s=this.createOnigString(e),i=s.content.length,a=new xx(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Jd(this,s,o,0,t,a,!0,r);return Hd(s),{lineLength:i,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Dd(e,t){return e=Dy(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 Vr=class _t{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,o=t?.scopePath??null;for(let s of n)o=qa.push(o,s.scopeNames),r=new _t(r,o,s.encodedTokenAttributes);return r}static createRoot(t,n){return new _t(null,new qa(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let o=r.getMetadataForScope(t),s=new qa(null,t),i=r.themeProvider.themeMatch(s),a=_t.mergeAttributes(n,o,i);return new _t(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return _t.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 o=-1,s=0,i=0;return r!==null&&(o=r.fontStyle,s=r.foregroundId,i=r.backgroundId),nn.set(t,n.languageId,n.tokenType,null,o,s,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return _t._pushAttributed(this,t,n);let r=t.split(/ /g),o=this;for(let s of r)o=_t._pushAttributed(o,s,n);return o}static _pushAttributed(t,n,r){let o=r.getMetadataForScope(n),s=t.scopePath.push(n),i=r.themeProvider.themeMatch(s),a=_t.mergeAttributes(t.tokenAttributes,o,i);return new _t(t,s,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let n=[],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}},el=class _n{constructor(t,n,r,o,s,i,a,l){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=o}_stackElementBrand=void 0;static NULL=new _n(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:_n._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Vr.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(){_n._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,o,s,i,a){return new _n(this,t,n,r,o,s,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let 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 _n(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){let r=Vr.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new _n(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Vr.fromExtension(r,n.contentNameScopesList))}},yx=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):xs(n,ks).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>xs(n,ks).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(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},xx=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,o=!1;if(this.balancedBracketSelectors?.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let s=e?.getScopeNames()??[];for(let i of this._tokenTypeOverrides)i.matcher(s)&&(r=nn.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(s))}if(o&&(r=nn.set(r,0,8,o,-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}let 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);let n=new Uint32Array(this._binaryTokens.length);for(let r=0,o=this._binaryTokens.length;r<o;r++)n[r]=this._binaryTokens[r];return n}},bx=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let 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,o){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,mx(e,s,t,n,r,o,this,this._onigLib))}return this._grammars.get(e)}},Qd=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new bx(zr.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(zr.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new yx(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,o){let s=new Xy(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(i=>this._loadSingleGrammar(i.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,n,r,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,o=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,o)}},Ss=el.NULL;p();var ol=Eg(ip(),1),sr=ol.default,{Ansis:ZR,fg:YR,bg:QR,rgb:eA,bgRgb:tA,hex:nA,bgHex:rA,reset:oA,inverse:sA,hidden:iA,visible:aA,link:lA,bold:cA,dim:uA,italic:dA,underline:pA,strikethrough:fA,black:mA,red:hA,green:gA,yellow:yA,blue:xA,magenta:bA,cyan:wA,white:kA,gray:SA,redBright:TA,greenBright:CA,yellowBright:_A,blueBright:vA,magentaBright:RA,cyanBright:AA,whiteBright:EA,bgBlack:IA,bgRed:PA,bgGreen:LA,bgYellow:$A,bgBlue:OA,bgMagenta:DA,bgCyan:NA,bgWhite:MA,bgGray:BA,bgRedBright:FA,bgGreenBright:GA,bgYellowBright:jA,bgBlueBright:UA,bgMagentaBright:WA,bgCyanBright:HA,bgWhiteBright:VA}=ol.default;p();p();var sl=Object.defineProperty,_x=Object.getOwnPropertyDescriptor,vx=Object.getOwnPropertyNames,Rx=Object.prototype.hasOwnProperty,ir=(e,t)=>{let n={};for(var r in e)sl(n,r,{get:e[r],enumerable:!0});return t||sl(n,Symbol.toStringTag,{value:"Module"}),n},ap=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=vx(t),s=0,i=o.length,a;s<i;s++)a=o[s],!Rx.call(e,a)&&a!==n&&sl(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=_x(t,a))||r.enumerable});return e},Cs=(e,t,n)=>(ap(e,t,"default"),n&&ap(n,t,"default"));p();var ar=[{id:"abap",name:"ABAP",import:(()=>import("./abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("./actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("./ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("./angular-html-FD45HTTF.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("./angular-ts-UGSD62EB.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("./apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("./apex-27CRTE2E.js"))},{id:"apl",name:"APL",import:(()=>import("./apl-DZEE5XRN.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("./applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("./ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("./asciidoc-6DTTKQ3A.js"))},{id:"asm",name:"Assembly",import:(()=>import("./asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("./astro-AZ66H24C.js"))},{id:"awk",name:"AWK",import:(()=>import("./awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("./ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("./bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("./beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("./berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("./bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("./bicep-EOACOM4G.js"))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>import("./bird2-ZG3DO533.js"))},{id:"blade",name:"Blade",import:(()=>import("./blade-6Y7SALML.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("./bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("./c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("./c3-4Z2YI6YO.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("./cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("./cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("./clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("./clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("./cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("./cobol-KCXH3T3Q.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("./codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("./codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("./coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("./common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("./coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("./cpp-B4ITA36J.js"))},{id:"crystal",name:"Crystal",import:(()=>import("./crystal-DVILAEWU.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("./csharp-VNJLKKRO.js"))},{id:"css",name:"CSS",import:(()=>import("./css-NLVM2B53.js"))},{id:"csv",name:"CSV",import:(()=>import("./csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("./cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("./cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("./d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("./dart-KG257MMB.js"))},{id:"dax",name:"DAX",import:(()=>import("./dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("./desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("./diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("./docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("./dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("./dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("./edge-75EAMBUG.js"))},{id:"elixir",name:"Elixir",import:(()=>import("./elixir-NWFINHZW.js"))},{id:"elm",name:"Elm",import:(()=>import("./elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("./emacs-lisp-NRIAYFLD.js"))},{id:"erb",name:"ERB",import:(()=>import("./erb-L6I32JVH.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("./erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("./fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("./fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("./fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("./fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("./fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("./fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("./gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("./gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("./gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("./genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("./gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("./git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("./git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("./gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("./glimmer-js-EJYO25PG.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("./glimmer-ts-Q2ZC2IIP.js"))},{id:"glsl",name:"GLSL",import:(()=>import("./glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("./gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("./gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("./go-WER5FUYJ.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("./graphql-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("./groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("./hack-FLOLYEQ5.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("./haml-SCHIB33Y.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("./handlebars-BNURLECZ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("./haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("./haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("./hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("./hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("./hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("./html-DXDULU5G.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("./html-derivative-QD4CE6YQ.js"))},{id:"http",name:"HTTP",import:(()=>import("./http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("./hurl-BZB5LDD5.js"))},{id:"hxml",name:"HXML",import:(()=>import("./hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("./hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("./imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("./ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("./java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("./javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("./jinja-DC3WU6ZJ.js"))},{id:"jison",name:"Jison",import:(()=>import("./jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("./json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("./json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("./jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("./jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("./jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("./jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("./jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("./julia-CHGX5VFI.js"))},{id:"just",name:"Just",import:(()=>import("./just-XO4JBQP4.js"))},{id:"kdl",name:"KDL",import:(()=>import("./kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("./kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("./kusto-55BKOIH6.js"))},{id:"latex",name:"LaTeX",import:(()=>import("./latex-7PE6CJI5.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("./lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("./less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("./liquid-OUYRJBEI.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("./llvm-F6576PPM.js"))},{id:"log",name:"Log file",import:(()=>import("./log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("./logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("./lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("./luau-7VRLQHZS.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("./make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("./markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("./marko-TQJFHH5J.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("./matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("./mdc-BVI2JKDR.js"))},{id:"mdx",name:"MDX",import:(()=>import("./mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("./mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("./mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("./mojo-NUFJUGRT.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("./moonbit-IQKVCQX6.js"))},{id:"move",name:"Move",import:(()=>import("./move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("./narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("./nextflow-OTA6EZBU.js"))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>import("./nextflow-groovy-434C6PKN.js"))},{id:"nginx",name:"Nginx",import:(()=>import("./nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("./nim-LBV5OEXG.js"))},{id:"nix",name:"Nix",import:(()=>import("./nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("./nushell-WFCCYAUY.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("./objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("./objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("./ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("./odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("./openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("./pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("./perl-N2JOL2L5.js"))},{id:"php",name:"PHP",import:(()=>import("./php-OXA56EZC.js"))},{id:"pkl",name:"Pkl",import:(()=>import("./pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("./plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("./po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("./polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("./postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("./powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("./powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("./prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("./prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("./proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("./pug-CWA4QCVE.js"))},{id:"puppet",name:"Puppet",import:(()=>import("./puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("./purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("./python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("./qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("./qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("./qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("./r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("./racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("./raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("./razor-B3X33ONZ.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("./reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("./regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("./rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("./riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("./ron-G4N7ZKMH.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("./rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("./rst-D5R5URHP.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("./ruby-DWCE4YYU.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("./rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("./sas-T7S4QIRM.js"))},{id:"sass",name:"Sass",import:(()=>import("./sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("./scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("./scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("./scss-RIXXNXKR.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("./sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("./shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("./shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("./shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("./smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("./solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("./soy-4TQM2FCJ.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("./sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("./splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("./sql-52F5XK5C.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("./ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("./stata-6C4TLAPQ.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("./stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("./surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("./svelte-NTV6SKXK.js"))},{id:"swift",name:"Swift",import:(()=>import("./swift-KMR3DOSF.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("./system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("./systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("./talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("./tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("./tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("./templ-U5PIZYER.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("./terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("./tex-MVHXDK4A.js"))},{id:"toml",name:"TOML",import:(()=>import("./toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("./ts-tags-K7BWB4VX.js"))},{id:"tsv",name:"TSV",import:(()=>import("./tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("./tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("./turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("./twig-7UZRHYW3.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("./typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("./typespec-535S7LOL.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("./typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("./v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("./vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("./vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("./verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("./vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("./viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("./vue-CKPBQTY7.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("./vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("./vue-vine-Q32TIQRB.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("./vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("./wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("./wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("./wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("./wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("./wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("./wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("./xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("./xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("./yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("./zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("./zig-6LJUAPBA.js"))}],Zr=Object.fromEntries(ar.map(e=>[e.id,e.import])),Yr=Object.fromEntries(ar.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Qr={...Zr,...Yr};p();var eo=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("./andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("./aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("./ayu-dark-55BH6GCR.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("./ayu-light-IPNR4FEJ.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("./ayu-mirage-MOSAI7A2.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("./catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("./catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("./catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("./catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("./dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("./dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("./dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("./everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("./everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("./github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("./github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("./github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("./github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("./github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("./github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("./github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("./gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("./gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("./gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("./gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("./gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("./gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("./horizon-EAAZ4KVN.js"))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>import("./horizon-bright-CGMA7ELN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("./houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("./kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("./kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("./kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("./laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("./light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("./material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("./material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("./material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("./material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("./material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("./min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("./min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("./monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("./night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("./night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("./nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("./one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("./one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("./plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("./poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("./red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("./rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("./rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("./rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("./slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("./slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("./snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("./solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("./solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("./synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("./tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("./vesper-DY3BCX5Y.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("./vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("./vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("./vitesse-light-RICZI4IG.js"))}],to=Object.fromEntries(eo.map(e=>[e.id,e.import]));p();p();var ul={};Zu(ul,{createOnigurumaEngine:()=>cl,getDefaultWasmLoader:()=>Wx,loadWasm:()=>As,setDefaultWasmLoader:()=>Ux});p();var ll=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Ax(){return 2147483648}function Ex(){return typeof performance<"u"?performance.now():Date.now()}var Ix=(e,t)=>e+(t-e%t)%t;async function Px(e){let t,n,r={};function o(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function s(h,f,g){r.HEAPU8.copyWithin(h,f,f+g)}function i(h){try{return t.grow(h-n.byteLength+65535>>>16),o(t.buffer),1}catch{}}function a(h){let f=r.HEAPU8.length;h=h>>>0;let g=Ax();if(h>g)return!1;for(let b=1;b<=4;b*=2){let w=f*(1+.2/b);w=Math.min(w,h+100663296);let S=Math.min(g,Ix(Math.max(h,w),65536));if(i(S))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function c(h,f,g=1024){let b=f+g,w=f;for(;h[w]&&!(w>=b);)++w;if(w-f>16&&h.buffer&&l)return l.decode(h.subarray(f,w));let S="";for(;f<w;){let v=h[f++];if(!(v&128)){S+=String.fromCharCode(v);continue}let _=h[f++]&63;if((v&224)===192){S+=String.fromCharCode((v&31)<<6|_);continue}let E=h[f++]&63;if((v&240)===224?v=(v&15)<<12|_<<6|E:v=(v&7)<<18|_<<12|E<<6|h[f++]&63,v<65536)S+=String.fromCharCode(v);else{let M=v-65536;S+=String.fromCharCode(55296|M>>10,56320|M&1023)}}return S}function u(h,f){return h?c(r.HEAPU8,h,f):""}let d={emscripten_get_now:Ex,emscripten_memcpy_big:s,emscripten_resize_heap:a,fd_write:()=>0};async function m(){let f=await e({env:d,wasi_snapshot_preview1:d});t=f.memory,o(t.buffer),Object.assign(r,f),r.UTF8ToString=u}return await m(),r}var Lx=Object.defineProperty,$x=(e,t,n)=>t in e?Lx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Te=(e,t,n)=>$x(e,typeof t!="symbol"?t+"":t,n),Re=null;function Ox(e){throw new ll(e.UTF8ToString(e.getLastOnigError()))}var vs=class e{constructor(t){Te(this,"utf16Length"),Te(this,"utf8Length"),Te(this,"utf16Value"),Te(this,"utf8Value"),Te(this,"utf16OffsetToUtf8"),Te(this,"utf8OffsetToUtf16");let n=t.length,r=e._utf8ByteLength(t),o=r!==n,s=o?new Uint32Array(n+1):null;o&&(s[n]=r);let i=o?new Uint32Array(r+1):null;o&&(i[r]=n);let a=new Uint8Array(r),l=0;for(let c=0;c<n;c++){let u=t.charCodeAt(c),d=u,m=!1;if(u>=55296&&u<=56319&&c+1<n){let h=t.charCodeAt(c+1);h>=56320&&h<=57343&&(d=(u-55296<<10)+65536|h-56320,m=!0)}o&&(s[c]=l,m&&(s[c+1]=l),d<=127?i[l+0]=c:d<=2047?(i[l+0]=c,i[l+1]=c):d<=65535?(i[l+0]=c,i[l+1]=c,i[l+2]=c):(i[l+0]=c,i[l+1]=c,i[l+2]=c,i[l+3]=c)),d<=127?a[l++]=d:d<=2047?(a[l++]=192|(d&1984)>>>6,a[l++]=128|(d&63)>>>0):d<=65535?(a[l++]=224|(d&61440)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0):(a[l++]=240|(d&1835008)>>>18,a[l++]=128|(d&258048)>>>12,a[l++]=128|(d&4032)>>>6,a[l++]=128|(d&63)>>>0),m&&c++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=a,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=i}static _utf8ByteLength(t){let n=0;for(let r=0,o=t.length;r<o;r++){let s=t.charCodeAt(r),i=s,a=!1;if(s>=55296&&s<=56319&&r+1<o){let l=t.charCodeAt(r+1);l>=56320&&l<=57343&&(i=(s-55296<<10)+65536|l-56320,a=!0)}i<=127?n+=1:i<=2047?n+=2:i<=65535?n+=3:n+=4,a&&r++}return n}createString(t){let n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}},Rs=class vt{constructor(t){if(Te(this,"id",++vt.LAST_ID),Te(this,"_onigBinding"),Te(this,"content"),Te(this,"utf16Length"),Te(this,"utf8Length"),Te(this,"utf16OffsetToUtf8"),Te(this,"utf8OffsetToUtf16"),Te(this,"ptr"),!Re)throw new ll("Must invoke loadWasm first.");this._onigBinding=Re,this.content=t;let n=new vs(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!vt._sharedPtrInUse?(vt._sharedPtr||(vt._sharedPtr=Re.omalloc(1e4)),vt._sharedPtrInUse=!0,Re.HEAPU8.set(n.utf8Value,vt._sharedPtr),this.ptr=vt._sharedPtr):this.ptr=n.createString(Re)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===vt._sharedPtr?vt._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Te(Rs,"LAST_ID",0);Te(Rs,"_sharedPtr",0);Te(Rs,"_sharedPtrInUse",!1);var lp=Rs,al=class{constructor(t){if(Te(this,"_onigBinding"),Te(this,"_ptr"),!Re)throw new ll("Must invoke loadWasm first.");let n=[],r=[];for(let a=0,l=t.length;a<l;a++){let c=new vs(t[a]);n[a]=c.createString(Re),r[a]=c.utf8Length}let o=Re.omalloc(4*t.length);Re.HEAPU32.set(n,o/4);let s=Re.omalloc(4*t.length);Re.HEAPU32.set(r,s/4);let i=Re.createOnigScanner(o,s,t.length);for(let a=0,l=t.length;a<l;a++)Re.ofree(n[a]);Re.ofree(s),Re.ofree(o),i===0&&Ox(Re),this._onigBinding=Re,this._ptr=i}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let o=0;if(typeof r=="number"&&(o=r),typeof t=="string"){t=new lp(t);let s=this._findNextMatchSync(t,n,!1,o);return t.dispose(),s}return this._findNextMatchSync(t,n,!1,o)}_findNextMatchSync(t,n,r,o){let s=this._onigBinding,i=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),o);if(i===0)return null;let a=s.HEAPU32,l=i/4,c=a[l++],u=a[l++],d=[];for(let m=0;m<u;m++){let h=t.convertUtf8OffsetToUtf16(a[l++]),f=t.convertUtf8OffsetToUtf16(a[l++]);d[m]={start:h,end:f,length:f-h}}return{index:c,captureIndices:d}}};function Dx(e){return typeof e.instantiator=="function"}function Nx(e){return typeof e.default=="function"}function Mx(e){return typeof e.data<"u"}function Bx(e){return typeof Response<"u"&&e instanceof Response}function Fx(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var _s;function As(e){if(_s)return _s;async function t(){Re=await Px(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),Dx(r)?r=await r.instantiator(n):Nx(r)?r=await r.default(n):(Mx(r)&&(r=r.data),Bx(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await Gx(r)(n):r=await jx(r)(n):Fx(r)?r=await il(r)(n):r instanceof WebAssembly.Module?r=await il(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await il(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return _s=t(),_s}function il(e){return t=>WebAssembly.instantiate(e,t)}function Gx(e){return t=>WebAssembly.instantiateStreaming(e,t)}function jx(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var cp;function Ux(e){cp=e}function Wx(){return cp}async function cl(e){return e&&await As(e),{createScanner(t){return new al(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new lp(t)}}}var dl=ir({});Cs(dl,ul);p();p();var re=class extends Error{constructor(e){super(e),this.name="ShikiError"}};p();function ro(e,t){let n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(let[o,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?n[o]=s:o===r&&Object.assign(n,s);return n}function Dt(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function mp(e){return Array.isArray(e)?e:[e]}async function pl(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function oo(e){return!e||["plaintext","txt","text","plain"].includes(e)}function fl(e){return e==="ansi"||oo(e)}function so(e){return e==="none"}function ml(e){return so(e)}var Hx=/(\r?\n)/g;function lr(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(Hx),r=0,o=[];for(let s=0;s<n.length;s+=2){let i=t?n[s]+(n[s+1]||""):n[s];o.push([i,r]),r+=n[s].length,r+=n[s+1]?.length||0}return o}var up={light:"#333333",dark:"#bbbbbb"},dp={light:"#fffffe",dark:"#1e1e1e"},pp="__shiki_resolved";function Es(e){if(e?.[pp])return e;let 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){let a=t.settings?t.settings.find(l=>!l.name&&!l.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"?up.light:up.dark),n||(n=t.type==="light"?dp.light:dp.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 o=0,s=new Map;function i(a){if(s.has(a))return s.get(a);o+=1;let l=`#${o.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?i(a):(s.set(a,l),l)}t.settings=t.settings.map(a=>{let l=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),c=a.settings?.background&&!a.settings.background.startsWith("#");if(!l&&!c)return a;let u={...a,settings:{...a.settings}};if(l){let d=i(a.settings.foreground);t.colorReplacements[d]=a.settings.foreground,u.settings.foreground=d}if(c){let d=i(a.settings.background);t.colorReplacements[d]=a.settings.background,u.settings.background=d}return u});for(let a of Object.keys(t.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!t.colors[a]?.startsWith("#")){let l=i(t.colors[a]);t.colorReplacements[l]=t.colors[a],t.colors[a]=l}return Object.defineProperty(t,pp,{enumerable:!1,writable:!1,value:!0}),t}async function hp(e){return[...new Set((await Promise.all(e.filter(t=>!fl(t)).map(async t=>await pl(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function gp(e){return(await Promise.all(e.map(async t=>ml(t)?null:Es(await pl(t))))).filter(t=>!!t)}function yp(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new re(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Vx=class extends Qd{_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(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Es(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=zr.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=yp(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,t.size)for(let o of t)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],n=t.filter(([r,o])=>!o);if(n.length){let r=t.filter(([o,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(i=>n.map(([a])=>a).includes(i)):!1).filter(o=>!n.includes(o));throw new re(`Missing languages ${n.map(([o])=>`\`${o}\``).join(", ")}, required by ${r.map(([o])=>`\`${o}\``).join(", ")}`)}for(let[r,o]of t)this._resolver.addLanguage(o);for(let[r,o]of t)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let n of t)this._langGraph.set(n,this._langMap.get(n))}},zx=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){let t=e.split("."),n=[];for(let r=1;r<=t.length;r++){let o=t.slice(0,r).join(".");n=[...n,...this._injections.get(o)||[]]}return n}},no=0;function hl(e){no+=1,e.warnings!==!1&&no>=10&&no%10===0&&console.warn(`[Shiki] ${no} 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 re("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Es),o=new Vx(new zx(e.engine,n),r,n,e.langAlias),s;function i(S){return yp(S,e.langAlias)}function a(S){b();let v=o.getGrammar(typeof S=="string"?S:S.name);if(!v)throw new re(`Language \`${S}\` not found, you may need to load it first`);return v}function l(S){if(S==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};b();let v=o.getTheme(S);if(!v)throw new re(`Theme \`${S}\` not found, you may need to load it first`);return v}function c(S){b();let v=l(S);return s!==S&&(o.setTheme(v),s=S),{theme:v,colorMap:o.getColorMap()}}function u(){return b(),o.getLoadedThemes()}function d(){return b(),o.getLoadedLanguages()}function m(...S){b(),o.loadLanguages(S.flat(1))}async function h(...S){return m(await hp(S))}function f(...S){b();for(let v of S.flat(1))o.loadTheme(v)}async function g(...S){return b(),f(await gp(S))}function b(){if(t)throw new re("Shiki instance has been disposed")}function w(){t||(t=!0,o.dispose(),no-=1)}return{setTheme:c,getTheme:l,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:g,loadThemeSync:f,dispose:w,[Symbol.dispose]:w}}async function gl(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([gp(e.themes||[]),hp(e.langs||[]),e.engine]);return hl({...e,themes:t,langs:n,engine:r})}var xp=new WeakMap;function io(e,t){xp.set(e,t)}function cr(e){return xp.get(e)}var Is=class bp{_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 bp(Object.fromEntries(mp(n).map(r=>[r,Ss])),t)}constructor(...t){if(t.length===2){let[n,r]=t;this.lang=r,this._stacks=n}else{let[n,r,o]=t;this.lang=r,this._stacks={[o]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return qx(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function qx(e){let t=[],n=new Set;function r(o){if(n.has(o))return;n.add(o);let s=o?.nameScopesList?.scopeName;s&&t.push(s),o.parent&&r(o.parent)}return r(e),t}function Kx(e,t){if(!(e instanceof Is))throw new re("Invalid grammar state");return e.getInternalStack(t)}var Xx=/,/,Jx=/ /;function yl(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(oo(e.resolveLangAlias(n.lang||"text"))||so(r))return lr(t).map(a=>[{content:a[0],offset:a[1]}]);let{theme:o,colorMap:s}=e.setTheme(r),i=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new re(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new re(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return kp(t,i,o,s,n)}function wp(...e){if(e.length===2)return cr(e[1]);let[t,n,r={}]=e,{lang:o="text",theme:s=t.getLoadedThemes()[0]}=r;if(oo(o)||so(s))throw new re("Plain language does not have grammar state");if(o==="ansi")throw new re("ANSI language does not have grammar state");let{theme:i,colorMap:a}=t.setTheme(s),l=t.getLanguage(o);return new Is(xl(n,l,i,a,r).stateStack,l.name,i.name)}function kp(e,t,n,r,o){let s=xl(e,t,n,r,o),i=new Is(s.stateStack,t.name,n.name);return io(s.tokens,i),s.tokens}function xl(e,t,n,r,o){let s=ro(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=o,c=lr(e),u=o.grammarState?Kx(o.grammarState,n.name)??Ss:o.grammarContextCode!=null?xl(o.grammarContextCode,t,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ss,d=[],m=[];for(let h=0,f=c.length;h<f;h++){let[g,b]=c[h];if(g===""){d=[],m.push([]);continue}if(i>0&&g.length>=i){d=[],m.push([{content:g,offset:b,color:"",fontStyle:0}]);continue}let w,S,v;l&&l!=="tokenType"&&(w=t.tokenizeLine(g,u,a),S=w.tokens,v=0);let _=t.tokenizeLine2(g,u,a),E=_.tokens.length/2;for(let M=0;M<E;M++){let U=_.tokens[2*M],T=M+1<E?_.tokens[2*M+2]:g.length;if(U===T)continue;let N=_.tokens[2*M+1],F=Dt(r[nn.getForeground(N)],s),q=nn.getFontStyle(N),$={content:g.substring(U,T),offset:b+U,color:F,fontStyle:q};if(l==="tokenType")$.type=nn.getTokenType(N);else if(l){let oe=[];if(l!=="scopeName")for(let ee of n.settings){let W;switch(typeof ee.scope){case"string":W=ee.scope.split(Xx).map(se=>se.trim());break;case"object":W=ee.scope;break;default:continue}oe.push({settings:ee,selectors:W.map(se=>se.split(Jx))})}$.explanation=[];let le=0;for(;U+le<T;){let ee=S[v],W=g.substring(ee.startIndex,ee.endIndex);le+=W.length,$.explanation.push({content:W,scopes:l==="scopeName"?Zx(ee.scopes):Yx(oe,ee.scopes)}),v+=1}}d.push($)}m.push(d),d=[],u=_.ruleStack}return{tokens:m,stateStack:u}}function Zx(e){return e.map(t=>({scopeName:t}))}function Yx(e,t){let n=[];for(let r=0,o=t.length;r<o;r++){let s=t[r];n[r]={scopeName:s,themeMatches:eb(e,s,t.slice(0,r))}}return n}function fp(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Qx(e,t,n){if(!fp(e.at(-1),t))return!1;let r=e.length-2,o=n.length-1;for(;r>=0&&o>=0;)fp(e[r],n[o])&&(r-=1),o-=1;return r===-1}function eb(e,t,n){let r=[];for(let{selectors:o,settings:s}of e)for(let i of o)if(Qx(i,t,n)){r.push(s);break}return r}function Ps(e,t,n,r=yl){let o=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),s=o.map(c=>{let u=r(e,t,{...n,theme:c.theme});return{tokens:u,state:cr(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=tb(...s.map(c=>c.tokens)),a=i[0].map((c,u)=>c.map((d,m)=>{let h={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=d.explanation),i.forEach((f,g)=>{let{content:b,explanation:w,offset:S,...v}=f[u][m];h.variants[o[g].color]=v}),h})),l=s[0].state?new Is(Object.fromEntries(s.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),s[0].state.lang):void 0;return l&&io(a,l),a}function tb(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let o=e.map(l=>l[r]),s=t.map(()=>[]);t.forEach((l,c)=>l.push(s[c]));let i=o.map(()=>0),a=o.map(l=>l[0]);for(;a.every(l=>l);){let l=Math.min(...a.map(c=>c.content.length));for(let c=0;c<n;c++){let u=a[c];u.content.length===l?(s[c].push(u),i[c]+=1,a[c]=o[c][i[c]]):(s[c].push({...u,content:u.content.slice(0,l)}),a[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return t}p();p();p();var Sp=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];p();p();p();var Nt=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Nt.prototype.normal={};Nt.prototype.property={};Nt.prototype.space=void 0;function bl(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Nt(n,r,t)}p();p();p();function ao(e){return e.toLowerCase()}p();p();var Ae=class{constructor(t,n){this.attribute=n,this.property=t}};Ae.prototype.attribute="";Ae.prototype.booleanish=!1;Ae.prototype.boolean=!1;Ae.prototype.commaOrSpaceSeparated=!1;Ae.prototype.commaSeparated=!1;Ae.prototype.defined=!1;Ae.prototype.mustUseProperty=!1;Ae.prototype.number=!1;Ae.prototype.overloadedBoolean=!1;Ae.prototype.property="";Ae.prototype.spaceSeparated=!1;Ae.prototype.space=void 0;var lo={};Zu(lo,{boolean:()=>X,booleanish:()=>pe,commaOrSpaceSeparated:()=>je,commaSeparated:()=>Mt,number:()=>A,overloadedBoolean:()=>Ls,spaceSeparated:()=>ne});p();var nb=0,X=vn(),pe=vn(),Ls=vn(),A=vn(),ne=vn(),Mt=vn(),je=vn();function vn(){return 2**++nb}var wl=Object.keys(lo),Rn=class extends Ae{constructor(t,n,r,o){let s=-1;if(super(t,n),Tp(this,"space",o),typeof r=="number")for(;++s<wl.length;){let i=wl[s];Tp(this,wl[s],(r&lo[i])===lo[i])}}};Rn.prototype.defined=!0;function Tp(e,t,n){n&&(e[t]=n)}function it(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let s=new Rn(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ao(r)]=r,n[ao(s.attribute)]=r}return new Nt(t,n,e.space)}var kl=it({properties:{ariaActiveDescendant:null,ariaAtomic:pe,ariaAutoComplete:null,ariaBusy:pe,ariaChecked:pe,ariaColCount:A,ariaColIndex:A,ariaColSpan:A,ariaControls:ne,ariaCurrent:null,ariaDescribedBy:ne,ariaDetails:null,ariaDisabled:pe,ariaDropEffect:ne,ariaErrorMessage:null,ariaExpanded:pe,ariaFlowTo:ne,ariaGrabbed:pe,ariaHasPopup:null,ariaHidden:pe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ne,ariaLevel:A,ariaLive:null,ariaModal:pe,ariaMultiLine:pe,ariaMultiSelectable:pe,ariaOrientation:null,ariaOwns:ne,ariaPlaceholder:null,ariaPosInSet:A,ariaPressed:pe,ariaReadOnly:pe,ariaRelevant:null,ariaRequired:pe,ariaRoleDescription:ne,ariaRowCount:A,ariaRowIndex:A,ariaRowSpan:A,ariaSelected:pe,ariaSetSize:A,ariaSort:null,ariaValueMax:A,ariaValueMin:A,ariaValueNow:A,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});p();p();p();function $s(e,t){return t in e?e[t]:t}function Os(e,t){return $s(e,t.toLowerCase())}var Cp=it({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Mt,acceptCharset:ne,accessKey:ne,action:null,allow:null,allowFullScreen:X,allowPaymentRequest:X,allowUserMedia:X,alpha:X,alt:null,as:null,async:X,autoCapitalize:null,autoComplete:ne,autoFocus:X,autoPlay:X,blocking:ne,capture:null,charSet:null,checked:X,cite:null,className:ne,closedBy:null,colorSpace:null,cols:A,colSpan:A,command:null,commandFor:null,content:null,contentEditable:pe,controls:X,controlsList:ne,coords:A|Mt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:X,defer:X,dir:null,dirName:null,disabled:X,download:Ls,draggable:pe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:X,formTarget:null,headers:ne,height:A,hidden:Ls,high:A,href:null,hrefLang:null,htmlFor:ne,httpEquiv:ne,id:null,imageSizes:null,imageSrcSet:null,inert:X,inputMode:null,integrity:null,is:null,isMap:X,itemId:null,itemProp:ne,itemRef:ne,itemScope:X,itemType:ne,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:X,low:A,manifest:null,max:null,maxLength:A,media:null,method:null,min:null,minLength:A,multiple:X,muted:X,name:null,nonce:null,noModule:X,noValidate:X,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:X,optimum:A,pattern:null,ping:ne,placeholder:null,playsInline:X,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:X,referrerPolicy:null,rel:ne,required:X,reversed:X,rows:A,rowSpan:A,sandbox:ne,scope:null,scoped:X,seamless:X,selected:X,shadowRootClonable:X,shadowRootCustomElementRegistry:X,shadowRootDelegatesFocus:X,shadowRootMode:null,shadowRootSerializable:X,shape:null,size:A,sizes:null,slot:null,span:A,spellCheck:pe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:A,step:null,style:null,tabIndex:A,target:null,title:null,translate:null,type:null,typeMustMatch:X,useMap:null,value:pe,width:A,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ne,axis:null,background:null,bgColor:null,border:A,borderColor:null,bottomMargin:A,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:X,declare:X,event:null,face:null,frame:null,frameBorder:null,hSpace:A,leftMargin:A,link:null,longDesc:null,lowSrc:null,marginHeight:A,marginWidth:A,noResize:X,noHref:X,noShade:X,noWrap:X,object:null,profile:null,prompt:null,rev:null,rightMargin:A,rules:null,scheme:null,scrolling:pe,standby:null,summary:null,text:null,topMargin:A,valueType:null,version:null,vAlign:null,vLink:null,vSpace:A,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:X,disablePictureInPicture:X,disableRemotePlayback:X,exportParts:Mt,part:ne,prefix:null,property:null,results:A,security:null,unselectable:null},space:"html",transform:Os});p();var _p=it({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:je,accentHeight:A,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:A,amplitude:A,arabicForm:null,ascent:A,attributeName:null,attributeType:null,azimuth:A,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:A,by:null,calcMode:null,capHeight:A,className:ne,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:A,diffuseConstant:A,direction:null,display:null,dur:null,divisor:A,dominantBaseline:null,download:X,dx:null,dy:null,edgeMode:null,editable:null,elevation:A,enableBackground:null,end:null,event:null,exponent:A,externalResourcesRequired:null,fill:null,fillOpacity:A,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Mt,g2:Mt,glyphName:Mt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:A,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:A,horizOriginX:A,horizOriginY:A,id:null,ideographic:A,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:A,k:A,k1:A,k2:A,k3:A,k4:A,kernelMatrix:je,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:A,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:A,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:A,overlineThickness:A,paintOrder:null,panose1:null,path:null,pathLength:A,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ne,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:A,pointsAtY:A,pointsAtZ:A,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:je,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:je,rev:je,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:je,requiredFeatures:je,requiredFonts:je,requiredFormats:je,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:A,specularExponent:A,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:A,strikethroughThickness:A,string:null,stroke:null,strokeDashArray:je,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:A,strokeOpacity:A,strokeWidth:null,style:null,surfaceScale:A,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:je,tabIndex:A,tableValues:null,target:null,targetX:A,targetY:A,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:je,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:A,underlineThickness:A,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:A,values:null,vAlphabetic:A,vMathematical:A,vectorEffect:null,vHanging:A,vIdeographic:A,version:null,vertAdvY:A,vertOriginX:A,vertOriginY:A,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:$s});p();var Sl=it({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});p();var Tl=it({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Os});p();var Cl=it({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});p();var rb=/[A-Z]/g,vp=/-[a-z]/g,ob=/^data[-\w.:]+$/i;function _l(e,t){let n=ao(t),r=t,o=Ae;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ob.test(t)){if(t.charAt(4)==="-"){let s=t.slice(5).replace(vp,ib);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{let s=t.slice(4);if(!vp.test(s)){let i=s.replace(rb,sb);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=Rn}return new o(r,t)}function sb(e){return"-"+e.toLowerCase()}function ib(e){return e.charAt(1).toUpperCase()}var Rp=bl([kl,Cp,Sl,Tl,Cl],"html"),Ds=bl([kl,_p,Sl,Tl,Cl],"svg");p();p();var Ap={}.hasOwnProperty;function Ep(e,t){let n=t||{};function r(o,...s){let i=r.invalid,a=r.handlers;if(o&&Ap.call(o,e)){let l=String(o[e]);i=Ap.call(a,l)?a[l]:r.unknown}if(i)return i.call(this,o,...s)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}p();p();p();var ab=/["&'<>`]/g,lb=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,cb=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ub=/[|\\{}()[\]^$+*?.]/g,Ip=new WeakMap;function Pp(e,t){if(e=e.replace(t.subset?db(t.subset):ab,r),t.subset||t.escapeOnly)return e;return e.replace(lb,n).replace(cb,r);function n(o,s,i){return t.format((o.charCodeAt(0)-55296)*1024+o.charCodeAt(1)-56320+65536,i.charCodeAt(s+2),t)}function r(o,s,i){return t.format(o.charCodeAt(0),i.charCodeAt(s+1),t)}}function db(e){let t=Ip.get(e);return t||(t=pb(e),Ip.set(e,t)),t}function pb(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(ub,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}p();p();var fb=/[\dA-Fa-f]/;function Lp(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!fb.test(String.fromCharCode(t))?r:r+";"}p();var mb=/\d/;function $p(e,t,n){let r="&#"+String(e);return n&&t&&!mb.test(String.fromCharCode(t))?r:r+";"}p();p();var Op=["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"];p();var Ns={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};p();var Dp=["cent","copy","divide","gt","lt","not","para","times"];var Np={}.hasOwnProperty,vl={},Ms;for(Ms in Ns)Np.call(Ns,Ms)&&(vl[Ns[Ms]]=Ms);var hb=/[^\dA-Za-z]/;function Mp(e,t,n,r){let o=String.fromCharCode(e);if(Np.call(vl,o)){let s=vl[o],i="&"+s;return n&&Op.includes(s)&&!Dp.includes(s)&&(!r||t&&t!==61&&hb.test(String.fromCharCode(t)))?i:i+";"}return""}function Bp(e,t,n){let r=Lp(e,t,n.omitOptionalSemicolons),o;if((n.useNamedReferences||n.useShortestReferences)&&(o=Mp(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!o)&&n.useShortestReferences){let s=$p(e,t,n.omitOptionalSemicolons);s.length<r.length&&(r=s)}return o&&(!n.useShortestReferences||o.length<r.length)?o:r}function Bt(e,t){return Pp(e,Object.assign({format:Bp},t))}var gb=/^>|^->|<!--|-->|--!>|<!-$/g,yb=[">"],xb=["<",">"];function Fp(e,t,n,r){return r.settings.bogusComments?"<?"+Bt(e.value,Object.assign({},r.settings.characterReferences,{subset:yb}))+">":"<!--"+e.value.replace(gb,o)+"-->";function o(s){return Bt(s,Object.assign({},r.settings.characterReferences,{subset:xb}))}}p();function Gp(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}p();p();function Rl(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;o!==-1;)r++,o=n.indexOf(t,o+t.length);return r}p();function jp(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}p();function Up(e){return e.join(" ").trim()}p();p();p();var bb=/[ \t\n\f\r]/g;function An(e){return typeof e=="object"?e.type==="text"?Wp(e.value):!1:Wp(e)}function Wp(e){return e.replace(bb,"")===""}p();var he=Hp(1),Al=Hp(-1),wb=[];function Hp(e){return t;function t(n,r,o){let s=n?n.children:wb,i=(r||0)+e,a=s[i];if(!o)for(;a&&An(a);)i+=e,a=s[i];return a}}p();var kb={}.hasOwnProperty;function Bs(e){return t;function t(n,r,o){return kb.call(e,n.tagName)&&e[n.tagName](n,r,o)}}var co=Bs({body:Tb,caption:El,colgroup:El,dd:Rb,dt:vb,head:El,html:Sb,li:_b,optgroup:Ab,option:Eb,p:Cb,rp:Vp,rt:Vp,tbody:Pb,td:zp,tfoot:Lb,th:zp,thead:Ib,tr:$b});function El(e,t,n){let r=he(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&An(r.value.charAt(0)))}function Sb(e,t,n){let r=he(n,t);return!r||r.type!=="comment"}function Tb(e,t,n){let r=he(n,t);return!r||r.type!=="comment"}function Cb(e,t,n){let r=he(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 _b(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="li"}function vb(e,t,n){let r=he(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Rb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Vp(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Ab(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function Eb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Ib(e,t,n){let r=he(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Pb(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Lb(e,t,n){return!he(n,t)}function $b(e,t,n){let r=he(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function zp(e,t,n){let r=he(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}p();var qp=Bs({body:Nb,colgroup:Mb,head:Db,html:Ob,tbody:Bb});function Ob(e){let t=he(e,-1);return!t||t.type!=="comment"}function Db(e){let t=new Set;for(let 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)}let n=e.children[0];return!n||n.type==="element"}function Nb(e){let t=he(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&An(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Mb(e,t,n){let r=Al(n,t),o=he(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&co(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function Bb(e,t,n){let r=Al(n,t),o=he(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&co(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}var Fs={name:[[`
|
|
27
27
|
\f\r &/=>`.split(""),`
|
|
28
28
|
\f\r "&'/=>\``.split("")],[`\0
|
|
29
29
|
\f\r "&'/<=>`.split(""),`\0
|
|
@@ -31,10 +31,10 @@ import{a as td}from"./chunk-KMMG6QC6.js";import{a as Oe,b as Yn,c as Sa}from"./c
|
|
|
31
31
|
\f\r &>`.split(""),`\0
|
|
32
32
|
\f\r "&'<=>\``.split("")],[`\0
|
|
33
33
|
\f\r "&'<=>\``.split(""),`\0
|
|
34
|
-
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function qp(e,t,n,r){let o=r.schema,s=o.space==="svg"?!1:r.settings.omitOptionalTags,i=o.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),a=[],l;o.space==="html"&&e.tagName==="svg"&&(r.schema=Os);let c=Ux(r,e.properties),u=r.all(o.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=o,u&&(i=!1),(c||!s||!zp(e,t,n))&&(a.push("<",e.tagName,c?" "+c:""),i&&(o.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(u),!i&&(!s||!lo(e,t,n))&&a.push("</"+e.tagName+">"),a.join("")}function Ux(e,t){let n=[],r=-1,o;if(t){for(o in t)if(t[o]!==null&&t[o]!==void 0){let s=Wx(e,o,t[o]);s&&n.push(s)}}for(;++r<n.length;){let s=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&s!=='"'&&s!=="'"&&(n[r]+=" ")}return n.join("")}function Wx(e,t,n){let r=Tl(e.schema,t),o=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,i=e.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";let l=Gt(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Bs.name[o][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?Gp:jp)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?l:(e.settings.preferUnquoted&&(a=Gt(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Bs.unquoted[o][s]}))),a!==n&&(e.settings.quoteSmart&&_l(n,i)>_l(n,e.alternative)&&(i=e.alternative),a=i+Gt(n,Object.assign({},e.settings.characterReferences,{subset:(i==="'"?Bs.single:Bs.double)[o][s],attribute:!0}))+i),l+(a&&"="+a))}p();p();var Hx=["<","&"];function Fs(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Gt(e.value,Object.assign({},r.settings.characterReferences,{subset:Hx}))}function Kp(e,t,n,r){return r.settings.allowDangerousHtml?e.value:Fs(e,t,n,r)}p();function Xp(e,t,n,r){return r.all(e)}var Jp=Ap("type",{invalid:Vx,unknown:zx,handlers:{comment:Bp,doctype:Fp,element:qp,raw:Kp,root:Xp,text:Fs}});function Vx(e){throw new Error("Expected node, not `"+e+"`")}function zx(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var qx={},Kx={},Xx=[];function Al(e,t){let n=t||qx,r=n.quote||'"',o=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Jx,all:Zx,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||kp,characterReferences:n.characterReferences||Kx,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Os:vp,quote:r,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Jx(e,t,n){return Jp(e,t,n,this)}function Zx(e){let t=[],n=e&&e.children||Xx,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}var Zp=/\s+/g;function ef(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Zp)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Zp);for(let r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}var Yx=/:?lang=["']([^"']+)["']/g,Qx=/(?:```|~~~)([\w-]+)/g,ew=/\\begin\{([\w-]+)\}/g,tw=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function nw(e){let t=ar(e,!0).map(([o])=>o);function n(o){if(o===e.length)return{line:t.length-1,character:t.at(-1).length};let s=o,i=0;for(let a of t){if(s<a.length)break;s-=a.length,i++}return{line:i,character:s}}function r(o,s){let i=0;for(let a=0;a<o;a++)i+=t[a].length;return i+=s,i}return{lines:t,indexToPos:n,posToIndex:r}}function tf(e,t,n){let r=new Set;for(let s of e.matchAll(Yx)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(Qx)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(ew)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(tw)){let i=s[1].toLowerCase().trim(),a=i.includes("/")?i.split("/").pop():i;a&&r.add(a)}if(!n)return[...r];let o=n.getBundledLanguages();return[...r].filter(s=>s&&o[s])}var rw=["color","background-color"];function ow(e,t){let n=0,r=[];for(let o of t)o>n&&r.push({...e,content:e.content.slice(n,o),offset:e.offset+n}),n=o;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function sw(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((r,o)=>r-o);return n.length?e.map(r=>r.flatMap(o=>{let s=n.filter(i=>o.offset<i&&i<o.offset+o.content.length).map(i=>i-o.offset).sort((i,a)=>i-a);return s.length?ow(o,s):o})):e}function iw(e,t,n,r,o="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>Gs(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),l={},c=(u,d)=>{let m=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return n+t[u]+(d==="color"?"":m)};return i.forEach((u,d)=>{for(let m of a){let h=u[m]||"inherit";if(d===0&&r&&rw.includes(m))if(r==="light-dark()"&&i.length>1){let f=t.findIndex(w=>w==="light"),g=t.findIndex(w=>w==="dark");if(f===-1||g===-1)throw new te('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');l[m]=`light-dark(${i[f][m]||"inherit"}, ${i[g][m]||"inherit"})`,o==="css-vars"&&(l[c(d,m)]=h)}else l[m]=h;else o==="css-vars"&&(l[c(d,m)]=h)}}),s.htmlStyle=l,s}function Gs(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&pe.Italic&&(t["font-style"]="italic"),e.fontStyle&pe.Bold&&(t["font-weight"]="bold");let n=[];e.fontStyle&pe.Underline&&n.push("underline"),e.fontStyle&pe.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Il(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function aw(){let e=new WeakMap;function t(n){if(!e.has(n.meta)){let s=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new te(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...o.indexToPos(a),offset:a}}else{let l=o.lines[a.line];if(l===void 0)throw new te(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${o.lines.length}`);let c=a.character;if(c<0&&(c=l.length+c),c<0||c>l.length)throw new te(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${l.length}`);return{...a,character:c,offset:o.posToIndex(a.line,c)}}};var r=s;let o=nw(n.source),i=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));lw(i),e.set(n.meta,{decorations:i,converter:o,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return sw(n,t(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;let r=t(this),o=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(o.length!==r.converter.lines.length)throw new te(`Number of lines in code element (${o.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function s(u,d,m,h){let f=o[u],g="",w=-1,x=-1;if(d===0&&(w=0),m===0&&(x=0),m===Number.POSITIVE_INFINITY&&(x=f.children.length),w===-1||x===-1)for(let v=0;v<f.children.length;v++)g+=nf(f.children[v]),w===-1&&g.length===d&&(w=v+1),x===-1&&g.length===m&&(x=v+1);if(w===-1)throw new te(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(x===-1)throw new te(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let T=f.children.slice(w,x);if(!h.alwaysWrap&&T.length===f.children.length)a(f,h,"line");else if(!h.alwaysWrap&&T.length===1&&T[0].type==="element")a(T[0],h,"token");else{let v={type:"element",tagName:"span",properties:{},children:T};a(v,h,"wrapper"),f.children.splice(w,T.length,v)}}function i(u,d){o[u]=a(o[u],d,"line")}function a(u,d,m){let h=d.properties||{},f=d.transform||(g=>g);return u.tagName=d.tagName||"span",u.properties={...u.properties,...h,class:u.properties.class},d.properties?.class&&ef(u,d.properties.class),u=f(u,m)||u,u}let l=[],c=r.decorations.sort((u,d)=>d.start.offset-u.start.offset||u.end.offset-d.end.offset);for(let u of c){let{start:d,end:m}=u;if(d.line===m.line)s(d.line,d.character,m.character,u);else if(d.line<m.line){s(d.line,d.character,Number.POSITIVE_INFINITY,u);for(let h=d.line+1;h<m.line;h++)l.unshift(()=>i(h,u));s(m.line,0,m.character,u)}}l.forEach(u=>u())}}}function lw(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new te(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let o=e[r],s=n.start.offset<=o.start.offset&&o.start.offset<n.end.offset,i=n.start.offset<o.end.offset&&o.end.offset<=n.end.offset,a=o.start.offset<=n.start.offset&&n.start.offset<o.end.offset,l=o.start.offset<n.end.offset&&n.end.offset<=o.end.offset;if(s||i||a||l){if(s&&i||a&&l||a&&n.start.offset===n.end.offset||i&&o.start.offset===o.end.offset)continue;throw new te(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function nf(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(nf).join(""):""}var cw=[aw()];function js(e){let t=uw(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...cw]}function uw(e){let t=[],n=[],r=[];for(let o of e)switch(o.enforce){case"pre":t.push(o);break;case"post":n.push(o);break;default:r.push(o)}return{pre:t,post:n,normal:r}}var In=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],El={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function dw(e,t){let n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){let r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Yp(e){let t=e.shift();if(t==="2"){let n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){let n=e.shift();if(n)return{type:"table",index:Number(n)}}}function pw(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)El[r]&&t.push({type:"setDecoration",value:El[r]});else if(r<=29){let o=El[r-20];o&&(t.push({type:"resetDecoration",value:o}),o==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:In[r-30]}});else if(r===38){let o=Yp(e);o&&t.push({type:"setForegroundColor",value:o})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:In[r-40]}});else if(r===48){let o=Yp(e);o&&t.push({type:"setBackgroundColor",value:o})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:In[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:In[r-100+8]}})}return t}function fw(){let e=null,t=null,n=new Set;return{parse(r){let o=[],s=0;do{let i=dw(r,s),a=i.sequence?r.substring(s,i.startPosition):r.substring(s);if(a.length>0&&o.push({value:a,foreground:e,background:t,decorations:new Set(n)}),i.sequence){let l=pw(i.sequence);for(let c of l)c.type==="resetAll"?(e=null,t=null,n.clear()):c.type==="resetForegroundColor"?e=null:c.type==="resetBackgroundColor"?t=null:c.type==="resetDecoration"&&n.delete(c.value);for(let c of l)c.type==="setForegroundColor"?e=c.value:c.type==="setBackgroundColor"?t=c.value:c.type==="setDecoration"&&n.add(c.value)}s=i.position}while(s<r.length);return o}}}var mw={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function hw(e=mw){function t(a){return e[a]}function n(a){return`#${a.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function o(){if(r)return r;r=[];for(let c=0;c<In.length;c++)r.push(t(In[c]));let a=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let d=0;d<6;d++)r.push(n([a[c],a[u],a[d]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function s(a){return o()[a]}function i(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return s(a.index)}}return{value:i}}var gw=/#([0-9a-f]{3,8})/i,yw=/var\((--[\w-]+-ansi-[\w-]+)\)/,bw={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function xw(e,t,n){let r=no(e,n),o=ar(t),s=hw(Object.fromEntries(In.map(a=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||bw[a]]}))),i=fw();return o.map(a=>i.parse(a[0]).map(l=>{let c,u;l.decorations.has("reverse")?(c=l.background?s.value(l.background):e.bg,u=l.foreground?s.value(l.foreground):e.fg):(c=l.foreground?s.value(l.foreground):e.fg,u=l.background?s.value(l.background):void 0),c=Mt(c,r),u=Mt(u,r),l.decorations.has("dim")&&(c=ww(c));let d=pe.None;return l.decorations.has("bold")&&(d|=pe.Bold),l.decorations.has("italic")&&(d|=pe.Italic),l.decorations.has("underline")&&(d|=pe.Underline),l.decorations.has("strikethrough")&&(d|=pe.Strikethrough),{content:l.value,offset:a[1],color:c,bgColor:u,fontStyle:d}}))}function ww(e){let t=e.match(gw);if(t){let r=t[1];if(r.length===8){let o=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${o}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){let o=r[0],s=r[1],i=r[2],a=r[3];return`#${o}${o}${s}${s}${i}${i}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){let o=r[0],s=r[1],i=r[2];return`#${o}${o}${s}${s}${i}${i}80`}}}let n=e.match(yw);return n?`var(${n[1]}-dim)`:e}function Pl(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:o=e.getLoadedThemes()[0]}=n;if(!ro(r)&&!oo(o)&&r==="ansi"){let{theme:s}=e.setTheme(o);return xw(s,t,n)}return hl(e,t,n)}function Us(e,t,n){let r,o,s,i,a,l;if("themes"in n){let{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:d="css-vars"}=n,m=Object.entries(n.themes).filter(x=>x[1]).map(x=>({color:x[0],theme:x[1]})).sort((x,T)=>x.color===c?-1:T.color===c?1:0);if(m.length===0)throw new te("`themes` option must not be empty");let h=Is(e,t,n,Pl);if(l=lr(h),c&&c!=="light-dark()"&&!m.some(x=>x.color===c))throw new te(`\`themes\` option must contain the defaultColor key \`${c}\``);let f=m.map(x=>e.getTheme(x.theme)),g=m.map(x=>x.color);s=h.map(x=>x.map(T=>iw(T,g,u,c,d))),l&&so(s,l);let w=m.map(x=>no(x.theme,n));o=Qp(m,f,w,u,c,"fg",d),r=Qp(m,f,w,u,c,"bg",d),i=`shiki-themes ${f.map(x=>x.name).join(" ")}`,a=c?void 0:[o,r].join(";")}else if("theme"in n){let c=no(n.theme,n);s=Pl(e,t,n);let u=e.getTheme(n.theme);r=Mt(u.bg,c),o=Mt(u.fg,c),i=u.name,l=lr(s)}else throw new te("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:o,bg:r,themeName:i,rootStyle:a,grammarState:l}}function Qp(e,t,n,r,o,s,i){return e.map((a,l)=>{let c=Mt(t[l][s],n[l])||"inherit",u=`${r+a.color}${s==="bg"?"-bg":""}:${c}`;if(l===0&&o){if(o==="light-dark()"&&e.length>1){let d=e.findIndex(h=>h.color==="light"),m=e.findIndex(h=>h.color==="dark");if(d===-1||m===-1)throw new te('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Mt(t[d][s],n[d])||"inherit"}, ${Mt(t[m][s],n[m])||"inherit"});${u}`}return c}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}var rf=/^\s+$/,kw=/^(\s*)(.*?)(\s*)$/;function Ws(e,t,n,r={meta:{},options:n,codeToHast:(o,s)=>Ws(e,o,s),codeToTokens:(o,s)=>Us(e,o,s)}){let o=t;for(let f of js(n))o=f.preprocess?.call(r,o,n)||o;let{tokens:s,fg:i,bg:a,themeName:l,rootStyle:c,grammarState:u}=Us(e,o,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:m=!1}=n;d===!0?s=Tw(s):d==="never"&&(s=Cw(s)),m&&(s=_w(s));let h={...r,get source(){return o}};for(let f of js(n))s=f.tokens?.call(h,s)||s;return Sw(s,{...n,fg:i,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},h,u)}function Sw(e,t,n,r=lr(e)){let o=js(t),s=[],i={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t,c={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?c.style=t.rootStyle:c.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(let[g,w]of Object.entries(t.meta||{}))g.startsWith("_")||(c[g]=w);let u={type:"element",tagName:"pre",properties:c,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},m=[],h={...n,structure:a,addClassToHast:ef,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return i},get pre(){return u},get code(){return d},get lines(){return m}};if(e.forEach((g,w)=>{w&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&s.push({type:"text",value:`
|
|
35
|
-
`}));let
|
|
34
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Kp(e,t,n,r){let o=r.schema,s=o.space==="svg"?!1:r.settings.omitOptionalTags,i=o.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),a=[],l;o.space==="html"&&e.tagName==="svg"&&(r.schema=Ds);let c=Fb(r,e.properties),u=r.all(o.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=o,u&&(i=!1),(c||!s||!qp(e,t,n))&&(a.push("<",e.tagName,c?" "+c:""),i&&(o.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(u),!i&&(!s||!co(e,t,n))&&a.push("</"+e.tagName+">"),a.join("")}function Fb(e,t){let n=[],r=-1,o;if(t){for(o in t)if(t[o]!==null&&t[o]!==void 0){let s=Gb(e,o,t[o]);s&&n.push(s)}}for(;++r<n.length;){let s=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&s!=='"'&&s!=="'"&&(n[r]+=" ")}return n.join("")}function Gb(e,t,n){let r=_l(e.schema,t),o=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,i=e.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";let l=Bt(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Fs.name[o][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?jp:Up)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?l:(e.settings.preferUnquoted&&(a=Bt(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Fs.unquoted[o][s]}))),a!==n&&(e.settings.quoteSmart&&Rl(n,i)>Rl(n,e.alternative)&&(i=e.alternative),a=i+Bt(n,Object.assign({},e.settings.characterReferences,{subset:(i==="'"?Fs.single:Fs.double)[o][s],attribute:!0}))+i),l+(a&&"="+a))}p();p();var jb=["<","&"];function Gs(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Bt(e.value,Object.assign({},r.settings.characterReferences,{subset:jb}))}function Xp(e,t,n,r){return r.settings.allowDangerousHtml?e.value:Gs(e,t,n,r)}p();function Jp(e,t,n,r){return r.all(e)}var Zp=Ep("type",{invalid:Ub,unknown:Wb,handlers:{comment:Fp,doctype:Gp,element:Kp,raw:Xp,root:Jp,text:Gs}});function Ub(e){throw new Error("Expected node, not `"+e+"`")}function Wb(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var Hb={},Vb={},zb=[];function Il(e,t){let n=t||Hb,r=n.quote||'"',o=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:qb,all:Kb,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Sp,characterReferences:n.characterReferences||Vb,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Ds:Rp,quote:r,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function qb(e,t,n){return Zp(e,t,n,this)}function Kb(e){let t=[],n=e&&e.children||zb,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}var Yp=/\s+/g;function tf(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Yp)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Yp);for(let r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}var Xb=/:?lang=["']([^"']+)["']/g,Jb=/(?:```|~~~)([\w-]+)/g,Zb=/\\begin\{([\w-]+)\}/g,Yb=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function Qb(e){let t=lr(e,!0).map(([o])=>o);function n(o){if(o===e.length)return{line:t.length-1,character:t.at(-1).length};let s=o,i=0;for(let a of t){if(s<a.length)break;s-=a.length,i++}return{line:i,character:s}}function r(o,s){let i=0;for(let a=0;a<o;a++)i+=t[a].length;return i+=s,i}return{lines:t,indexToPos:n,posToIndex:r}}function nf(e,t,n){let r=new Set;for(let s of e.matchAll(Xb)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(Jb)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(Zb)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(Yb)){let i=s[1].toLowerCase().trim(),a=i.includes("/")?i.split("/").pop():i;a&&r.add(a)}if(!n)return[...r];let o=n.getBundledLanguages();return[...r].filter(s=>s&&o[s])}var ew=["color","background-color"];function tw(e,t){let n=0,r=[];for(let o of t)o>n&&r.push({...e,content:e.content.slice(n,o),offset:e.offset+n}),n=o;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function nw(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((r,o)=>r-o);return n.length?e.map(r=>r.flatMap(o=>{let s=n.filter(i=>o.offset<i&&i<o.offset+o.content.length).map(i=>i-o.offset).sort((i,a)=>i-a);return s.length?tw(o,s):o})):e}function rw(e,t,n,r,o="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>js(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),l={},c=(u,d)=>{let m=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return n+t[u]+(d==="color"?"":m)};return i.forEach((u,d)=>{for(let m of a){let h=u[m]||"inherit";if(d===0&&r&&ew.includes(m))if(r==="light-dark()"&&i.length>1){let f=t.findIndex(b=>b==="light"),g=t.findIndex(b=>b==="dark");if(f===-1||g===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');l[m]=`light-dark(${i[f][m]||"inherit"}, ${i[g][m]||"inherit"})`,o==="css-vars"&&(l[c(d,m)]=h)}else l[m]=h;else o==="css-vars"&&(l[c(d,m)]=h)}}),s.htmlStyle=l,s}function js(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&de.Italic&&(t["font-style"]="italic"),e.fontStyle&de.Bold&&(t["font-weight"]="bold");let n=[];e.fontStyle&de.Underline&&n.push("underline"),e.fontStyle&de.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Ll(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function ow(){let e=new WeakMap;function t(n){if(!e.has(n.meta)){let s=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new re(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...o.indexToPos(a),offset:a}}else{let l=o.lines[a.line];if(l===void 0)throw new re(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${o.lines.length}`);let c=a.character;if(c<0&&(c=l.length+c),c<0||c>l.length)throw new re(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${l.length}`);return{...a,character:c,offset:o.posToIndex(a.line,c)}}};var r=s;let o=Qb(n.source),i=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));sw(i),e.set(n.meta,{decorations:i,converter:o,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return nw(n,t(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;let r=t(this),o=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(o.length!==r.converter.lines.length)throw new re(`Number of lines in code element (${o.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function s(u,d,m,h){let f=o[u],g="",b=-1,w=-1;if(d===0&&(b=0),m===0&&(w=0),m===Number.POSITIVE_INFINITY&&(w=f.children.length),b===-1||w===-1)for(let v=0;v<f.children.length;v++)g+=rf(f.children[v]),b===-1&&g.length===d&&(b=v+1),w===-1&&g.length===m&&(w=v+1);if(b===-1)throw new re(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(w===-1)throw new re(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let S=f.children.slice(b,w);if(!h.alwaysWrap&&S.length===f.children.length)a(f,h,"line");else if(!h.alwaysWrap&&S.length===1&&S[0].type==="element")a(S[0],h,"token");else{let v={type:"element",tagName:"span",properties:{},children:S};a(v,h,"wrapper"),f.children.splice(b,S.length,v)}}function i(u,d){o[u]=a(o[u],d,"line")}function a(u,d,m){let h=d.properties||{},f=d.transform||(g=>g);return u.tagName=d.tagName||"span",u.properties={...u.properties,...h,class:u.properties.class},d.properties?.class&&tf(u,d.properties.class),u=f(u,m)||u,u}let l=[],c=r.decorations.sort((u,d)=>d.start.offset-u.start.offset||u.end.offset-d.end.offset);for(let u of c){let{start:d,end:m}=u;if(d.line===m.line)s(d.line,d.character,m.character,u);else if(d.line<m.line){s(d.line,d.character,Number.POSITIVE_INFINITY,u);for(let h=d.line+1;h<m.line;h++)l.unshift(()=>i(h,u));s(m.line,0,m.character,u)}}l.forEach(u=>u())}}}function sw(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new re(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let o=e[r],s=n.start.offset<=o.start.offset&&o.start.offset<n.end.offset,i=n.start.offset<o.end.offset&&o.end.offset<=n.end.offset,a=o.start.offset<=n.start.offset&&n.start.offset<o.end.offset,l=o.start.offset<n.end.offset&&n.end.offset<=o.end.offset;if(s||i||a||l){if(s&&i||a&&l||a&&n.start.offset===n.end.offset||i&&o.start.offset===o.end.offset)continue;throw new re(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function rf(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(rf).join(""):""}var iw=[ow()];function Us(e){let t=aw(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...iw]}function aw(e){let t=[],n=[],r=[];for(let o of e)switch(o.enforce){case"pre":t.push(o);break;case"post":n.push(o);break;default:r.push(o)}return{pre:t,post:n,normal:r}}var En=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Pl={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function lw(e,t){let n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){let r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Qp(e){let t=e.shift();if(t==="2"){let n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){let n=e.shift();if(n)return{type:"table",index:Number(n)}}}function cw(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)Pl[r]&&t.push({type:"setDecoration",value:Pl[r]});else if(r<=29){let o=Pl[r-20];o&&(t.push({type:"resetDecoration",value:o}),o==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:En[r-30]}});else if(r===38){let o=Qp(e);o&&t.push({type:"setForegroundColor",value:o})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:En[r-40]}});else if(r===48){let o=Qp(e);o&&t.push({type:"setBackgroundColor",value:o})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:En[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:En[r-100+8]}})}return t}function uw(){let e=null,t=null,n=new Set;return{parse(r){let o=[],s=0;do{let i=lw(r,s),a=i.sequence?r.substring(s,i.startPosition):r.substring(s);if(a.length>0&&o.push({value:a,foreground:e,background:t,decorations:new Set(n)}),i.sequence){let l=cw(i.sequence);for(let c of l)c.type==="resetAll"?(e=null,t=null,n.clear()):c.type==="resetForegroundColor"?e=null:c.type==="resetBackgroundColor"?t=null:c.type==="resetDecoration"&&n.delete(c.value);for(let c of l)c.type==="setForegroundColor"?e=c.value:c.type==="setBackgroundColor"?t=c.value:c.type==="setDecoration"&&n.add(c.value)}s=i.position}while(s<r.length);return o}}}var dw={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function pw(e=dw){function t(a){return e[a]}function n(a){return`#${a.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function o(){if(r)return r;r=[];for(let c=0;c<En.length;c++)r.push(t(En[c]));let a=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let d=0;d<6;d++)r.push(n([a[c],a[u],a[d]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function s(a){return o()[a]}function i(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return s(a.index)}}return{value:i}}var fw=/#([0-9a-f]{3,8})/i,mw=/var\((--[\w-]+-ansi-[\w-]+)\)/,hw={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function gw(e,t,n){let r=ro(e,n),o=lr(t),s=pw(Object.fromEntries(En.map(a=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||hw[a]]}))),i=uw();return o.map(a=>i.parse(a[0]).map(l=>{let c,u;l.decorations.has("reverse")?(c=l.background?s.value(l.background):e.bg,u=l.foreground?s.value(l.foreground):e.fg):(c=l.foreground?s.value(l.foreground):e.fg,u=l.background?s.value(l.background):void 0),c=Dt(c,r),u=Dt(u,r),l.decorations.has("dim")&&(c=yw(c));let d=de.None;return l.decorations.has("bold")&&(d|=de.Bold),l.decorations.has("italic")&&(d|=de.Italic),l.decorations.has("underline")&&(d|=de.Underline),l.decorations.has("strikethrough")&&(d|=de.Strikethrough),{content:l.value,offset:a[1],color:c,bgColor:u,fontStyle:d}}))}function yw(e){let t=e.match(fw);if(t){let r=t[1];if(r.length===8){let o=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${o}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){let o=r[0],s=r[1],i=r[2],a=r[3];return`#${o}${o}${s}${s}${i}${i}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){let o=r[0],s=r[1],i=r[2];return`#${o}${o}${s}${s}${i}${i}80`}}}let n=e.match(mw);return n?`var(${n[1]}-dim)`:e}function $l(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:o=e.getLoadedThemes()[0]}=n;if(!oo(r)&&!so(o)&&r==="ansi"){let{theme:s}=e.setTheme(o);return gw(s,t,n)}return yl(e,t,n)}function Ws(e,t,n){let r,o,s,i,a,l;if("themes"in n){let{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:d="css-vars"}=n,m=Object.entries(n.themes).filter(w=>w[1]).map(w=>({color:w[0],theme:w[1]})).sort((w,S)=>w.color===c?-1:S.color===c?1:0);if(m.length===0)throw new re("`themes` option must not be empty");let h=Ps(e,t,n,$l);if(l=cr(h),c&&c!=="light-dark()"&&!m.some(w=>w.color===c))throw new re(`\`themes\` option must contain the defaultColor key \`${c}\``);let f=m.map(w=>e.getTheme(w.theme)),g=m.map(w=>w.color);s=h.map(w=>w.map(S=>rw(S,g,u,c,d))),l&&io(s,l);let b=m.map(w=>ro(w.theme,n));o=ef(m,f,b,u,c,"fg",d),r=ef(m,f,b,u,c,"bg",d),i=`shiki-themes ${f.map(w=>w.name).join(" ")}`,a=c?void 0:[o,r].join(";")}else if("theme"in n){let c=ro(n.theme,n);s=$l(e,t,n);let u=e.getTheme(n.theme);r=Dt(u.bg,c),o=Dt(u.fg,c),i=u.name,l=cr(s)}else throw new re("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:o,bg:r,themeName:i,rootStyle:a,grammarState:l}}function ef(e,t,n,r,o,s,i){return e.map((a,l)=>{let c=Dt(t[l][s],n[l])||"inherit",u=`${r+a.color}${s==="bg"?"-bg":""}:${c}`;if(l===0&&o){if(o==="light-dark()"&&e.length>1){let d=e.findIndex(h=>h.color==="light"),m=e.findIndex(h=>h.color==="dark");if(d===-1||m===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Dt(t[d][s],n[d])||"inherit"}, ${Dt(t[m][s],n[m])||"inherit"});${u}`}return c}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}var of=/^\s+$/,xw=/^(\s*)(.*?)(\s*)$/;function Hs(e,t,n,r={meta:{},options:n,codeToHast:(o,s)=>Hs(e,o,s),codeToTokens:(o,s)=>Ws(e,o,s)}){let o=t;for(let f of Us(n))o=f.preprocess?.call(r,o,n)||o;let{tokens:s,fg:i,bg:a,themeName:l,rootStyle:c,grammarState:u}=Ws(e,o,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:m=!1}=n;d===!0?s=ww(s):d==="never"&&(s=kw(s)),m&&(s=Sw(s));let h={...r,get source(){return o}};for(let f of Us(n))s=f.tokens?.call(h,s)||s;return bw(s,{...n,fg:i,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},h,u)}function bw(e,t,n,r=cr(e)){let o=Us(t),s=[],i={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t,c={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?c.style=t.rootStyle:c.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(let[g,b]of Object.entries(t.meta||{}))g.startsWith("_")||(c[g]=b);let u={type:"element",tagName:"pre",properties:c,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},m=[],h={...n,structure:a,addClassToHast:tf,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return i},get pre(){return u},get code(){return d},get lines(){return m}};if(e.forEach((g,b)=>{b&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&s.push({type:"text",value:`
|
|
35
|
+
`}));let w={type:"element",tagName:"span",properties:{class:"line"},children:[]},S=0;for(let v of g){let _={type:"element",tagName:"span",properties:{...v.htmlAttrs},children:[{type:"text",value:v.content}]},E=Ll(v.htmlStyle||js(v));E&&(_.properties.style=E);for(let M of o)_=M?.span?.call(h,_,b+1,S,w,v)||_;a==="inline"?i.children.push(_):a==="classic"&&w.children.push(_),S+=v.content.length}if(a==="classic"){for(let v of o)w=v?.line?.call(h,w,b+1)||w;m.push(w),s.push(w)}else a==="inline"&&m.push(w)}),a==="classic"){for(let g of o)d=g?.code?.call(h,d)||d;u.children.push(d);for(let g of o)u=g?.pre?.call(h,u)||u;i.children.push(u)}else if(a==="inline"){let g=[],b={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let S of i.children)S.type==="element"&&S.tagName==="br"?(g.push(b),b={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(S.type==="element"||S.type==="text")&&b.children.push(S);g.push(b);let w={type:"element",tagName:"code",properties:{},children:g};for(let S of o)w=S?.code?.call(h,w)||w;i.children=[];for(let S=0;S<w.children.length;S++){S>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});let v=w.children[S];v.type==="element"&&i.children.push(...v.children)}}let f=i;for(let g of o)f=g?.root?.call(h,f)||f;return r&&io(f,r),f}function ww(e){return e.map(t=>{let n=[],r="",o;return t.forEach((s,i)=>{let a=!(s.fontStyle&&(s.fontStyle&de.Underline||s.fontStyle&de.Strikethrough));a&&of.test(s.content)&&t[i+1]?(o===void 0&&(o=s.offset),r+=s.content):r?(a?n.push({...s,offset:o,content:r+s.content}):n.push({content:r,offset:o},s),o=void 0,r=""):n.push(s)}),n})}function kw(e){return e.map(t=>t.flatMap(n=>{if(of.test(n.content))return n;let r=n.content.match(xw);if(!r)return n;let[,o,s,i]=r;if(!o&&!i)return n;let a=[{...n,offset:n.offset+o.length,content:s}];return o&&a.unshift({content:o,offset:n.offset}),i&&a.push({content:i,offset:n.offset+o.length+s.length}),a}))}function Sw(e){return e.map(t=>{let n=[];for(let r of t){if(n.length===0){n.push({...r});continue}let o=n.at(-1),s=Ll(o.htmlStyle||js(o)),i=Ll(r.htmlStyle||js(r)),a=o.fontStyle&&(o.fontStyle&de.Underline||o.fontStyle&de.Strikethrough),l=r.fontStyle&&(r.fontStyle&de.Underline||r.fontStyle&de.Strikethrough);!a&&!l&&s===i?o.content+=r.content:n.push({...r})}return n})}var Tw=Il;function Cw(e,t,n){let r={meta:{},options:n,codeToHast:(s,i)=>Hs(e,s,i),codeToTokens:(s,i)=>Ws(e,s,i)},o=Tw(Hs(e,t,n,r));for(let s of Us(n))o=s.postprocess?.call(r,o,n)||o;return o}async function _w(e){let t=await gl(e);return{getLastGrammarState:(...n)=>wp(t,...n),codeToTokensBase:(n,r)=>$l(t,n,r),codeToTokensWithThemes:(n,r)=>Ps(t,n,r),codeToTokens:(n,r)=>Ws(t,n,r),codeToHast:(n,r)=>Hs(t,n,r),codeToHtml:(n,r)=>Cw(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function sf(e){let t=e.langs,n=e.themes,r=e.engine;async function o(s){function i(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,fl(d))return[];let m=t[d];if(!m)throw new re(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}function a(d){if(ml(d))return"none";if(typeof d=="string"){let m=n[d];if(!m)throw new re(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return m}return d}let l=(s.themes??[]).map(d=>a(d)),c=(s.langs??[]).map(d=>i(d)),u=await _w({engine:s.engine??r(),...s,themes:l,langs:c});return{...u,loadLanguage(...d){return u.loadLanguage(...d.map(i))},loadTheme(...d){return u.loadTheme(...d.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return o}function vw(e){let t;async function n(r={}){if(t){let o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}else{t=e({...r,themes:[],langs:[]});let o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}}return n}function af(e,t){let n=vw(e);async function r(o,s){let i=await n({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),a=await t?.guessEmbeddedLanguages?.(o,s.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(o){return n(o)},async codeToHtml(o,s){return(await r(o,s)).codeToHtml(o,s)},async codeToHast(o,s){return(await r(o,s)).codeToHast(o,s)},async codeToTokens(o,s){return(await r(o,s)).codeToTokens(o,s)},async codeToTokensBase(o,s){return(await r(o,s)).codeToTokensBase(o,s)},async codeToTokensWithThemes(o,s){return(await r(o,s)).codeToTokensWithThemes(o,s)},async getLastGrammarState(o,s){return(await n({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(o,s)}}}var lf=ir({bundledLanguages:()=>Qr,bundledLanguagesAlias:()=>Yr,bundledLanguagesBase:()=>Zr,bundledLanguagesInfo:()=>ar,bundledThemes:()=>to,bundledThemesInfo:()=>eo,codeToHast:()=>Dl,codeToHtml:()=>Ol,codeToTokens:()=>Nl,codeToTokensBase:()=>uo,codeToTokensWithThemes:()=>Ml,createHighlighter:()=>Vs,getLastGrammarState:()=>Bl,getSingletonHighlighter:()=>po}),Vs=sf({langs:Qr,themes:to,engine:()=>(0,dl.createOnigurumaEngine)(import("./wasm-FXCISVGQ.js"))}),{codeToHtml:Ol,codeToHast:Dl,codeToTokens:Nl,codeToTokensBase:uo,codeToTokensWithThemes:Ml,getSingletonHighlighter:po,getLastGrammarState:Bl}=af(Vs,{guessEmbeddedLanguages:nf});p();p();var cf=class{patterns;options;regexps;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:o}=t;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(s=>{if(typeof s!="string")return s;let i=r?.get(s);if(i){if(i instanceof RegExp)return i;if(n)return null;throw i}try{let a=o(s);return r?.set(s,a),a}catch(a){if(r?.set(s,a),n)return null;throw a}})}findNextMatchSync(e,t,n){let r=typeof e=="string"?e:e.content,o=[];function s(i,a,l=0){return{index:i,captureIndices:a.indices.map(c=>c==null?{start:4294967295,end:4294967295,length:0}:{start:c[0]+l,end:c[1]+l,length:c[1]-c[0]})}}for(let i=0;i<this.regexps.length;i++){let a=this.regexps[i];if(a)try{a.lastIndex=t;let l=a.exec(r);if(!l)continue;if(l.index===t)return s(i,l,0);o.push([i,l,0])}catch(l){if(this.options.forgiving)continue;throw l}}if(o.length){let i=Math.min(...o.map(a=>a[1].index));for(let[a,l,c]of o)if(l.index===i)return s(a,l,c)}return null}};p();p();p();p();p();function rn(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function uf(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var fo=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),we=String.raw;function Ft(e,t){if(e==null)throw new Error(t??"Value expected");return e}var gf=we`\[\^?`,yf=`c.? | C(?:-.?)?|${we`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${we`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${we`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${we`o\{[^\}]*\}?`}|${we`\d{1,3}`}`,Gl=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,zs=new RegExp(we`
|
|
36
36
|
\\ (?:
|
|
37
|
-
${
|
|
37
|
+
${yf}
|
|
38
38
|
| [gk]<[^>]*>?
|
|
39
39
|
| [gk]'[^']*'?
|
|
40
40
|
| .
|
|
@@ -51,20 +51,20 @@ import{a as td}from"./chunk-KMMG6QC6.js";import{a as Oe,b as Yn,c as Sa}from"./c
|
|
|
51
51
|
)?
|
|
52
52
|
| \*[^\)]*\)?
|
|
53
53
|
)?
|
|
54
|
-
| (?:${
|
|
55
|
-
| ${
|
|
54
|
+
| (?:${Gl.source})+
|
|
55
|
+
| ${gf}
|
|
56
56
|
| .
|
|
57
|
-
`.replace(/\s+/g,""),"gsu"),
|
|
57
|
+
`.replace(/\s+/g,""),"gsu"),Fl=new RegExp(we`
|
|
58
58
|
\\ (?:
|
|
59
|
-
${
|
|
59
|
+
${yf}
|
|
60
60
|
| .
|
|
61
61
|
)
|
|
62
62
|
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
63
|
-
| ${
|
|
63
|
+
| ${gf}
|
|
64
64
|
| &&
|
|
65
65
|
| .
|
|
66
|
-
`.replace(/\s+/g,""),"gsu");function
|
|
67
|
-
`,r);return{lastIndex:i===-1?t.length:i}}if(/^\s$/.test(n)){let i=/\s+/y;return i.lastIndex=r,{lastIndex:i.exec(t)?i.lastIndex:r}}}if(n===".")return{token:Pn("dot",n)};if(n==="^"||n==="$"){let i=e.singleline?{"^":Se`\A`,$:Se`\Z`}[n]:n;return{token:uf(i,n)}}return n==="|"?{token:$w(n)}:Bl.test(n)?{tokens:Zw(n)}:{token:Ut(on(n),n)}}function Pw(e,t,n){let r=[df(t[1]==="^",t)],o=1,s;for(Ml.lastIndex=n;s=Ml.exec(e);){let i=s[0];if(i[0]==="["&&i[1]!==":")o++,r.push(df(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Ut(93,i));else if(o--,r.push(Ow(i)),!o)break}else{let a=Lw(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:Ml.lastIndex||e.length}}function Lw(e){if(e[0]==="\\")return bf(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!po.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Pn("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Dw(e):e==="&&"?Nw(e):Ut(on(e),e)}function bf(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return Ww(e);if("dDhHsSwW".includes(n))return zw(e);if(e.startsWith(Se`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return qw(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{let r=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),o=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),s=new TextEncoder;return[...o].map(i=>{let a=[...s.encode(i)].map(l=>`\\x${l.toString(16)}`).join("");return Ut(on(i),a)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Ut(Xw(e),e);if(pf.has(n))return Ut(pf.get(n),e);if(/\d/.test(n))return Mw(t,e);if(e==="\\")throw new Error(Se`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Ut(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function $w(e){return{type:"Alternator",raw:e}}function uf(e,t){return{type:"Assertion",kind:e,raw:t}}function xf(e){return{type:"Backreference",raw:e}}function Ut(e,t){return{type:"Character",value:e,raw:t}}function Ow(e){return{type:"CharacterClassClose",raw:e}}function Dw(e){return{type:"CharacterClassHyphen",raw:e}}function Nw(e){return{type:"CharacterClassIntersector",raw:e}}function df(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Pn(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function wf(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:jt(n.flags),raw:t}}function Mw(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Bw(e){return{type:"GroupClose",raw:e}}function cr(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function Fw(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Gw(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function jw(e){return{type:"Subroutine",raw:e}}var Uw=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),pf=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Ww(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Ut(on(t.toUpperCase())-64,e)}function Hw(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";let o=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),s=mf(n),i=mf(r),a={};if(s&&(a.enable=s),i&&(a.disable=i),e.endsWith(")"))return t.replaceCurrentModX(o),wf("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,cr("group",e,{...(s||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function Vw(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:o}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);let s=o?o.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[i,a,l]=s,c=Uw.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof i=="string")throw new Error(`Named callout argument must be a number "${i}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(s.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${i}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return Fw(c,r??null,o?.split(",")??null,e)}function ff(e){let t=null,n,r;if(e[0]==="{"){let{minStr:o,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,i=1e5;if(+o>i||s&&+s>i)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+o,r=s===void 0?+o:s===""?1/0:+s,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return Gw(t,n,r,e)}function zw(e){let t=e[1].toLowerCase();return Pn({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function qw(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Pn("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function mf(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Kw(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function Xw(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Jw(e,t){let{raw:n,inCharClass:r}=e,o=n.slice(1);if(!r&&(o!=="0"&&o.length===1||o[0]!=="0"&&+o<=t))return[xf(n)];let s=[],i=o.match(/^[0-7]+|\d/g);for(let a=0;a<i.length;a++){let l=i[a],c;if(a===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(Se`Octal encoded byte above 177 unsupported "${n}"`)}else c=on(l);s.push(Ut(c,(a===0?"\\":"")+l))}return s}function Zw(e){let t=[],n=new RegExp(Bl,"gy"),r;for(;r=n.exec(e);){let o=r[0];if(o[0]==="{"){let s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(o);if(s){let{min:i,max:a}=s.groups;if(+i>+a&&o.endsWith("?")){n.lastIndex--,t.push(ff(o.slice(0,-1)));continue}}}t.push(ff(o))}return t}p();function zs(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function kf(e){return Yw.has(e.type)}var Yw=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Ks(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=yf(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),o=(m,h)=>{let f=r.tokens[s.nextIndex];switch(s.parent=m,s.nextIndex++,f.type){case"Alternator":return Wt();case"Assertion":return Qw(f);case"Backreference":return e0(f,s);case"Character":return ur(f.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return t0(f,s,h);case"CharacterClassOpen":return n0(f,s,h);case"CharacterSet":return r0(f,s);case"Directive":return c0(f.kind,{flags:f.flags});case"GroupOpen":return o0(f,s,h);case"NamedCallout":return d0(f.kind,f.tag,f.arguments);case"Quantifier":return s0(f,s);case"Subroutine":return i0(f,s);default:throw new Error(`Unexpected token type "${f.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:o},i=f0(u0(r.flags)),a=i.body[0];for(;s.nextIndex<r.tokens.length;){let m=o(a,{});m.type==="Alternative"?(i.body.push(m),a=m):a.body.push(m)}let{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:d}=s;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:m}of d)if(typeof m=="number"){if(m>l.length)throw new Error("Subroutine uses a group number that's not defined");m&&(l[m-1].isSubroutined=!0)}else if(u.has(m)){if(u.get(m).length>1)throw new Error(Se`Subroutine uses a duplicate group name "\g<${m}>"`);u.get(m)[0].isSubroutined=!0}else throw new Error(Se`Subroutine uses a group name that's not defined "\g<${m}>"`);return i}function Qw({kind:e}){return Xs(jt({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===Se`\B`||e===Se`\Y`})}function e0({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),o=(s,i=!1)=>{let a=t.capturingGroups.length,l=!1;if(s>a)if(t.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,qs(i?a+1-s:s,{orphan:l})};if(n){let s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(s)return o(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return qs(r)}return o(+r)}function t0(e,t,n){let{tokens:r,walk:o}=t,s=t.parent,i=s.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){let l=o(s,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&l.type==="Character")return s.body.pop(),l0(i,l);throw new Error("Invalid character class range")}return ur(on("-"))}function n0({negate:e},t,n){let{tokens:r,walk:o}=t,s=[fo()],i=r[t.nextIndex],a=Cf(i);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")s.push(fo()),t.nextIndex++;else{let c=s.at(-1);c.body.push(o(c,n))}a=Cf(r[t.nextIndex],i)}let l=fo({negate:e});return s.length===1?l.body=s[0].body:(l.kind="intersection",l.body=s.map(c=>c.body.length===1?c.body[0]:c)),t.nextIndex++,l}function r0({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i}=r;if(e==="property"){let a=dr(n);if(po.has(a)&&!i?.has(a))e="posix",n=a;else return Ln(n,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i})}return e==="posix"?p0(n,{negate:t}):Js(e,{negate:t})}function o0(e,t,n){let{tokens:r,capturingGroups:o,namedGroupsByName:s,skipLookbehindValidation:i,walk:a}=t,l=m0(e),c=l.type==="AbsenceFunction",u=Tf(l),d=u&&l.negate;if(l.type==="CapturingGroup"&&(o.push(l),l.name&&cf(s,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let m=_f(r[t.nextIndex]);for(;m.type!=="GroupClose";){if(m.type==="Alternator")l.body.push(Wt()),t.nextIndex++;else{let h=l.body.at(-1),f=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(h.body.push(f),(u||n.isInLookbehind)&&!i){let g="Lookbehind includes a pattern not allowed by Oniguruma";if(d||n.isInNegLookbehind){if(Sf(f)||f.type==="CapturingGroup")throw new Error(g)}else if(Sf(f)||Tf(f)&&f.negate)throw new Error(g)}}m=_f(r[t.nextIndex])}return t.nextIndex++,l}function s0({kind:e,min:t,max:n},r){let o=r.parent,s=o.body.at(-1);if(!s||!kf(s))throw new Error("Quantifier requires a repeatable token");let i=Gl(e,t,n,s);return o.body.pop(),i}function i0({raw:e},t){let{capturingGroups:n,subroutines:r}=t,o=e.slice(3,-1),s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(o);if(s){let a=+s.groups.num,l=n.length;if(t.hasNumberedRef=!0,o={"":a,"+":l+a,"-":l+1-a}[s.groups.sign],o<1)throw new Error("Invalid subroutine number")}else o==="0"&&(o=0);let i=jl(o);return r.push(i),i}function a0(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:mo(t?.body)}}function Wt(e){return{type:"Alternative",body:vf(e?.body)}}function Xs(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function qs(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function Fl(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!h0(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:mo(t?.body)}}function ur(e,t){let n={useLastValid:!1,...t};if(e>1114111){let r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function fo(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:vf(e?.body)}}function l0(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Js(e,t){let n=!!t?.negate,r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function c0(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:jt(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function u0(e){return{type:"Flags",...e}}function Qe(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:mo(e?.body)}}function sn(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:mo(e?.body)}}function d0(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function p0(e,t){let n=!!t?.negate;if(!po.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function Gl(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function f0(e,t){return{type:"Regex",body:mo(t?.body),flags:e}}function jl(e){return{type:"Subroutine",ref:e}}function Ln(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(dr(e));if(!r){if(n.normalizeUnknownPropertyNames)r=g0(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Se`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function m0({flags:e,kind:t,name:n,negate:r,number:o}){switch(t){case"absence_repeater":return a0("repeater");case"atomic":return Qe({atomic:!0});case"capturing":return Fl(o,{name:n});case"group":return Qe({flags:e});case"lookahead":case"lookbehind":return sn({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function mo(e){if(e===void 0)e=[Wt()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function vf(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function Sf(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Tf(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function h0(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function g0(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function dr(e){return e.replace(/[- _]+/g,"").toLowerCase()}function Cf(e,t){let n=t;return jt(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function _f(e){return jt(e,"Unclosed group")}p();function $n(e,t,n=null){function r(s,i){for(let a=0;a<s.length;a++){let l=o(s[a],i,a,s);a=Math.max(-1,a+l)}}function o(s,i=null,a=null,l=null){let c=0,u=!1,d={node:s,parent:i,key:a,container:l,root:e,remove(){Zs(l).splice(Math.max(0,pr(a)+c),1),c--,u=!0},removeAllNextSiblings(){return Zs(l).splice(pr(a)+1)},removeAllPrevSiblings(){let x=pr(a)+c;return c-=x,Zs(l).splice(0,Math.max(0,x))},replaceWith(x,T={}){let v=!!T.traverse;l?l[Math.max(0,pr(a)+c)]=x:jt(i,"Can't replace root node")[a]=x,v&&o(x,i,a,l),u=!0},replaceWithMultiple(x,T={}){let v=!!T.traverse;if(Zs(l).splice(Math.max(0,pr(a)+c),1,...x),c+=x.length-1,v){let _=0;for(let S=0;S<x.length;S++)_+=o(x[S],i,pr(a)+S+_,l)}u=!0},skip(){u=!0}},{type:m}=s,h=t["*"],f=t[m],g=typeof h=="function"?h:h?.enter,w=typeof f=="function"?f:f?.enter;if(g?.(d,n),w?.(d,n),!u)switch(m){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":o(s.min,s,"min"),o(s.max,s,"max");break;case"Quantifier":o(s.body,s,"body");break;case"Regex":r(s.body,s),o(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return f?.exit?.(d,n),h?.exit?.(d,n),c}return o(e),e}function Zs(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function pr(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}p();p();p();var Rf=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Af(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Ef(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}p();var He=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function ho(e,t,n,r){let o=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1],i=0,a="";for(let l of e.matchAll(o)){let{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===He.DEFAULT==!i)){n instanceof Function?a+=n(l,{context:i?He.CHAR_CLASS:He.DEFAULT,negated:s[s.length-1]}):a+=n;continue}c[0]==="["?(i++,s.push(c[1]==="^")):c==="]"&&i&&(i--,s.pop()),a+=c}return a}function Ul(e,t,n,r){ho(e,t,n,r)}function y0(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let o=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");o.lastIndex=n;let s=0,i;for(;i=o.exec(e);){let{0:a,groups:{$skip:l}}=i;if(!l&&(!r||r===He.DEFAULT==!s))return i;a==="["?s++:a==="]"&&s&&s--,o.lastIndex==i.index&&o.lastIndex++}return null}function go(e,t,n){return!!y0(e,t,0,n)}function If(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,s=1,i;for(;i=n.exec(e);){let[a]=i;if(a==="[")o++;else if(o)a==="]"&&o--;else if(a==="(")s++;else if(a===")"&&(s--,!s)){r=i.index;break}}return e.slice(t,r)}var Pf=new RegExp(String.raw`(?<noncapturingStart>${Rf})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Hl(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let o="(?>",s="(?:(?=(",i=[0],a=[],l=0,c=0,u=NaN,d;do{d=!1;let m=0,h=0,f=!1,g;for(Pf.lastIndex=Number.isNaN(u)?0:u+s.length;g=Pf.exec(e);){let{0:w,index:x,groups:{capturingStart:T,noncapturingStart:v}}=g;if(w==="[")m++;else if(m)w==="]"&&m--;else if(w===o&&!f)u=x,f=!0;else if(f&&v)h++;else if(T)f?h++:(l++,i.push(l+c));else if(w===")"&&f){if(!h){c++;let _=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+o.length,x)}))<$$${_}>)${e.slice(x+1)}`,d=!0,a.push(_),Af(n,_),r.size){let S=new Map;r.forEach((D,H)=>{S.set(H>=_?H+1:H,D.map(E=>E>=_?E+1:E))}),r=S}break}h--}}}while(d);return n.push(...a),e=ho(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:m,groups:{backrefNum:h,wrappedBackrefNum:f}})=>{if(h){let g=+h;if(g>i.length-1)throw new Error(`Backref "${m}" greater than number of captures`);return`\\${i[g]}`}return`\\${f}`},He.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var Lf=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Wl=new RegExp(String.raw`
|
|
66
|
+
`.replace(/\s+/g,""),"gsu");function xf(e,t={}){let n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");let r=Vw(n.flags),o=[r.extended],s={captureGroup:n.rules.captureGroup,getCurrentModX(){return o.at(-1)},numOpenGroups:0,popModX(){o.pop()},pushModX(d){o.push(d)},replaceCurrentModX(d){o[o.length-1]=d},singleline:n.rules.singleline},i=[],a;for(zs.lastIndex=0;a=zs.exec(e);){let d=Rw(s,e,a[0],zs.lastIndex);d.tokens?i.push(...d.tokens):d.token&&i.push(d.token),d.lastIndex!==void 0&&(zs.lastIndex=d.lastIndex)}let l=[],c=0;i.filter(d=>d.type==="GroupOpen").forEach(d=>{d.kind==="capturing"?d.number=++c:d.raw==="("&&l.push(d)}),c||l.forEach((d,m)=>{d.kind="capturing",d.number=m+1});let u=c||l.length;return{tokens:i.map(d=>d.type==="EscapedNumber"?qw(d,u):d).flat(),flags:r}}function Rw(e,t,n,r){let[o,s]=n;if(n==="["||n==="[^"){let i=Aw(t,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(o==="\\"){if("AbBGyYzZ".includes(s))return{token:df(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Bw(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:wf(n)}}if(s==="K")return{token:kf("keep",n)};if(s==="N"||s==="R")return{token:In("newline",n,{negate:s==="N"})};if(s==="O")return{token:In("any",n)};if(s==="X")return{token:In("text_segment",n)};let i=bf(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(o==="("){if(s==="*")return{token:Uw(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:jw(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:ur("group",n)};if(n==="(?>")return{token:ur("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:ur(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:ur("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:ur("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Dw(n)}}if(e.getCurrentModX()){if(n==="#"){let i=t.indexOf(`
|
|
67
|
+
`,r);return{lastIndex:i===-1?t.length:i}}if(/^\s$/.test(n)){let i=/\s+/y;return i.lastIndex=r,{lastIndex:i.exec(t)?i.lastIndex:r}}}if(n===".")return{token:In("dot",n)};if(n==="^"||n==="$"){let i=e.singleline?{"^":we`\A`,$:we`\Z`}[n]:n;return{token:df(i,n)}}return n==="|"?{token:Iw(n)}:Gl.test(n)?{tokens:Kw(n)}:{token:Gt(rn(n),n)}}function Aw(e,t,n){let r=[pf(t[1]==="^",t)],o=1,s;for(Fl.lastIndex=n;s=Fl.exec(e);){let i=s[0];if(i[0]==="["&&i[1]!==":")o++,r.push(pf(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Gt(93,i));else if(o--,r.push(Pw(i)),!o)break}else{let a=Ew(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:Fl.lastIndex||e.length}}function Ew(e){if(e[0]==="\\")return bf(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!fo.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return In("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Lw(e):e==="&&"?$w(e):Gt(rn(e),e)}function bf(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return Gw(e);if("dDhHsSwW".includes(n))return Ww(e);if(e.startsWith(we`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Hw(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{let r=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),o=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),s=new TextEncoder;return[...o].map(i=>{let a=[...s.encode(i)].map(l=>`\\x${l.toString(16)}`).join("");return Gt(rn(i),a)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Gt(zw(e),e);if(ff.has(n))return Gt(ff.get(n),e);if(/\d/.test(n))return Ow(t,e);if(e==="\\")throw new Error(we`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Gt(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Iw(e){return{type:"Alternator",raw:e}}function df(e,t){return{type:"Assertion",kind:e,raw:t}}function wf(e){return{type:"Backreference",raw:e}}function Gt(e,t){return{type:"Character",value:e,raw:t}}function Pw(e){return{type:"CharacterClassClose",raw:e}}function Lw(e){return{type:"CharacterClassHyphen",raw:e}}function $w(e){return{type:"CharacterClassIntersector",raw:e}}function pf(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function In(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function kf(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Ft(n.flags),raw:t}}function Ow(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Dw(e){return{type:"GroupClose",raw:e}}function ur(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function Nw(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Mw(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Bw(e){return{type:"Subroutine",raw:e}}var Fw=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),ff=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Gw(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Gt(rn(t.toUpperCase())-64,e)}function jw(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";let o=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),s=hf(n),i=hf(r),a={};if(s&&(a.enable=s),i&&(a.disable=i),e.endsWith(")"))return t.replaceCurrentModX(o),kf("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,ur("group",e,{...(s||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function Uw(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:o}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);let s=o?o.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[i,a,l]=s,c=Fw.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof i=="string")throw new Error(`Named callout argument must be a number "${i}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(s.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${i}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return Nw(c,r??null,o?.split(",")??null,e)}function mf(e){let t=null,n,r;if(e[0]==="{"){let{minStr:o,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,i=1e5;if(+o>i||s&&+s>i)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+o,r=s===void 0?+o:s===""?1/0:+s,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return Mw(t,n,r,e)}function Ww(e){let t=e[1].toLowerCase();return In({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Hw(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return In("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function hf(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Vw(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function zw(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function qw(e,t){let{raw:n,inCharClass:r}=e,o=n.slice(1);if(!r&&(o!=="0"&&o.length===1||o[0]!=="0"&&+o<=t))return[wf(n)];let s=[],i=o.match(/^[0-7]+|\d/g);for(let a=0;a<i.length;a++){let l=i[a],c;if(a===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(we`Octal encoded byte above 177 unsupported "${n}"`)}else c=rn(l);s.push(Gt(c,(a===0?"\\":"")+l))}return s}function Kw(e){let t=[],n=new RegExp(Gl,"gy"),r;for(;r=n.exec(e);){let o=r[0];if(o[0]==="{"){let s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(o);if(s){let{min:i,max:a}=s.groups;if(+i>+a&&o.endsWith("?")){n.lastIndex--,t.push(mf(o.slice(0,-1)));continue}}}t.push(mf(o))}return t}p();function qs(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function Sf(e){return Xw.has(e.type)}var Xw=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Xs(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=xf(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),o=(m,h)=>{let f=r.tokens[s.nextIndex];switch(s.parent=m,s.nextIndex++,f.type){case"Alternator":return jt();case"Assertion":return Jw(f);case"Backreference":return Zw(f,s);case"Character":return dr(f.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return Yw(f,s,h);case"CharacterClassOpen":return Qw(f,s,h);case"CharacterSet":return ek(f,s);case"Directive":return ik(f.kind,{flags:f.flags});case"GroupOpen":return tk(f,s,h);case"NamedCallout":return lk(f.kind,f.tag,f.arguments);case"Quantifier":return nk(f,s);case"Subroutine":return rk(f,s);default:throw new Error(`Unexpected token type "${f.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:o},i=uk(ak(r.flags)),a=i.body[0];for(;s.nextIndex<r.tokens.length;){let m=o(a,{});m.type==="Alternative"?(i.body.push(m),a=m):a.body.push(m)}let{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:d}=s;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:m}of d)if(typeof m=="number"){if(m>l.length)throw new Error("Subroutine uses a group number that's not defined");m&&(l[m-1].isSubroutined=!0)}else if(u.has(m)){if(u.get(m).length>1)throw new Error(we`Subroutine uses a duplicate group name "\g<${m}>"`);u.get(m)[0].isSubroutined=!0}else throw new Error(we`Subroutine uses a group name that's not defined "\g<${m}>"`);return i}function Jw({kind:e}){return Js(Ft({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===we`\B`||e===we`\Y`})}function Zw({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),o=(s,i=!1)=>{let a=t.capturingGroups.length,l=!1;if(s>a)if(t.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Ks(i?a+1-s:s,{orphan:l})};if(n){let s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(s)return o(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return Ks(r)}return o(+r)}function Yw(e,t,n){let{tokens:r,walk:o}=t,s=t.parent,i=s.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){let l=o(s,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&l.type==="Character")return s.body.pop(),sk(i,l);throw new Error("Invalid character class range")}return dr(rn("-"))}function Qw({negate:e},t,n){let{tokens:r,walk:o}=t,s=[mo()],i=r[t.nextIndex],a=_f(i);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")s.push(mo()),t.nextIndex++;else{let c=s.at(-1);c.body.push(o(c,n))}a=_f(r[t.nextIndex],i)}let l=mo({negate:e});return s.length===1?l.body=s[0].body:(l.kind="intersection",l.body=s.map(c=>c.body.length===1?c.body[0]:c)),t.nextIndex++,l}function ek({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i}=r;if(e==="property"){let a=pr(n);if(fo.has(a)&&!i?.has(a))e="posix",n=a;else return Pn(n,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i})}return e==="posix"?ck(n,{negate:t}):Zs(e,{negate:t})}function tk(e,t,n){let{tokens:r,capturingGroups:o,namedGroupsByName:s,skipLookbehindValidation:i,walk:a}=t,l=dk(e),c=l.type==="AbsenceFunction",u=Cf(l),d=u&&l.negate;if(l.type==="CapturingGroup"&&(o.push(l),l.name&&uf(s,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let m=vf(r[t.nextIndex]);for(;m.type!=="GroupClose";){if(m.type==="Alternator")l.body.push(jt()),t.nextIndex++;else{let h=l.body.at(-1),f=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(h.body.push(f),(u||n.isInLookbehind)&&!i){let g="Lookbehind includes a pattern not allowed by Oniguruma";if(d||n.isInNegLookbehind){if(Tf(f)||f.type==="CapturingGroup")throw new Error(g)}else if(Tf(f)||Cf(f)&&f.negate)throw new Error(g)}}m=vf(r[t.nextIndex])}return t.nextIndex++,l}function nk({kind:e,min:t,max:n},r){let o=r.parent,s=o.body.at(-1);if(!s||!Sf(s))throw new Error("Quantifier requires a repeatable token");let i=Ul(e,t,n,s);return o.body.pop(),i}function rk({raw:e},t){let{capturingGroups:n,subroutines:r}=t,o=e.slice(3,-1),s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(o);if(s){let a=+s.groups.num,l=n.length;if(t.hasNumberedRef=!0,o={"":a,"+":l+a,"-":l+1-a}[s.groups.sign],o<1)throw new Error("Invalid subroutine number")}else o==="0"&&(o=0);let i=Wl(o);return r.push(i),i}function ok(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:ho(t?.body)}}function jt(e){return{type:"Alternative",body:Rf(e?.body)}}function Js(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function Ks(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function jl(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!pk(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:ho(t?.body)}}function dr(e,t){let n={useLastValid:!1,...t};if(e>1114111){let r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function mo(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Rf(e?.body)}}function sk(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Zs(e,t){let n=!!t?.negate,r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function ik(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Ft(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function ak(e){return{type:"Flags",...e}}function Ze(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:ho(e?.body)}}function on(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:ho(e?.body)}}function lk(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function ck(e,t){let n=!!t?.negate;if(!fo.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function Ul(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function uk(e,t){return{type:"Regex",body:ho(t?.body),flags:e}}function Wl(e){return{type:"Subroutine",ref:e}}function Pn(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(pr(e));if(!r){if(n.normalizeUnknownPropertyNames)r=fk(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(we`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function dk({flags:e,kind:t,name:n,negate:r,number:o}){switch(t){case"absence_repeater":return ok("repeater");case"atomic":return Ze({atomic:!0});case"capturing":return jl(o,{name:n});case"group":return Ze({flags:e});case"lookahead":case"lookbehind":return on({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function ho(e){if(e===void 0)e=[jt()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Rf(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function Tf(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Cf(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function pk(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function fk(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function pr(e){return e.replace(/[- _]+/g,"").toLowerCase()}function _f(e,t){let n=t;return Ft(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function vf(e){return Ft(e,"Unclosed group")}p();function Ln(e,t,n=null){function r(s,i){for(let a=0;a<s.length;a++){let l=o(s[a],i,a,s);a=Math.max(-1,a+l)}}function o(s,i=null,a=null,l=null){let c=0,u=!1,d={node:s,parent:i,key:a,container:l,root:e,remove(){Ys(l).splice(Math.max(0,fr(a)+c),1),c--,u=!0},removeAllNextSiblings(){return Ys(l).splice(fr(a)+1)},removeAllPrevSiblings(){let w=fr(a)+c;return c-=w,Ys(l).splice(0,Math.max(0,w))},replaceWith(w,S={}){let v=!!S.traverse;l?l[Math.max(0,fr(a)+c)]=w:Ft(i,"Can't replace root node")[a]=w,v&&o(w,i,a,l),u=!0},replaceWithMultiple(w,S={}){let v=!!S.traverse;if(Ys(l).splice(Math.max(0,fr(a)+c),1,...w),c+=w.length-1,v){let _=0;for(let E=0;E<w.length;E++)_+=o(w[E],i,fr(a)+E+_,l)}u=!0},skip(){u=!0}},{type:m}=s,h=t["*"],f=t[m],g=typeof h=="function"?h:h?.enter,b=typeof f=="function"?f:f?.enter;if(g?.(d,n),b?.(d,n),!u)switch(m){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":o(s.min,s,"min"),o(s.max,s,"max");break;case"Quantifier":o(s.body,s,"body");break;case"Regex":r(s.body,s),o(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return f?.exit?.(d,n),h?.exit?.(d,n),c}return o(e),e}function Ys(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function fr(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}p();p();p();var Af=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Ef(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function If(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}p();var Ue=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function go(e,t,n,r){let o=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1],i=0,a="";for(let l of e.matchAll(o)){let{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===Ue.DEFAULT==!i)){n instanceof Function?a+=n(l,{context:i?Ue.CHAR_CLASS:Ue.DEFAULT,negated:s[s.length-1]}):a+=n;continue}c[0]==="["?(i++,s.push(c[1]==="^")):c==="]"&&i&&(i--,s.pop()),a+=c}return a}function Hl(e,t,n,r){go(e,t,n,r)}function mk(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let o=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");o.lastIndex=n;let s=0,i;for(;i=o.exec(e);){let{0:a,groups:{$skip:l}}=i;if(!l&&(!r||r===Ue.DEFAULT==!s))return i;a==="["?s++:a==="]"&&s&&s--,o.lastIndex==i.index&&o.lastIndex++}return null}function yo(e,t,n){return!!mk(e,t,0,n)}function Pf(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,s=1,i;for(;i=n.exec(e);){let[a]=i;if(a==="[")o++;else if(o)a==="]"&&o--;else if(a==="(")s++;else if(a===")"&&(s--,!s)){r=i.index;break}}return e.slice(t,r)}var Lf=new RegExp(String.raw`(?<noncapturingStart>${Af})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function zl(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let o="(?>",s="(?:(?=(",i=[0],a=[],l=0,c=0,u=NaN,d;do{d=!1;let m=0,h=0,f=!1,g;for(Lf.lastIndex=Number.isNaN(u)?0:u+s.length;g=Lf.exec(e);){let{0:b,index:w,groups:{capturingStart:S,noncapturingStart:v}}=g;if(b==="[")m++;else if(m)b==="]"&&m--;else if(b===o&&!f)u=w,f=!0;else if(f&&v)h++;else if(S)f?h++:(l++,i.push(l+c));else if(b===")"&&f){if(!h){c++;let _=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+o.length,w)}))<$$${_}>)${e.slice(w+1)}`,d=!0,a.push(_),Ef(n,_),r.size){let E=new Map;r.forEach((M,U)=>{E.set(U>=_?U+1:U,M.map(T=>T>=_?T+1:T))}),r=E}break}h--}}}while(d);return n.push(...a),e=go(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:m,groups:{backrefNum:h,wrappedBackrefNum:f}})=>{if(h){let g=+h;if(g>i.length-1)throw new Error(`Backref "${m}" greater than number of captures`);return`\\${i[g]}`}return`\\${f}`},Ue.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var $f=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Vl=new RegExp(String.raw`
|
|
68
68
|
\\(?: \d+
|
|
69
69
|
| c[A-Za-z]
|
|
70
70
|
| [gk]<[^>]+>
|
|
@@ -77,9 +77,9 @@ import{a as td}from"./chunk-KMMG6QC6.js";import{a as Oe,b as Yn,c as Sa}from"./c
|
|
|
77
77
|
| [A-Za-z\-]+:
|
|
78
78
|
| \(DEFINE\)
|
|
79
79
|
))?
|
|
80
|
-
| (?<qBase>${
|
|
80
|
+
| (?<qBase>${$f})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
81
81
|
| \\?.
|
|
82
|
-
`.replace(/\s+/g,""),"gsu");function
|
|
82
|
+
`.replace(/\s+/g,""),"gsu");function ql(e){if(!new RegExp(`${$f}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,o="",s=0,i;for(Vl.lastIndex=0;i=Vl.exec(e);){let{0:a,index:l,groups:{qBase:c,qMod:u,invalidQ:d}}=i;if(a==="[")s||(r=l),s++;else if(a==="]")s?s--:r=null;else if(!s)if(u==="+"&&o&&!o.startsWith("(")){if(d)throw new Error(`Invalid quantifier "${a}"`);let m=-1;if(/^\{\d+\}$/.test(c))e=If(e,l+c.length,u,"");else{if(o===")"||o==="]"){let h=o===")"?n:r;if(h===null)throw new Error(`Invalid unmatched "${o}"`);e=`${e.slice(0,h)}(?>${e.slice(h,l)}${c})${e.slice(l+a.length)}`}else e=`${e.slice(0,l-o.length)}(?>${o}${c})${e.slice(l+a.length)}`;m+=4}Vl.lastIndex+=m}else a[0]==="("?t.push(l):a===")"&&(n=t.length?t.pop():null);o=a}return{pattern:e}}p();p();var at=String.raw,hk=at`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Xl=at`\(\?R=(?<rDepth>[^\)]+)\)|${hk}`,Qs=at`\(\?<(?![=!])(?<captureName>[^>]+)>`,Bf=at`${Qs}|(?<unnamed>\()(?!\?)`,$n=new RegExp(at`${Qs}|${Xl}|\(\?|\\?.`,"gsu"),Kl="Cannot use multiple overlapping recursions";function Ff(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t},o=t?.captureTransfers??new Map;if(!new RegExp(Xl,"su").test(e))return{pattern:e,captureTransfers:o,hiddenCaptures:n};if(r==="plugin"&&yo(e,at`\(\?\(DEFINE\)`,Ue.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let s=[],i=yo(e,at`\\[1-9]`,Ue.DEFAULT),a=new Map,l=[],c=!1,u=0,d=0,m;for($n.lastIndex=0;m=$n.exec(e);){let{0:h,groups:{captureName:f,rDepth:g,gRNameOrNum:b,gRDepth:w}}=m;if(h==="[")u++;else if(u)h==="]"&&u--;else if(g){if(Of(g),c)throw new Error(Kl);if(i)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let S=e.slice(0,m.index),v=e.slice($n.lastIndex);if(yo(v,Xl,Ue.DEFAULT))throw new Error(Kl);let _=+g-1;e=Df(S,v,_,!1,n,s,d),o=Mf(o,S,_,s.length,0,d);break}else if(b){Of(w);let S=!1;for(let $ of l)if($.name===b||$.num===+b){if(S=!0,$.hasRecursedWithin)throw new Error(Kl);break}if(!S)throw new Error(at`Recursive \g cannot be used outside the referenced group "${r==="external"?b:at`\g<${b}&R=${w}>`}"`);let v=a.get(b),_=Pf(e,v);if(i&&yo(_,at`${Qs}|\((?!\?)`,Ue.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let E=e.slice(v,m.index),M=_.slice(E.length+h.length),U=s.length,T=+w-1,N=Df(E,M,T,!0,n,s,d);o=Mf(o,E,T,s.length-U,U,d);let F=e.slice(0,v),q=e.slice(v+_.length);e=`${F}${N}${q}`,$n.lastIndex+=N.length-h.length-E.length-M.length,l.forEach($=>$.hasRecursedWithin=!0),c=!0}else if(f)d++,a.set(String(d),$n.lastIndex),a.set(f,$n.lastIndex),l.push({num:d,name:f});else if(h[0]==="("){let S=h==="(";S&&(d++,a.set(String(d),$n.lastIndex)),l.push(S?{num:d}:{})}else h===")"&&l.pop()}return n.push(...s),{pattern:e,captureTransfers:o,hiddenCaptures:n}}function Of(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function Df(e,t,n,r,o,s,i){let a=new Set;r&&Hl(e+t,Qs,({groups:{captureName:c}})=>{a.add(c)},Ue.DEFAULT);let l=[n,r?a:null,o,s,i];return`${e}${Nf(`(?:${e}`,"forward",...l)}(?:)${Nf(`${t})`,"backward",...l)}${t}`}function Nf(e,t,n,r,o,s,i){let l=u=>t==="forward"?u+2:n-u+2-1,c="";for(let u=0;u<n;u++){let d=l(u);c+=go(e,at`${Bf}|\\k<(?<backref>[^>]+)>`,({0:m,groups:{captureName:h,unnamed:f,backref:g}})=>{if(g&&r&&!r.has(g))return m;let b=`_$${d}`;if(f||h){let w=i+s.length+1;return s.push(w),gk(o,w),f?m:`(?<${h}${b}>`}return at`\k<${g}${b}>`},Ue.DEFAULT)}return c}function gk(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Mf(e,t,n,r,o,s){if(e.size&&r){let i=0;Hl(t,Bf,()=>i++,Ue.DEFAULT);let a=s-i+o,l=new Map;return e.forEach((c,u)=>{let d=(r-i*n)/n,m=i*n,h=u>a+i?u+r:u,f=[];for(let g of c)if(g<=a)f.push(g);else if(g>a+i+d)f.push(g+r);else if(g<=a+i)for(let b=0;b<=n;b++)f.push(g+i*b);else for(let b=0;b<=n;b++)f.push(g+m+d*b);l.set(h,f)}),l}return e}var Ce=String.fromCodePoint,J=String.raw,ht={},ti=globalThis.RegExp;ht.flagGroups=(()=>{try{new ti("(?i:)")}catch{return!1}return!0})();ht.unicodeSets=(()=>{try{new ti("[[]]","v")}catch{return!1}return!0})();ht.bugFlagVLiteralHyphenIsRange=ht.unicodeSets?(()=>{try{new ti(J`[\d\-a]`,"v")}catch{return!0}return!1})():!1;ht.bugNestedClassIgnoresNegation=ht.unicodeSets&&new ti("[[^a]]","v").test("a");function ei(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function xo(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function ec(e,t){return Gf[e]>=Gf[t]}function yk(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Gf={ES2025:2025,ES2024:2024,ES2018:2018},xk={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function Vf(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!xk[e.target])throw new Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=ht.flagGroups?"ES2025":ht.unicodeSets?"ES2024":"ES2018"),t}var bk="[ -\r ]",wk=new Set([Ce(304),Ce(305)]),Ut=J`[\p{L}\p{M}\p{N}\p{Pc}]`;function zf(e){if(wk.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),o=Tk.get(n),s=kk.get(n),i=Sk.get(n);return[...r].length===1&&t.add(r),i&&t.add(i),o&&t.add(o),t.add(n),s&&t.add(s),[...t]}var nc=new Map(`C Other
|
|
83
83
|
Cc Control cntrl
|
|
84
84
|
Cf Format
|
|
85
85
|
Cn Unassigned
|
|
@@ -169,24 +169,24 @@ Uppercase Upper
|
|
|
169
169
|
Variation_Selector VS
|
|
170
170
|
White_Space space
|
|
171
171
|
XID_Continue XIDC
|
|
172
|
-
XID_Start XIDS`.split(/\s/).map(e=>[
|
|
172
|
+
XID_Start XIDS`.split(/\s/).map(e=>[pr(e),e])),kk=new Map([["s",Ce(383)],[Ce(383),"s"]]),Sk=new Map([[Ce(223),Ce(7838)],[Ce(107),Ce(8490)],[Ce(229),Ce(8491)],[Ce(969),Ce(8486)]]),Tk=new Map([sn(453),sn(456),sn(459),sn(498),...Jl(8072,8079),...Jl(8088,8095),...Jl(8104,8111),sn(8124),sn(8140),sn(8188)]),Ck=new Map([["alnum",J`[\p{Alpha}\p{Nd}]`],["alpha",J`\p{Alpha}`],["ascii",J`\p{ASCII}`],["blank",J`[\p{Zs}\t]`],["cntrl",J`\p{Cc}`],["digit",J`\p{Nd}`],["graph",J`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",J`\p{Lower}`],["print",J`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",J`[\p{P}\p{S}]`],["space",J`\p{space}`],["upper",J`\p{Upper}`],["word",J`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",J`\p{AHex}`]]);function _k(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function sn(e){let t=Ce(e);return[t.toLowerCase(),t]}function Jl(e,t){return _k(e,t).map(n=>sn(n))}var qf=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function vk(e,t){let n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};Kf(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:ec(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Ln(e,Rk,r);let o={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},s={currentFlags:o,prevFlags:null,globalFlags:o,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};Ln(e,Ak,s);let i={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return Ln(e,Ek,i),e._originMap=s.groupOriginByCopy,e._strategy=r.strategy,e}var Rk={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:o}=e;if(o==="repeater"){let s=Ze();s.body[0].body.push(on({negate:!0,body:r}),Pn("Any"));let i=Ze();i.body[0].body.push(Ul("greedy",0,1/0,s)),n(ge(i,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let o=e.body.filter(s=>s.kind==="flags");for(let s=n+1;s<t.body.length;s++){let i=t.body[s];xo(r,i,[]).push(...o)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Jf(t.get(e));if(n){let r=Ze({flags:n});r.body[0].body=e.body,e.body=[ge(r,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:o,remove:s,replaceWith:i},a){let{kind:l,negate:c}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:m,wordIsAscii:h}=a;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")i(ge(on({body:[jt({body:[Js("string_end")]}),jt({body:[dr(10)]})]}),t));else if(l==="line_start")i(ge(Wt(J`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(l==="search_start")if(m.has(e))o.flags.sticky=!0,s();else{let f=r[n-1];if(f&&Dk(f))i(ge(on({negate:!0}),t));else{if(d)throw new Error(J`Uses "\G" in a way that requires a subclass`);i(an(Js("string_start"),t)),a.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")i(ge(Wt(J`(?=\n?\z)`),t));else if(l==="word_boundary"){if(!h&&!u){let f=`(?:(?<=${Ut})(?!${Ut})|(?<!${Ut})(?=${Ut}))`,g=`(?:(?<=${Ut})(?=${Ut})|(?<!${Ut})(?!${Ut}))`;i(ge(Wt(c?g:f),t))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Yl(n)&&(n=Zl(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Yl(r)&&(r=Zl(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){let r=mo({body:[e]});n(ge(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:o,digitIsAscii:s,spaceIsAscii:i,wordIsAscii:a}){let{kind:l,negate:c,value:u}=e;if(s&&(l==="digit"||u==="digit")){n(an(Zs("digit",{negate:c}),t));return}if(i&&(l==="space"||u==="space")){n(ge(Ql(Wt(bk),c),t));return}if(a&&(l==="word"||u==="word")){n(an(Zs("word",{negate:c}),t));return}if(l==="any")n(an(Pn("Any"),t));else if(l==="digit")n(an(Pn("Nd",{negate:c}),t));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(J`Use of "\X" requires non-strict accuracy`);let d="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",m=J`\p{RI}{2}|${d}(?:\u200D${d})*`;n(ge(Wt(J`(?>\r\n|${o?J`\p{RGI_Emoji}`:m}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(l==="hex")n(an(Pn("AHex",{negate:c}),t));else if(l==="newline")n(ge(Wt(c?`[^
|
|
173
173
|
]`:`(?>\r
|
|
174
174
|
?|[
|
|
175
|
-
\v\f\x85\u2028\u2029])`),t));else if(l==="posix")if(!o&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let d={graph:"!-~",print:" -~"}[u];c&&(d=`\0-${_e(d.codePointAt(0)-1)}${_e(d.codePointAt(2)+1)}-\u{10FFFF}`),n(be(Vt(`[${d}]`),t))}else n(be(Zl(Vt(R0.get(u)),c),t));else if(l==="property")ec.has(dr(u))||(e.key="sc");else if(l==="space")n(ln(Ln("space",{negate:c}),t));else if(l==="word")n(be(Zl(Vt(Ht),c),t));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:o,removeAllPrevSiblings:s,removeAllNextSiblings:i}){let{kind:a,flags:l}=e;if(a==="flags")if(!l.enable&&!l.disable)r();else{let c=Qe({flags:l});c.body[0].body=i(),o(be(c,t),{traverse:!0})}else if(a==="keep"){let c=n.body[0],d=n.body.length===1&&zs(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(t.parent!==d||d.body.length>1)throw new Error(X`Uses "\K" in a way that's unsupported`);let m=sn({behind:!0});m.body[0].body=s(),o(be(m,t))}else throw new Error(`Unexpected directive kind "${a}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r==="fail")n(be(sn({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=Qe();t.body[0].body.push(e.body),e.body=be(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,o=!1;for(let s of e.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{let i=Zf(s.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):o=!0}r&&!o&&n.forEach(s=>t.add(s))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(X`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Jl(n)&&(n=Xl(n,t),e.ref=n)}},P0={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:o}=e;r||n.set(e,[...t.get(o).map(({node:s})=>s)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:o,groupsByName:s,multiplexCapturesToLeftByRef:i,openRefs:a,reffedNodesByReferencer:l}){let c=o.get(e);if(c&&a.has(e.number)){let d=ln(Gf(e.number),t);l.set(d,a.get(e.number)),n(d);return}a.set(e.number,e),i.set(e.number,[]),e.name&&yo(i,e.name,[]);let u=i.get(e.name??e.number);for(let d=0;d<u.length;d++){let m=u[d];if(c===m.node||c&&c===m.origin||e===m.origin){u.splice(d,1);break}}if(i.get(e.number).push({node:e,origin:c}),e.name&&i.get(e.name).push({node:e,origin:c}),e.name){let d=yo(s,e.name,new Map),m=!1;if(c)m=!0;else for(let h of d.values())if(!h.hasDuplicateNameToRemove){m=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:m})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Qs(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:o,ref:s}=e;if(o){let u=t;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===s||u.number===s)););r.reffedNodesByReferencer.set(e,u);return}let i=r.subroutineRefMap.get(s),a=s===0,l=a?Gf(0):Kf(i,r.groupOriginByCopy,null),c=l;if(!a){let u=Xf(D0(i,m=>m.type==="Group"&&!!m.flags)),d=u?Qs(r.globalFlags,u):r.globalFlags;$0(d,r.currentFlags)||(c=Qe({flags:N0(d)}),c.body[0].body.push(l))}n(be(c,t),{traverse:!a})}},L0={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let s=r.reffedNodesByReferencer.get(e).filter(i=>O0(i,e));if(!s.length)n(be(sn({negate:!0}),t));else if(s.length>1){let i=Qe({atomic:!0,body:s.reverse().map(a=>Wt({body:[qs(a.number)]}))});n(be(i,t))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){let o=Fl();e.body.at(-1).body.push(o)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function qf(e){$n(e,{"*"({node:t,parent:n}){t.parent=n}})}function $0(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function O0(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=Jf(n.parent);for(let o of r){if(o===n)break;if(o===e||Yf(o,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Kf(e,t,n,r){let o=Array.isArray(e)?[]:{};for(let[s,i]of Object.entries(e))s==="parent"?o.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?o[s]=Kf(i,t,o,n):(s==="type"&&i==="CapturingGroup"&&t.set(o,t.get(e)??e),o[s]=i);return o}function Gf(e){let t=jl(e);return t.isRecursive=!0,t}function D0(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Xl(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function Xf(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(o=>{r.enable?.[o]&&(delete n.disable[o],n.enable[o]=!0),r.disable?.[o]&&(n.disable[o]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function N0({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Jf(e){if(!e)throw new Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Zf(e){let t=e.find(n=>n.kind==="search_start"||F0(n,{negate:!1})||!M0(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){let n=[];for(let r of t.body){let o=Zf(r.body);if(!o)return null;Array.isArray(o)?n.push(...o):n.push(o)}return n}return null}function Yf(e,t){let n=Jf(e)??[];for(let r of n)if(r===t||Yf(r,t))return!0;return!1}function M0({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function B0(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function F0(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&zs(e.body[0],{type:"Assertion",kind:"search_start"})}function Jl(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Vt(e,t){let r=Ks(e,{...t,unicodePropertyMap:ec}).body;return r.length>1||r[0].body.length>1?Qe({body:r}):r[0].body[0]}function Zl(e,t){return e.negate=t,e}function ln(e,t){return e.parent=t,e}function be(e,t){return qf(e),e.parent=t,e}function G0(e,t){let n=Hf(t),r=Yl(n.target,"ES2024"),o=Yl(n.target,"ES2025"),s=n.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,a=null;if(!o){let h=[e.flags.ignoreCase];$n(e,j0,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(f){h.push(f)},setHasCasedChar(){h.at(-1)?i=!0:a=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!a)},c=e,u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!o&&i&&a),useFlagMods:o,useFlagV:r,verbose:n.verbose};function d(h){return u.lastNode=c,c=h,w0(U0[h.type],`Unexpected node type "${h.type}"`)(h,u,d)}let m={pattern:e.body.map(d).join("|"),flags:d(e.flags),options:{...e.options}};return r||(delete m.options.force.v,m.options.disable.v=!0,m.options.unicodeSetsPlugin=null),m._captureTransfers=new Map,m._hiddenCaptures=[],u.captureMap.forEach((h,f)=>{h.hidden&&m._hiddenCaptures.push(f),h.transferTo&&yo(m._captureTransfers,h.transferTo,[]).push(f)}),m}var j0={"*":{enter({node:e},t){if(Uf(e)){let n=t.getCurrentModI();t.pushModI(e.flags?Qs({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Uf(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){tc(_e(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Qf(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&zf.has(e.value)&&t.setHasCasedChar()}},U0={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?X`\B`:X`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){let{body:r,name:o,number:s}=e,i={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(i.hidden=!0,s>a.number&&(i.transferTo=a.number)),t.captureMap.set(s,i),`(${o?`?<${o}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=_e(e),r=fr(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&tc(n)){let o=Vf(n);return t.inCharClass?o.join(""):o.length>1?`[${o.join("")}]`:o[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:o,parent:s}=e,{body:i}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(Wf)&&(i=[ur(45),...i.filter(c=>!Wf(c))]);let a=()=>`[${o?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ht.bugNestedClassIgnoresNegation)&&!o){let u=i.filter(d=>d.type==="CharacterClass"&&d.kind==="union"&&d.negate);if(u.length){let d=Qe(),m=d.body[0];return d.parent=s,m.parent=d,i=i.filter(h=>!u.includes(h)),e.body=i,i.length?(e.parent=m,m.body.push(e)):d.body.pop(),u.forEach(h=>{let f=Wt({body:[h]});h.parent=f,f.parent=d,d.body.push(f)}),n(d)}}t.inCharClass=!0;let c=a();return t.inCharClass=!1,c}let l=i[0];if(r==="union"&&!o&&l&&((!t.useFlagV||!t.verbose)&&s.kind==="union"&&!(ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&s.kind==="intersection"&&i.length===1&&l.type!=="CharacterClassRange"))return i.map(n).join("");if(!t.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,o={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},s=fr(n,o),i=fr(r,o),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=Qf(e);q0(l).forEach(u=>{a.add(Array.isArray(u)?`${fr(u[0],o)}-${fr(u[1],o)}`:fr(u,o))})}return`${s}-${i}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},o){if(e==="dot")return o.currentFlags.dotAll?o.appliedGlobalFlags.dotAll||o.useFlagMods?".":"[^]":X`[^\n]`;if(e==="digit")return t?X`\D`:X`\d`;if(e==="property"){if(o.useAppliedIgnoreCase&&o.currentFlags.ignoreCase&&zf.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?X`\P`:X`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?X`\W`:X`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},o,s){let i=o.currentFlags;n&&(o.currentFlags=Qs(i,n));let a=t.map(s).join("|"),l=!o.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!o.useFlagMods||!n)?a:`(?${K0(e,n,o.useFlagMods)}${a})`;return o.currentFlags=i,l},LookaroundAssertion({body:e,kind:t,negate:n},r,o){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(o).join("|")})`},Quantifier(e,t,n){return n(e.body)+X0(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");let r=n.recursionLimit;return t===0?`(?R=${r})`:X`\g<${t}&R=${r}>`}},W0=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),H0=new Set(["-","\\","]","^","["]),V0=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),jf=new Map([[9,X`\t`],[10,X`\n`],[11,X`\v`],[12,X`\f`],[13,X`\r`],[8232,X`\u2028`],[8233,X`\u2029`],[65279,X`\uFEFF`]]),z0=new RegExp("^\\p{Cased}$","u");function tc(e){return z0.test(e)}function Qf(e,t){let n=!!t?.firstOnly,r=e.min.value,o=e.max.value,s=[];if(r<65&&(o===65535||o>=131071)||r===65536&&o>=131071)return s;for(let i=r;i<=o;i++){let a=_e(i);if(!tc(a))continue;let l=Vf(a).filter(c=>{let u=c.codePointAt(0);return u<r||u>o});if(l.length&&(s.push(...l),n))break}return s}function fr(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(jf.has(e))return jf.get(e);if(e<32||e>126&&e<160||e>262143||t&&J0(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let o=n?r?V0:H0:W0,s=_e(e);return(o.has(s)?"\\":"")+s}function q0(e){let t=e.map(o=>o.codePointAt(0)).sort((o,s)=>o-s),n=[],r=null;for(let o=0;o<t.length;o++)t[o+1]===t[o]+1?r??=t[o]:r===null?n.push(t[o]):(n.push([r,t[o]]),r=null);return n}function K0(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:o,disable:s}=t;r=(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")+(s?"-":"")+(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")}return`${r}:`}function X0({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function Uf({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function J0(e){return e>47&&e<58}function Wf({type:e,value:t}){return e==="Character"&&t===45}var Z0=class Ql extends RegExp{#e=new Map;#t=null;#r;#o=null;#n=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){let o=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");let s=t;super(s,n),this.#r=s.source,s instanceof Ql&&(this.#e=s.#e,this.#o=s.#o,this.#n=s.#n,this.rawOptions=s.rawOptions)}else{let s={hiddenCaptures:[],strategy:null,transfers:[],...r};super(o?"":t,n),this.#r=t,this.#e=Q0(s.hiddenCaptures,s.transfers),this.#n=s.strategy,this.rawOptions=r??{}}o||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:o,...s}=this.rawOptions;this.#t=new Ql(this.#r,this.flags,s)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#n==="clip_search"&&n&&r){this.lastIndex=0;let o=this.#a(t.slice(r));return o&&(Y0(o,r,t,this.hasIndices),this.lastIndex+=r),o}return this.#a(t)}#a(t){this.#t.lastIndex=this.lastIndex;let n=super.exec.call(this.#t,t);if(this.lastIndex=this.#t.lastIndex,!n||!this.#e.size)return n;let r=[...n];n.length=1;let o;this.hasIndices&&(o=[...n.indices],n.indices.length=1);let s=[0];for(let i=1;i<r.length;i++){let{hidden:a,transferTo:l}=this.#e.get(i)??{};if(a?s.push(null):(s.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(o[i])),l&&r[i]!==void 0){let c=s[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[i],this.hasIndices&&(n.indices[c]=o[i]),n.groups){this.#o||(this.#o=ek(this.source));let u=this.#o.get(l);u&&(n.groups[u]=r[i],this.hasIndices&&(n.indices.groups[u]=o[i]))}}}return n}};function Y0(e,t,n,r){if(e.index+=t,e.input=n,r){let o=e.indices;for(let i=0;i<o.length;i++){let a=o[i];a&&(o[i]=[a[0]+t,a[1]+t])}let s=o.groups;s&&Object.keys(s).forEach(i=>{let a=s[i];a&&(s[i]=[a[0]+t,a[1]+t])})}}function Q0(e,t){let n=new Map;for(let r of e)n.set(r,{hidden:!0});for(let[r,o]of t)for(let s of o)yo(n,s,{}).transferTo=r;return n}function ek(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,o=0,s;for(;s=t.exec(e);){let{0:i,groups:{capture:a,name:l}}=s;i==="["?r++:r?i==="]"&&r--:a&&(o++,l&&n.set(o,l))}return n}function em(e,t){let n=tk(e,t);return n.options?new Z0(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function tk(e,t){let n=Hf(t),r=Ks(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:ec}),o=E0(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=G0(o,n),i=Bf(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),a=Vl(i.pattern),l=Hl(a.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{let u=l.hiddenCaptures.sort((f,g)=>f-g),d=Array.from(l.captureTransfers),m=o._strategy,h=c.pattern.length>=n.lazyCompileLength;(u.length||d.length||m||h)&&(c.options={...u.length&&{hiddenCaptures:u},...d.length&&{transfers:d},...m&&{strategy:m},...h&&{lazyCompile:h}})}return c}function ti(e,t){return em(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function nc(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>ti(n,{target:t.target}),{createScanner(n){return new lf(n,t)},createString(n){return{content:n}}}}Ts(sr({bundledLanguages:()=>Yr,bundledLanguagesAlias:()=>Zr,bundledLanguagesBase:()=>Jr,bundledLanguagesInfo:()=>ir,bundledThemes:()=>eo,bundledThemesInfo:()=>Qr,codeToHast:()=>$l,codeToHtml:()=>Ll,codeToTokens:()=>Ol,codeToTokensBase:()=>co,codeToTokensWithThemes:()=>Dl,createHighlighter:()=>Hs,createJavaScriptRegexEngine:()=>nc,createOnigurumaEngine:()=>al,defaultJavaScriptRegexConstructor:()=>ti,getLastGrammarState:()=>Nl,getSingletonHighlighter:()=>uo,loadWasm:()=>Rs}),af);var nk=/#/;function rk(e){return e=e.replace(nk,""),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),e.length===4&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),e.length===6&&(e=`${e}ff`),e.toLowerCase()}function ok(e){return e=rk(e),{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16),a:Number.parseInt(e.slice(6,8),16)/255}}function tm(e,t,n){return[e,t,n].map(r=>{let o=r.toString(16);return o.length===1?`0${o}`:o}).join("")}function sk(e,t="dark"){let{r:n,g:r,b:o,a:s}=ok(e);return t==="dark"?tm(n*s,r*s,o*s):tm(n*s+255*(1-s),r*s+255*(1-s),o*s+255*(1-s))}async function rc(e,t,n){let r="",o=await co(e,{lang:t,theme:n}),s=(await uo()).getTheme(n);for(let i of o){for(let a of i){let l=a.content,c=a.color||s.fg;c&&(l=or.hex(sk(c,s.type))(l)),a.fontStyle&&(a.fontStyle&pe.Bold&&(l=or.bold(l)),a.fontStyle&pe.Italic&&(l=or.italic(l)),a.fontStyle&pe.Underline&&(l=or.underline(l)),a.fontStyle&pe.Strikethrough&&(l=or.strikethrough(l))),r+=l}r+=`
|
|
176
|
-
`}return r}p();var
|
|
177
|
-
`),u=c.length>l,d=u?c.slice(0,Math.max(l-1,0)):c,m=d.map(f=>
|
|
175
|
+
\v\f\x85\u2028\u2029])`),t));else if(l==="posix")if(!o&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let d={graph:"!-~",print:" -~"}[u];c&&(d=`\0-${Ce(d.codePointAt(0)-1)}${Ce(d.codePointAt(2)+1)}-\u{10FFFF}`),n(ge(Wt(`[${d}]`),t))}else n(ge(Ql(Wt(Ck.get(u)),c),t));else if(l==="property")nc.has(pr(u))||(e.key="sc");else if(l==="space")n(an(Pn("space",{negate:c}),t));else if(l==="word")n(ge(Ql(Wt(Ut),c),t));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:o,removeAllPrevSiblings:s,removeAllNextSiblings:i}){let{kind:a,flags:l}=e;if(a==="flags")if(!l.enable&&!l.disable)r();else{let c=Ze({flags:l});c.body[0].body=i(),o(ge(c,t),{traverse:!0})}else if(a==="keep"){let c=n.body[0],d=n.body.length===1&&qs(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(t.parent!==d||d.body.length>1)throw new Error(J`Uses "\K" in a way that's unsupported`);let m=on({behind:!0});m.body[0].body=s(),o(ge(m,t))}else throw new Error(`Unexpected directive kind "${a}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r==="fail")n(ge(on({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=Ze();t.body[0].body.push(e.body),e.body=ge(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,o=!1;for(let s of e.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{let i=Yf(s.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):o=!0}r&&!o&&n.forEach(s=>t.add(s))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(J`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Yl(n)&&(n=Zl(n,t),e.ref=n)}},Ak={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:o}=e;r||n.set(e,[...t.get(o).map(({node:s})=>s)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:o,groupsByName:s,multiplexCapturesToLeftByRef:i,openRefs:a,reffedNodesByReferencer:l}){let c=o.get(e);if(c&&a.has(e.number)){let d=an(jf(e.number),t);l.set(d,a.get(e.number)),n(d);return}a.set(e.number,e),i.set(e.number,[]),e.name&&xo(i,e.name,[]);let u=i.get(e.name??e.number);for(let d=0;d<u.length;d++){let m=u[d];if(c===m.node||c&&c===m.origin||e===m.origin){u.splice(d,1);break}}if(i.get(e.number).push({node:e,origin:c}),e.name&&i.get(e.name).push({node:e,origin:c}),e.name){let d=xo(s,e.name,new Map),m=!1;if(c)m=!0;else for(let h of d.values())if(!h.hasDuplicateNameToRemove){m=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:m})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=ei(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:o,ref:s}=e;if(o){let u=t;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===s||u.number===s)););r.reffedNodesByReferencer.set(e,u);return}let i=r.subroutineRefMap.get(s),a=s===0,l=a?jf(0):Xf(i,r.groupOriginByCopy,null),c=l;if(!a){let u=Jf(Lk(i,m=>m.type==="Group"&&!!m.flags)),d=u?ei(r.globalFlags,u):r.globalFlags;Ik(d,r.currentFlags)||(c=Ze({flags:$k(d)}),c.body[0].body.push(l))}n(ge(c,t),{traverse:!a})}},Ek={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let s=r.reffedNodesByReferencer.get(e).filter(i=>Pk(i,e));if(!s.length)n(ge(on({negate:!0}),t));else if(s.length>1){let i=Ze({atomic:!0,body:s.reverse().map(a=>jt({body:[Ks(a.number)]}))});n(ge(i,t))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){let o=jl();e.body.at(-1).body.push(o)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Kf(e){Ln(e,{"*"({node:t,parent:n}){t.parent=n}})}function Ik(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Pk(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=Zf(n.parent);for(let o of r){if(o===n)break;if(o===e||Qf(o,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Xf(e,t,n,r){let o=Array.isArray(e)?[]:{};for(let[s,i]of Object.entries(e))s==="parent"?o.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?o[s]=Xf(i,t,o,n):(s==="type"&&i==="CapturingGroup"&&t.set(o,t.get(e)??e),o[s]=i);return o}function jf(e){let t=Wl(e);return t.isRecursive=!0,t}function Lk(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Zl(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function Jf(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(o=>{r.enable?.[o]&&(delete n.disable[o],n.enable[o]=!0),r.disable?.[o]&&(n.disable[o]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function $k({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Zf(e){if(!e)throw new Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Yf(e){let t=e.find(n=>n.kind==="search_start"||Nk(n,{negate:!1})||!Ok(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){let n=[];for(let r of t.body){let o=Yf(r.body);if(!o)return null;Array.isArray(o)?n.push(...o):n.push(o)}return n}return null}function Qf(e,t){let n=Zf(e)??[];for(let r of n)if(r===t||Qf(r,t))return!0;return!1}function Ok({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function Dk(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function Nk(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&qs(e.body[0],{type:"Assertion",kind:"search_start"})}function Yl(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Wt(e,t){let r=Xs(e,{...t,unicodePropertyMap:nc}).body;return r.length>1||r[0].body.length>1?Ze({body:r}):r[0].body[0]}function Ql(e,t){return e.negate=t,e}function an(e,t){return e.parent=t,e}function ge(e,t){return Kf(e),e.parent=t,e}function Mk(e,t){let n=Vf(t),r=ec(n.target,"ES2024"),o=ec(n.target,"ES2025"),s=n.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,a=null;if(!o){let h=[e.flags.ignoreCase];Ln(e,Bk,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(f){h.push(f)},setHasCasedChar(){h.at(-1)?i=!0:a=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!a)},c=e,u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!o&&i&&a),useFlagMods:o,useFlagV:r,verbose:n.verbose};function d(h){return u.lastNode=c,c=h,yk(Fk[h.type],`Unexpected node type "${h.type}"`)(h,u,d)}let m={pattern:e.body.map(d).join("|"),flags:d(e.flags),options:{...e.options}};return r||(delete m.options.force.v,m.options.disable.v=!0,m.options.unicodeSetsPlugin=null),m._captureTransfers=new Map,m._hiddenCaptures=[],u.captureMap.forEach((h,f)=>{h.hidden&&m._hiddenCaptures.push(f),h.transferTo&&xo(m._captureTransfers,h.transferTo,[]).push(f)}),m}var Bk={"*":{enter({node:e},t){if(Wf(e)){let n=t.getCurrentModI();t.pushModI(e.flags?ei({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Wf(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){rc(Ce(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),em(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&qf.has(e.value)&&t.setHasCasedChar()}},Fk={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?J`\B`:J`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){let{body:r,name:o,number:s}=e,i={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);return a&&(i.hidden=!0,s>a.number&&(i.transferTo=a.number)),t.captureMap.set(s,i),`(${o?`?<${o}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=Ce(e),r=mr(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&rc(n)){let o=zf(n);return t.inCharClass?o.join(""):o.length>1?`[${o.join("")}]`:o[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:o,parent:s}=e,{body:i}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(Hf)&&(i=[dr(45),...i.filter(c=>!Hf(c))]);let a=()=>`[${o?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ht.bugNestedClassIgnoresNegation)&&!o){let u=i.filter(d=>d.type==="CharacterClass"&&d.kind==="union"&&d.negate);if(u.length){let d=Ze(),m=d.body[0];return d.parent=s,m.parent=d,i=i.filter(h=>!u.includes(h)),e.body=i,i.length?(e.parent=m,m.body.push(e)):d.body.pop(),u.forEach(h=>{let f=jt({body:[h]});h.parent=f,f.parent=d,d.body.push(f)}),n(d)}}t.inCharClass=!0;let c=a();return t.inCharClass=!1,c}let l=i[0];if(r==="union"&&!o&&l&&((!t.useFlagV||!t.verbose)&&s.kind==="union"&&!(ht.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&s.kind==="intersection"&&i.length===1&&l.type!=="CharacterClassRange"))return i.map(n).join("");if(!t.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,o={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},s=mr(n,o),i=mr(r,o),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=em(e);Hk(l).forEach(u=>{a.add(Array.isArray(u)?`${mr(u[0],o)}-${mr(u[1],o)}`:mr(u,o))})}return`${s}-${i}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},o){if(e==="dot")return o.currentFlags.dotAll?o.appliedGlobalFlags.dotAll||o.useFlagMods?".":"[^]":J`[^\n]`;if(e==="digit")return t?J`\D`:J`\d`;if(e==="property"){if(o.useAppliedIgnoreCase&&o.currentFlags.ignoreCase&&qf.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?J`\P`:J`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?J`\W`:J`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},o,s){let i=o.currentFlags;n&&(o.currentFlags=ei(i,n));let a=t.map(s).join("|"),l=!o.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!o.useFlagMods||!n)?a:`(?${Vk(e,n,o.useFlagMods)}${a})`;return o.currentFlags=i,l},LookaroundAssertion({body:e,kind:t,negate:n},r,o){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(o).join("|")})`},Quantifier(e,t,n){return n(e.body)+zk(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");let r=n.recursionLimit;return t===0?`(?R=${r})`:J`\g<${t}&R=${r}>`}},Gk=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),jk=new Set(["-","\\","]","^","["]),Uk=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Uf=new Map([[9,J`\t`],[10,J`\n`],[11,J`\v`],[12,J`\f`],[13,J`\r`],[8232,J`\u2028`],[8233,J`\u2029`],[65279,J`\uFEFF`]]),Wk=new RegExp("^\\p{Cased}$","u");function rc(e){return Wk.test(e)}function em(e,t){let n=!!t?.firstOnly,r=e.min.value,o=e.max.value,s=[];if(r<65&&(o===65535||o>=131071)||r===65536&&o>=131071)return s;for(let i=r;i<=o;i++){let a=Ce(i);if(!rc(a))continue;let l=zf(a).filter(c=>{let u=c.codePointAt(0);return u<r||u>o});if(l.length&&(s.push(...l),n))break}return s}function mr(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Uf.has(e))return Uf.get(e);if(e<32||e>126&&e<160||e>262143||t&&qk(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let o=n?r?Uk:jk:Gk,s=Ce(e);return(o.has(s)?"\\":"")+s}function Hk(e){let t=e.map(o=>o.codePointAt(0)).sort((o,s)=>o-s),n=[],r=null;for(let o=0;o<t.length;o++)t[o+1]===t[o]+1?r??=t[o]:r===null?n.push(t[o]):(n.push([r,t[o]]),r=null);return n}function Vk(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:o,disable:s}=t;r=(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")+(s?"-":"")+(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")}return`${r}:`}function zk({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function Wf({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function qk(e){return e>47&&e<58}function Hf({type:e,value:t}){return e==="Character"&&t===45}var Kk=class tc extends RegExp{#e=new Map;#n=null;#r;#s=null;#t=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){let o=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");let s=t;super(s,n),this.#r=s.source,s instanceof tc&&(this.#e=s.#e,this.#s=s.#s,this.#t=s.#t,this.rawOptions=s.rawOptions)}else{let s={hiddenCaptures:[],strategy:null,transfers:[],...r};super(o?"":t,n),this.#r=t,this.#e=Jk(s.hiddenCaptures,s.transfers),this.#t=s.strategy,this.rawOptions=r??{}}o||(this.#n=this)}exec(t){if(!this.#n){let{lazyCompile:o,...s}=this.rawOptions;this.#n=new tc(this.#r,this.flags,s)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#t==="clip_search"&&n&&r){this.lastIndex=0;let o=this.#c(t.slice(r));return o&&(Xk(o,r,t,this.hasIndices),this.lastIndex+=r),o}return this.#c(t)}#c(t){this.#n.lastIndex=this.lastIndex;let n=super.exec.call(this.#n,t);if(this.lastIndex=this.#n.lastIndex,!n||!this.#e.size)return n;let r=[...n];n.length=1;let o;this.hasIndices&&(o=[...n.indices],n.indices.length=1);let s=[0];for(let i=1;i<r.length;i++){let{hidden:a,transferTo:l}=this.#e.get(i)??{};if(a?s.push(null):(s.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(o[i])),l&&r[i]!==void 0){let c=s[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[i],this.hasIndices&&(n.indices[c]=o[i]),n.groups){this.#s||(this.#s=Zk(this.source));let u=this.#s.get(l);u&&(n.groups[u]=r[i],this.hasIndices&&(n.indices.groups[u]=o[i]))}}}return n}};function Xk(e,t,n,r){if(e.index+=t,e.input=n,r){let o=e.indices;for(let i=0;i<o.length;i++){let a=o[i];a&&(o[i]=[a[0]+t,a[1]+t])}let s=o.groups;s&&Object.keys(s).forEach(i=>{let a=s[i];a&&(s[i]=[a[0]+t,a[1]+t])})}}function Jk(e,t){let n=new Map;for(let r of e)n.set(r,{hidden:!0});for(let[r,o]of t)for(let s of o)xo(n,s,{}).transferTo=r;return n}function Zk(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,o=0,s;for(;s=t.exec(e);){let{0:i,groups:{capture:a,name:l}}=s;i==="["?r++:r?i==="]"&&r--:a&&(o++,l&&n.set(o,l))}return n}function tm(e,t){let n=Yk(e,t);return n.options?new Kk(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Yk(e,t){let n=Vf(t),r=Xs(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:nc}),o=vk(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=Mk(o,n),i=Ff(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),a=ql(i.pattern),l=zl(a.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{let u=l.hiddenCaptures.sort((f,g)=>f-g),d=Array.from(l.captureTransfers),m=o._strategy,h=c.pattern.length>=n.lazyCompileLength;(u.length||d.length||m||h)&&(c.options={...u.length&&{hiddenCaptures:u},...d.length&&{transfers:d},...m&&{strategy:m},...h&&{lazyCompile:h}})}return c}function ni(e,t){return tm(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function oc(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>ni(n,{target:t.target}),{createScanner(n){return new cf(n,t)},createString(n){return{content:n}}}}Cs(ir({bundledLanguages:()=>Qr,bundledLanguagesAlias:()=>Yr,bundledLanguagesBase:()=>Zr,bundledLanguagesInfo:()=>ar,bundledThemes:()=>to,bundledThemesInfo:()=>eo,codeToHast:()=>Dl,codeToHtml:()=>Ol,codeToTokens:()=>Nl,codeToTokensBase:()=>uo,codeToTokensWithThemes:()=>Ml,createHighlighter:()=>Vs,createJavaScriptRegexEngine:()=>oc,createOnigurumaEngine:()=>cl,defaultJavaScriptRegexConstructor:()=>ni,getLastGrammarState:()=>Bl,getSingletonHighlighter:()=>po,loadWasm:()=>As}),lf);var Qk=/#/;function e0(e){return e=e.replace(Qk,""),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),e.length===4&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),e.length===6&&(e=`${e}ff`),e.toLowerCase()}function t0(e){return e=e0(e),{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16),a:Number.parseInt(e.slice(6,8),16)/255}}function nm(e,t,n){return[e,t,n].map(r=>{let o=r.toString(16);return o.length===1?`0${o}`:o}).join("")}function n0(e,t="dark"){let{r:n,g:r,b:o,a:s}=t0(e);return t==="dark"?nm(n*s,r*s,o*s):nm(n*s+255*(1-s),r*s+255*(1-s),o*s+255*(1-s))}async function sc(e,t,n){let r="",o=await uo(e,{lang:t,theme:n}),s=(await po()).getTheme(n);for(let i of o){for(let a of i){let l=a.content,c=a.color||s.fg;c&&(l=sr.hex(n0(c,s.type))(l)),a.fontStyle&&(a.fontStyle&de.Bold&&(l=sr.bold(l)),a.fontStyle&de.Italic&&(l=sr.italic(l)),a.fontStyle&de.Underline&&(l=sr.underline(l)),a.fontStyle&de.Strikethrough&&(l=sr.strikethrough(l))),r+=l}r+=`
|
|
176
|
+
`}return r}p();var om={".ts":"typescript",".tsx":"tsx",".cts":"typescript",".mts":"typescript",".js":"javascript",".jsx":"jsx",".cjs":"javascript",".mjs":"javascript",".vue":"vue",".svelte":"svelte",".astro":"astro",".css":"css",".scss":"scss",".less":"less",".html":"html",".htm":"html",".xml":"xml",".svg":"xml",".json":"json",".jsonc":"json",".md":"markdown",".mdx":"markdown",".yaml":"yaml",".yml":"yaml",".toml":"toml",".ini":"ini",".sh":"bash",".bash":"bash",".zsh":"bash",".py":"python",".rb":"ruby",".rs":"rust",".go":"go",".java":"java",".kt":"kotlin",".swift":"swift",".c":"c",".h":"c",".cpp":"cpp",".hpp":"cpp",".cs":"csharp",".php":"php",".sql":"sql",".graphql":"graphql",".dockerfile":"dockerfile",".lua":"lua",".r":"r",".dart":"dart",".ex":"elixir",".exs":"elixir",".erl":"erlang",".hs":"haskell",".scala":"scala",".pl":"perl"},rm={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",".bashrc":"bash",".zshrc":"bash",".profile":"bash"};function sm(e){let t=e.split(/[\\/]/).pop()??"";if(rm[t])return rm[t];let n=t.lastIndexOf(".");if(n<0)return;let r=t.slice(n).toLowerCase();return om[r]}var zL=new Set(Object.keys(om));p();function am(e,t){if(!e)return 1e3;let n=e.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return 1e3;let r=n[0],o=t.toLowerCase();if(o===r)return 0;if(o.startsWith(r))return 5;let s=o.indexOf(r);return s>=0?s+10:null}function lm(e,t){let n=e.toLowerCase(),r=t.toLowerCase(),o=n.split(/\s+/).filter(Boolean);return o.length===0?!0:o.every(s=>r.includes(s))}function ic(e,t){let n=[];for(let r of t){if(!lm(e,r))continue;let o=am(e,r);o!==null&&n.push({path:r,score:o})}return n.sort((r,o)=>r.score-o.score),n}var ri=10;function bo(e,t){let n=e.match(/(?:^|\s)@([^@]*)$/);if(!n)return null;let o=(n[1]??"").toLowerCase().trim();if(!o)return e.startsWith("@")?[...t]:[];let s=ic(o,t);return s.length===0?[]:s[0]?.path.toLowerCase()===o?[]:s.map(i=>i.path)}var im="\x1B[0m";function cm(e){return e>=4352&&e<=4447||e>=11904&&e<=12350||e>=12353&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=40960&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510}function r0(e){let t=0;for(let n=0;n<e.length;){let o=e[n].charCodeAt(0);if(o===27&&n+1<e.length&&e[n+1]==="["){for(n+=2;n<e.length;){let i=e.charCodeAt(n);if(n++,i>=64&&i<=126)break}continue}if(o===27&&n+1<e.length&&e[n+1]==="]"){for(n+=2;n<e.length;){let i=e.charCodeAt(n);if(i===7){n++;break}if(i===27&&n+1<e.length&&e[n+1]==="\\"){n+=2;break}n++}continue}let s=e.codePointAt(n);t+=cm(s)?2:1,n+=s>65535?2:1}return t}function um(e,t){if(t<=0)return"";if(r0(e)<=t)return e;let r=t-1;if(r<=0)return"\u2026"+im;let o="",s=0;for(let i=0;i<e.length;){let l=e[i].charCodeAt(0);if(l===27&&i+1<e.length&&e[i+1]==="["){let d=i;for(i+=2;i<e.length;){let m=e.charCodeAt(i);if(i++,m>=64&&m<=126)break}o+=e.slice(d,i);continue}if(l===27&&i+1<e.length&&e[i+1]==="]"){let d=i;for(i+=2;i<e.length;){let m=e.charCodeAt(i);if(m===7){i++;break}if(m===27&&i+1<e.length&&e[i+1]==="\\"){i+=2;break}i++}o+=e.slice(d,i);continue}let c=e.codePointAt(i),u=cm(c)?2:1;if(s+u>r)break;o+=String.fromCodePoint(c),s+=u,i+=c>65535?2:1}return o+"\u2026"+im}import{jsx as Ht,jsxs as oi}from"react/jsx-runtime";var i0="github-dark",a0=512*1024,pm=4e3;var ac="#808080",lc="#ff4444",dm=512;async function l0(e,t,n){let{stat:r,readFile:o}=await import("fs/promises"),{join:s}=await import("path"),i=s(t,e),a;try{a=await r(i)}catch(h){return{kind:"error",message:h instanceof Error?h.message:String(h)}}if(!a.isFile())return{kind:"error",message:"\u4E0D\u662F\u6587\u4EF6"};try{let f=await(await import("fs/promises")).open(i,"r");try{let g=Buffer.alloc(dm),{bytesRead:b}=await f.read(g,0,dm,0);for(let w=0;w<b;w++)if(g[w]===0)return{kind:"binary"}}finally{await f.close()}}catch{}let l=a.size>a0,c=l?pm:a.size,u;try{u=(await o(i)).subarray(0,c).toString("utf8")}catch(h){return{kind:"error",message:h instanceof Error?h.message:String(h)}}if(n.cancelled)return{kind:"idle"};let d=sm(e),m;if(d)try{m=await sc(u,d,i0)}catch(h){return{kind:"error",message:`\u9AD8\u4EAE\u5931\u8D25: ${h instanceof Error?h.message:String(h)}`}}else m=u;return n.cancelled?{kind:"idle"}:{kind:"ready",ansi:m,truncated:l}}function si({relativePath:e,cwd:t,width:n,maxLines:r}){let[o,s]=s0({kind:"idle"});if(o0(()=>{if(!e){s({kind:"idle"});return}let f={cancelled:!1};return s({kind:"loading"}),l0(e,t,f).then(g=>{f.cancelled||s(g)}),()=>{f.cancelled=!0}},[e,t]),!e)return Ht(hr,{flexDirection:"column",paddingX:1,children:Ht(On,{color:ac,dimColor:!0,children:"\u2190 \u9009\u62E9\u5DE6\u4FA7\u6587\u4EF6\u67E5\u770B\u9AD8\u4EAE\u4EE3\u7801"})});if(o.kind==="loading"||o.kind==="idle")return Ht(hr,{flexDirection:"column",paddingX:1,children:Ht(On,{color:ac,children:"\u2699 \u52A0\u8F7D\u4E2D\u2026"})});if(o.kind==="binary")return Ht(hr,{flexDirection:"column",paddingX:1,children:Ht(On,{color:lc,children:"\u26A0 \u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"})});if(o.kind==="too-large")return Ht(hr,{flexDirection:"column",paddingX:1,children:oi(On,{color:lc,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF08",o.bytes," \u5B57\u8282\uFF09\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"]})});if(o.kind==="error")return Ht(hr,{flexDirection:"column",paddingX:1,children:oi(On,{color:lc,children:["\u26A0 \u8BFB\u53D6\u5931\u8D25: ",o.message]})});let i=Math.max(n-4,8),a=o.truncated?1:0,l=Math.max(r-a,1),c=o.ansi.split(`
|
|
177
|
+
`),u=c.length>l,d=u?c.slice(0,Math.max(l-1,0)):c,m=d.map(f=>um(f,i)).join(`
|
|
178
178
|
`),h=u&&l>0?`${m}
|
|
179
|
-
\u2026 \u4EE5\u4E0B ${c.length-d.length} \u884C\u672A\u663E\u793A`:m;return
|
|
179
|
+
\u2026 \u4EE5\u4E0B ${c.length-d.length} \u884C\u672A\u663E\u793A`:m;return oi(hr,{flexDirection:"column",paddingX:1,children:[o.truncated&&oi(On,{color:ac,dimColor:!0,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF0C\u4EC5\u663E\u793A\u524D ",pm," \u5B57\u8282"]}),Ht(On,{children:h})]})}import{jsx as Dn,jsxs as cn}from"react/jsx-runtime";var fm="#00ff41",yr="#808080",cc=4,d0=60,p0=20;function f0(e,t){return t<=0?"":e.length<=t?e:t<=1?"\u2026":e.slice(0,t-1)+"\u2026"}function uc({files:e,input:t,selectedIndex:n,cwd:r,width:o}){let s=bo(t,e);if(!s||s.length===0)return null;let i=ri,a=Math.max(1,Math.ceil(s.length/i)),[l,c]=u0(0);c0(()=>{c(v=>v<0||v>=s.length?Math.floor(n/i)*i:n<v?Math.max(0,Math.floor(n/i)*i):n>=v+i?Math.floor(n/i)*i:v)},[n,s.length,i]);let u=l,d=s.slice(u,u+i);if(!(o>=d0))return cn(ln,{flexDirection:"column",marginLeft:cc,marginTop:1,children:[cn(gr,{color:yr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),d.map((v,_)=>{let M=u+_===n;return Dn(ln,{children:cn(gr,{color:M?fm:yr,children:[M?" \u203A ":" ",v]})},v)})]});let h=o-cc,f=Math.max(Math.floor(h/3),p0),g=Math.max(h-f-1,20),b=10,w=n>=0&&n<s.length?s[n]??null:null,S=Math.max(f-2,4);return cn(ln,{flexDirection:"row",paddingLeft:cc,marginTop:1,children:[cn(ln,{flexDirection:"column",width:f,flexShrink:0,children:[cn(gr,{color:yr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),Dn(ln,{flexDirection:"column",marginTop:1,children:d.map((v,_)=>{let M=u+_===n;return cn(gr,{color:M?fm:yr,bold:M,children:[M?"\u25B8 ":" ",f0(v,S)]},v)})})]}),Dn(ln,{width:1,flexShrink:0,children:Dn(gr,{color:yr,children:"\u2502"})}),cn(ln,{flexDirection:"column",width:g,flexShrink:0,children:[Dn(gr,{color:yr,dimColor:!0,children:w?`\u{1F4C4} ${w}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),Dn(ln,{flexDirection:"column",marginTop:1,children:Dn(si,{relativePath:w,cwd:r,width:g,maxLines:b})})]})]})}p();import{Box as Rt,Text as Nn,useInput as m0}from"ink";import h0 from"ink-text-input";import{useEffect as mm,useMemo as g0,useState as dc}from"react";import{jsx as lt,jsxs as Mn}from"react/jsx-runtime";var y0="#00ff41",wo="#808080",ii="#00ffff",At=ri;function hm({files:e,cwd:t,width:n,height:r,onPick:o,onClose:s}){let[i,a]=dc(""),[l,c]=dc(0),u=g0(()=>i.trim()?ic(i,e):[],[i,e]),d=Math.max(1,Math.ceil(u.length/At)),[m,h]=dc(0);mm(()=>{h(0),c(0)},[i]),mm(()=>{h(E=>u.length===0?0:E<0||E>=u.length?Math.floor(l/At)*At:l<E?Math.max(0,Math.floor(l/At)*At):l>=E+At?Math.floor(l/At)*At:E)},[l,u.length]);let f=m,g=u.slice(f,f+At),b=l>=f&&l<f+g.length?l-f:0;m0((E,M)=>{if(M.ctrl&&E==="p"){s();return}if(M.escape){s();return}if(M.upArrow){if(u.length===0)return;c(U=>(U-1+u.length)%u.length);return}if(M.downArrow){if(u.length===0)return;c(U=>(U+1)%u.length);return}if(M.return){let U=u[l];U&&o(U.path);return}},{isActive:!0});let w=Math.max(Math.floor(n/3),24),S=Math.max(n-w-1,20),v=Math.max(r-11,4),_=u[l]?.path??null;return Mn(Rt,{flexDirection:"column",height:r,children:[Mn(Rt,{flexDirection:"row",borderStyle:"round",borderColor:ii,paddingX:1,children:[lt(Nn,{bold:!0,color:ii,children:"\u{1F50D} "}),lt(Rt,{flexGrow:1,children:lt(h0,{value:i,onChange:a,placeholder:"\u8F93\u5165\u6587\u4EF6\u540D"})})]}),Mn(Rt,{flexDirection:"row",flexGrow:1,marginTop:1,children:[Mn(Rt,{flexDirection:"column",width:w,borderStyle:"single",borderColor:ii,paddingX:1,flexShrink:0,children:[Mn(Nn,{color:wo,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6 (",u.length," \u6761)",d>1?` \xB7 ${Math.floor(m/At)+1}/${d}`:""]}),lt(Rt,{flexDirection:"column",marginTop:1,children:g.length===0?lt(Nn,{color:wo,dimColor:!0,children:i.trim()?e.length===0?"\uFF08\u9879\u76EE\u65E0\u6587\u4EF6\uFF09":"\uFF08\u65E0\u5339\u914D\uFF09":"\uFF08\u8F93\u5165\u5173\u952E\u5B57\u5F00\u59CB\u5339\u914D\uFF09"}):g.map((E,M)=>{let U=M===b;return Mn(Nn,{color:U?y0:void 0,bold:U,children:[U?"\u25B8 ":" ",E.path]},E.path)})})]}),lt(Rt,{width:1,flexShrink:0,children:lt(Nn,{color:wo,children:"\u2502"})}),Mn(Rt,{flexDirection:"column",width:S,borderStyle:"single",borderColor:ii,flexShrink:0,children:[lt(Nn,{color:wo,dimColor:!0,children:_?`\u{1F4C4} ${_}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),lt(Rt,{flexDirection:"column",marginTop:1,children:lt(si,{relativePath:_,cwd:t,width:S,maxLines:v})})]})]}),lt(Rt,{marginTop:1,children:lt(Nn,{color:wo,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u56DE\u586B\u8DEF\u5F84\u5230\u8F93\u5165\u6846 \xB7 Esc / Ctrl+P \u5173\u95ED"})})]})}p();import{Text as Bn,useInput as x0}from"ink";import{jsx as ko,jsxs as gm}from"react/jsx-runtime";function ym({value:e,onChange:t,onSubmit:n,placeholder:r="",focus:o=!0}){if(x0((s,i)=>{if(o&&!(i.upArrow||i.downArrow||i.leftArrow||i.rightArrow)&&!(i.pageDown||i.pageUp||i.home||i.end)){if(i.return){n?.(e);return}if(!i.escape&&!i.tab&&!(i.shift&&i.tab)&&!i.ctrl){if(i.backspace||i.delete){t(e.slice(0,-1));return}s&&t(e+s)}}},{isActive:o}),!o)return!e&&r?ko(Bn,{dimColor:!0,children:r}):ko(Bn,{children:e});if(!e&&r){let s=r[0],i=r.slice(1);return gm(Bn,{children:[ko(Bn,{inverse:!0,children:s}),ko(Bn,{dimColor:!0,children:i})]})}return gm(Bn,{children:[e,ko(Bn,{inverse:!0,children:" "})]})}p();p();function pc(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function b0(e){return e.replace(/<skill_content/g,"<skill_content").replace(/<\/skill_content/g,"</skill_content")}function ai(e,t){let n=pc(e.name),r=pc(e.source),o=pc(e.directoryPath),s=b0(t.trim());return`<skill_content name="${n}">
|
|
180
180
|
<source>${r}</source>
|
|
181
181
|
<directory>${o}</directory>
|
|
182
182
|
Relative paths in this skill resolve against <directory>.
|
|
183
183
|
|
|
184
184
|
${s}
|
|
185
185
|
</skill_content>
|
|
186
|
-
`}var
|
|
186
|
+
`}var w0=/^\/(\S+)(?:\s+(.*))?$/;async function xm(e,t){let n=w0.exec(e);if(!n)return{kind:"no-match"};let r=n[1],o=(n[2]??"").trim(),s=t.find(l=>l.name===r);if(!s)return{kind:"no-match"};let i;try{i=await ls(s.skillFilePath)}catch(l){return{kind:"error",message:l instanceof Error?l.message:String(l)}}let a=ai(s,i);return{kind:"text",text:o?`${a}
|
|
187
187
|
|
|
188
|
-
${o}`:a}}p();import{Box as
|
|
189
|
-
`)){if(r.length===0){n.push("");continue}let o="",s=0;for(let i of r){let l=i.codePointAt(0)>11904?2:1;s+l>t&&o.length>0?(n.push(o),o=i,s=l):(o+=i,s+=l)}o.length>0&&n.push(o)}return n}function
|
|
188
|
+
${o}`:a}}p();import{Box as fc,Text as Fn}from"ink";import k0 from"ink-spinner";import{jsx as Et,jsxs as wm}from"react/jsx-runtime";function bm(e){switch(e){case"pending":return"\u2610";case"done":return"\u2611";case"failed":return"\u2717";case"skipped":return"\u2298";case"running":return"\u25B6"}}function S0({status:e}){return e==="running"?Et(Fn,{color:"cyan",children:Et(k0,{type:"dots"})}):e==="done"?Et(Fn,{color:"green",children:"\u2705"}):e==="failed"?Et(Fn,{color:"red",children:bm(e)}):Et(Fn,{dimColor:!0,children:bm(e)})}function mc({items:e}){return e.length===0?null:wm(fc,{flexDirection:"column",marginTop:1,children:[Et(fc,{children:Et(Fn,{dimColor:!0,children:"\u{1F527} \u4EFB\u52A1\u8FDB\u5EA6"})}),e.map(t=>wm(fc,{children:[Et(Fn,{dimColor:!0,children:" "}),Et(S0,{status:t.status}),Et(Fn,{dimColor:!0,children:` ${t.content}`})]},t.id))]})}p();import{Box as Be,Text as ke}from"ink";import T0 from"ink-spinner";import{useMemo as km}from"react";import{Fragment as I0,jsx as ye,jsxs as _e}from"react/jsx-runtime";function C0(e){if(e.phase==="idle")return 0;if(e.phase==="done"||e.phase==="error")return 100;let t=e.progress;if(!t)return 5;if(t.type==="start")return 10;if(t.type==="summary_delta"){let n=Math.min(t.totalSoFar.length/800,1);return Math.min(10+n*80,90)}return t.type==="fallback"?95:5}function _0(e){if(e.phase==="error")return{icon:"\u2717",text:"\u538B\u7F29\u51FA\u9519",color:"#ff6347"};if(e.phase==="done")return e.strategy==="fallback"?{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210\uFF08\u672C\u5730\u515C\u5E95\uFF09",color:"#ff9800"}:{icon:"\u2714",text:"\u538B\u7F29\u5B8C\u6210",color:"#00ff41"};let t=e.progress;return t?t.type==="start"?{icon:"\u280B",text:`\u51C6\u5907\u6458\u8981 ${t.droppedTurns} \u4E2A\u65E7\u56DE\u5408...`,color:"#00ffff"}:t.type==="summary_delta"?{icon:"\u280B",text:"\u8C03\u7528 LLM \u751F\u6210\u6458\u8981...",color:"#00ffff"}:t.type==="fallback"?{icon:"\u26A0",text:`LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\uFF1A${t.reason}`,color:"#ff9800"}:{icon:"\u280B",text:"\u538B\u7F29\u4E2D...",color:"#00ffff"}:{icon:"\u280B",text:"\u51C6\u5907\u538B\u7F29...",color:"#00ffff"}}function v0({percent:e,color:t}){let r=Math.round(e/100*24),o=24-r;return _e(ke,{children:[ye(ke,{color:t,children:"\u2588".repeat(r)}),ye(ke,{color:"#444444",children:"\u2591".repeat(o)}),_e(ke,{color:t,children:[" ",e.toFixed(0),"%"]})]})}function R0({state:e}){let t=(()=>{if(e.phase==="idle")return 0;if(e.phase==="error"){let o=e.progress;return o?.type==="summary_delta"||o?.type==="start"?1:2}if(e.phase==="done")return 3;let r=e.progress;return!r||r.type==="start"?0:r.type==="summary_delta"?1:(r.type==="fallback",2)})(),n=["\u542F\u52A8","LLM \u6458\u8981","\u5E94\u7528\u538B\u7F29","\u5B8C\u6210"];return ye(Be,{children:n.map((r,o)=>{let s=o===t,i=o<t;return _e(Be,{marginRight:1,children:[_e(ke,{color:i?"#00ff41":s?"#00ffff":"#444444",children:[i?"\u2713":s?"\u25B8":"\xB7"," ",r]}),o<n.length-1&&ye(ke,{color:"#444444",children:" \u2192 "})]},r)})})}function A0({text:e,contentWidth:t}){let r=Math.max(t-6,20);if(!e)return ye(ke,{dimColor:!0,children:" (\u7B49\u5F85 LLM \u8F93\u51FA...)"});let s=E0(e,r).slice(-4);return ye(Be,{flexDirection:"column",children:s.map((i,a)=>_e(ke,{dimColor:!0,children:[" ",i]},a))})}function E0(e,t){if(e==="")return[];if(t<=0)return[e];let n=[];for(let r of e.split(`
|
|
189
|
+
`)){if(r.length===0){n.push("");continue}let o="",s=0;for(let i of r){let l=i.codePointAt(0)>11904?2:1;s+l>t&&o.length>0?(n.push(o),o=i,s=l):(o+=i,s+=l)}o.length>0&&n.push(o)}return n}function Sm(e){return e.toLocaleString()}function hc({state:e,contentWidth:t}){let n=km(()=>C0(e),[e]),r=km(()=>_0(e),[e]),o=e.progress?.type==="summary_delta"?e.progress.totalSoFar:e.progress?.type==="fallback"?e.progress.fallbackSummary:(e.phase==="done"&&e.strategy==="summary",""),s=e.phase==="done"&&e.strategy==="summary"?e.progress?.type==="summary_delta"?e.progress.totalSoFar:"":o,i=e.phase==="error"?"#ff6347":"#00ffff";return ye(Be,{flexDirection:"column",marginTop:1,children:_e(Be,{flexDirection:"row",children:[ye(Be,{width:1,backgroundColor:"#9b59b6",flexShrink:0}),_e(Be,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[_e(Be,{children:[ye(ke,{bold:!0,color:i,children:"\u{1F5DC} \u4E0A\u4E0B\u6587\u538B\u7F29"}),ye(Be,{flexGrow:1}),e.phase==="running"&&_e(ke,{color:r.color,children:[ye(T0,{type:"dots"})," ",r.text]}),e.phase==="done"&&_e(ke,{color:r.color,children:[r.icon," ",r.text]}),e.phase==="error"&&_e(ke,{color:r.color,children:[r.icon," ",r.text]})]}),_e(Be,{marginTop:1,children:[ye(ke,{color:"#808080",children:"\u8FDB\u5EA6: "}),ye(v0,{percent:n,color:e.phase==="error"?"#ff6347":r.color})]}),ye(Be,{marginTop:1,children:ye(R0,{state:e})}),(e.beforeTokens!==void 0||e.droppedTurns!==void 0)&&_e(Be,{marginTop:1,flexDirection:"column",children:[e.droppedTurns!==void 0&&_e(ke,{color:"#00ff41",children:["\u{1F4CA} \u56DE\u5408: ",e.droppedTurns," \u6298\u53E0 \u2192 ",e.keptTurns??0," \u4FDD\u7559"]}),e.beforeTokens!==void 0&&_e(ke,{color:"#ff9800",children:["\u{1F4E6} token: ",Sm(e.beforeTokens),e.afterTokens!==void 0&&_e(I0,{children:[" \u2192 ",ye(ke,{color:"#00ff41",bold:!0,children:Sm(e.afterTokens)}),_e(ke,{color:"#808080",children:[" (\u8282\u7701 ",((e.beforeTokens-e.afterTokens)/Math.max(e.beforeTokens,1)*100).toFixed(1),"%)"]})]})]})]}),(e.phase==="running"||e.phase==="done")&&s&&_e(Be,{marginTop:1,flexDirection:"column",children:[ye(ke,{color:"#808080",children:"\u2504\u2504\u2504 LLM \u6458\u8981\u9884\u89C8 \u2504\u2504\u2504"}),ye(A0,{text:s,contentWidth:t})]}),e.phase==="done"&&e.strategy==="fallback"&&ye(Be,{marginTop:1,children:ye(ke,{color:"#ff9800",children:"\u26A0 LLM \u6458\u8981\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u515C\u5E95\u6458\u8981\u3002\u538B\u7F29\u5DF2\u751F\u6548\u4F46\u6458\u8981\u8D28\u91CF\u8F83\u4F4E\u3002"})}),e.phase==="error"&&e.errorMessage&&ye(Be,{marginTop:1,children:_e(ke,{color:"#ff6347",children:["\u26A0 ",e.errorMessage]})})]})]})})}p();var Tm={name:"dskcode",version:"0.1.48",keywords:["cli","ink","commander","deepseek","asciichart"],description:"A DeepSeek-native AI coding agent for your terminal",type:"module",bin:{dskcode:"dist/index.js"},exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist","README.md","LICENSE","!dist/**/*.map"],scripts:{dev:"tsup --watch",debug:"npm run build && node dist/index.js",build:"tsup",obfuscate:"node scripts/obfuscate.mjs","build:clean":"node scripts/clean-sourcemaps.mjs","type-check":"tsc --noEmit",format:"prettier --write src/ tests/","format:check":"prettier --check src/ tests/",test:"vitest run --exclude 'tests/checkpoint.test.ts' --exclude 'tests/session-rewind.test.ts'","test:checkpoint":"vitest run tests/checkpoint.test.ts tests/session-rewind.test.ts",prepublishOnly:"npm run build && npm run test && npm run build:clean"},dependencies:{asciichart:"^1.5.25",chalk:"^5.6.2",commander:"^13.1.0",handlebars:"^4.7.9",ink:"^7.1.0","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0",react:"^19.2.7",ws:"^8.21.0",yaml:"^2.6.0",zod:"^3.25.76"},devDependencies:{"@shikijs/cli":"^4.3.1","@types/node":"^22.14.0","@types/react":"^19.2.17","@types/ws":"^8.18.1","javascript-obfuscator":"^4.1.1",prettier:"^3.5.3",tsup:"^8.4.0",typescript:"^5.8.3",vitest:"^3.1.1"},engines:{node:">=22.0.0"},license:"MIT"};var So=Tm.version;p();p();var li=class{#e=new Map;#n=new Map;register(t,n){this.#e.set(t,n)}get(t,n){if(!ka(n.model))throw new Sa(n.model);let r=`${t}:${n.baseUrl}:${n.model}`,o=this.#n.get(r);if(o)return o;let s=this.#e.get(t);if(!s){let a=[...this.#e.keys()].join(", ");throw new Error(`\u672A\u6CE8\u518C\u7684 Provider: "${t}"\u3002\u53EF\u7528: ${a}`)}let i=s(n);return this.#n.set(r,i),i}list(){return[...this.#e.keys()]}clear(){this.#n.clear()}},gc=new li;gc.register("deepseek",e=>new Ta({apiKey:e.apiKey,baseUrl:e.baseUrl,model:e.model}));function yc(e){return gc.get(e.name,e)}p();p();import vm from"handlebars";var Cm=`\u4F60\u662F dskcode\uFF0C\u4E00\u4E2A\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u7EC8\u7AEF\u4E2D\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u5F00\u53D1\u8005\u7F16\u5199\u3001\u7406\u89E3\u3001\u8C03\u8BD5\u548C\u91CD\u6784\u4EE3\u7801\u3002\r
|
|
190
190
|
\r
|
|
191
191
|
## \u6838\u5FC3\u539F\u5219\r
|
|
192
192
|
- \u56DE\u7B54\u4F7F\u7528\u4E2D\u6587\uFF0C\u4EE3\u7801\u6807\u8BC6\u7B26\u4FDD\u6301\u82F1\u6587\r
|
|
@@ -361,7 +361,7 @@ ${o}`:a}}p();import{Box as dc,Text as Gn}from"ink";import Ck from"ink-spinner";i
|
|
|
361
361
|
- \u5F53\u524D\u65E5\u671F\uFF1A{{date}}\r
|
|
362
362
|
- \u5F53\u524D\u65F6\u95F4\uFF1A{{time}}\r
|
|
363
363
|
- \u5DE5\u4F5C\u76EE\u5F55\uFF1A{{cwd}}\r
|
|
364
|
-
`;var
|
|
364
|
+
`;var _m=`\u4F60\u662F dskcode\uFF0C\u5F53\u524D\u5DE5\u4F5C\u5728**\u8BA1\u5212\u6A21\u5F0F\uFF08Plan Mode\uFF09**\u3002\r
|
|
365
365
|
\r
|
|
366
366
|
\u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C**\u4F60\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u80FD\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u64CD\u4F5C**\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u7528\u6237\u7406\u89E3\u4EE3\u7801\u3001\u8BBE\u8BA1\u67B6\u6784\u3001\u89C4\u5212\u4EFB\u52A1\u3001\u8BC4\u4F30\u65B9\u6848\u3002\r
|
|
367
367
|
\r
|
|
@@ -461,7 +461,7 @@ ${o}`:a}}p();import{Box as dc,Text as Gn}from"ink";import Ck from"ink-spinner";i
|
|
|
461
461
|
- \u5F53\u524D\u65E5\u671F\uFF1A{{date}}\r
|
|
462
462
|
- \u5F53\u524D\u65F6\u95F4\uFF1A{{time}}\r
|
|
463
463
|
- \u5DE5\u4F5C\u76EE\u5F55\uFF1A{{cwd}}\r
|
|
464
|
-
`;var
|
|
464
|
+
`;var O0=vm.compile(Cm),D0=vm.compile(_m);function N0(e){return e.map(t=>{let n=t.parameters&&Object.keys(t.parameters.properties??{}).join(", ");return{name:t.name,description:t.description,params:n||void 0}})}function Rm(e){let t=new Date,n=t.toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric",weekday:"long"}),r=t.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return{model:e.model,maxToolRounds:e.maxToolRounds,cwd:e.cwd,date:n,time:r,tools:e.tools?N0(e.tools):void 0,projectContext:e.projectContext??void 0,skills:e.availableSkills,hasSkills:(e.availableSkills?.length??0)>0}}function Am(e){return O0(Rm(e))}function Em(e){return D0(Rm(e))}p();function Pm(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Yn(t)+10}function ci(e){let t=[],n=null;for(let r of e)r.role==="user"?(n&&t.push(n),n=[r]):(n||(n=[]),n.push(r));return n&&n.length>0&&t.push(n),t}function Im(e){let t=0;for(let n of e)t+=Pm(n);return t}function Lm(e,t){let r=tn(t.model).contextWindow-t.reservedForOutput,o=Yn(t.systemPrompt),s=r-o,i=ci(e),a=[],l=0;for(let f=i.length-1;f>=0&&l<t.preserveRecentRounds;f--)a.unshift(i[f]),l++;let c=a.flat();for(let f of c)s-=Pm(f);if(s<0){for(;a.length>1&&s<0;){let f=a.shift();s+=Im(f)}return[a.flat(),!0]}let u=i.slice(0,i.length-a.length),d=[];for(let f=u.length-1;f>=0;f--){let g=Im(u[f]);if(s-g<0)break;s-=g,d.unshift(u[f])}let m=[...d,...a].flat(),h=m.length<e.length;return[m,h]}function $m(e,t){return[{role:"system",content:e},...t]}p();var bc=.85,wc=6,ui=8,M0="[history-summary]",B0=`\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u5BF9\u8BDD\u6458\u8981\u52A9\u624B\u3002\u4F60\u7684\u4EFB\u52A1\u662F\u628A\u591A\u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u4E2D\u6587\u6458\u8981\u3002
|
|
465
465
|
|
|
466
466
|
\u6458\u8981\u5FC5\u987B\u4FDD\u7559\u4EE5\u4E0B\u4FE1\u606F\uFF08\u6309\u91CD\u8981\u6027\u6392\u5E8F\uFF09\uFF1A
|
|
467
467
|
1. \u7528\u6237\u7684\u6838\u5FC3\u76EE\u6807\u4E0E\u6700\u7EC8\u610F\u56FE
|
|
@@ -476,21 +476,21 @@ ${o}`:a}}p();import{Box as dc,Text as Gn}from"ink";import Ck from"ink-spinner";i
|
|
|
476
476
|
- \u6BCF\u6761\u4FE1\u606F\u72EC\u7ACB\u6210\u884C\uFF0C\u65B9\u4FBF\u540E\u7EED\u6309\u884C\u89E3\u6790
|
|
477
477
|
- \u603B\u957F\u5EA6\u63A7\u5236\u5728 2000 \u5B57\u4EE5\u5185
|
|
478
478
|
- \u4E0D\u9700\u8981\u5BA2\u5957\u8BDD\u3001\u4E0D\u9700\u8981"\u4EE5\u4E0B\u662F\u6458\u8981"\u7B49\u5F00\u5934
|
|
479
|
-
|
|
480
|
-
`)}function
|
|
481
|
-
`)}async function
|
|
479
|
+
`,Om=500,F0=60;function G0(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Yn(t)+10}function xc(e){let t=0;for(let n of e)t+=G0(n);return t}function kc(e,t){let n=xc(e),r=t>0?n/t:0;return{messageCount:e.length,estimatedTokens:n,contextWindow:t,ratio:r,headroom:t-n}}function Nm(e,t){let n=ci(e),r=t.minTurnsToCompact??ui;if(n.length<r)return!1;let o=t.autoCompactRatio??bc;return kc(e,t.contextWindow).ratio>=o}function j0(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(`--- \u7B2C ${n+1} \u56DE\u5408 ---`);for(let o of r){let s=`[${o.role}]`,i=o.content.length>Om?o.content.slice(0,Om)+`\u2026(\u5DF2\u622A\u65AD,\u539F\u957F ${o.content.length})`:o.content;if(t.push(`${s} ${i}`),o.toolCalls)for(let a of o.toolCalls)t.push(` tool_call: ${a.name}(${a.arguments})`)}}return t.join(`
|
|
480
|
+
`)}function Dm(e){let t=["\u3010\u672C\u5730\u6458\u8981\uFF08LLM \u8C03\u7528\u5931\u8D25\u65F6\u515C\u5E95\uFF09\u3011"];for(let n=0;n<e.length;n++){let r=e[n],o=r.find(i=>i.role==="user");if(o){let i=o.content.slice(0,F0);t.push(`\u56DE\u5408${n+1} \u7528\u6237: ${i}`)}let s=[];for(let i of r)if(i.toolCalls)for(let a of i.toolCalls)s.push({name:a.name,argsRaw:a.arguments});if(s.length>0){let i=s.map(a=>{let l=or(a.argsRaw);return l.ok?us(a.name,jr(l.args)):`${a.name}(\u89E3\u6790\u5931\u8D25)`});t.push(` \u8C03\u7528\u5DE5\u5177: ${i.join("; ")}`)}}return t.join(`
|
|
481
|
+
`)}async function U0(e,t){if(e.length===0)return"";let n=j0(e);try{let r=[{role:"system",content:B0},{role:"user",content:`\u8BF7\u628A\u4EE5\u4E0B ${e.length} \u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u6458\u8981\uFF1A
|
|
482
482
|
|
|
483
|
-
${n}`}],o=t.provider.chat(r,{...t.signal?{signal:t.signal}:{},temperature:.2}),s="";for await(let i of o)if(i.content&&(s+=i.content,t.onProgress))try{t.onProgress({type:"summary_delta",delta:i.content,totalSoFar:s})}catch{}if(!s.trim()){let i=
|
|
484
|
-
${e}`}}async function wc(e,t){let n=gc(e),r=li(e),o=t.minTurnsToCompact??ci,s=t.preserveRecentRounds??bc;if(r.length<o)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};if(r.length<=s)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};let i=r.length-s,a=r.slice(0,i),l=r.slice(i);if(t.onProgress)try{t.onProgress({type:"start",droppedTurns:a.length,beforeTokens:n})}catch{}let c=await Vk(a,t),u=[zk(c)];for(let m of l)for(let h of m)u.push(h);let d=gc(u);if(t.onProgress)try{t.onProgress({type:"done",droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d})}catch{}return{messages:u,summary:c,droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d}}p();var dn=class{#e=new Map;#t;#r;#o;static ALL_TOOL_NAMES=[];constructor(t){this.#t=new Set(t?.disabledTools??[]),this.#r=t?.featureFlagChecker??(()=>!0),this.#o=t?.provider}register(t){return this.registerErased(Oe(t))}registerErased(t){if(this.#e.has(t.name))throw new Error(`\u5DE5\u5177 "${t.name}" \u5DF2\u6CE8\u518C\uFF0C\u4E0D\u80FD\u91CD\u590D\u6CE8\u518C`);return this.#e.set(t.name,t),this}registerAll(t){for(let n of t)this.registerErased(n);return this}unregister(t){return this.#e.delete(t)}get(t){if(this.#n(t))return this.#e.get(t)}list(){let t=[];for(let[n,r]of this.#e)this.#n(n)&&t.push(r);return t}listByKind(t){return this.list().filter(n=>n.kind===t)}listReadTools(){return this.listByKind("read")}listWriteTools(){return this.list().filter(t=>!Yn(t.kind))}names(){return[...this.#e.keys()]}has(t){return this.#e.has(t)}isEnabled(t){return this.#e.has(t)&&this.#n(t)}disable(t){this.#t.add(t)}enable(t){this.#t.delete(t)}kindOf(t){return this.#e.get(t)?.kind}async execute(t,n,r){let o=this.get(t);if(!o)return{success:!1,data:`\u5DE5\u5177 "${t}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`,error:"TOOL_NOT_FOUND"};try{return await o.execute(n,r)}catch(s){let i=s instanceof Error?s.message:String(s);return{success:!1,data:`\u5DE5\u5177 "${t}" \u6267\u884C\u5F02\u5E38\uFF1A${i}`,error:"EXECUTION_ERROR"}}}#n(t){let n=this.#e.get(t);return!(!n||this.#t.has(t)||!this.#r(t)||this.#o&&n.supportedProviders.length>0&&!n.supportedProviders.includes(this.#o))}};p();p();p();import{z as uD}from"zod";function kc(e,t){let n=t.safeParse(e);if(n.success)return{ok:!0,issues:[]};let r=n.error.issues.map(o=>qk(o,e));return{ok:r.length===0,issues:r}}function qk(e,t){let n=Kk(e.path),r=Xk(e),o=Jk(t,e.path),s=Zk(n,r,o,e);return{path:n,expected:r,received:o,message:s}}function Kk(e){if(e.length===0)return"$";let t="$";for(let n of e)typeof n=="number"?t+=`[${n}]`:typeof n=="string"?t+=`.${n}`:t+="[]";return t}function Xk(e){switch(e.code){case"invalid_type":return e.expected;case"too_small":{let t=e.type,n=e.minimum;return t==="string"?`length >= ${n}`:t==="array"?`length >= ${n}`:t==="number"?`>= ${n}`:`>= ${n}`}case"too_big":{let t=e.type,n=e.maximum;return t==="string"?`length <= ${n}`:t==="array"?`length <= ${n}`:t==="number"?`<= ${n}`:`<= ${n}`}case"invalid_enum_value":return`enum[${e.options.map(n=>JSON.stringify(n)).join(",")}]`;case"invalid_string":return`string ${e.validation}`;case"unrecognized_keys":return`\u672A\u5728 schema \u4E2D\u5B9A\u4E49: ${e.keys.join(",")}`;case"invalid_literal":{let t=e.expected;return`literal[${JSON.stringify(t)}]`}default:return e.code}}function Jk(e,t){let n=e;for(let r of t){if(n==null||typeof n!="object")return"undefined";if(typeof r=="number"){if(!Array.isArray(n))return"undefined";n=n[r]}else if(typeof r=="string")n=n[r];else return"undefined"}return n===null?"null":n===void 0?"undefined":typeof n=="string"?n.length>60?JSON.stringify(n.slice(0,57)+"..."):JSON.stringify(n):typeof n=="number"||typeof n=="boolean"?JSON.stringify(n):Array.isArray(n)?`array(len=${n.length})`:typeof n=="object"?`object{keys=${Object.keys(n).length}}`:typeof n}function Zk(e,t,n,r){if(r.code==="invalid_type")return`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="too_small"){let o=r.type,s=r.minimum;return o==="string"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="too_big"){let o=r.type,s=r.maximum;return o==="string"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="invalid_enum_value")return`${e} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="unrecognized_keys"){let o=r.keys;return`${e} \u4E0D\u5141\u8BB8\u952E: ${o.join(", ")}`}return r.code==="invalid_literal"?`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`:r.code==="invalid_string"?`${e} \u4E0D\u5339\u914D ${t}`:`${e} ${r.message}\uFF08\u671F\u671B ${t}\uFF0C\u5B9E\u9645 ${n}\uFF09`}function Nm(e,t){if(Yk(t))return kc(e,t);let n=[];return Fm(t)?t.type!==void 0&&t.type!=="object"?{ok:!0,issues:n}:(Mm(e,t,"$",n),{ok:n.length===0,issues:n}):{ok:!0,issues:n}}function Yk(e){if(e===null||typeof e!="object")return!1;let t=e;return"_def"in t&&typeof t.parse=="function"&&typeof t.safeParse=="function"}function Mm(e,t,n,r){if(!Fm(e)){r.push({path:n,expected:"object",received:pn(e),message:`${n} \u5E94\u4E3A object\uFF0C\u5B9E\u9645\u4E3A ${pn(e)}`});return}for(let i of t.required??[])i in e||r.push({path:`${n}.${i}`,expected:"present",received:"missing",message:`${n}.${i} \u662F\u5FC5\u586B\u5B57\u6BB5`});let o=t.properties??{},s=t.additionalProperties;for(let[i,a]of Object.entries(e)){let l=o[i];if(l===void 0){s===!1&&r.push({path:`${n}.${i}`,expected:"\u672A\u5728 schema \u4E2D\u5B9A\u4E49",received:pn(a),message:`${n}.${i} \u4E0D\u5728\u5141\u8BB8\u5B57\u6BB5\u4E2D`});continue}Bm(a,l,`${n}.${i}`,r)}}function Bm(e,t,n,r){if(t.type!==void 0){let o=eS(e);if(!tS(o,t.type)){r.push({path:n,expected:t.type,received:pn(e),message:`${n} \u5E94\u4E3A ${t.type}\uFF0C\u5B9E\u9645\u4E3A ${o}`});return}}if(t.enum&&t.enum.length>0&&(Qk(e)?t.enum.includes(e)||r.push({path:n,expected:`enum[${t.enum.map(o=>JSON.stringify(o)).join(",")}]`,received:pn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${JSON.stringify(e)}`}):r.push({path:n,expected:`enum[${t.enum.map(o=>JSON.stringify(o)).join(",")}]`,received:pn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${pn(e)}`})),typeof e=="number"&&(t.minimum!==void 0&&e<t.minimum&&r.push({path:n,expected:`>= ${t.minimum}`,received:String(e),message:`${n} \u5E94 >= ${t.minimum}\uFF0C\u5B9E\u9645\u4E3A ${e}`}),t.maximum!==void 0&&e>t.maximum&&r.push({path:n,expected:`<= ${t.maximum}`,received:String(e),message:`${n} \u5E94 <= ${t.maximum}\uFF0C\u5B9E\u9645\u4E3A ${e}`})),typeof e=="string"&&(t.minLength!==void 0&&e.length<t.minLength&&r.push({path:n,expected:`length >= ${t.minLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 >= ${t.minLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.maxLength!==void 0&&e.length>t.maxLength&&r.push({path:n,expected:`length <= ${t.maxLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 <= ${t.maxLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.pattern!==void 0))try{new RegExp(t.pattern).test(e)||r.push({path:n,expected:`pattern ${t.pattern}`,received:pn(e),message:`${n} \u4E0D\u5339\u914D pattern ${t.pattern}`})}catch{}if(t.properties!==void 0&&Mm(e,t,n,r),t.items!==void 0&&Array.isArray(e))for(let o=0;o<e.length;o++)Bm(e[o],t.items,`${n}[${o}]`,r)}function Fm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qk(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function eS(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e}function tS(e,t){return e===t||t==="integer"&&e==="number"||t==="number"&&e==="integer"}function pn(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string"){let t=e.length>60?e.slice(0,57)+"...":e;return JSON.stringify(t)}return typeof e=="number"||typeof e=="boolean"?JSON.stringify(e):Array.isArray(e)?`array(len=${e.length})`:typeof e=="object"?`object{keys=${Object.keys(e).length}}`:typeof e}var ui=class{#e;#t;#r;#o;constructor(t){this.#e=t.registry,this.#t=t.gate,this.#r={cwd:t.baseCtx.cwd,signal:t.baseCtx.signal,writeRoots:t.baseCtx.writeRoots,...t.baseCtx.timeout!==void 0?{timeout:t.baseCtx.timeout}:{}},this.#o=t.maxParallel??8}async executeBatch(t){return t.length===0?{items:[],records:[]}:this.#n(t)&&t.length>1?this.#a(t):this.#u(t)}#n(t){return t.every(n=>{let r=this.#e.get(n.name);return r?Yn(r.kind):!0})}async#a(t){let n=[],r=[];for(let o=0;o<t.length;o+=this.#o){let s=t.slice(o,o+this.#o),i=await Promise.all(s.map(a=>this.#i(a)));for(let a of i)n.push(a.item),a.record.success||r.push(a.record)}return{items:n,records:r}}async#u(t){let n=[],r=[];for(let o of t){let s=await this.#i(o);if(n.push(s.item),!s.record.success&&(r.push(s.record),s.record.error==="GATE_DENIED"&&s.item.result.denial?.source==="user_prompt"))break}return{items:n,records:r}}async#i(t){let n=t.name,r=Date.now(),o=this.#e.get(n);if(!o){let u=`\u5DE5\u5177 "${n}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`;return{item:{name:n,callId:t.id,result:{success:!1,data:u,error:"TOOL_NOT_FOUND"}},record:{name:n,success:!1,error:"TOOL_NOT_FOUND",timestamp:r}}}let s=rr(t.arguments??"");if(!s.ok){if(s.reason==="PARTIAL"){let d=`\u5DE5\u5177 "${n}" \u53C2\u6570\u5C1A\u672A\u6536\u5168\uFF0C\u672C\u8F6E\u8DF3\u8FC7\uFF08\u6D41\u5F0F\u5206\u7247\u5BFC\u81F4\uFF09\uFF1A${s.hint}`;return{item:{name:n,callId:t.id,result:{success:!1,data:d,error:"PARTIAL_JSON"}},record:{name:n,success:!1,error:"PARTIAL_JSON",timestamp:r}}}let u=`\u5DE5\u5177 "${n}" \u53C2\u6570\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${s.error}
|
|
485
|
-
\u539F\u6587: ${s.raw.slice(0,200)}`;return{item:{name:n,callId:t.id,result:{success:!1,data:u,error:"INVALID_JSON"}},record:{name:n,success:!1,error:"INVALID_JSON",timestamp:r}}}let i=s.args,a,l=o.schema??o.parameters;if(l){let u=
|
|
483
|
+
${n}`}],o=t.provider.chat(r,{...t.signal?{signal:t.signal}:{},temperature:.2}),s="";for await(let i of o)if(i.content&&(s+=i.content,t.onProgress))try{t.onProgress({type:"summary_delta",delta:i.content,totalSoFar:s})}catch{}if(!s.trim()){let i=Dm(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:"LLM \u8FD4\u56DE\u7A7A\u5B57\u7B26\u4E32",fallbackSummary:i})}catch{}return i}return s.trim()}catch(r){let o=r instanceof Error?r.message:String(r),s=Dm(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:o,fallbackSummary:s})}catch{}return s}}function W0(e){return{role:"system",content:`${M0}
|
|
484
|
+
${e}`}}async function Sc(e,t){let n=xc(e),r=ci(e),o=t.minTurnsToCompact??ui,s=t.preserveRecentRounds??wc;if(r.length<o)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};if(r.length<=s)return{messages:e.slice(),summary:"",droppedTurns:0,keptTurns:r.length,beforeTokens:n,afterTokens:n};let i=r.length-s,a=r.slice(0,i),l=r.slice(i);if(t.onProgress)try{t.onProgress({type:"start",droppedTurns:a.length,beforeTokens:n})}catch{}let c=await U0(a,t),u=[W0(c)];for(let m of l)for(let h of m)u.push(h);let d=xc(u);if(t.onProgress)try{t.onProgress({type:"done",droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d})}catch{}return{messages:u,summary:c,droppedTurns:a.length,keptTurns:l.length,beforeTokens:n,afterTokens:d}}p();var un=class{#e=new Map;#n;#r;#s;static ALL_TOOL_NAMES=[];constructor(t){this.#n=new Set(t?.disabledTools??[]),this.#r=t?.featureFlagChecker??(()=>!0),this.#s=t?.provider}register(t){return this.registerErased(Oe(t))}registerErased(t){if(this.#e.has(t.name))throw new Error(`\u5DE5\u5177 "${t.name}" \u5DF2\u6CE8\u518C\uFF0C\u4E0D\u80FD\u91CD\u590D\u6CE8\u518C`);return this.#e.set(t.name,t),this}registerAll(t){for(let n of t)this.registerErased(n);return this}unregister(t){return this.#e.delete(t)}get(t){if(this.#t(t))return this.#e.get(t)}list(){let t=[];for(let[n,r]of this.#e)this.#t(n)&&t.push(r);return t}listByKind(t){return this.list().filter(n=>n.kind===t)}listReadTools(){return this.listByKind("read")}listWriteTools(){return this.list().filter(t=>!Qn(t.kind))}names(){return[...this.#e.keys()]}has(t){return this.#e.has(t)}isEnabled(t){return this.#e.has(t)&&this.#t(t)}disable(t){this.#n.add(t)}enable(t){this.#n.delete(t)}kindOf(t){return this.#e.get(t)?.kind}async execute(t,n,r){let o=this.get(t);if(!o)return{success:!1,data:`\u5DE5\u5177 "${t}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`,error:"TOOL_NOT_FOUND"};try{return await o.execute(n,r)}catch(s){let i=s instanceof Error?s.message:String(s);return{success:!1,data:`\u5DE5\u5177 "${t}" \u6267\u884C\u5F02\u5E38\uFF1A${i}`,error:"EXECUTION_ERROR"}}}#t(t){let n=this.#e.get(t);return!(!n||this.#n.has(t)||!this.#r(t)||this.#s&&n.supportedProviders.length>0&&!n.supportedProviders.includes(this.#s))}};p();p();p();import{z as KO}from"zod";function Tc(e,t){let n=t.safeParse(e);if(n.success)return{ok:!0,issues:[]};let r=n.error.issues.map(o=>H0(o,e));return{ok:r.length===0,issues:r}}function H0(e,t){let n=V0(e.path),r=z0(e),o=q0(t,e.path),s=K0(n,r,o,e);return{path:n,expected:r,received:o,message:s}}function V0(e){if(e.length===0)return"$";let t="$";for(let n of e)typeof n=="number"?t+=`[${n}]`:typeof n=="string"?t+=`.${n}`:t+="[]";return t}function z0(e){switch(e.code){case"invalid_type":return e.expected;case"too_small":{let t=e.type,n=e.minimum;return t==="string"?`length >= ${n}`:t==="array"?`length >= ${n}`:t==="number"?`>= ${n}`:`>= ${n}`}case"too_big":{let t=e.type,n=e.maximum;return t==="string"?`length <= ${n}`:t==="array"?`length <= ${n}`:t==="number"?`<= ${n}`:`<= ${n}`}case"invalid_enum_value":return`enum[${e.options.map(n=>JSON.stringify(n)).join(",")}]`;case"invalid_string":return`string ${e.validation}`;case"unrecognized_keys":return`\u672A\u5728 schema \u4E2D\u5B9A\u4E49: ${e.keys.join(",")}`;case"invalid_literal":{let t=e.expected;return`literal[${JSON.stringify(t)}]`}default:return e.code}}function q0(e,t){let n=e;for(let r of t){if(n==null||typeof n!="object")return"undefined";if(typeof r=="number"){if(!Array.isArray(n))return"undefined";n=n[r]}else if(typeof r=="string")n=n[r];else return"undefined"}return n===null?"null":n===void 0?"undefined":typeof n=="string"?n.length>60?JSON.stringify(n.slice(0,57)+"..."):JSON.stringify(n):typeof n=="number"||typeof n=="boolean"?JSON.stringify(n):Array.isArray(n)?`array(len=${n.length})`:typeof n=="object"?`object{keys=${Object.keys(n).length}}`:typeof n}function K0(e,t,n,r){if(r.code==="invalid_type")return`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="too_small"){let o=r.type,s=r.minimum;return o==="string"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 >= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="too_big"){let o=r.type,s=r.maximum;return o==="string"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="array"?`${e} \u957F\u5EA6\u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:o==="number"?`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`:`${e} \u5E94 <= ${s}\uFF0C\u5B9E\u9645\u4E3A ${n}`}if(r.code==="invalid_enum_value")return`${e} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${n}`;if(r.code==="unrecognized_keys"){let o=r.keys;return`${e} \u4E0D\u5141\u8BB8\u952E: ${o.join(", ")}`}return r.code==="invalid_literal"?`${e} \u5E94\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${n}`:r.code==="invalid_string"?`${e} \u4E0D\u5339\u914D ${t}`:`${e} ${r.message}\uFF08\u671F\u671B ${t}\uFF0C\u5B9E\u9645 ${n}\uFF09`}function Mm(e,t){if(X0(t))return Tc(e,t);let n=[];return Gm(t)?t.type!==void 0&&t.type!=="object"?{ok:!0,issues:n}:(Bm(e,t,"$",n),{ok:n.length===0,issues:n}):{ok:!0,issues:n}}function X0(e){if(e===null||typeof e!="object")return!1;let t=e;return"_def"in t&&typeof t.parse=="function"&&typeof t.safeParse=="function"}function Bm(e,t,n,r){if(!Gm(e)){r.push({path:n,expected:"object",received:dn(e),message:`${n} \u5E94\u4E3A object\uFF0C\u5B9E\u9645\u4E3A ${dn(e)}`});return}for(let i of t.required??[])i in e||r.push({path:`${n}.${i}`,expected:"present",received:"missing",message:`${n}.${i} \u662F\u5FC5\u586B\u5B57\u6BB5`});let o=t.properties??{},s=t.additionalProperties;for(let[i,a]of Object.entries(e)){let l=o[i];if(l===void 0){s===!1&&r.push({path:`${n}.${i}`,expected:"\u672A\u5728 schema \u4E2D\u5B9A\u4E49",received:dn(a),message:`${n}.${i} \u4E0D\u5728\u5141\u8BB8\u5B57\u6BB5\u4E2D`});continue}Fm(a,l,`${n}.${i}`,r)}}function Fm(e,t,n,r){if(t.type!==void 0){let o=Z0(e);if(!Y0(o,t.type)){r.push({path:n,expected:t.type,received:dn(e),message:`${n} \u5E94\u4E3A ${t.type}\uFF0C\u5B9E\u9645\u4E3A ${o}`});return}}if(t.enum&&t.enum.length>0&&(J0(e)?t.enum.includes(e)||r.push({path:n,expected:`enum[${t.enum.map(o=>JSON.stringify(o)).join(",")}]`,received:dn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${JSON.stringify(e)}`}):r.push({path:n,expected:`enum[${t.enum.map(o=>JSON.stringify(o)).join(",")}]`,received:dn(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${dn(e)}`})),typeof e=="number"&&(t.minimum!==void 0&&e<t.minimum&&r.push({path:n,expected:`>= ${t.minimum}`,received:String(e),message:`${n} \u5E94 >= ${t.minimum}\uFF0C\u5B9E\u9645\u4E3A ${e}`}),t.maximum!==void 0&&e>t.maximum&&r.push({path:n,expected:`<= ${t.maximum}`,received:String(e),message:`${n} \u5E94 <= ${t.maximum}\uFF0C\u5B9E\u9645\u4E3A ${e}`})),typeof e=="string"&&(t.minLength!==void 0&&e.length<t.minLength&&r.push({path:n,expected:`length >= ${t.minLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 >= ${t.minLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.maxLength!==void 0&&e.length>t.maxLength&&r.push({path:n,expected:`length <= ${t.maxLength}`,received:`length ${e.length}`,message:`${n} \u957F\u5EA6\u5E94 <= ${t.maxLength}\uFF0C\u5B9E\u9645\u4E3A ${e.length}`}),t.pattern!==void 0))try{new RegExp(t.pattern).test(e)||r.push({path:n,expected:`pattern ${t.pattern}`,received:dn(e),message:`${n} \u4E0D\u5339\u914D pattern ${t.pattern}`})}catch{}if(t.properties!==void 0&&Bm(e,t,n,r),t.items!==void 0&&Array.isArray(e))for(let o=0;o<e.length;o++)Fm(e[o],t.items,`${n}[${o}]`,r)}function Gm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function J0(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Z0(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e}function Y0(e,t){return e===t||t==="integer"&&e==="number"||t==="number"&&e==="integer"}function dn(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string"){let t=e.length>60?e.slice(0,57)+"...":e;return JSON.stringify(t)}return typeof e=="number"||typeof e=="boolean"?JSON.stringify(e):Array.isArray(e)?`array(len=${e.length})`:typeof e=="object"?`object{keys=${Object.keys(e).length}}`:typeof e}var di=class{#e;#n;#r;#s;constructor(t){this.#e=t.registry,this.#n=t.gate,this.#r={cwd:t.baseCtx.cwd,signal:t.baseCtx.signal,writeRoots:t.baseCtx.writeRoots,...t.baseCtx.timeout!==void 0?{timeout:t.baseCtx.timeout}:{}},this.#s=t.maxParallel??8}async executeBatch(t){return t.length===0?{items:[],records:[]}:this.#t(t)&&t.length>1?this.#c(t):this.#p(t)}#t(t){return t.every(n=>{let r=this.#e.get(n.name);return r?Qn(r.kind):!0})}async#c(t){let n=[],r=[];for(let o=0;o<t.length;o+=this.#s){let s=t.slice(o,o+this.#s),i=await Promise.all(s.map(a=>this.#i(a)));for(let a of i)n.push(a.item),a.record.success||r.push(a.record)}return{items:n,records:r}}async#p(t){let n=[],r=[];for(let o of t){let s=await this.#i(o);if(n.push(s.item),!s.record.success&&(r.push(s.record),s.record.error==="GATE_DENIED"&&s.item.result.denial?.source==="user_prompt"))break}return{items:n,records:r}}async#i(t){let n=t.name,r=Date.now(),o=this.#e.get(n);if(!o){let u=`\u5DE5\u5177 "${n}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`;return{item:{name:n,callId:t.id,result:{success:!1,data:u,error:"TOOL_NOT_FOUND"}},record:{name:n,success:!1,error:"TOOL_NOT_FOUND",timestamp:r}}}let s=or(t.arguments??"");if(!s.ok){if(s.reason==="PARTIAL"){let d=`\u5DE5\u5177 "${n}" \u53C2\u6570\u5C1A\u672A\u6536\u5168\uFF0C\u672C\u8F6E\u8DF3\u8FC7\uFF08\u6D41\u5F0F\u5206\u7247\u5BFC\u81F4\uFF09\uFF1A${s.hint}`;return{item:{name:n,callId:t.id,result:{success:!1,data:d,error:"PARTIAL_JSON"}},record:{name:n,success:!1,error:"PARTIAL_JSON",timestamp:r}}}let u=`\u5DE5\u5177 "${n}" \u53C2\u6570\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${s.error}
|
|
485
|
+
\u539F\u6587: ${s.raw.slice(0,200)}`;return{item:{name:n,callId:t.id,result:{success:!1,data:u,error:"INVALID_JSON"}},record:{name:n,success:!1,error:"INVALID_JSON",timestamp:r}}}let i=s.args,a,l=o.schema??o.parameters;if(l){let u=Mm(i,l);u.ok||(a=u.issues)}if(!await this.#n.check(n,i)){let u=this.#n.lastDenial,d=u?`Permission to run tool denied by user (${u.reason})\u3002\u8BF7\u52FF\u5C1D\u8BD5\u7528\u5176\u4ED6\u65B9\u5F0F\u4FEE\u6539\u540C\u4E00\u4E2A\u6587\u4EF6\u6216\u7ED5\u8FC7\u6B64\u51B3\u5B9A\uFF1B\u5982\u9700\u7EE7\u7EED\uFF0C\u8BF7\u5148\u4E0E\u7528\u6237\u786E\u8BA4\u3002`:"Permission to run tool denied by user\u3002\u8BF7\u52FF\u5C1D\u8BD5\u7528\u5176\u4ED6\u65B9\u5F0F\u4FEE\u6539\u540C\u4E00\u4E2A\u6587\u4EF6\u6216\u7ED5\u8FC7\u6B64\u51B3\u5B9A\uFF1B\u5982\u9700\u7EE7\u7EED\uFF0C\u8BF7\u5148\u4E0E\u7528\u6237\u786E\u8BA4\u3002";return{item:{name:n,callId:t.id,result:{success:!1,data:d,error:"GATE_DENIED",...u?{denial:u}:{}}},record:{name:n,success:!1,error:"GATE_DENIED",timestamp:r}}}if(!Qn(o.kind)){let u=o.preview;if(typeof u=="function")try{await u(i,this.#r)}catch{}}try{let u=await this.#d(o,i);if(a&&a.length>0){let m=a.map(f=>` - ${f.message}`).join(`
|
|
486
486
|
`),h=u.success?"[schema \u8B66\u544A]":"[schema \u95EE\u9898]";u={...u,data:`${u.data}
|
|
487
487
|
|
|
488
488
|
${h} \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A
|
|
489
|
-
${m}`,issues:a}}let d={name:n,success:u.success,error:u.error,timestamp:r,...a?{issues:a}:{}};return{item:{name:n,callId:t.id,result:u},record:d}}catch(u){let d=u instanceof Error?u.message:String(u),m={success:!1,data:`\u5DE5\u5177 "${n}" \u6267\u884C\u5F02\u5E38\uFF1A${d}`,error:"EXECUTION_ERROR"};return{item:{name:n,callId:t.id,result:m},record:{name:n,success:!1,error:"EXECUTION_ERROR",timestamp:r}}}}async#
|
|
489
|
+
${m}`,issues:a}}let d={name:n,success:u.success,error:u.error,timestamp:r,...a?{issues:a}:{}};return{item:{name:n,callId:t.id,result:u},record:d}}catch(u){let d=u instanceof Error?u.message:String(u),m={success:!1,data:`\u5DE5\u5177 "${n}" \u6267\u884C\u5F02\u5E38\uFF1A${d}`,error:"EXECUTION_ERROR"};return{item:{name:n,callId:t.id,result:m},record:{name:n,success:!1,error:"EXECUTION_ERROR",timestamp:r}}}}async#d(t,n){return t.execute(n,this.#r)}};p();var pi=class{#e;constructor(t={}){this.#e=t.threshold??3}shouldBreak(t,n){if(t.length<this.#e)return!1;let r=t.slice(-this.#e);if(r.length<this.#e)return!1;let o=r[0];return r.every(i=>i.name===o.name&&i.error===o.error&&!i.success)?n.some(i=>i.name===o.name):!1}};p();var fi=class{#e;#n;#r;constructor(t={}){this.#e=t.repeatThreshold??2,this.#n=t.maxReflections??5,this.#r=t.maxHintChars??800}analyze(t,n){let r=[];for(let o of t){if(o.result.success)continue;let s=this.#s(o)??this.#t(o)??this.#c(o)??this.#p(o)??this.#i(o,n.writeRoots)??this.#o(o);if(s&&r.push(s),r.length>=this.#n)break}return r}injectIntoPrompt(t,n){if(n.length===0)return t;let o=["## \u26A0\uFE0F \u4E0A\u4E00\u8F6E\u5DE5\u5177\u8C03\u7528\u7684\u53CD\u601D","\u4EE5\u4E0B\u662F\u672C\u8F6E\u5DE5\u5177\u6267\u884C\u5931\u8D25\u7684\u539F\u56E0\u5206\u6790\u3002\u8BF7\u5728\u4E0B\u4E00\u6B21\u8C03\u7528\u524D\u5148\u89E3\u51B3\u8FD9\u4E9B\u95EE\u9898\uFF0C\u4E0D\u8981\u91CD\u590D\u76F8\u540C\u7684\u9519\u8BEF\u8C03\u7528\u3002",...n.map(s=>{let i=this.#d(s.hint);return`- \u5DE5\u5177 \`${s.toolName}\` \u5931\u8D25\uFF1A${i}`})].join(`
|
|
490
490
|
`);return t+`
|
|
491
491
|
|
|
492
|
-
`+o}#
|
|
493
|
-
`)}#r(t){return this.#e.find(n=>n.id===t)}#
|
|
492
|
+
`+o}#s(t){let n=t.recentSameTool;if(n.length<this.#e)return null;let r=n.slice(-this.#e),o=r[0];if(!r.every(i=>!i.success&&i.error===o.error))return null;let s=o.error??"\u672A\u77E5\u9519\u8BEF";return{category:"repeated_failure",toolName:t.name,hint:`\u4F60\u5DF2\u8FDE\u7EED ${this.#e} \u6B21\u8C03\u7528 \`${t.name}\` \u5931\u8D25\uFF08\u9519\u8BEF\uFF1A${s}\uFF09\u3002\u8BF7\u5148 \`read_file\` \u770B\u6E05\u73B0\u573A\u6216\u6362\u5176\u4ED6\u5DE5\u5177\uFF0C\u4E0D\u8981\u7EE7\u7EED\u540C\u6837\u7684\u9519\u8BEF\u8C03\u7528\u3002`}}#t(t){let n=t.result.error==="TOOL_NOT_FOUND",r=t.result.data??"",o=r.includes("ENOENT")||r.includes("No such file")||/\bnot found\b/i.test(r);return!n&&!o?null:{category:"file_not_found",toolName:t.name,hint:`\`${t.name}\` \u5931\u8D25\uFF1A\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\u8BF7\u5148\u7528 \`ls\` / \`glob\` \u770B\u4E00\u4E0B\u76EE\u5F55\u7ED3\u6784\uFF0C\u6216\u786E\u8BA4\u8DEF\u5F84\u62FC\u5199\uFF08\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u89C1 system prompt\uFF09\u3002`}}#c(t){if(!(t.result.error==="TEXT_NOT_FOUND"||t.result.error==="TEXT_MULTIPLE_MATCHES"))return null;let o=t.result.error==="TEXT_MULTIPLE_MATCHES"?`\`${t.name}\`\uFF1Aold_text \u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\u3002\u8BF7\u8865\u5145\u4E0A\u4E0B\u6587\u8BA9 old_text \u552F\u4E00\uFF0C\u6216\u6539\u7528 multi_edit \u7684 replaceAll\u3002`:`\`${t.name}\`\uFF1A\u672A\u627E\u5230 old_text\u3002\u8BF7\u91CD\u65B0 \`read_file\` \u770B\u5F53\u524D\u5185\u5BB9\uFF0C\u9010\u5B57\u590D\u5236\u8981\u66FF\u6362\u7684\u7247\u6BB5\uFF08\u6CE8\u610F\u7F29\u8FDB\u4E0E\u7A7A\u683C\uFF09\uFF1B\u884C\u5C3E\u5DF2\u505A CRLF \u5F52\u4E00\u5316\uFF0C\u65E0\u9700\u624B\u5199 \\r\\n\u3002`;return{category:"text_not_found",toolName:t.name,hint:o}}#p(t){let n=t.result.error==="GATE_DENIED",r=t.result.data??"",o=r.includes("EACCES")||/\bpermission\b/i.test(r)||/\bdenied\b/i.test(r);return!n&&!o?null:{category:"permission_denied",toolName:t.name,hint:`\`${t.name}\` \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\u3002\u8BF7\u68C0\u67E5\uFF1A1) \u8DEF\u5F84\u662F\u5426\u5728\u5141\u8BB8\u6839\u76EE\u5F55\u5185\uFF1B2) \u662F\u5426\u9700\u8981\u5207\u6362\u6388\u6743\u6A21\u5F0F\uFF1B3) \u6539\u7528\u5176\u4ED6\u4E0D\u9700\u8981\u6743\u9650\u7684\u5DE5\u5177\u3002`}}#i(t,n){if(!(t.kind==="edit"||t.kind==="delete"||t.kind==="move")||t.result.error!=="OUTSIDE_WRITE_ROOTS")return null;let o=n[0]??"<\u672A\u914D\u7F6E>";return{category:"out_of_write_root",toolName:t.name,hint:`\`${t.name}\` \u662F\u5199\u64CD\u4F5C\u4F46\u76EE\u6807\u8DEF\u5F84\u4E0D\u5728\u5141\u8BB8\u7684\u6839\u76EE\u5F55\u5185\u3002\u8BF7\u6539\u7528 \`${o}\` \u4E0B\u7684\u8DEF\u5F84\uFF0C\u6216\u8C03\u6574\u9879\u76EE\u7684 \`writeRoots\` \u914D\u7F6E\u3002`}}#d(t){return t.length<=this.#r?t:t.slice(0,this.#r-3)+"..."}#o(t){let n=t.result.issues;if(!n||n.length===0)return null;let r=n.slice(0,3).map(s=>s.message).join("; "),o=n.length>3?`\uFF08\u53E6\u6709 ${n.length-3} \u6761\uFF09`:"";return{category:"invalid_args",toolName:t.name,hint:`\`${t.name}\` \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A${r}${o}\u3002\u8BF7\u68C0\u67E5\u5FC5\u586B\u5B57\u6BB5\u3001\u7C7B\u578B\u4E0E enum \u767D\u540D\u5355\u3002`}}};p();function jm(e,t){return(t==="plan"?e.listReadTools():e.list()).map(r=>({type:"function",function:{name:r.name,description:r.description,parameters:r.parameters}}))}p();var mi=class{#e=[];#n=0;add(t,n=[]){for(let o of n)if(!this.#e.find(s=>s.id===o))throw new Error(`todo \u4F9D\u8D56 #${o} \u4E0D\u5B58\u5728\uFF08\u5DF2\u5206\u914D\u7684 id: ${this.#e.map(s=>s.id).join(", ")||"(\u7A7A)"}\uFF09`);let r=this.#n++;return this.#e.push({id:r,content:t,status:"pending",deps:[...n],updatedAt:Date.now()}),r}resetForRetry(t){let n=this.#r(t);return!n||n.status!=="failed"?!1:(n.status="pending",n.evidence=void 0,n.updatedAt=Date.now(),!0)}markRunning(t){let n=this.#r(t);return!n||n.status!=="pending"||!this.#s(n.deps)?!1:(n.status="running",n.updatedAt=Date.now(),!0)}markDone(t,n){let r=this.#r(t);return!r||r.status!=="running"&&r.status!=="pending"?!1:(r.status="done",n!==void 0&&(r.evidence=n),r.updatedAt=Date.now(),!0)}markFailed(t,n){let r=this.#r(t);return!r||r.status==="done"?!1:(r.status="failed",r.evidence=n,r.updatedAt=Date.now(),!0)}markSkipped(t,n){let r=this.#r(t);return!r||r.status==="done"||r.status==="failed"?!1:(r.status="skipped",r.evidence=n,r.updatedAt=Date.now(),!0)}pending(){return this.#e.filter(t=>t.status==="pending"&&this.#s(t.deps))}unfinished(){return this.#e.filter(t=>t.status==="pending"||t.status==="running"||t.status==="failed")}isAllTerminated(){return this.#e.every(t=>t.status==="done"||t.status==="failed"||t.status==="skipped")}get items(){return this.#e.map(t=>({...t}))}toMarkdown(t=20){if(this.#e.length===0)return"";let n=this.#e.filter(l=>l.status==="pending"||l.status==="running"||l.status==="failed"),o=[...this.#e.filter(l=>l.status==="done"||l.status==="skipped")].sort((l,c)=>c.updatedAt-l.updatedAt),s=o.length>t,i=s?o.slice(0,Math.max(0,t-n.length)):o,a=[...n,...i].map(l=>{let c=this.#t(l.status),u=l.deps.length>0?` (\u4F9D\u8D56: #${l.deps.join(", #")})`:"",d=l.evidence?` \u2014 ${l.evidence}`:"";return`- ${c} #${l.id} ${l.content}${u}${d}`});if(s){let l=o.length-i.length;a.push(`- ...\uFF08\u53E6\u6709 ${l} \u6761\u5DF2\u5B8C\u6210\u5DF2\u6298\u53E0\uFF09`)}return["## \u{1F4CB} \u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6",...a,"","\u89C4\u5219\uFF1A\u6309\u987A\u5E8F\u63A8\u8FDB\uFF1B\u672A\u5B8C\u6210\u4F9D\u8D56\u65F6\u4E0D\u8981\u8DF3\u6B65\uFF1B\u5B8C\u6210\u8BF7\u8C03\u7528 todo_mark_done\uFF0C\u5931\u8D25\u8BF7\u8C03\u7528 todo_mark_failed\uFF1B\u91CD\u8BD5\u5931\u8D25\u9879\u5148\u8C03 todo_retry \u518D\u91CD\u8DD1\u3002"].join(`
|
|
493
|
+
`)}#r(t){return this.#e.find(n=>n.id===t)}#s(t){return t.every(n=>{let r=this.#e.find(o=>o.id===n);return r?.status==="done"||r?.status==="skipped"})}#t(t){switch(t){case"pending":return"\u2610";case"running":return"\u25B6";case"done":return"\u2705";case"failed":return"\u274C";case"skipped":return"\u23ED"}}};p();function Um(e){return[Q0(e),eS(e),tS(e),nS(e),rS(e)]}function Q0(e){return{name:"todo_add",kind:"other",description:`\u26A0\uFE0F \u3010\u590D\u6742\u4EFB\u52A1\u7B2C\u4E00\u6B65\u3011\u6DFB\u52A0\u4E00\u4E2A\u5F85\u529E\u5230\u5F53\u524D\u4EFB\u52A1\u8FDB\u5EA6\u3002
|
|
494
494
|
|
|
495
495
|
\u4EC0\u4E48\u60C5\u51B5\u4E0B\u8C03\u6211\uFF1A
|
|
496
496
|
- \u9700\u8981\u591A\u6B65\u624D\u80FD\u5B8C\u6210\uFF08\u6539\u591A\u4E2A\u6587\u4EF6 / \u8DE8\u591A\u8F6E\uFF09
|
|
@@ -502,110 +502,105 @@ ${m}`,issues:a}}let d={name:n,success:u.success,error:u.error,timestamp:r,...a?{
|
|
|
502
502
|
|
|
503
503
|
\u7528\u6CD5\uFF1A\u6BCF\u6B21\u52A0\u4E00\u4E2A step\uFF0C\u591A\u6B65\u5C31\u8C03\u591A\u6B21\u3002\u6709\u4F9D\u8D56\u5173\u7CFB\u4F20 deps=[\u524D\u6B65 id]\u3002\u8FD4\u56DE\u5206\u914D\u7684 id\uFF0C\u540E\u7EED\u7528 todo_mark_done / todo_mark_failed \u5F15\u7528\u3002
|
|
504
504
|
|
|
505
|
-
\u793A\u4F8B\uFF1A\u7528\u6237\u8BF4\u300C\u628A X \u6539\u6210 Y\u300D\u2192 \u8C03 1) todo_add("\u8BFB X") 2) todo_add("\u6539 X", deps=[0]) 3) todo_add("\u68C0\u67E5\u6539\u52A8", deps=[1])`,parameters:{type:"object",properties:{content:{type:"string",description:"\u6B65\u9AA4\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF0C\u5EFA\u8BAE\u7B80\u6D01\uFF09"},deps:{type:"array",description:"\u4F9D\u8D56\u7684 todo id \u6570\u7EC4\uFF08\u8FD9\u4E9B\u90FD done \u540E\u672C\u9879\u624D\u53EF\u6267\u884C\uFF09",items:{type:"number"}}},required:["content"],additionalProperties:!1},async execute(t){if(typeof t?.content!="string"||t.content.length===0)return{success:!1,data:"\u7F3A\u5C11 content \u53C2\u6570",error:"INVALID_ARGS"};let n=Array.isArray(t.deps)?t.deps.filter(r=>typeof r=="number"):[];try{let r=e.add(t.content,n);return{success:!0,data:`\u5DF2\u6DFB\u52A0 todo #${r}\uFF1A${t.content}${n.length>0?`\uFF08\u4F9D\u8D56: ${n.join(", ")})`:""}`,summary:`\u{1F4CB} \u6DFB\u52A0 #${r}`}}catch(r){return{success:!1,data:r instanceof Error?r.message:String(r),error:"TODO_DEPS_INVALID"}}}}}function
|
|
505
|
+
\u793A\u4F8B\uFF1A\u7528\u6237\u8BF4\u300C\u628A X \u6539\u6210 Y\u300D\u2192 \u8C03 1) todo_add("\u8BFB X") 2) todo_add("\u6539 X", deps=[0]) 3) todo_add("\u68C0\u67E5\u6539\u52A8", deps=[1])`,parameters:{type:"object",properties:{content:{type:"string",description:"\u6B65\u9AA4\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF0C\u5EFA\u8BAE\u7B80\u6D01\uFF09"},deps:{type:"array",description:"\u4F9D\u8D56\u7684 todo id \u6570\u7EC4\uFF08\u8FD9\u4E9B\u90FD done \u540E\u672C\u9879\u624D\u53EF\u6267\u884C\uFF09",items:{type:"number"}}},required:["content"],additionalProperties:!1},async execute(t){if(typeof t?.content!="string"||t.content.length===0)return{success:!1,data:"\u7F3A\u5C11 content \u53C2\u6570",error:"INVALID_ARGS"};let n=Array.isArray(t.deps)?t.deps.filter(r=>typeof r=="number"):[];try{let r=e.add(t.content,n);return{success:!0,data:`\u5DF2\u6DFB\u52A0 todo #${r}\uFF1A${t.content}${n.length>0?`\uFF08\u4F9D\u8D56: ${n.join(", ")})`:""}`,summary:`\u{1F4CB} \u6DFB\u52A0 #${r}`}}catch(r){return{success:!1,data:r instanceof Error?r.message:String(r),error:"TODO_DEPS_INVALID"}}}}}function eS(e){return{name:"todo_mark_running",kind:"other",description:`\u628A todo \u4ECE pending \u63A8\u8FDB\u5230 running\uFF0C\u8868\u793A\u4F60\u300C\u6B63\u5728\u505A\u300D\u8FD9\u4E00\u6B65\u3002
|
|
506
506
|
\u524D\u63D0\uFF1A\u8BE5 todo \u5B58\u5728\u3001\u5F53\u524D\u662F pending\u3001\u4E14\u6240\u6709 deps \u5DF2 done \u6216 skipped\u3002
|
|
507
507
|
\u5DE5\u4F5C\u6D41\uFF1A\u5148\u8C03 todo_mark_running\uFF0C\u518D\u53BB\u8C03\u5B9E\u9645\u7684\u5DE5\u5177\uFF08read_file / edit_file \u7B49\uFF09\uFF0C\u6700\u540E\u7528 todo_mark_done \u6216 todo_mark_failed \u6536\u5C3E\u3002
|
|
508
|
-
**\u4E0D\u8981\u8DF3\u8FC7 mark_running \u76F4\u63A5 mark_done** \u2014 \u4F1A\u7834\u574F\u4F9D\u8D56\u68C0\u67E5\uFF0C\u4E0B\u6E38\u6B65\u9AA4\u53EF\u80FD\u8BEF\u4EE5\u4E3A\u4F9D\u8D56\u5DF2\u6EE1\u8DB3\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="pending"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 pending \u53EF\u4EE5\u63A8\u8FDB\u5230 running`,error:"TODO_INVALID_STATE"}:e.markRunning(t.id)?{success:!0,data:`\u5DF2\u5F00\u59CB todo #${t.id}\uFF1A${n.content}`,summary:`\u25B6 \u5F00\u59CB #${t.id}`}:{success:!1,data:`todo #${t.id} \u4F9D\u8D56\u672A\u5168\u90E8\u5B8C\u6210\uFF08\u4F9D\u8D56: #${n.deps.join(", #")}\uFF09`,error:"TODO_DEPS_NOT_READY"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function
|
|
509
|
-
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},evidence:{type:"string",description:"\u5B8C\u6210\u8BC1\u636E\uFF08\u4E00\u53E5\u8BDD\uFF0C\u53EF\u9009\uFF09"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_done\uFF1B\u5982\u9700\u91CD\u8BD5\u8BF7\u5148 todo_retry`,error:"TODO_INVALID_STATE"}:e.markDone(t.id,t.evidence)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5B8C\u6210${t.evidence?`\uFF1A${t.evidence}`:""}`,summary:`\u2705 \u5B8C\u6210 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function
|
|
508
|
+
**\u4E0D\u8981\u8DF3\u8FC7 mark_running \u76F4\u63A5 mark_done** \u2014 \u4F1A\u7834\u574F\u4F9D\u8D56\u68C0\u67E5\uFF0C\u4E0B\u6E38\u6B65\u9AA4\u53EF\u80FD\u8BEF\u4EE5\u4E3A\u4F9D\u8D56\u5DF2\u6EE1\u8DB3\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="pending"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 pending \u53EF\u4EE5\u63A8\u8FDB\u5230 running`,error:"TODO_INVALID_STATE"}:e.markRunning(t.id)?{success:!0,data:`\u5DF2\u5F00\u59CB todo #${t.id}\uFF1A${n.content}`,summary:`\u25B6 \u5F00\u59CB #${t.id}`}:{success:!1,data:`todo #${t.id} \u4F9D\u8D56\u672A\u5168\u90E8\u5B8C\u6210\uFF08\u4F9D\u8D56: #${n.deps.join(", #")}\uFF09`,error:"TODO_DEPS_NOT_READY"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function tS(e){return{name:"todo_mark_done",kind:"other",description:`\u628A todo \u6807\u8BB0\u4E3A\u5B8C\u6210\u3002evidence \u586B\u300C\u5B8C\u6210\u8BC1\u636E\u300D\uFF08\u5982\u300C\u8BFB\u5230 120 \u884C\u300D\u3001\u300Ctypecheck \u901A\u8FC7\u300D\u3001\u300Cedit \u6210\u529F\u300D\uFF09\uFF0C\u4E0D\u586B\u4E5F\u884C\u3002
|
|
509
|
+
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},evidence:{type:"string",description:"\u5B8C\u6210\u8BC1\u636E\uFF08\u4E00\u53E5\u8BDD\uFF0C\u53EF\u9009\uFF09"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_done\uFF1B\u5982\u9700\u91CD\u8BD5\u8BF7\u5148 todo_retry`,error:"TODO_INVALID_STATE"}:e.markDone(t.id,t.evidence)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5B8C\u6210${t.evidence?`\uFF1A${t.evidence}`:""}`,summary:`\u2705 \u5B8C\u6210 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function nS(e){return{name:"todo_mark_failed",kind:"other",description:`\u628A todo \u6807\u8BB0\u4E3A\u5931\u8D25\uFF0Creason \u586B\u300C\u5931\u8D25\u539F\u56E0\u300D\uFF08\u5982\u300Cold_text \u62FC\u9519\u300D\u3001\u300C\u6587\u4EF6\u4E0D\u5B58\u5728\u300D\uFF09\u3002
|
|
510
510
|
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002
|
|
511
|
-
\u8C03\u7528\u540E\u8BE5 step \u72B6\u6001\u53D8\u4E3A failed\u3002\u60F3\u91CD\u8BD5\uFF1A\u8C03 todo_retry(id) \u91CD\u7F6E\u56DE pending\uFF0C\u518D mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 mark_done\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},reason:{type:"string",description:"\u5931\u8D25\u539F\u56E0\uFF08\u4E00\u53E5\u8BDD\uFF09"}},required:["id","reason"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};if(typeof t?.reason!="string")return{success:!1,data:"\u7F3A\u5C11 reason \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_failed`,error:"TODO_INVALID_STATE"}:e.markFailed(t.id,t.reason)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5931\u8D25\uFF1A${t.reason}`,summary:`\u274C \u5931\u8D25 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function
|
|
512
|
-
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F failed\u3002done / skipped / running \u4E0D\u5141\u8BB8\u91CD\u8BD5\uFF08done \u4E0D\u53EF\u53CD\u6094\u3001running \u5E94\u5148 mark_failed\uFF09\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="failed"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 failed \u53EF\u4EE5\u91CD\u8BD5`,error:"TODO_INVALID_STATE"}:e.resetForRetry(t.id)?{success:!0,data:`\u5DF2\u91CD\u7F6E todo #${t.id} \u4E3A pending\uFF0C\u53EF\u91CD\u65B0\u8DD1`,summary:`\u{1F504} \u91CD\u8BD5 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}p();p();import{execFile as
|
|
513
|
-
`).map(n=>n.trim()).filter(Boolean)}async function
|
|
511
|
+
\u8C03\u7528\u540E\u8BE5 step \u72B6\u6001\u53D8\u4E3A failed\u3002\u60F3\u91CD\u8BD5\uFF1A\u8C03 todo_retry(id) \u91CD\u7F6E\u56DE pending\uFF0C\u518D mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 mark_done\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"},reason:{type:"string",description:"\u5931\u8D25\u539F\u56E0\uFF08\u4E00\u53E5\u8BDD\uFF09"}},required:["id","reason"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};if(typeof t?.reason!="string")return{success:!1,data:"\u7F3A\u5C11 reason \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="running"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 running \u53EF\u4EE5 mark_failed`,error:"TODO_INVALID_STATE"}:e.markFailed(t.id,t.reason)?{success:!0,data:`\u5DF2\u6807\u8BB0 todo #${t.id} \u5931\u8D25\uFF1A${t.reason}`,summary:`\u274C \u5931\u8D25 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}function rS(e){return{name:"todo_retry",kind:"other",description:`\u628A\u5931\u8D25\u7684 todo \u91CD\u7F6E\u56DE pending\uFF08\u6E05\u7A7A evidence\uFF09\uFF0C\u7136\u540E\u4F60\u53EF\u4EE5\u91CD\u65B0\u8D70 todo_mark_running \u2192 \u8DD1\u5DE5\u5177 \u2192 todo_mark_done \u7684\u6D41\u7A0B\u3002
|
|
512
|
+
\u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F failed\u3002done / skipped / running \u4E0D\u5141\u8BB8\u91CD\u8BD5\uFF08done \u4E0D\u53EF\u53CD\u6094\u3001running \u5E94\u5148 mark_failed\uFF09\u3002`,parameters:{type:"object",properties:{id:{type:"number",description:"todo \u7684 id"}},required:["id"],additionalProperties:!1},async execute(t){if(typeof t?.id!="number")return{success:!1,data:"\u7F3A\u5C11 id \u53C2\u6570",error:"INVALID_ARGS"};let n=e.items.find(o=>o.id===t.id);return n?n.status!=="failed"?{success:!1,data:`todo #${t.id} \u5F53\u524D\u72B6\u6001\u662F ${n.status}\uFF0C\u53EA\u6709 failed \u53EF\u4EE5\u91CD\u8BD5`,error:"TODO_INVALID_STATE"}:e.resetForRetry(t.id)?{success:!0,data:`\u5DF2\u91CD\u7F6E todo #${t.id} \u4E3A pending\uFF0C\u53EF\u91CD\u65B0\u8DD1`,summary:`\u{1F504} \u91CD\u8BD5 #${t.id}`}:{success:!1,data:`todo #${t.id} \u72B6\u6001\u8F6C\u6362\u5931\u8D25`,error:"TODO_INVALID"}:{success:!1,data:`todo #${t.id} \u4E0D\u5B58\u5728`,error:"TODO_NOT_FOUND"}}}}p();p();import{execFile as oS}from"child_process";import{promisify as sS}from"util";var gi=sS(oS),yi={windowsHide:!0};async function Cc(e){try{return await gi("git",["rev-parse","--is-inside-work-tree"],{cwd:e,...yi}),!0}catch{return!1}}async function Wm(e){try{return await gi("git",["rev-parse","--verify","HEAD"],{cwd:e,...yi}),!0}catch{return!1}}async function iS(e){return(await gi("git",["status","--porcelain"],{cwd:e,...yi})).stdout.trim().length>0}async function It(e,t){try{let{stdout:n}=await gi("git",e,{cwd:t,...yi});return n}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`git ${e.join(" ")} \u5931\u8D25: ${r}`)}}async function hi(e){return(await It(["stash","list","--format=%H"],e)).split(`
|
|
513
|
+
`).map(n=>n.trim()).filter(Boolean)}async function _c(e){let t=Date.now();if(!await Cc(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!1};if(!await Wm(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};if(!await iS(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};let r=await hi(e);await It(["stash","push","-m",`dskcode-cp-${t}`,"-u"],e);let o=await hi(e);if(o.length===0)throw new Error("git stash push \u672A\u80FD\u521B\u5EFA stash entry");let s=o.find(i=>!r.includes(i))??o[0];return await It(["stash","apply",s],e),{stashSha:s,timestamp:t,cwd:e,isGitRepo:!0}}async function vc(e){if(!e.isGitRepo)throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!e.stashSha)throw new Error("\u68C0\u67E5\u70B9\u4E3A\u7A7A\uFF08\u5DE5\u4F5C\u533A\u539F\u672C\u5C31\u5E72\u51C0\uFF09\uFF0C\u65E0\u9700\u6062\u590D");let{cwd:t,stashSha:n}=e,r=await hi(t);if(!r.includes(n))throw new Error("\u68C0\u67E5\u70B9\u5DF2\u5931\u6548\uFF08stash entry \u5DF2\u88AB\u6D88\u8D39\u6216 GC\uFF09\uFF0C\u65E0\u6CD5\u6062\u590D");await It(["checkout","--","."],t),await It(["clean","-fd"],t),await It(["stash","apply",n],t);let o=r.indexOf(n);o>=0&&await It(["stash","drop",`stash@{${o}}`],t)}async function Rc(e){if(!await Cc(e))throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!await Wm(e))throw new Error("\u4ED3\u5E93\u65E0 commit\uFF0C\u65E0\u6CD5\u6062\u590D");await It(["checkout","--","."],e),await It(["clean","-fd"],e)}async function xi(e){if(!e.isGitRepo||!e.stashSha)return;let{cwd:t,stashSha:n}=e,r;try{r=await hi(t)}catch{return}let o=r.indexOf(n);if(!(o<0))try{await It(["stash","drop",`stash@{${o}}`],t)}catch{}}p();p();import{mkdir as aS,readFile as Hm,writeFile as lS,readdir as cS,unlink as uS,rename as dS}from"fs/promises";import{join as xr}from"path";import{randomUUID as pS}from"crypto";function Vm(){let e=process.env.HOME??process.env.USERPROFILE??"~";return xr(e,".dskcode","sessions")}var Gn=class{#e;constructor(t){this.#e=t??Vm()}get dir(){return this.#e}async save(t){await aS(this.#e,{recursive:!0});let n=xr(this.#e,`${t.id}.json`),r=xr(this.#e,`.${t.id}.json.tmp`);await lS(r,JSON.stringify(t,null,2),"utf-8"),await dS(r,n)}async load(t){let n=xr(this.#e,`${t}.json`);try{let r=await Hm(n,"utf-8");return JSON.parse(r)}catch(r){if(Ac(r))return null;throw r}}async list(){let t;try{t=await cS(this.#e)}catch(r){if(Ac(r))return[];throw r}let n=[];for(let r of t)if(!(!r.endsWith(".json")||r.startsWith(".")))try{let o=await Hm(xr(this.#e,r),"utf-8"),s=JSON.parse(o);n.push({id:s.id,title:s.title||"\uFF08\u65E0\u6807\u9898\uFF09",updatedAt:s.updatedAt,cwd:s.cwd,messageCount:s.messages?.length??0})}catch{}return n.sort((r,o)=>o.updatedAt-r.updatedAt)}async delete(t){let n=xr(this.#e,`${t}.json`);try{await uS(n)}catch(r){if(!Ac(r))throw r}}async exists(t){return await this.load(t)!==null}static newId(){return pS()}};function Ac(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}p();p();import{readFile as yS,stat as xS}from"fs/promises";import{open as bS}from"fs/promises";import{relative as wS}from"path";p();import{resolve as To,relative as Km,isAbsolute as fS}from"path";import{realpath as zm}from"fs/promises";import{spawn as mS}from"child_process";import Xm from"process";var Jm=3e4,hS=5e4,ND=10*1024*1024,bi=Xm.platform==="win32";function br(e){return e.startsWith("@")?e.slice(1):e}function Ye(e,t){let n=br(e),r=fS(n)?n:To(t,n);return To(r)}async function qm(e){try{return await zm(e)}catch{let t=To(e,"..");try{let n=await zm(t);return To(n,Km(t,e))}catch{return To(e)}}}async function Vt(e,t){if(e.length===0)return{ok:!0};let n=await qm(t);for(let r of e){let o=await qm(r),s=Km(o,n);if(!s.startsWith("..")&&s!==""&&!s.startsWith("/")&&!s.startsWith("\\"))return{ok:!0};if(n===o)return{ok:!0}}return{ok:!1,error:`\u8DEF\u5F84 "${t}" \u4E0D\u5728\u5141\u8BB8\u7684\u5199\u5165\u8303\u56F4\u5185 ${e.join(", ")}`}}function We(e,t=hS){return e.length<=t?e:`${e.slice(0,t)}
|
|
514
514
|
|
|
515
|
-
... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u5171 ${String(e.length)} \u5B57\u7B26]`}function
|
|
516
|
-
\u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF1A${f.message}`,i({stdout:d,stderr:m,exitCode:null})})})}p();import{writeFile as
|
|
515
|
+
... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u5171 ${String(e.length)} \u5B57\u7B26]`}function Ec(){return Jm}async function Ic(e,t,n,r=Jm,o,s){return new Promise(i=>{let a,l,c;s?(a=e,l=t,c=!1,bi&&a==="cmd"&&l[0]==="/c"&&(l=["/c",`chcp 65001 >nul && ${l[1]??""}`])):(c=!bi,a=bi?"cmd":e,l=bi?["/c",e,...t]:t);let u=mS(a,l,{cwd:n,shell:c,env:{...Xm.env},stdio:["pipe","pipe","pipe"]}),d="",m="";u.stdout.on("data",f=>{d+=f.toString("utf8")}),u.stderr.on("data",f=>{m+=f.toString("utf8")});let h=setTimeout(()=>{u.kill("SIGTERM"),setTimeout(()=>{u.kill("SIGKILL")},5e3)},r);o&&(o.aborted&&u.kill("SIGTERM"),o.addEventListener("abort",()=>{u.kill("SIGTERM")},{once:!0})),u.on("close",f=>{clearTimeout(h),i({stdout:d,stderr:m,exitCode:f})}),u.on("error",f=>{clearTimeout(h),m+=`
|
|
516
|
+
\u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF1A${f.message}`,i({stdout:d,stderr:m,exitCode:null})})})}p();import{writeFile as gS}from"fs/promises";function Zm(e){if(e.length===0)return`
|
|
517
517
|
`;let t=e.indexOf(`\r
|
|
518
518
|
`),n=e.indexOf(`
|
|
519
519
|
`);return t!==-1&&(n===-1||t<=n)?`\r
|
|
520
520
|
`:`
|
|
521
|
-
`}function
|
|
521
|
+
`}function Ym(e){return e.endsWith(`
|
|
522
522
|
`)||e.endsWith(`\r
|
|
523
|
-
`)}function
|
|
523
|
+
`)}function Ge(e){return e.includes("\r")?e.replace(/\r\n/g,`
|
|
524
524
|
`).replace(/\r/g,`
|
|
525
|
-
`):e}function
|
|
525
|
+
`):e}function pn(e,t){let n=Zm(e),r=t.replace(/\r\n/g,`
|
|
526
526
|
`).split(`
|
|
527
|
-
`),o=
|
|
527
|
+
`),o=Ym(e),s=r.length>0&&r[r.length-1]==="",i=r.join(n);return o&&!s&&(i+=n),!o&&s&&i.endsWith(n)&&(i=i.slice(0,-n.length)),i}async function Pc(e,t,n){let r=t.length>0?pn(t,n):n;await gS(e,r,"utf-8")}async function kS(e){let t=await bS(e,"r");try{let n=Buffer.alloc(8192),{bytesRead:r}=await t.read(n,0,8192,0);return n.subarray(0,r).includes(0)}finally{await t.close()}}var Lc={name:"read_file",kind:"read",description:"\u8BFB\u53D6\u6307\u5B9A\u8DEF\u5F84\u7684\u6587\u4EF6\u5185\u5BB9\u3002\u652F\u6301\u884C\u53F7\u8303\u56F4\u9009\u62E9\uFF0C\u8F93\u51FA\u5E26\u884C\u53F7\u3002\u9002\u7528\u4E8E\u67E5\u770B\u6E90\u4EE3\u7801\u3001\u914D\u7F6E\u6587\u4EF6\u7B49\u6587\u672C\u6587\u4EF6\u3002\u81EA\u52A8\u62D2\u7EDD\u4E8C\u8FDB\u5236\u6587\u4EF6\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},startLine:{type:"number",description:"\u8D77\u59CB\u884C\u53F7\uFF08\u4ECE 1 \u5F00\u59CB\uFF09\uFF0C\u9ED8\u8BA4\u4E3A 1"},endLine:{type:"number",description:"\u7ED3\u675F\u884C\u53F7\uFF08\u5305\u542B\uFF09\uFF0C\u9ED8\u8BA4\u5230\u6587\u4EF6\u672B\u5C3E"}},required:["path"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);try{let r=await xS(n),o=10*1024*1024;if(r.size>o)return{success:!1,data:`\u6587\u4EF6\u8FC7\u5927\uFF08${(r.size/1024/1024).toFixed(1)}MB\uFF09\uFF0C\u8D85\u8FC7 10MB \u9650\u5236`,error:"FILE_TOO_LARGE"};if(r.isDirectory())return{success:!1,data:`"${n}" \u662F\u4E00\u4E2A\u76EE\u5F55\uFF0C\u8BF7\u4F7F\u7528 ls \u5DE5\u5177\u67E5\u770B\u76EE\u5F55\u5185\u5BB9`,error:"IS_DIRECTORY"};if(r.size>0&&await kS(n))return{success:!1,data:`"${n}" \u770B\u8D77\u6765\u662F\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u8BFB\u53D6`,error:"BINARY_FILE"};let s=await yS(n,"utf-8"),i=Ge(s).split(`
|
|
528
528
|
`);i.length>0&&i[i.length-1]===""&&s.endsWith(`
|
|
529
|
-
`)&&i.pop();let a=Math.max(1,e.startLine??1)-1,l=e.endLine?Math.min(e.endLine,i.length):i.length,c=i.slice(a,l),u=String(l).length,d=c.map((w
|
|
529
|
+
`)&&i.pop();let a=Math.max(1,e.startLine??1)-1,l=e.endLine?Math.min(e.endLine,i.length):i.length,c=i.slice(a,l),u=String(l).length,d=c.map((b,w)=>`${String(a+w+1).padStart(u," ")}\u2192${b}`).join(`
|
|
530
530
|
`),m=i.length-l,h=m>0?`
|
|
531
531
|
|
|
532
|
-
[\u8FD8\u6709 ${m} \u884C\uFF1B\u4F7F\u7528 startLine=${l+1} \u7EE7\u7EED\u67E5\u770B]`:"",f=
|
|
532
|
+
[\u8FD8\u6709 ${m} \u884C\uFF1B\u4F7F\u7528 startLine=${l+1} \u7EE7\u7EED\u67E5\u770B]`:"",f=wS(t.cwd,n).replace(/\\/g,"/"),g=a>0||l<i.length?`\u7B2C ${a+1}-${l} \u884C`:`${i.length} \u884C`;return{success:!0,data:We(d)+h,summary:`\u{1F4D6} ${f}\uFF08${g}\uFF09`}}catch(r){return{success:!1,data:`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"READ_ERROR"}}}};p();import{mkdir as AS,readFile as ES}from"fs/promises";import{dirname as IS,relative as PS,basename as LS}from"path";p();function wi(e){if(e.length===0)return{lines:[],eol:`
|
|
533
533
|
`,eofStyle:"no-eol"};let t=e.indexOf(`\r
|
|
534
534
|
`),n=e.indexOf(`
|
|
535
535
|
`),r;t!==-1&&(n===-1||t<=n)?r=`\r
|
|
536
536
|
`:r=`
|
|
537
|
-
`;let o=e.split(r),s;return e.endsWith(r)?(o.length>0&&o[o.length-1]===""&&o.pop(),s="lf"):s="no-eol",{lines:o,eol:r,eofStyle:s}}function
|
|
538
|
-
`)}function
|
|
539
|
-
`)}function
|
|
540
|
-
`)}function
|
|
541
|
-
`).length,l=Buffer.byteLength(s,"utf-8"),c=o?"\u5DF2\u4FEE\u6539":"\u5DF2\u521B\u5EFA",u=o?`\uFF0C+${i.additions} -${i.deletions}`:`\uFF0C+${i.additions} \u884C\uFF08\u65B0\u5EFA\uFF09`,d=
|
|
537
|
+
`;let o=e.split(r),s;return e.endsWith(r)?(o.length>0&&o[o.length-1]===""&&o.pop(),s="lf"):s="no-eol",{lines:o,eol:r,eofStyle:s}}function SS(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map(l=>({op:"add",line:l}));if(r===0)return e.map(l=>({op:"remove",line:l}));let o=[],s=n+r,i=new Array(2*s+2).fill(-1),a=s;i[a+1]=0;for(let l=0;l<=s;l++){let c=new Map,u=-l,d=l;for(let m=u;m<=d;m+=2){let h=m+a,f;m===-l||m!==l&&i[h-1]<i[h+1]?f=i[h+1]:f=i[h-1]+1;let g=f-m;for(;f<n&&g<r&&e[f]===t[g];)f++,g++;if(i[h]=f,c.set(m,f),f>=n&&g>=r)return o.push(c),TS(o,n,r,e,t,a)}o.push(c)}return e.map(l=>({op:"remove",line:l})).concat(t.map(l=>({op:"add",line:l})))}function TS(e,t,n,r,o,s){let i=[],a=t,l=n;for(let c=e.length-1;c>=1;c--){let u=a-l,d=e[c-1],m=d.get(u-1),h=d.get(u+1),f;u===-c?f=u+1:u===c?f=u-1:(m??-1)<(h??-1)?f=u+1:f=u-1;let g=d.get(f)??0,b=g-f;if(f===u-1){for(;a>g+1&&l>b;)a--,l--,i.unshift({op:"equal",line:r[a]});a>g&&(a--,i.unshift({op:"remove",line:r[a]}))}else{for(;a>g&&l>b+1;)a--,l--,i.unshift({op:"equal",line:r[a]});l>b&&(l--,i.unshift({op:"add",line:o[l]}))}}for(;a>0&&l>0;)a--,l--,i.unshift({op:"equal",line:r[a]});return i}var $c=3;function CS(e){if(e.length===0)return[];let t=[];for(let o=0;o<e.length;o++)e[o].op!=="equal"&&t.push(o);if(t.length===0)return[];let n=[[t[0]]];for(let o=1;o<t.length;o++){let s=n[n.length-1],i=s[s.length-1],a=t[o],l=0;for(let c=i+1;c<a;c++)e[c].op==="equal"&&l++;l<=2*$c?s.push(a):n.push([a])}let r=[];for(let o of n){let s=o[0],i=o[o.length-1],a=Math.max(0,s-$c),l=Math.min(e.length-1,i+$c),c=e.slice(a,l+1),u=0,d=0;for(let f=0;f<a;f++){let g=e[f];(g.op==="equal"||g.op==="remove")&&u++,(g.op==="equal"||g.op==="add")&&d++}let m=0,h=0;for(let f of c)(f.op==="equal"||f.op==="remove")&&m++,(f.op==="equal"||f.op==="add")&&h++;r.push({oldStart:u+1,oldCount:m,newStart:d+1,newCount:h,lines:c})}return r}function _S(e,t){if(e.length===0)return"";let n=[],r=Oc(t);n.push(`--- a/${r}`),n.push(`+++ b/${r}`);for(let o of e){n.push(`@@ -${String(o.oldStart)},${String(o.oldCount)} +${String(o.newStart)},${String(o.newCount)} @@`);for(let s of o.lines)switch(s.op){case"equal":n.push(` ${s.line}`);break;case"remove":n.push(`-${s.line}`);break;case"add":n.push(`+${s.line}`);break}}return n.join(`
|
|
538
|
+
`)}function vS(e,t){let n=Oc(t),r=[];r.push("--- /dev/null"),r.push(`+++ b/${n}`),r.push(`@@ -0,0 +1,${String(e.length)} @@`);for(let o of e)r.push(`+${o}`);return r.join(`
|
|
539
|
+
`)}function RS(e,t){let n=Oc(t),r=[];r.push(`--- a/${n}`),r.push("+++ /dev/null"),r.push(`@@ -1,${String(e.length)} +0,0 @@`);for(let o of e)r.push(`-${o}`);return r.join(`
|
|
540
|
+
`)}function Oc(e){return e.replace(/\\/g,"/").split("/").pop()??e}function zt(e,t,n){if(e===t)return{filePath:n,patch:"",existedBefore:e.length>0,additions:0,deletions:0};if(e.length===0){let u=wi(t),d=vS(u.lines,n);return{filePath:n,patch:d,existedBefore:!1,additions:u.lines.length,deletions:0}}if(t.length===0){let u=wi(e),d=RS(u.lines,n);return{filePath:n,patch:d,existedBefore:!0,additions:0,deletions:u.lines.length}}let r=wi(e),o=wi(t),s=SS(r.lines,o.lines),i=0,a=0;for(let u of s)u.op==="add"&&i++,u.op==="remove"&&a++;let l=CS(s),c=_S(l,n);return{filePath:n,patch:c,existedBefore:!0,additions:i,deletions:a}}var Dc={name:"write_file",kind:"edit",description:"\u521B\u5EFA\u6216\u8986\u76D6\u6587\u4EF6\u3002\u5982\u679C\u7236\u76EE\u5F55\u4E0D\u5B58\u5728\u4F1A\u81EA\u52A8\u521B\u5EFA\u3002\u9002\u7528\u4E8E\u521B\u5EFA\u65B0\u6587\u4EF6\u6216\u5B8C\u5168\u66FF\u6362\u6587\u4EF6\u5185\u5BB9\u3002\u8BF7\u52FF\u7528\u6B64\u5DE5\u5177\u521B\u5EFA _temp_\u3001_debug_ \u7B49\u7528\u4E8E\u8BCA\u65AD/\u8C03\u8BD5\u7684\u4E34\u65F6\u6587\u4EF6\u2014\u2014\u5982\u9700\u8BCA\u65AD\u8BF7\u6539\u7528 bash \u5DE5\u5177\u5185\u8054\u811A\u672C\uFF08node -e\uFF09\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},content:{type:"string",description:"\u8981\u5199\u5165\u7684\u6587\u4EF6\u5185\u5BB9"}},required:["path","content"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(e.content===void 0||e.content===null)return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 content",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);try{if(t.writeRoots&&t.writeRoots.length>0){let h=await Vt(t.writeRoots,n);if(!h.ok)return{success:!1,data:h.error,error:"OUTSIDE_WRITE_ROOTS"}}let r="",o=!1;try{r=await ES(n,"utf-8"),o=!0}catch{}await AS(IS(n),{recursive:!0});let s=e.content;await Pc(n,r,s);let i=zt(r,s,n);i.existedBefore=o;let a=s.split(`
|
|
541
|
+
`).length,l=Buffer.byteLength(s,"utf-8"),c=o?"\u5DF2\u4FEE\u6539":"\u5DF2\u521B\u5EFA",u=o?`\uFF0C+${i.additions} -${i.deletions}`:`\uFF0C+${i.additions} \u884C\uFF08\u65B0\u5EFA\uFF09`,d=LS(n),m=o?`\u{1F4DD} \u4FEE\u6539: ${d} (+${i.additions} -${i.deletions})`:`\u{1F4DD} \u65B0\u5EFA: ${d} (+${i.additions} \u884C)`;return{success:!0,data:`\u6587\u4EF6${c}\uFF1A${PS(t.cwd,n).replace(/\\/g,"/")}\uFF08${a} \u884C\uFF0C${l} \u5B57\u8282${u}\uFF09`,summary:m,diff:i}}catch(r){return{success:!1,data:`\u5199\u5165\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"WRITE_ERROR"}}}};p();import{readFile as $S}from"fs/promises";import{writeFile as OS}from"fs/promises";import{basename as DS}from"path";var Nc={name:"edit_file",kind:"edit",description:"\u5BF9\u6587\u4EF6\u8FDB\u884C\u7CBE\u786E\u5B57\u7B26\u4E32\u66FF\u6362\u3002\u67E5\u627E\u6587\u4EF6\u4E2D\u7684 old_text \u5E76\u66FF\u6362\u4E3A new_text\u3002\u5982\u679C old_text \u51FA\u73B0\u591A\u6B21\u6216\u672A\u627E\u5230\u5219\u62A5\u9519\u3002\u9002\u7528\u4E8E\u5C0F\u8303\u56F4\u7CBE\u786E\u4FEE\u6539\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},old_text:{type:"string",description:"\u8981\u67E5\u627E\u7684\u539F\u59CB\u6587\u672C\uFF08\u7CBE\u786E\u5339\u914D\uFF09"},new_text:{type:"string",description:"\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"}},required:["path","old_text","new_text"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(typeof e.old_text!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 old_text",error:"INVALID_ARGS"};if(typeof e.new_text!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 new_text",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await Vt(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await $S(n,"utf-8"),o=Ge(r),s=Ge(e.old_text),i=o.indexOf(s);if(i===-1)return{success:!1,data:"\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\u3002\u8BF7\u786E\u8BA4 old_text \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF08\u5305\u62EC\u7F29\u8FDB\u548C\u7A7A\u683C\uFF09\u3002",error:"TEXT_NOT_FOUND"};if(o.indexOf(s,i+1)!==-1)return{success:!1,data:"\u8981\u66FF\u6362\u7684\u6587\u672C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\uFF0C\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4EE5\u7CBE\u786E\u5B9A\u4F4D\u3002",error:"TEXT_MULTIPLE_MATCHES"};let l=o.slice(0,i)+Ge(e.new_text)+o.slice(i+s.length),c=pn(r,l);await OS(n,c,"utf-8");let u=zt(r,c,n);u.existedBefore=!0;let m=o.slice(0,i).split(`
|
|
542
542
|
`).length,h=s.split(`
|
|
543
|
-
`).length,f=
|
|
544
|
-
`).length,g=`+${u.additions} -${u.deletions}`,
|
|
543
|
+
`).length,f=Ge(e.new_text).split(`
|
|
544
|
+
`).length,g=`+${u.additions} -${u.deletions}`,b=`\u{1F4DD} \u4FEE\u6539: ${DS(n)} (+${u.additions} -${u.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
|
|
545
545
|
\u66FF\u6362\u4F4D\u7F6E\uFF1A\u7B2C ${m} \u884C
|
|
546
546
|
${h} \u884C \u2192 ${f} \u884C
|
|
547
|
-
\u53D8\u66F4\uFF1A${g}`,summary:
|
|
547
|
+
\u53D8\u66F4\uFF1A${g}`,summary:b,diff:u}}catch(r){return{success:!1,data:`\u7F16\u8F91\u6587\u4EF6\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"EDIT_ERROR"}}}};p();import{readFile as NS}from"fs/promises";import{writeFile as MS}from"fs/promises";import{basename as BS}from"path";var Mc={name:"multi_edit",kind:"edit",description:"\u5BF9\u6587\u4EF6\u8FDB\u884C\u539F\u5B50\u6279\u91CF\u66FF\u6362\u7F16\u8F91\u3002\u5728\u4E00\u4E2A\u8BF7\u6C42\u4E2D\u6267\u884C\u591A\u4E2A\u7CBE\u786E\u66FF\u6362\uFF0C\u4EFB\u4E00\u5931\u8D25\u5219\u5168\u90E8\u56DE\u6EDA\u3002\u652F\u6301 replaceAll \u53C2\u6570\u505A\u5168\u5C40\u66FF\u6362\u3002\u9002\u7528\u4E8E\u9700\u8981\u540C\u65F6\u4FEE\u6539\u6587\u4EF6\u591A\u5904\u7684\u573A\u666F\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},edits:{type:"array",description:"\u6709\u5E8F\u7684\u7F16\u8F91\u6B65\u9AA4\u5217\u8868\u3002\u6BCF\u4E2A\u6B65\u9AA4\u5305\u542B oldText\uFF08\u7CBE\u786E\u5339\u914D\uFF09\u3001newText\uFF08\u66FF\u6362\u5185\u5BB9\uFF09\u548C\u53EF\u9009\u7684 replaceAll\uFF08\u662F\u5426\u66FF\u6362\u6240\u6709\u5339\u914D\u9879\uFF09",items:{type:"object",properties:{oldText:{type:"string",description:"\u8981\u67E5\u627E\u7684\u539F\u59CB\u6587\u672C\uFF08\u7CBE\u786E\u5339\u914D\uFF09"},newText:{type:"string",description:"\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"},replaceAll:{type:"boolean",description:"\u662F\u5426\u66FF\u6362\u6240\u6709\u5339\u914D\u9879\uFF0C\u9ED8\u8BA4 false"}},required:["oldText","newText"],additionalProperties:!1}}},required:["path","edits"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(!Array.isArray(e.edits)||e.edits.length===0)return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 edits\uFF08\u975E\u7A7A\u6570\u7EC4\uFF09",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await Vt(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await NS(n,"utf-8"),o=Ge(r);for(let a=0;a<e.edits.length;a++){let l=e.edits[a];if(typeof l.oldText!="string")return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u7F3A\u5C11\u6709\u6548\u7684 oldText`,error:"INVALID_STEP_ARGS"};if(typeof l.newText!="string")return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u7F3A\u5C11\u6709\u6548\u7684 newText`,error:"INVALID_STEP_ARGS"};let c=Ge(l.oldText),u=Ge(l.newText);if(l.replaceAll){let d=0,m=-1;for(;(m=o.indexOf(c,m+1))!==-1;)d++;if(d===0)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\uFF0C\u8BF7\u786E\u8BA4 oldText \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4`,error:"TEXT_NOT_FOUND"};o=o.split(c).join(u)}else{let d=o.indexOf(c);if(d===-1)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u6587\u672C\u3002\u8BF7\u786E\u8BA4 oldText \u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF08\u5305\u62EC\u7F29\u8FDB\u548C\u7A7A\u683C\uFF09\u3002`,error:"TEXT_NOT_FOUND"};if(o.indexOf(c,d+1)!==-1)return{success:!1,data:`\u7B2C ${a+1} \u6B65\uFF1A\u8981\u66FF\u6362\u7684\u6587\u672C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0\u591A\u6B21\uFF0C\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4EE5\u7CBE\u786E\u5B9A\u4F4D\uFF0C\u6216\u8BBE\u7F6E replaceAll=true`,error:"TEXT_MULTIPLE_MATCHES"};o=o.slice(0,d)+u+o.slice(d+c.length)}}let s=pn(r,o);await MS(n,s,"utf-8");let i=zt(r,s,n);return i.existedBefore=!0,{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
|
|
548
548
|
\u5171\u6267\u884C ${e.edits.length} \u6B65\u66FF\u6362
|
|
549
|
-
\u53D8\u66F4\uFF1A+${i.additions} -${i.deletions}`,summary:`\u{1F4DD} \u4FEE\u6539: ${
|
|
550
|
-
`),i=
|
|
551
|
-
`),f=
|
|
552
|
-
\u5220\u9664\u884C\u8303\u56F4\uFF1A\u7B2C ${u+1} \u884C ~ \u7B2C ${d+1} \u884C\uFF08\u5171 ${
|
|
553
|
-
\u53D8\u66F4\uFF1A+${g.additions} -${g.deletions}`,summary:
|
|
554
|
-
${
|
|
549
|
+
\u53D8\u66F4\uFF1A+${i.additions} -${i.deletions}`,summary:`\u{1F4DD} \u4FEE\u6539: ${BS(n)} (${e.edits.length} \u6B65, +${i.additions} -${i.deletions})`,diff:i}}catch(r){return{success:!1,data:`\u6279\u91CF\u7F16\u8F91\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"MULTI_EDIT_ERROR"}}}};p();import{readFile as FS}from"fs/promises";import{writeFile as GS}from"fs/promises";import{basename as jS}from"path";function Qm(e,t,n){let r=Ge(t),o=[];for(let s=0;s<e.length;s++)Ge(e[s])===r&&o.push(s);return o.length===0?{error:`\u672A\u627E\u5230 "${n}" \u951A\u70B9\u884C\uFF0C\u8BF7\u786E\u8BA4\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4`}:o.length>1?{error:`"${n}" \u951A\u70B9\u884C\u5728\u6587\u4EF6\u4E2D\u51FA\u73B0 ${o.length} \u6B21\uFF0C\u8BF7\u4F7F\u7528\u66F4\u552F\u4E00\u7684\u884C\u5185\u5BB9`}:{line:o[0]}}var Bc={name:"delete_range",kind:"edit",description:"\u5220\u9664\u6587\u4EF6\u4E2D\u4E24\u4E2A\u951A\u70B9\u884C\u4E4B\u95F4\u7684\u5185\u5BB9\u3002\u901A\u8FC7\u4E24\u4E2A\u552F\u4E00\u7684\u884C\u5185\u5BB9\u7CBE\u786E\u5B9A\u4F4D\u8303\u56F4\u3002\u9002\u7528\u4E8E\u5220\u9664\u65B9\u6CD5\u3001\u4EE3\u7801\u5757\u3001\u914D\u7F6E\u6BB5\u7B49\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09"},startAnchor:{type:"string",description:"\u5220\u9664\u8303\u56F4\u7684\u8D77\u59CB\u6807\u8BB0\u884C\u5185\u5BB9\uFF08\u5FC5\u987B\u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u7CBE\u786E\u5339\u914D\u6574\u884C\uFF09"},endAnchor:{type:"string",description:"\u5220\u9664\u8303\u56F4\u7684\u7ED3\u675F\u6807\u8BB0\u884C\u5185\u5BB9\uFF08\u5FC5\u987B\u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u7CBE\u786E\u5339\u914D\u6574\u884C\uFF0C\u987B\u5728 start_anchor \u4E4B\u540E\uFF09"},inclusive:{type:"boolean",description:"\u662F\u5426\u5305\u542B\u951A\u70B9\u884C\u672C\u8EAB\uFF0C\u9ED8\u8BA4 false\uFF08\u53EA\u5220\u9664\u4E24\u884C\u4E4B\u95F4\u7684\u5185\u5BB9\uFF09"}},required:["path","startAnchor","endAnchor"],additionalProperties:!1},async execute(e,t){if(!e?.path||typeof e.path!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path",error:"INVALID_ARGS"};if(typeof e.startAnchor!="string")return{success:!1,data:"\u7F3A\u5C11\u6709\u6548\u53C2\u6570 startAnchor",error:"INVALID_ARGS"};if(typeof e.endAnchor!="string")return{success:!1,data:"\u7F3A\u5C11\u6709\u6548\u53C2\u6570 endAnchor",error:"INVALID_ARGS"};let n=Ye(e.path,t.cwd),r=e.inclusive??!1;if(t.writeRoots&&t.writeRoots.length>0){let o=await Vt(t.writeRoots,n);if(!o.ok)return{success:!1,data:o.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let o=await FS(n,"utf-8"),s=Ge(o).split(`
|
|
550
|
+
`),i=Qm(s,e.startAnchor,"start_anchor");if("error"in i)return{success:!1,data:i.error,error:"ANCHOR_NOT_FOUND"};let a=Qm(s,e.endAnchor,"end_anchor");if("error"in a)return{success:!1,data:a.error,error:"ANCHOR_NOT_FOUND"};let l=i.line,c=a.line;if(l>=c)return{success:!1,data:"end_anchor \u5FC5\u987B\u5728 start_anchor \u4E4B\u540E",error:"ANCHOR_ORDER_ERROR"};let u=r?l:l+1,d=r?c:c-1;if(u>d)return{success:!1,data:"\u5220\u9664\u8303\u56F4\u4E3A\u7A7A\uFF08\u4E24\u884C\u951A\u70B9\u76F8\u90BB\u4E14 inclusive=false\uFF09",error:"EMPTY_RANGE"};let h=[...s.slice(0,u),...s.slice(d+1)].join(`
|
|
551
|
+
`),f=pn(o,h);await GS(n,f,"utf-8");let g=zt(o,f,n);g.existedBefore=!0;let b=d-u+1,w=`\u{1F4DD} \u4FEE\u6539: ${jS(n)} (\u5220 ${b} \u884C, +${g.additions} -${g.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
|
|
552
|
+
\u5220\u9664\u884C\u8303\u56F4\uFF1A\u7B2C ${u+1} \u884C ~ \u7B2C ${d+1} \u884C\uFF08\u5171 ${b} \u884C\uFF09
|
|
553
|
+
\u53D8\u66F4\uFF1A+${g.additions} -${g.deletions}`,summary:w,diff:g}}catch(o){return{success:!1,data:`\u5220\u9664\u8303\u56F4\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"DELETE_RANGE_ERROR"}}}};p();import wr from"process";import{existsSync as eh}from"fs";import{join as th}from"path";var US=wr.platform==="win32";function WS(){if(!US)return{bin:"sh",args:["-c"],label:"sh",hint:"\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002"};let e=wr.env.DSKCODE_BASH;if(e&&eh(e))return{bin:e,args:["-c"],label:"Git Bash",hint:nh};let t=[wr.env.ProgramFiles,wr.env["ProgramFiles(x86)"],wr.env.LOCALAPPDATA?th(wr.env.LOCALAPPDATA,"Programs"):null,"D:\\Program Files","E:\\Program Files"].filter(n=>!!n);for(let n of t)for(let r of["Git\\bin\\bash.exe","Git\\usr\\bin\\bash.exe"]){let o=th(n,r);if(eh(o))return{bin:o,args:["-c"],label:"Git Bash",hint:nh}}return{bin:"cmd",args:["/c"],label:"cmd.exe",hint:"\u5F53\u524D shell \u662F Windows cmd.exe\u3002\u8BF7\u4F7F\u7528 cmd \u8BED\u6CD5\uFF1A\u8DEF\u5F84\u7528\u53CD\u659C\u6760\u6216\u6B63\u659C\u6760\u5747\u53EF\u3001\u547D\u4EE4\u94FE\u7528 & \u6216\u6362\u884C\uFF0C\u907F\u514D\u4F7F\u7528 pwd/ls/&& \u7B49 Unix \u547D\u4EE4\u3002"}}var nh="\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002",Co=WS();var Fc={name:"bash",kind:"other",description:["\u5728 shell \u4E2D\u6267\u884C\u547D\u4EE4\uFF0C\u8FD4\u56DE stdout / stderr / \u9000\u51FA\u7801\u3002\u652F\u6301\u8D85\u65F6\u63A7\u5236\u548C\u4FE1\u53F7\u4E2D\u6B62\u3002",`\u5F53\u524D shell\uFF1A${Co.label}\u3002${Co.hint}`,"\u8BFB\u53D6\u6587\u4EF6\u8BF7\u4F18\u5148\u4F7F\u7528 read_file \u5DE5\u5177\uFF0C\u4E0D\u8981\u7528 cat/type/Get-Content\uFF1B","\u641C\u7D22\u4EE3\u7801\u7528 grep / glob\uFF0C\u5217\u76EE\u5F55\u7528 ls\u2014\u2014\u8FD9\u4E9B\u4E13\u7528\u5DE5\u5177\u5728\u6240\u6709\u5E73\u53F0\u90FD\u53EF\u7528\u4E14\u65E0\u9700\u5173\u5FC3 shell \u8BED\u6CD5\u3002"].join(""),parameters:{type:"object",properties:{command:{type:"string",description:`\u8981\u6267\u884C\u7684 shell \u547D\u4EE4\uFF08\u5F53\u524D shell\uFF1A${Co.label}\uFF09`},timeout:{type:"number",description:"\u6267\u884C\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 30000"}},required:["command"],additionalProperties:!1},async execute(e,t){if(!e?.command||typeof e.command!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 command",error:"INVALID_ARGS"};let n=e.timeout??t.timeout??Ec();try{let r=Co.bin??"cmd",o=[...Co.args,e.command],s=await Ic(r,o,t.cwd,n,t.signal,!0),i=[];s.stdout&&i.push(We(s.stdout)),s.stderr&&i.push(`[stderr]
|
|
554
|
+
${We(s.stderr)}`);let a=s.exitCode===0,l=i.length>0?i.join(`
|
|
555
555
|
`):"(\u65E0\u8F93\u51FA)",u=`\u{1F527} $ ${e.command.length>60?e.command.slice(0,57)+"...":e.command}\uFF08exit ${s.exitCode??"\u672A\u77E5"}\uFF09`;return{success:a,data:`${l}
|
|
556
|
-
[\u9000\u51FA\u7801: ${s.exitCode??"\u672A\u77E5"}]`,summary:u,error:a?void 0:`EXIT_CODE_${s.exitCode??"UNKNOWN"}`}}catch(r){return{success:!1,data:`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"EXECUTION_ERROR"}}}};p();import{readdir as
|
|
556
|
+
[\u9000\u51FA\u7801: ${s.exitCode??"\u672A\u77E5"}]`,summary:u,error:a?void 0:`EXIT_CODE_${s.exitCode??"UNKNOWN"}`}}catch(r){return{success:!1,data:`\u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF1A${r instanceof Error?r.message:String(r)}`,error:"EXECUTION_ERROR"}}}};p();import{readdir as HS,stat as VS}from"fs/promises";import{join as rh,relative as zS,isAbsolute as qS}from"path";function KS(e){let t=e;return t=t.replace(/\*\*\//g,"<<GLOBSTAR_SLASH>>"),t=t.replace(/\*\*/g,"<<GLOBSTAR>>"),t=t.replace(/\?/g,"<<QUESTION>>"),t=t.replace(/[.+^${}()|[\]\\]/g,"\\$&"),t=t.replace(/\*/g,"[^/]*"),t=t.replace(/<<GLOBSTAR_SLASH>>/g,"(.*/)?"),t=t.replace(/<<GLOBSTAR>>/g,".*"),t=t.replace(/<<QUESTION>>/g,"[^/]"),new RegExp(`^${t}$`,"i")}async function oh(e,t){let n=[],r;try{r=await HS(e,{withFileTypes:!0})}catch{return n}for(let o of r){if(o.isDirectory()&&(o.name==="node_modules"||o.name===".git"))continue;let s=rh(e,o.name),i=zS(t,s);o.isDirectory()?n.push(...await oh(s,t)):n.push(i)}return n}var Gc={name:"glob",kind:"read",description:"\u6309\u6A21\u5F0F\u641C\u7D22\u6587\u4EF6\u8DEF\u5F84\u3002\u652F\u6301 *\uFF08\u5339\u914D\u6587\u4EF6\u540D\u90E8\u5206\uFF09\u548C **\uFF08\u5339\u914D\u591A\u5C42\u76EE\u5F55\uFF09\u901A\u914D\u7B26\u3002\u81EA\u52A8\u8DF3\u8FC7 node_modules \u548C .git \u76EE\u5F55\u3002",parameters:{type:"object",properties:{pattern:{type:"string",description:"\u641C\u7D22\u6A21\u5F0F\uFF08\u652F\u6301 * \u548C ** \u901A\u914D\u7B26\uFF0C\u5982 **/*.ts\u3001src/**/*.test.ts\uFF09"},directory:{type:"string",description:"\u641C\u7D22\u7684\u8D77\u59CB\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"}},required:["pattern"],additionalProperties:!1},async execute(e,t){if(!e?.pattern||typeof e.pattern!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 pattern",error:"INVALID_ARGS"};let n=e.directory?br(e.directory):void 0,r=n?qS(n)?n:rh(t.cwd,n):t.cwd,o=KS(e.pattern);try{if(!(await VS(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let a=(await oh(r,r)).filter(m=>o.test(m));if(a.length===0)return{success:!0,data:`\u672A\u627E\u5230\u5339\u914D "${e.pattern}" \u7684\u6587\u4EF6`,summary:`${e.pattern} \u2192 0 \u4E2A\u6587\u4EF6`};let l=200,u=a.slice(0,l).join(`
|
|
557
557
|
`),d=a.length>l?`
|
|
558
558
|
|
|
559
|
-
... \u5171 ${a.length} \u4E2A\u6587\u4EF6\uFF0C\u53EA\u663E\u793A\u524D ${l} \u4E2A`:"";return{success:!0,data:
|
|
560
|
-
`),
|
|
561
|
-
`),d=new Set(c.map(h=>h.file)),m=`\u{1F50D} "${e.pattern}" \u2192 ${c.length} \u6761\u547D\u4E2D / ${d.size} \u4E2A\u6587\u4EF6`;return{success:!0,data:
|
|
559
|
+
... \u5171 ${a.length} \u4E2A\u6587\u4EF6\uFF0C\u53EA\u663E\u793A\u524D ${l} \u4E2A`:"";return{success:!0,data:We(u+d),summary:`${e.pattern} \u2192 ${a.length} \u4E2A\u6587\u4EF6`}}catch(s){return{success:!1,data:`\u6587\u4EF6\u641C\u7D22\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"GLOB_ERROR"}}}};p();import{readdir as XS,readFile as JS,stat as ZS}from"fs/promises";import{join as sh,relative as YS,isAbsolute as QS}from"path";async function ih(e,t,n=200){let r=[],o;try{o=await XS(e,{withFileTypes:!0})}catch{return r}for(let s of o){if(r.length>=n)break;if(s.isDirectory()&&(s.name==="node_modules"||s.name===".git"||s.name==="dist"))continue;let i=sh(e,s.name);if(s.isDirectory())r.push(...await ih(i,t,n-r.length));else{if(t&&!s.name.endsWith(`.${t}`))continue;r.push(i)}}return r}var jc={name:"grep",kind:"read",description:"\u5728\u6587\u4EF6\u5185\u5BB9\u4E2D\u641C\u7D22\u6B63\u5219\u8868\u8FBE\u5F0F\u3002\u8FD4\u56DE\u5339\u914D\u884C\u7684\u6587\u4EF6\u8DEF\u5F84\u3001\u884C\u53F7\u548C\u5185\u5BB9\u3002\u652F\u6301\u5927\u5C0F\u5199\u654F\u611F\u3001\u6587\u4EF6\u6269\u5C55\u540D\u8FC7\u6EE4\u3002",parameters:{type:"object",properties:{pattern:{type:"string",description:"\u6B63\u5219\u8868\u8FBE\u5F0F\u641C\u7D22\u6A21\u5F0F"},directory:{type:"string",description:"\u641C\u7D22\u7684\u76EE\u5F55\u8DEF\u5F84\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"},include:{type:"string",description:"\u6587\u4EF6\u6269\u5C55\u540D\u8FC7\u6EE4\uFF08\u5982 ts\u3001json\uFF09\uFF0C\u4E0D\u542B\u70B9\u53F7"},case_sensitive:{type:"boolean",description:"\u662F\u5426\u5927\u5C0F\u5199\u654F\u611F\uFF0C\u9ED8\u8BA4 false"},max_files:{type:"number",description:"\u6700\u5927\u641C\u7D22\u6587\u4EF6\u6570\uFF0C\u9ED8\u8BA4 200"}},required:["pattern"],additionalProperties:!1},async execute(e,t){if(!e?.pattern||typeof e.pattern!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 pattern",error:"INVALID_ARGS"};let n=e.directory?br(e.directory):void 0,r=n?QS(n)?n:sh(t.cwd,n):t.cwd,o=e.max_files??200;try{let s=e.case_sensitive?"g":"gi",i=new RegExp(e.pattern,s);if(!(await ZS(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let l=await ih(r,e.include,o),c=[];for(let h of l)try{let g=(await JS(h,"utf-8")).split(`
|
|
560
|
+
`),b=YS(r,h);for(let w=0;w<g.length&&!(i.test(g[w]??"")&&(i.lastIndex=0,c.push({file:b,line:w+1,content:g[w]}),c.length>=500));w++);if(c.length>=500)break}catch{continue}if(c.length===0)return{success:!0,data:`\u672A\u627E\u5230\u5339\u914D "${e.pattern}" \u7684\u5185\u5BB9`,summary:`\u{1F50D} "${e.pattern}" \u2192 0 \u6761\u547D\u4E2D`};let u=c.map(h=>`${h.file}:${h.line}: ${h.content}`).join(`
|
|
561
|
+
`),d=new Set(c.map(h=>h.file)),m=`\u{1F50D} "${e.pattern}" \u2192 ${c.length} \u6761\u547D\u4E2D / ${d.size} \u4E2A\u6587\u4EF6`;return{success:!0,data:We(u),summary:m}}catch(s){return{success:!1,data:`\u5185\u5BB9\u641C\u7D22\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"GREP_ERROR"}}}};p();import{readdir as eT,stat as tT}from"fs/promises";import{join as nT,relative as ah}from"path";var Uc={name:"ls",kind:"read",description:"\u5217\u51FA\u76EE\u5F55\u5185\u5BB9\u3002\u663E\u793A\u6761\u76EE\u7C7B\u578B\uFF08\u6587\u4EF6/\u76EE\u5F55/\u94FE\u63A5\uFF09\u548C\u5927\u5C0F\u3002\u53EF\u9009\u62E9\u662F\u5426\u663E\u793A\u9690\u85CF\u6587\u4EF6\u3002",parameters:{type:"object",properties:{path:{type:"string",description:"\u76EE\u5F55\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u76EE\u5F55"},all:{type:"boolean",description:"\u662F\u5426\u663E\u793A\u9690\u85CF\u6587\u4EF6\uFF08\u4EE5 . \u5F00\u5934\u7684\u6587\u4EF6\uFF09\uFF0C\u9ED8\u8BA4 false"}},required:[],additionalProperties:!1},async execute(e,t){let n=e.path?Ye(e.path,t.cwd):t.cwd,r=e.all??!1;try{let o=await eT(n,{withFileTypes:!0}),s=[],i=[...o].toSorted((l,c)=>l.isDirectory()!==c.isDirectory()?l.isDirectory()?-1:1:l.name.localeCompare(c.name));for(let l of i){if(!r&&l.name.startsWith("."))continue;let c=l.isDirectory()?"DIR":l.isSymbolicLink()?"LINK":"FILE",u="";if(c==="FILE")try{let m=await tT(nT(n,l.name));m.size<1024?u=`${m.size}B`:m.size<1024*1024?u=`${(m.size/1024).toFixed(1)}KB`:u=`${(m.size/1024/1024).toFixed(1)}MB`}catch{u="?"}let d=c==="DIR"?"\u{1F4C1}":c==="LINK"?"\u{1F517}":"\u{1F4C4}";s.push(`${d} ${l.name}${u?` (${u})`:""}`)}if(s.length===0)return{success:!0,data:"\u76EE\u5F55\u4E3A\u7A7A",summary:`\u{1F4C2} ${ah(t.cwd,n).replace(/\\/g,"/")}\uFF08\u7A7A\uFF09`};let a=ah(t.cwd,n).replace(/\\/g,"/");return{success:!0,data:We(`\u76EE\u5F55\uFF1A${n}
|
|
562
562
|
${s.join(`
|
|
563
|
-
`)}`),summary:`\u{1F4C2} ${a}\uFF08${s.length} \u9879\uFF09`}}catch(o){return{success:!1,data:`\u5217\u76EE\u5F55\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"LS_ERROR"}}}};p();var
|
|
563
|
+
`)}`),summary:`\u{1F4C2} ${a}\uFF08${s.length} \u9879\uFF09`}}catch(o){return{success:!1,data:`\u5217\u76EE\u5F55\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"LS_ERROR"}}}};p();var Wc={name:"fetch",kind:"read",description:"\u53D1\u8D77 HTTP \u8BF7\u6C42\u5E76\u8FD4\u56DE\u54CD\u5E94\u5185\u5BB9\u3002\u652F\u6301\u81EA\u5B9A\u4E49\u65B9\u6CD5\u548C\u8BF7\u6C42\u5934\u3002\u9002\u7528\u4E8E\u83B7\u53D6\u7F51\u9875\u5185\u5BB9\u3001API \u8C03\u7528\u7B49\u573A\u666F\u3002",parameters:{type:"object",properties:{url:{type:"string",description:"\u8BF7\u6C42\u7684 URL"},method:{type:"string",description:"HTTP \u65B9\u6CD5\uFF08GET\u3001POST\u3001PUT\u3001DELETE \u7B49\uFF09\uFF0C\u9ED8\u8BA4 GET"},headers:{type:"object",description:"\u8BF7\u6C42\u5934\u952E\u503C\u5BF9",additionalProperties:{type:"string"}},body:{type:"string",description:"\u8BF7\u6C42\u4F53\u5185\u5BB9\uFF08POST/PUT \u65F6\u4F7F\u7528\uFF09"},max_length:{type:"number",description:"\u54CD\u5E94\u5185\u5BB9\u6700\u5927\u957F\u5EA6\uFF08\u5B57\u7B26\uFF09\uFF0C\u9ED8\u8BA4 50000"}},required:["url"],additionalProperties:!1},async execute(e,t){if(!e?.url||typeof e.url!="string")return{success:!1,data:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 url",error:"INVALID_ARGS"};let n=(e.method??"GET").toUpperCase(),r=3e4,o=e.max_length??5e4;try{let s={method:n,headers:e.headers??{},signal:t.signal??AbortSignal.timeout(r)};e.body&&(n==="POST"||n==="PUT"||n==="PATCH")&&(s.headers["Content-Type"]??="application/json",s.body=e.body);let i=await fetch(e.url,s),a=i.headers.get("content-type")??"unknown",l=`${i.status} ${i.statusText}`,c;try{c=await i.text()}catch{c="(\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u4F53)"}let u=We(c,o),d=`\u72B6\u6001: ${l}
|
|
564
564
|
\u5185\u5BB9\u7C7B\u578B: ${a}`,m=c.length>0?`
|
|
565
565
|
---
|
|
566
|
-
`:"",h=e.url.length>60?e.url.slice(0,57)+"...":e.url,f=`\u{1F310} ${n} ${h} \u2192 ${i.status}`;return{success:i.ok,data:`${d}${m}${u}`,summary:f,error:i.ok?void 0:`HTTP_${i.status}`}}catch(s){return s instanceof DOMException&&s.name==="AbortError"?{success:!1,data:"\u8BF7\u6C42\u88AB\u4E2D\u6B62",error:"ABORTED"}:s instanceof TypeError&&s.message.includes("fetch")?{success:!1,data:`\u7F51\u7EDC\u9519\u8BEF\uFF1A${s.message}`,error:"NETWORK_ERROR"}:{success:!1,data:`HTTP \u8BF7\u6C42\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"FETCH_ERROR"}}}};p();import{z as
|
|
567
|
-
`);for(let r of n){let o=mT.exec(r);if(!o)continue;let s=o[1]??o[3]??"",i=Number(o[2]??o[4]??"0");if(!s)continue;let a=s.replace(/^file:\/\/\//,"").replace(/^file:\/\//,"");if(a.includes(`${Un}${uh}${Un}`)||a.endsWith(`${Un}${uh}`)||a.includes(`${Un}node_modules${Un}`))continue;let l=a;return t&&a.startsWith(t)&&(l=a.slice(t.length).replace(/^[/\\]/,"")||Vc(a)),{file:l||Vc(a),line:i}}return{file:"<unknown>",line:0}}var hT=80,gT="\u2500".repeat(hT);function yT(e){let t=`[${e.time}] [${e.type}] @ ${e.loc.file}:${e.loc.line}`,n=JSON.stringify(e,null,2);return`${gT}
|
|
568
|
-
${t}
|
|
569
|
-
${n}
|
|
570
|
-
|
|
571
|
-
`}p();p();var wr=String.raw`(?:--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?\s+|-[a-zA-Z]+\s+)*`,_o=String.raw`(?:--\s+)?`,vo=String.raw`(?:\s+--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?|\s+-[a-zA-Z]+)*`,Ro=String.raw`(?:[\s;&|]|$)`,bT=[new RegExp(String.raw`\brm\s+${wr}${_o}/\*?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${wr}${_o}~/?\*?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${wr}${_o}\$\{?HOME\}?(?:/|\*)?(?:[^\s/]*\*)?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${wr}${_o}\.(?:/\*?|/\.\.?/?\*?|\*)?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${wr}${_o}\.\.(?:/\*?|/\.\.?/?\*?|\*)?${vo}${Ro}`),new RegExp(String.raw`\bmkfs(?:\.\w+)?\s+(?:-[\w]+\s+)*/dev/(?:sd[a-z]\d*|nvme\w+|hd[a-z]\d*|vd[a-z]\d*|mmcblk\d+)\b`),new RegExp(String.raw`\bdd\s+[^|;&]*\s+of=/dev/(?:sd[a-z]|nvme\w+|hd[a-z]|vd[a-z]|mmcblk\d+)\b`),new RegExp(String.raw`\bchmod\s+${wr}-R\s+777?\s+/(?:\s|$|;|&&|\|\||\*)`),new RegExp(String.raw`\bcurl\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bwget\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bgit\s+push\s+(?:[^|;&]*\s)?--?(?:force|f)\b[^|;&]*\b(?:origin\s+)?(?:main|master)\b`)];function hh(e){if(typeof e!="string"||e.length===0)return!1;if(mh(e))return!0;let t=xT(e);for(let n of t)if(mh(n))return!0;return!1}function mh(e){for(let t of bT)if(t.test(e))return!0;return!1}function xT(e){let t=[],n=/(?:&&|\|\||;|\n)/g,r=0,o;for(;(o=n.exec(e))!==null;){let i=e.slice(r,o.index).trim();i.length>0&&t.push(i),r=o.index+o[0].length}let s=e.slice(r).trim();return s.length>0&&t.push(s),t}var Wn=class{#e=void 0;async check(t,n){if(t!=="bash")return this.#e=void 0,!0;if(typeof n!="object"||n===null)return this.#e=void 0,!0;let r=n.command;return typeof r!="string"?(this.#e=void 0,!0):hh(r)?(this.#e={source:"hardcoded_blacklist",reason:"\u547D\u4EE4\u547D\u4E2D\u786C\u7F16\u7801\u707E\u96BE\u6A21\u5F0F\uFF1A"+r,hint:"\u8BF7\u6362\u79CD\u7B49\u6548\u4F46\u5B89\u5168\u7684\u5199\u6CD5\u3002\u8BE5\u89C4\u5219\u4E0D\u53EF\u88AB\u914D\u7F6E\u8986\u76D6\u3002"},!1):(this.#e=void 0,!0)}get lastDenial(){return this.#e}};p();var mn=class{#e;constructor(t){this.#e=t}async check(t,n){for(let r of this.#e)if(!await r.check(t,n))return!1;return!0}get lastDenial(){for(let t of this.#e){let n=t.lastDenial;if(n)return n}}get size(){return this.#e.length}};var Ao=class e{#e=[];#t;#r;#o;#n;#a=new AbortController;#u;#i;#p;#s=null;#l=new Map;#m=[];#f="code";#d;#b;#h;#g=null;#c;#w=!1;#y;#k;#S;constructor(t,n=[],r,o){this.#t=t,n instanceof dn?this.#r=n:(this.#r=new dn,this.#r.registerAll(n)),this.#o=r??new Fe;let s;if(o?.permissions){let i=o.permissions,a=i.engine??new ed([]);s=new mn([new Wn,new td({engine:a,grants:i.grants,prompt:i.prompt,defaultDecision:i.defaultDecision})])}else s=o?.gate??new Sa;if(this.#n={cwd:o?.cwd??process.cwd(),maxToolRounds:o?.maxToolRounds??20,reservedForOutput:o?.reservedForOutput??4096,preserveRecentRounds:o?.preserveRecentRounds??10,autoCompactRatio:o?.autoCompactRatio??yc,preserveRecentRoundsOnCompact:o?.preserveRecentRoundsOnCompact??bc,minTurnsToCompact:o?.minTurnsToCompact??ci,projectContext:o?.projectContext,gate:s,writeRoots:o?.writeRoots??[o?.cwd??process.cwd()],enableCheckpoint:o?.enableCheckpoint??!0,enableLog:o?.enableLog??!0,enableReflection:o?.enableReflection!==!1,enableHarness:o?.enableHarness!==!1,enableAutoCompact:o?.enableAutoCompact!==!1},this.#u=o?.sessionId??jn.newId(),this.#i=o?.store===!1?null:o?.store??new jn,this.#p=Date.now(),this.#d=new gt(this.#u,this.#n.cwd,{enabled:this.#n.enableLog}),this.#d.logSessionStart(this.#u,this.#n.cwd,this.#t.model(),this.#f),this.#b=new di({threshold:3}),this.#h=this.#n.enableReflection?new pi:null,this.#n.enableHarness){let i=new fi;this.#c=i;for(let a of jm(i))this.#r.registerErased(Oe(a))}else this.#c=null;this.#y=o?.skills??[],this.#k=()=>this.#y,this.#S=o?.skillCatalogBudgetBytes??is,this.#y.length>0&&this.#r.register(Uc({getSkills:this.#k,readBody:async i=>as(i.skillFilePath)}))}get messages(){return this.#e}get accumulatedCost(){return this.#o.sessionTotalCost}get costTracker(){return this.#o}get model(){return this.#t.model()}get toolRegistry(){return this.#r}get mode(){return this.#f}get id(){return this.#u}get store(){return this.#i}get createdAt(){return this.#p}setMode(t){return this.#f=t,this.#f}async*chat(t,n){this.#e.push({role:"user",content:t}),this.#d.logUserMessage(t);let r=this.#e.length-1;if(this.#n.enableCheckpoint)try{let l=await Tc(this.#n.cwd);this.#l.set(r,l)}catch{}if(this.#n.enableAutoCompact){let l=await this.#C();l&&(yield{type:"compaction",droppedTurns:l.droppedTurns,keptTurns:l.keptTurns,beforeTokens:l.beforeTokens,afterTokens:l.afterTokens,strategy:l.strategy})}let o=Date.now(),s=0,i=this.#R();this.#w=!1;try{for(;s<this.#n.maxToolRounds;){let l=this.#A();if(this.#h&&this.#g){let E=this.#h.analyze(this.#g,{writeRoots:this.#n.writeRoots,cwd:this.#n.cwd});E.length>0&&(l=this.#h.injectIntoPrompt(l,E),this.#d.logReflections(E.map(I=>({category:I.category,toolName:I.toolName,hint:I.hint})))),this.#g=null}let[c]=Pm([...this.#e],{model:this.#t.model(),reservedForOutput:this.#n.reservedForOutput,systemPrompt:l,preserveRecentRounds:this.#n.preserveRecentRounds}),u=Lm(l,c),d=Gm(this.#r,this.#f),m=this.#t.chat(u,{signal:this.#a.signal,tools:d.length>0?d:void 0,thinkingAllowed:n?.thinkingAllowed,thinkingEffort:n?.thinkingEffort,responseFormat:n?.responseFormat,toolChoice:n?.toolChoice}),h=this.#t.model(),f="",g="",w,x,T=null,v=0;for(let E of u)v+=this.#t.countTokens(E.content)+10;let _=0,S=300;for await(let E of m){if(E.reasoningContent&&(g+=E.reasoningContent,yield{type:"reasoning_delta",content:E.reasoningContent}),E.content){f+=E.content,yield{type:"text_delta",content:E.content};let I=Date.now();if(I-_>=S){_=I;let B=this.#t.countTokens(f),Y={promptTokens:v,completionTokens:B},q=Tt(Y,h);yield{type:"usage",usage:Y,model:h,cost:q.totalCost,estimated:!0}}}if(E.toolCalls&&E.toolCalls.length>0&&(x=E.toolCalls),E.usage){w=E.usage;let I=Tt(E.usage,h);yield{type:"usage",usage:E.usage,model:h,cost:I.totalCost,estimated:!1}}E.finishReason&&(T=E.finishReason)}if(f&&!w){let E=this.#t.countTokens(f),I={promptTokens:v,completionTokens:E},B=Tt(I,h);yield{type:"usage",usage:I,model:h,cost:B.totalCost,estimated:!0}}if(w){this.#o.record(w,h);let E=Tt(w,h);this.#d.logUsage(h,w.promptTokens,w.completionTokens,w.cachedPromptTokens,E.totalCost,s),yield{type:"usage",usage:w,model:h}}let D={role:"assistant",content:f};if(x&&x.length>0&&(D.toolCalls=x),this.#e.push(D),this.#d.logAssistantText(f,s),g&&this.#d.logReasoning(g,s),x&&x.length>0){yield{type:"tool_calls",calls:x};for(let B of x)this.#d.logToolCall(B.name,B.id,B.arguments,s);if(this.#b.shouldBreak(this.#m,x)){let B=`
|
|
566
|
+
`:"",h=e.url.length>60?e.url.slice(0,57)+"...":e.url,f=`\u{1F310} ${n} ${h} \u2192 ${i.status}`;return{success:i.ok,data:`${d}${m}${u}`,summary:f,error:i.ok?void 0:`HTTP_${i.status}`}}catch(s){return s instanceof DOMException&&s.name==="AbortError"?{success:!1,data:"\u8BF7\u6C42\u88AB\u4E2D\u6B62",error:"ABORTED"}:s instanceof TypeError&&s.message.includes("fetch")?{success:!1,data:`\u7F51\u7EDC\u9519\u8BEF\uFF1A${s.message}`,error:"NETWORK_ERROR"}:{success:!1,data:`HTTP \u8BF7\u6C42\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"FETCH_ERROR"}}}};p();import{z as lh}from"zod";var ch=lh.object({name:lh.string().min(1,"skill \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A").describe("Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>")});function Hc(e){return{name:"skill",kind:"other",description:"\u6309\u540D\u79F0\u52A0\u8F7D skill \u7684\u5B8C\u6574\u5185\u5BB9\u5230\u4E0A\u4E0B\u6587\u3002\u5F53\u7528\u6237\u8BF7\u6C42\u5339\u914D\u67D0\u4E2A skill \u7684 description \u65F6\u8C03\u7528\u672C\u5DE5\u5177\u3002",parameters:{type:"object",properties:{name:{type:"string",description:"Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>"}},required:["name"],additionalProperties:!1},schema:ch,async execute(t,n){let r=e.getSkills(),o=r.find(s=>s.name===t.name&&!s.disableModelInvocation);if(!o){let s=r.filter(i=>!i.disableModelInvocation).map(i=>i.name).join(", ");return{success:!1,data:`Skill "${t.name}" \u4E0D\u5B58\u5728\u3002\u53EF\u7528\uFF1A${s||"(\u65E0)"}`,error:"SKILL_NOT_FOUND",summary:`Skill \u4E0D\u5B58\u5728\uFF1A${t.name}`}}try{let s=await e.readBody(o);return{success:!0,data:ai(o,s),summary:`\u5DF2\u52A0\u8F7D skill: ${o.name}`}}catch(s){return{success:!1,data:`\u8BFB\u53D6 skill body \u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`,error:"SKILL_READ_FAILED",summary:`\u8BFB\u53D6 skill \u5931\u8D25\uFF1A${o.name}`}}},initialTitle(t){return`\`${t.name}\` Skill`}}}var Vc=[Oe(Lc),Oe(Dc),Oe(Nc),Oe(Mc),Oe(Bc),Oe(Fc),Oe(Gc),Oe(jc),Oe(Uc),Oe(Wc)];p();function uh(e,t={}){let n=t.maxBytes??as,r=[...e].toSorted((l,c)=>l.skillFilePath.localeCompare(c.skillFilePath)),o=[],s=[],i=0,a=!1;for(let l of r){if(l.disableModelInvocation)continue;let c=Buffer.byteLength(l.name,"utf8")+Buffer.byteLength(l.description,"utf8");!a&&i+c<=n?(i+=c,o.push({name:l.name,description:l.description,location:l.skillFilePath,source:l.source})):(a=!0,s.push(l))}return{catalog:o,dropped:s}}p();p();var kr=String.raw`(?:--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?\s+|-[a-zA-Z]+\s+)*`,_o=String.raw`(?:--\s+)?`,vo=String.raw`(?:\s+--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?|\s+-[a-zA-Z]+)*`,Ro=String.raw`(?:[\s;&|]|$)`,rT=[new RegExp(String.raw`\brm\s+${kr}${_o}/\*?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}~/?\*?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}\$\{?HOME\}?(?:/|\*)?(?:[^\s/]*\*)?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}\.(?:/\*?|/\.\.?/?\*?|\*)?${vo}${Ro}`),new RegExp(String.raw`\brm\s+${kr}${_o}\.\.(?:/\*?|/\.\.?/?\*?|\*)?${vo}${Ro}`),new RegExp(String.raw`\bmkfs(?:\.\w+)?\s+(?:-[\w]+\s+)*/dev/(?:sd[a-z]\d*|nvme\w+|hd[a-z]\d*|vd[a-z]\d*|mmcblk\d+)\b`),new RegExp(String.raw`\bdd\s+[^|;&]*\s+of=/dev/(?:sd[a-z]|nvme\w+|hd[a-z]|vd[a-z]|mmcblk\d+)\b`),new RegExp(String.raw`\bchmod\s+${kr}-R\s+777?\s+/(?:\s|$|;|&&|\|\||\*)`),new RegExp(String.raw`\bcurl\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bwget\b[^|;&]*\|\s*(?:sudo\s+)?(?:sh|bash|zsh|dash|ksh|fish|ash)\b`),new RegExp(String.raw`\bgit\s+push\s+(?:[^|;&]*\s)?--?(?:force|f)\b[^|;&]*\b(?:origin\s+)?(?:main|master)\b`)];function ph(e){if(typeof e!="string"||e.length===0)return!1;if(dh(e))return!0;let t=oT(e);for(let n of t)if(dh(n))return!0;return!1}function dh(e){for(let t of rT)if(t.test(e))return!0;return!1}function oT(e){let t=[],n=/(?:&&|\|\||;|\n)/g,r=0,o;for(;(o=n.exec(e))!==null;){let i=e.slice(r,o.index).trim();i.length>0&&t.push(i),r=o.index+o[0].length}let s=e.slice(r).trim();return s.length>0&&t.push(s),t}var jn=class{#e=void 0;async check(t,n){if(t!=="bash")return this.#e=void 0,!0;if(typeof n!="object"||n===null)return this.#e=void 0,!0;let r=n.command;return typeof r!="string"?(this.#e=void 0,!0):ph(r)?(this.#e={source:"hardcoded_blacklist",reason:"\u547D\u4EE4\u547D\u4E2D\u786C\u7F16\u7801\u707E\u96BE\u6A21\u5F0F\uFF1A"+r,hint:"\u8BF7\u6362\u79CD\u7B49\u6548\u4F46\u5B89\u5168\u7684\u5199\u6CD5\u3002\u8BE5\u89C4\u5219\u4E0D\u53EF\u88AB\u914D\u7F6E\u8986\u76D6\u3002"},!1):(this.#e=void 0,!0)}get lastDenial(){return this.#e}};p();var fn=class{#e;constructor(t){this.#e=t}async check(t,n){for(let r of this.#e)if(!await r.check(t,n))return!1;return!0}get lastDenial(){for(let t of this.#e){let n=t.lastDenial;if(n)return n}}get size(){return this.#e.length}};var Ao=class e{#e=[];#n;#r;#s;#t;#c=new AbortController;#p;#i;#d;#o=null;#a=new Map;#m=[];#f="code";#u;#x;#h;#g=null;#l;#w=!1;#y;#k;#S;constructor(t,n=[],r,o){this.#n=t,n instanceof un?this.#r=n:(this.#r=new un,this.#r.registerAll(n)),this.#s=r??new Me;let s;if(o?.permissions){let i=o.permissions,a=i.engine??new td([]);s=new fn([new jn,new nd({engine:a,grants:i.grants,prompt:i.prompt,defaultDecision:i.defaultDecision})])}else s=o?.gate??new Ca;if(this.#t={cwd:o?.cwd??process.cwd(),maxToolRounds:o?.maxToolRounds??20,reservedForOutput:o?.reservedForOutput??4096,preserveRecentRounds:o?.preserveRecentRounds??10,autoCompactRatio:o?.autoCompactRatio??bc,preserveRecentRoundsOnCompact:o?.preserveRecentRoundsOnCompact??wc,minTurnsToCompact:o?.minTurnsToCompact??ui,projectContext:o?.projectContext,gate:s,writeRoots:o?.writeRoots??[o?.cwd??process.cwd()],enableCheckpoint:o?.enableCheckpoint??!0,enableLog:o?.enableLog??!0,enableReflection:o?.enableReflection!==!1,enableHarness:o?.enableHarness!==!1,enableAutoCompact:o?.enableAutoCompact!==!1},this.#p=o?.sessionId??Gn.newId(),this.#i=o?.store===!1?null:o?.store??new Gn,this.#d=Date.now(),this.#u=new en(this.#p,this.#t.cwd,{enabled:this.#t.enableLog}),this.#u.logSessionStart(this.#p,this.#t.cwd,this.#n.model(),this.#f),this.#x=new pi({threshold:3}),this.#h=this.#t.enableReflection?new fi:null,this.#t.enableHarness){let i=new mi;this.#l=i;for(let a of Um(i))this.#r.registerErased(Oe(a))}else this.#l=null;this.#y=o?.skills??[],this.#k=()=>this.#y,this.#S=o?.skillCatalogBudgetBytes??as,this.#y.length>0&&this.#r.register(Hc({getSkills:this.#k,readBody:async i=>ls(i.skillFilePath)}))}get messages(){return this.#e}get accumulatedCost(){return this.#s.sessionTotalCost}get costTracker(){return this.#s}get model(){return this.#n.model()}get toolRegistry(){return this.#r}get mode(){return this.#f}get id(){return this.#p}get store(){return this.#i}get createdAt(){return this.#d}setMode(t){return this.#f=t,this.#f}async*chat(t,n){this.#e.push({role:"user",content:t}),this.#u.logUserMessage(t);let r=this.#e.length-1;if(this.#t.enableCheckpoint)try{let l=await _c(this.#t.cwd);this.#a.set(r,l)}catch{}if(this.#t.enableAutoCompact){let l=await this.#C();l&&(yield{type:"compaction",droppedTurns:l.droppedTurns,keptTurns:l.keptTurns,beforeTokens:l.beforeTokens,afterTokens:l.afterTokens,strategy:l.strategy})}let o=Date.now(),s=0,i=this.#R();this.#w=!1;try{for(;s<this.#t.maxToolRounds;){let l=this.#A();if(this.#h&&this.#g){let T=this.#h.analyze(this.#g,{writeRoots:this.#t.writeRoots,cwd:this.#t.cwd});T.length>0&&(l=this.#h.injectIntoPrompt(l,T),this.#u.logReflections(T.map(N=>({category:N.category,toolName:N.toolName,hint:N.hint})))),this.#g=null}let[c]=Lm([...this.#e],{model:this.#n.model(),reservedForOutput:this.#t.reservedForOutput,systemPrompt:l,preserveRecentRounds:this.#t.preserveRecentRounds}),u=$m(l,c),d=jm(this.#r,this.#f),m=this.#n.chat(u,{signal:this.#c.signal,tools:d.length>0?d:void 0,thinkingAllowed:n?.thinkingAllowed,thinkingEffort:n?.thinkingEffort,responseFormat:n?.responseFormat,toolChoice:n?.toolChoice}),h=this.#n.model(),f="",g="",b,w,S=null,v=0;for(let T of u)v+=this.#n.countTokens(T.content)+10;let _=0,E=300;for await(let T of m){if(T.reasoningContent&&(g+=T.reasoningContent,yield{type:"reasoning_delta",content:T.reasoningContent}),T.content){f+=T.content,yield{type:"text_delta",content:T.content};let N=Date.now();if(N-_>=E){_=N;let F=this.#n.countTokens(f),q={promptTokens:v,completionTokens:F},$=kt(q,h);yield{type:"usage",usage:q,model:h,cost:$.totalCost,estimated:!0}}}if(T.toolCalls&&T.toolCalls.length>0&&(w=T.toolCalls),T.usage){b=T.usage;let N=kt(T.usage,h);yield{type:"usage",usage:T.usage,model:h,cost:N.totalCost,estimated:!1}}T.finishReason&&(S=T.finishReason)}if(f&&!b){let T=this.#n.countTokens(f),N={promptTokens:v,completionTokens:T},F=kt(N,h);yield{type:"usage",usage:N,model:h,cost:F.totalCost,estimated:!0}}if(b){this.#s.record(b,h);let T=kt(b,h);this.#u.logUsage(h,b.promptTokens,b.completionTokens,b.cachedPromptTokens,T.totalCost,s),yield{type:"usage",usage:b,model:h}}let M={role:"assistant",content:f};if(w&&w.length>0&&(M.toolCalls=w),this.#e.push(M),this.#u.logAssistantText(f,s),g&&this.#u.logReasoning(g,s),w&&w.length>0){yield{type:"tool_calls",calls:w};for(let F of w)this.#u.logToolCall(F.name,F.id,F.arguments,s);if(this.#x.shouldBreak(this.#m,w)){let F=`
|
|
572
567
|
\u26A0\uFE0F \u540C\u4E00\u5DE5\u5177\u91CD\u590D\u51FA\u9519\uFF0C\u5DF2\u5F3A\u5236\u5207\u6362\u7B56\u7565
|
|
573
|
-
`;yield{type:"text_delta",content:
|
|
568
|
+
`;yield{type:"text_delta",content:F},M.toolCalls=void 0,M.content+=F,this.#m=[],s++;continue}let N=await i.executeBatch(w);this.#m=N.records,this.#g=N.items.map(F=>{let q=this.#r.get(F.name);return{name:F.name,result:F.result,kind:q?.kind??"other",recentSameTool:N.records.filter($=>$.name===F.name).map($=>({success:$.success,error:$.error}))}});for(let F of N.items){let q=F.name.startsWith("todo_")&&this.#l?this.#l.items.map(oe=>({...oe})):void 0;yield{type:"tool_result",name:F.name,result:F.result,todoSnapshot:q,callId:F.callId},this.#u.logToolResult(F.name,F.callId,F.result.success,F.result.data,F.result.error,void 0,s);let $=F.result.data;F.result.diff&&F.result.diff.patch&&($+=`
|
|
574
569
|
|
|
575
|
-
${
|
|
570
|
+
${F.result.diff.patch}`),this.#e.push({role:"tool",content:$,toolCallId:F.callId,name:F.name})}this.#E(N.items),s++;continue}let U=!1;if(this.#l){for(let T of this.#l.items)T.status==="running"&&(this.#l.markDone(T.id,"LLM \u5DF2\u8F93\u51FA\u6700\u7EC8\u7ED3\u679C\uFF0C\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"),U=!0);if(U){let T=this.#l.items.map(N=>({...N}));yield{type:"tool_result",name:"todo_mark_done",result:{success:!0,data:"\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"},todoSnapshot:T}}}this.#l&&this.#l.items.length>0&&this.#l.isAllTerminated()&&this.#e.push({role:"user",content:"[\u7CFB\u7EDF] \u5168\u90E8 todo \u5DF2\u5B8C\u6210\u3002\u8BF7\u505A\u4E00\u6B21\u4EFB\u52A1\u81EA\u68C0\uFF1A\u91CD\u65B0\u8BFB\u53D6\u672C\u6B21\u4FEE\u6539\u8FC7\u7684\u6587\u4EF6\uFF0C\u786E\u8BA4\u6539\u52A8\u6B63\u786E\u65E0\u8BEF\u3001\u7C7B\u578B\u517C\u5BB9\u3001\u6CA1\u6709\u9057\u6F0F\u3002\u5982\u6709\u95EE\u9898\u8BF7\u65B0\u589E todo \u4FEE\u590D\uFF1B\u786E\u8BA4\u65E0\u8BEF\u540E\u8F93\u51FA\u6700\u7EC8\u603B\u7ED3\u3002"});break}}catch(l){if(l instanceof DOMException&&l.name==="AbortError"||l instanceof Error&&l.name==="AbortError")return;this.#u.logError(l instanceof Error?l.message:String(l),l instanceof Error?l.stack:void 0),yield{type:"error",error:l instanceof Error?l:new Error(String(l))};return}let a=Date.now()-o;this.#u.logTurnDone(a,s),this.#b(),await this.#s.flush().catch(()=>{}),yield{type:"done",elapsed:a}}abort(){this.#c.abort(),this.#o&&(clearTimeout(this.#o),this.#o=null)}async flushLog(){await this.#u.flush()}reset(){this.#e.length=0,this.#s.resetSession(),this.#m=[],this.#a.clear(),this.#g=null}getContextStats(){let t=tn(this.#n.model());return kc(this.#e,t.contextWindow)}async compact(t){let n=tn(this.#n.model()),r=await Sc(this.#e,{contextWindow:n.contextWindow,autoCompactRatio:this.#t.autoCompactRatio,preserveRecentRounds:this.#t.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#t.minTurnsToCompact,provider:this.#n,signal:this.#c.signal,...t?{onProgress:t}:{}});if(r.droppedTurns>0){this.#e.length=0;for(let o of r.messages)this.#e.push(o);this.#a.clear(),this.#b()}return r}async#C(){let n={contextWindow:tn(this.#n.model()).contextWindow,autoCompactRatio:this.#t.autoCompactRatio,preserveRecentRounds:this.#t.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#t.minTurnsToCompact,provider:this.#n,signal:this.#c.signal};if(!Nm(this.#e,n))return null;let r=await Sc(this.#e,n);if(r.droppedTurns===0)return null;let o=r.summary.includes("\u672C\u5730\u6458\u8981")?"fallback":"summary";this.#e.length=0;for(let s of r.messages)this.#e.push(s);return this.#a.clear(),this.#b(),{...r,strategy:o}}async persistNow(){this.#o&&(clearTimeout(this.#o),this.#o=null),await this.#T()}#b(){if(this.#i){if(this.#o){this.#o.refresh();return}this.#o=setTimeout(()=>{this.#o=null,this.#T()},500),this.#o.unref()}}async#T(){if(!this.#i)return;let t={id:this.#p,title:this.#_(),createdAt:this.#d,updatedAt:Date.now(),cwd:this.#t.cwd,model:this.#n.model(),messages:this.#v(),totalCost:this.#s.sessionTotalCost};try{await this.#i.save(t)}catch(n){console.error("[Session] \u6301\u4E45\u5316\u5931\u8D25:",n)}}#_(){for(let t of this.#e)if(t.role==="user"&&t.content.trim())return t.content.trim().slice(0,40);return"\u65B0\u4F1A\u8BDD"}#v(){return this.#e.map((t,n)=>{let r=this.#a.get(n);return t.role==="user"&&r?{...t,checkpoint:r}:{...t}})}static async resume(t,n,r=[],o,s){let i=s?.store===!1?null:s?.store??new Gn;if(!i)throw new Error("resume \u9700\u8981\u542F\u7528\u6301\u4E45\u5316\uFF08options.store \u4E0D\u80FD\u4E3A false\uFF09");let a=await i.load(t);if(!a)throw new Error(`\u4F1A\u8BDD ${t} \u4E0D\u5B58\u5728`);let l=new e(n,r,o,{...s,sessionId:t,store:i});for(let c of a.messages)l.#e.push({role:c.role,content:c.content,toolCallId:c.toolCallId,name:c.name,toolCalls:c.toolCalls});for(let c=0;c<a.messages.length;c++){let u=a.messages[c]?.checkpoint;u&&l.#a.set(c,u)}return l.#d=a.createdAt,l}listCheckpoints(){let t=[];for(let[n,r]of this.#a){let o=this.#e[n];!o||o.role!=="user"||t.push({index:n,preview:o.content.slice(0,80),timestamp:r.timestamp,isGitRepo:r.isGitRepo})}return t.sort((n,r)=>n.index-r.index)}async rewind(t){if(t<0||t>=this.#e.length)return{ok:!1,error:`\u65E0\u6548\u7684\u6D88\u606F\u7D22\u5F15 ${t}`};let n=this.#e[t];if(!n||n.role!=="user")return{ok:!1,error:`\u7D22\u5F15 ${t} \u4E0D\u662F user \u6D88\u606F`};let r=this.#a.get(t);if(!r)return{ok:!1,error:"\u8BE5\u6D88\u606F\u6CA1\u6709\u68C0\u67E5\u70B9"};this.#e.length=t+1;let o=[];for(let[i,a]of this.#a)i>t&&(o.push(a),this.#a.delete(i));let s=!1;if(r.isGitRepo)try{r.stashSha?await vc(r):await Rc(this.#t.cwd),s=!0}catch(i){return{ok:!1,error:`\u5BF9\u8BDD\u5DF2\u622A\u65AD\u4F46\u6587\u4EF6\u6062\u590D\u5931\u8D25\uFF1A${i instanceof Error?i.message:String(i)}`}}this.#a.delete(t);for(let i of o)xi(i);return this.#b(),{ok:!0,fileRestored:s}}hasCheckpoints(){return this.listCheckpoints().length>0}get gate(){return this.#t.gate}async delete(){this.#i&&await this.#i.delete(this.#p);for(let t of this.#a.values())xi(t);this.#a.clear(),this.#u.logSessionEnd(Date.now()-this.#d),await this.#u.flush()}#R(){return new di({registry:this.#r,gate:this.#t.gate,baseCtx:{cwd:this.#t.cwd,signal:this.#c.signal,writeRoots:this.#t.writeRoots}})}#A(){let n=this.#r.list().map(a=>({name:a.name,description:a.description,parameters:a.parameters})),{catalog:r}=this.#y.length>0?uh(this.#y,{maxBytes:this.#S}):{catalog:[]},o=r.length>0?r.map(a=>({name:a.name,description:a.description,location:a.location})):void 0,s={model:this.#n.model(),maxToolRounds:this.#t.maxToolRounds,tools:n.length>0?n:void 0,projectContext:this.#t.projectContext??void 0,cwd:this.#t.cwd,availableSkills:o},i;return this.#f==="plan"?i=Em(s):i=Am(s),this.#l&&this.#l.items.length>0&&(i=i+`
|
|
576
571
|
|
|
577
|
-
`+this.#
|
|
572
|
+
`+this.#l.toMarkdown()),i}#E(t){!this.#l||this.#l.items.length>0||this.#w||!t.some(r=>!r.name.startsWith("todo_"))||(this.#w=!0,this.#e.push({role:"user",content:`[\u7CFB\u7EDF\u63D0\u793A] \u4F60\u8FD8\u6CA1\u6709 todo \u8FC7\uFF0C\u4F46\u5DF2\u7ECF\u8C03\u4E86\u5177\u4F53\u5DE5\u5177\u3002
|
|
578
573
|
\u8BF7\u56DE\u987E\u4F60\u521A\u505A\u7684\u4E8B\uFF1A\u8FD9\u662F\u300C\u7B80\u5355\u300D\u4EFB\u52A1\uFF081 \u8F6E 1 \u5DE5\u5177\u80FD\u5B8C\u6210\uFF09\u8FD8\u662F\u300C\u590D\u6742\u300D\u4EFB\u52A1\uFF1F
|
|
579
574
|
\u5982\u679C\u662F\u590D\u6742\uFF08\u6539\u4E86/\u521B\u5EFA\u4E86/\u8981\u8BFB\u540E\u6539/\u8DE8\u591A\u79CD\u5DE5\u5177\uFF09\uFF0C\u8BF7\u505C\u4E0B\uFF0C\u5148\u8C03 todo_add \u62C6\u89E3 3-7 \u6B65\u518D\u7EE7\u7EED\u3002
|
|
580
575
|
\u5982\u679C\u662F\u7B80\u5355\uFF0C\u5FFD\u7565\u672C\u63D0\u793A\u3002
|
|
581
|
-
\uFF08\u672C\u63D0\u793A\u672C\u4F1A\u8BDD\u4EC5\u53D1\u4E00\u6B21\uFF0C\u540E\u7EED\u4E0D\u518D\u63D0\u9192\u3002\uFF09`}))}};p();p();var zc=[[0,255,65],[0,255,255],[189,147,249]],qc=[[255,245,180],[255,210,80],[255,150,50]],Kc=[[255,191,0],[210,140,60],[175,70,40]],
|
|
582
|
-
`)}p();import{Box as ST,Text as TT}from"ink";import{useEffect as CT,useRef as _T,useState as vT}from"react";import{jsx as PT,jsxs as IT}from"react/jsx-runtime";var RT=[" \u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584 \u2584\u2584"," \u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2580\u2588\u2588\u2588\u2580\u2580","\u2580\u2588 \u2580\u2580\u2588\u2588\u2588\u2584 \u2588\u2588\u2588\u2588"," \u2580\u2588\u2584 \u2584 \u2580\u2588\u2588\u2588\u2588\u2588\u2580"," \u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2584\u2580\u2580\u2580\u2580\u2580"],Xc=22,AT=120,ET="#6185f6";function yh({panelWidth:e}){let t=_T(e),[n,r]=vT(0);CT(()=>{let l=setInterval(()=>{t.current-=1,t.current<=-Xc&&(t.current=e),r(c=>c+1)},AT);return()=>clearInterval(l)},[e]);let o=t.current;if(o>=e)return null;let s=Math.max(0,-o),i=Math.max(0,o+Xc-e),a=Math.max(0,o);return PT(ST,{flexDirection:"column",alignItems:"flex-start",children:RT.map((l,c)=>IT(TT,{color:ET,bold:!0,children:[" ".repeat(a),l.slice(s,Xc-i)]},c))})}p();import{Box as wi,Text as tt,useInput as LT}from"ink";import{useState as $T}from"react";import{jsx as yt,jsxs as kr}from"react/jsx-runtime";var Eo=[{number:"1",value:"yes",label:"Yes \u4EC5\u672C\u6B21",color:"green"},{number:"2",value:"no",label:"No \u62D2\u7EDD",color:"red"},{number:"3",value:"always",label:"Always \u672C\u4F1A\u8BDD\u540C\u7C7B\u64CD\u4F5C\u81EA\u52A8\u653E\u884C",color:"cyan"}];function bh({pending:e,onResponse:t}){let[n,r]=$T(0);if(LT((s,i)=>{if(e){if(i.escape){t("no");return}if(i.return){let a=Eo[n];a&&t(a.value);return}if(i.leftArrow){r(a=>(a-1+Eo.length)%Eo.length);return}if(i.rightArrow){r(a=>(a+1)%Eo.length);return}if(s==="1"){t("yes");return}if(s==="2"){t("no");return}if(s==="3"){t("always");return}}},{isActive:!!e}),!e)return null;let{ctx:o}=e;return kr(wi,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,marginTop:1,children:[yt(tt,{bold:!0,color:"yellow",children:"\u{1F510} \u6743\u9650\u5BA1\u6279"}),kr(wi,{flexDirection:"column",marginLeft:2,marginTop:1,children:[kr(tt,{children:[yt(tt,{dimColor:!0,children:"\u5DE5\u5177\uFF1A"}),yt(tt,{bold:!0,children:o.toolName}),yt(tt,{dimColor:!0,children:" \uFF08\u5199\u64CD\u4F5C\u786E\u8BA4\uFF09"})]}),kr(tt,{children:[yt(tt,{dimColor:!0,children:"\u539F\u56E0\uFF1A"}),yt(tt,{children:o.reason})]}),o.toolName==="bash"&&kr(tt,{children:[yt(tt,{dimColor:!0,children:"\u547D\u4EE4\uFF1A"}),yt(tt,{color:"cyan",children:OT(o)})]})]}),yt(wi,{flexDirection:"row",marginTop:1,gap:2,children:Eo.map((s,i)=>kr(tt,{color:i===n?s.color:"gray",bold:i===n,inverse:i===n,children:[" ","[",s.number,"] ",s.label," "]},s.value))}),yt(wi,{marginTop:1,children:yt(tt,{dimColor:!0,children:"\u2190/\u2192 \u5207\u6362 \xB7 1/2/3 \u76F4\u63A5\u9009 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u62D2\u7EDD"})})]})}function OT(e){if(typeof e.args!="object"||e.args===null)return"(\u65E0\u53C2\u6570)";let n=e.args.command;return typeof n!="string"?"(\u975E\u547D\u4EE4)":n.length<=60?n:n.slice(0,57)+"..."}p();p();import{EventEmitter as FT}from"events";import{randomUUID as wh}from"crypto";import GT from"ws";p();import{gunzipSync as DT,gzipSync as Jc}from"zlib";var NT=1,MT=1,hn={FULL_REQUEST:1,AUDIO_ONLY:2,SERVER_RESPONSE:9,ERROR:15},zn={NO_SEQUENCE:0,POSITIVE_SEQUENCE:1,LAST_PACKET_NO_SEQ:2,NEGATIVE_SEQUENCE:3,HAS_EVENT:4},Zc={JSON:1},Yc={GZIP:1};function ki(e,t,n,r){let o=Buffer.alloc(4);o[0]=NT<<4|MT,o[1]=e<<4|t&15,o[2]=Zc.JSON<<4|Yc.GZIP,o[3]=0;let s=Buffer.alloc(4);s.writeInt32BE(n);let i=Buffer.alloc(4);return i.writeUInt32BE(r.length),Buffer.concat([o,s,i,r])}function Qc(e,t){let n=Buffer.from(JSON.stringify(e),"utf8"),r=Jc(n);return ki(hn.FULL_REQUEST,zn.POSITIVE_SEQUENCE,t,r)}function eu(e,t){return ki(hn.AUDIO_ONLY,zn.POSITIVE_SEQUENCE,t,Jc(e))}function tu(e){return ki(hn.AUDIO_ONLY,zn.NEGATIVE_SEQUENCE,-Math.abs(e),Jc(Buffer.alloc(0)))}function nu(e){let t={messageType:"unknown",seq:0,isLast:!1,event:0,code:0,body:null,raw:e};if(e.length<4)return t;let n=e[0],r=e[1],o=e[2],s=n&15,i=r>>4,a=r&15,l=o>>4,c=o&15,u=i===hn.SERVER_RESPONSE?"full_response":i===hn.AUDIO_ONLY?"audio_only":i===hn.ERROR?"error":"unknown",d=e.subarray(s*4),m=0;a&zn.POSITIVE_SEQUENCE&&(m=d.readInt32BE(0),d=d.subarray(4));let h=(a&zn.LAST_PACKET_NO_SEQ)!==0,f=0;a&zn.HAS_EVENT&&(f=d.readInt32BE(0),d=d.subarray(4));let g=0;i===hn.ERROR&&(g=d.readInt32BE(0),d=d.subarray(4)),d.length>=4&&(d=d.subarray(4));let w=BT(d,c,l);return{messageType:u,seq:m,isLast:h,event:f,code:g,body:w,raw:e}}function BT(e,t,n){if(e.length===0)return null;let r=e;if(t===Yc.GZIP)try{r=DT(e)}catch{return null}return n===Zc.JSON||r.length>0&&r[0]===123?xh(r):null}function xh(e){try{return JSON.parse(e.toString("utf8"))}catch{return null}}function ru(e){return{user:{uid:e.user.uid,platform:e.user.platform??"Linux",sdk_version:e.user.sdkVersion??"0.1.x"},audio:{format:e.audio.format,codec:e.audio.codec,rate:e.audio.rate,bits:e.audio.bits,channel:e.audio.channel},request:{model_name:e.request.modelName,enable_itn:e.request.enableItn,enable_punc:e.request.enablePunc,enable_ddc:e.request.enableDdc,show_utterances:e.request.showUtterances}}}var jT="wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async",UT="volc.bigasr.sauc.duration",WT=(e,t)=>Reflect.construct(GT,[e,t]),Si=class extends FT{config;url;resourceId;ws=null;seq=1;started=!1;ended=!1;opened=!1;constructor(t){super(),this.config=t,this.url=t.url??jT,this.resourceId=t.resourceId??UT}connect(){return new Promise((t,n)=>{if(this.ws){n(new Error("VolcAsrClient: \u91CD\u590D\u8C03\u7528 connect()"));return}let r={"X-Api-Resource-Id":this.resourceId,"X-Api-Request-Id":wh(),"X-Api-Access-Key":this.config.accessKey,"X-Api-App-Key":this.config.appId,"X-Api-Sequence":"-1"},o=this.config.wsFactory??WT,s;try{s=o(this.url,{headers:r})}catch(l){n(l instanceof Error?l:new Error(String(l)));return}this.ws=s;let i=()=>{if(!this.opened){this.opened=!0;try{this.sendStart(),this.emit("log","\u2705 \u63E1\u624B\u6210\u529F\uFF0C\u8D77\u59CB\u5305\u5DF2\u53D1"),this.emit("open"),t()}catch(l){n(l instanceof Error?l:new Error(String(l)))}}},a=l=>{this.ended||(this.opened?this.emit("error",-1,l.message):n(l))};s.on("open",i),s.on("error",a),s.on("message",l=>this.onMessage(l)),s.on("close",(l,c)=>this.onClose(l,c))})}sendAudio(t){if(!this.ws||!this.started||this.ended)return;let n=eu(t,this.seq++);this.ws.send(n)}end(){if(!this.ws||this.ended)return;this.ended=!0;let t=tu(this.seq);this.ws.send(t),setTimeout(()=>{try{this.ws?.close()}catch{}},1500)}abort(){if(this.ws){this.ended=!0;try{this.ws.close()}catch{}}}sendStart(){if(!this.ws)return;let t=ru({user:{uid:`dskcode-cli-${wh().slice(0,8)}`},audio:{format:this.config.format??"pcm",codec:this.config.codec??"raw",rate:this.config.sampleRate??16e3,bits:this.config.bits??16,channel:this.config.channel??1},request:{modelName:"bigmodel",enableItn:this.config.enableItn??!0,enablePunc:this.config.enablePunc??!0,enableDdc:this.config.enableDdc??!1,showUtterances:this.config.showUtterances??!0}}),n=Qc(t,this.seq++);this.ws.send(n),this.started=!0}onMessage(t){let n=typeof t=="string"?Buffer.from(t):t,r=nu(n);this.handleResponse(r)}handleResponse(t){if(t.messageType==="error"){let r=t.body?.error??`ASR error code=${t.code}`;this.emit("error",t.code,r);return}if(t.messageType!=="full_response")return;let n=t.body?.result;if(n)if(n.utterances&&n.utterances.length>0)for(let r of n.utterances)r.definite?this.emit("final",r.text):this.emit("partial",r.text);else n.text&&this.emit("partial",n.text)}onClose(t,n){this.ws=null,this.emit("close"),this.emit("log",`\u8FDE\u63A5\u5173\u95ED code=${t} reason=${n?.toString("utf8")||""}`)}};function ou(e){return new Si(e)}p();import{EventEmitter as KT}from"events";p();import{spawn as HT}from"child_process";import{platform as su}from"os";var iu=(e,t)=>HT(e,t,{stdio:["ignore","pipe","pipe"]}),VT={ffmpeg:["D:\\ffmpeg\\ffmpeg-8.1.2-essentials_build\\bin\\ffmpeg.exe","C:\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files (x86)\\ffmpeg\\bin\\ffmpeg.exe","/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg","/usr/bin/ffmpeg"],sox:["C:\\Program Files (x86)\\sox-14-4-2\\sox.exe","/opt/homebrew/bin/sox","/usr/local/bin/sox","/usr/bin/sox"],arecord:["/usr/bin/arecord","/usr/local/bin/arecord"]};function zT(e,t,n){return new Promise(r=>{let o;try{o=t(e,["-version"])}catch{r(!1);return}let s=setTimeout(()=>{try{o.kill()}catch{}r(!1)},n);o.on("close",i=>{clearTimeout(s),r(i===0)}),o.on("error",()=>{clearTimeout(s),r(!1)})})}var kh={name:"ffmpeg",binary:"ffmpeg",buildArgs:e=>{let t=su();return t==="win32"?["-f","dshow","-i",`audio=${e??"Microphone"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:t==="darwin"?["-f","avfoundation","-i",`:${e??"0"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:["-f","alsa","-i",e??"default","-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]},listWindowsAudioDevices:async(e,t)=>new Promise(n=>{let r="",o;try{o=e(t,["-list_devices","true","-f","dshow","-i","dummy"])}catch{n(null);return}o.stderr?.on("data",s=>{r+=s.toString("utf8")}),o.on("close",()=>{let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)}),o.on("error",()=>n(null)),setTimeout(()=>{try{o.kill()}catch{}let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)},1e4)})},Sh={name:"sox",binary:"sox",buildArgs:e=>su()==="win32"||e!==void 0?["-q","-r","16000","-c","1","-t","waveaudio",e??"-d","-t","raw","-"]:["-q","-r","16000","-c","1","-t","waveaudio","-d","-t","raw","-"]},Th={name:"arecord",binary:"arecord",buildArgs:e=>["-q","-f","S16_LE","-r","16000","-c","1",e?["-D",e]:[],"-t","raw"].flat()};async function au(e,t){let n=e==="auto"?[kh,Sh,Th]:[kh,Sh,Th].filter(r=>r.name===e);for(let r of n){let o=await qT(r.binary,t);if(o)return{...r,binary:o}}throw new Error(`\u672A\u627E\u5230\u53EF\u7528\u7684\u5F55\u97F3\u9A71\u52A8\uFF08driver=${e}\uFF09\u3002\u8BF7\u5B89\u88C5 ffmpeg / sox / arecord \u4E4B\u4E00\u3002\u8BE6\u89C1 docs/\u8BED\u97F3\u8BC6\u522Bvoice\u547D\u4EE4\u63A5\u5165.md \xA712.1\u3002`)}async function qT(e,t){let n=VT[e]??[];for(let r of[e,...n])if(await zT(r,t,1500))return r;return null}async function Ch(e,t){return su()!=="win32"||!e.listWindowsAudioDevices?null:e.listWindowsAudioDevices(t,e.binary)}var XT=200,JT=60,ZT=16e3,YT=16,QT=1,eC=ZT*(YT/8)*QT,Ti=class extends KT{options;proc=null;driver=null;buf=[];bufSize=0;chunkBytes;started=!1;stopped=!1;maxDurationTimer=null;constructor(t={}){super(),this.options={chunkMs:t.chunkMs??XT,maxDurationSec:t.maxDurationSec??JT,driver:t.driver??"auto",deviceName:t.deviceName,spawner:t.spawner},this.chunkBytes=Math.floor(eC*this.options.chunkMs/1e3)}async start(){if(this.started)throw new Error("VoiceCapture: \u91CD\u590D\u8C03\u7528 start()");this.started=!0,this.stopped=!1;let t=this.options.spawner??iu;this.driver=await au(this.options.driver,t),this.emit("log",`\u4F7F\u7528\u5F55\u97F3\u9A71\u52A8: ${this.driver.name}`);let n=this.options.deviceName;if(!n){let s=await Ch(this.driver,t);s&&(n=s,this.emit("log",`\u68C0\u6D4B\u5230\u9EA6\u514B\u98CE\u8BBE\u5907: ${n}`))}let r=this.driver.buildArgs(n);this.emit("log",`\u542F\u52A8\u5B50\u8FDB\u7A0B: ${this.driver.binary} ${r.join(" ")}`);let o;try{o=t(this.driver.binary,r)}catch(s){throw this.started=!1,s instanceof Error?s:new Error(String(s))}this.proc=o,o.stdout?.on("data",s=>this.ingest(s)),o.on("error",s=>{this.emit("error",s)}),o.on("close",s=>{if(this.bufSize>0){let i=Buffer.concat(this.buf,this.bufSize);this.emit("data",i),this.buf=[],this.bufSize=0}if(this.started=!1,this.proc=null,!this.stopped&&s!==0&&s!==null){this.emit("error",new Error(`\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5F02\u5E38\u9000\u51FA code=${s}\uFF08\u53EF\u80FD\u662F\u8BBE\u5907\u540D\u9519\u8BEF\u6216\u6743\u9650\u88AB\u62D2\uFF09`));return}this.emit("end")}),this.options.maxDurationSec>0&&(this.maxDurationTimer=setTimeout(()=>{this.emit("log",`\u5DF2\u8FBE ${this.options.maxDurationSec}s \u4E0A\u9650\uFF0C\u81EA\u52A8\u505C\u6B62`),this.stop()},this.options.maxDurationSec*1e3))}stop(){if(!(!this.proc||this.stopped)){this.stopped=!0,this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null);try{this.proc.kill()}catch(t){this.emit("error",t instanceof Error?t:new Error(`kill \u5B50\u8FDB\u7A0B\u5931\u8D25: ${String(t)}`))}}}abort(){if(this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.proc)try{this.proc.kill()}catch{}this.started=!1}isRecording(){return this.started}ingest(t){for(this.buf.push(t),this.bufSize+=t.length;this.bufSize>=this.chunkBytes;){let n=Buffer.concat(this.buf),r=n.subarray(0,this.chunkBytes);this.buf=[n.subarray(this.chunkBytes)],this.bufSize=n.length-this.chunkBytes,this.emit("data",r)}}};function lu(e={}){return new Ti(e)}p();import{EventEmitter as tC}from"events";var Ci=class extends tC{config;phase="idle";asr=null;cap=null;connecting=!1;lastError=null;constructor(t){super(),this.config=t}async start(){if(this.phase!=="idle"&&this.phase!=="error"){this.emit("log",`\u5DF2\u7ECF\u5728 ${this.phase} \u72B6\u6001\uFF0C\u5FFD\u7565 start()`);return}this.connecting=!0,this.lastError=null,this.setPhase("connecting");let n=(this.config.asrFactory??(()=>nC(this.config.asr)))();this.asr=n,this.bindAsrEvents(n);try{await n.connect()}catch(s){this.lastError=`\u8FDE\u63A5 ASR \u5931\u8D25: ${_h(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}let o=(this.config.recorderOptions?.captureFactory??rC)();this.cap=o,this.bindCapEvents(o);try{await o.start()}catch(s){this.lastError=`\u542F\u52A8\u5F55\u97F3\u5931\u8D25: ${_h(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}this.connecting=!1,this.setPhase("recording")}stop(){if(this.phase!=="recording"&&this.phase!=="connecting"&&this.phase!=="finalizing"){this.emit("log",`\u5F53\u524D phase=${this.phase}\uFF0C\u5FFD\u7565 stop()`);return}if(this.phase==="finalizing"){this.abort();return}this.setPhase("finalizing"),this.cap&&this.cap.isRecording()&&this.cap.stop()}abort(){this.setPhase("error"),this.cleanup()}getPhase(){return this.phase}getLastError(){return this.lastError}setPhase(t){this.phase!==t&&(this.phase=t,this.emit("phase",t))}bindAsrEvents(t){t.on("partial",n=>this.emit("partial",n)),t.on("final",n=>this.emit("final",n)),t.on("error",(n,r)=>{this.lastError=`ASR \u9519\u8BEF: ${r}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("close",()=>{this.emit("log","ASR WebSocket \u5DF2\u5173\u95ED"),(this.phase==="recording"||this.phase==="finalizing")&&(this.setPhase("idle"),this.cleanup())}),t.on("log",n=>this.emit("log",`[asr] ${n}`))}bindCapEvents(t){t.on("data",n=>{this.asr&&this.phase==="recording"&&this.asr.sendAudio(n)}),t.on("error",n=>{this.lastError=`\u5F55\u97F3\u9519\u8BEF: ${n.message}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("end",()=>{if(this.emit("log","\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5DF2\u7ED3\u675F"),this.asr)try{this.asr.end()}catch{}}),t.on("log",n=>this.emit("log",`[rec] ${n}`))}cleanup(){try{this.asr?.abort()}catch{}try{this.cap?.abort()}catch{}this.asr=null,this.cap=null}};function nC(e){return ou({appId:e.appId,accessKey:e.accessKey,resourceId:e.resourceId})}function rC(){return lu()}function _h(e){return e instanceof Error?e.message:String(e)}function cu(e){return new Ci(e)}import{Fragment as Eh,jsx as L,jsxs as W}from"react/jsx-runtime";var uu={thinking:{icon:"\u{1F9E0}",label:"\u601D\u8003\u4E2D",color:"#ff9800"},generating:{icon:"\u2728",label:"\u751F\u6210\u4E2D",color:"#00ff41"},calling_tools:{icon:"\u{1F6E0}",label:"\u8C03\u7528\u5DE5\u5177",color:"#f59e0b"},executing_tools:{icon:"\u26A1",label:"\u6267\u884C\u5DE5\u5177",color:"#00ffff"}};function aC(e){return e==="edit_file"||e==="write_file"||e==="multi_edit"||e==="delete_range"}function Rh(e){if(!e)return;let t=e.filter(n=>!n.name.startsWith("todo_"));return t.length>0?t:void 0}var fu=new Map;function $e(e,t){fu.set(e,t)}function Ih(){return fu}$e("/exit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/quit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/help",{desc:"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F",handler:()=>{let e=Ih(),t=["\u53EF\u7528\u547D\u4EE4\uFF1A"];for(let[n,r]of e)t.push(` ${n.padEnd(16)}${r.desc}`);return{kind:"text",content:t.join(`
|
|
583
|
-
`)}}});$e("/clear",{desc:"\u6E05\u7A7A\u5BF9\u8BDD\u5386\u53F2",handler:()=>({kind:"clear"})});$e("/version",{desc:"\u663E\u793A\u7248\u672C\u4FE1\u606F",handler:()=>({kind:"text",content:`dskcode v${
|
|
576
|
+
\uFF08\u672C\u63D0\u793A\u672C\u4F1A\u8BDD\u4EC5\u53D1\u4E00\u6B21\uFF0C\u540E\u7EED\u4E0D\u518D\u63D0\u9192\u3002\uFF09`}))}};p();p();var zc=[[0,255,65],[0,255,255],[189,147,249]],qc=[[255,245,180],[255,210,80],[255,150,50]],Kc=[[255,191,0],[210,140,60],[175,70,40]],Un={idlePhaseStep:.06,idleInterval:200,streamingPhaseStep:.2,streamingInterval:200,cmdTipPhaseStep:.2,cmdTipInterval:200},sT=new Set([" ","~",".","\u3002","\uFF01","\u{1F447}"]);function iT(e,t){let n=t.length,r=e*(n-1),o=Math.min(Math.floor(r),n-2),s=r-o,i=t[o],a=t[o+1];if(!i||!a)return"#808080";let l=Math.round(i[0]+(a[0]-i[0])*s),c=Math.round(i[1]+(a[1]-i[1])*s),u=Math.round(i[2]+(a[2]-i[2])*s);return`#${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}`}function Wn(e,t,n){let r=e.length;return r===0?[]:e.split("").map((o,s)=>{if(sT.has(o))return"";let i=(s/(r-1)+t)%1;return iT(i,n)})}p();function fh(e){return e.map(t=>t.trim()).filter(t=>t.length>0).join(`
|
|
577
|
+
`)}p();import{Box as aT,Text as lT}from"ink";import{useEffect as cT,useRef as uT,useState as dT}from"react";import{jsx as gT,jsxs as hT}from"react/jsx-runtime";var pT=[" \u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584 \u2584\u2584"," \u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2580\u2588\u2588\u2588\u2580\u2580","\u2580\u2588 \u2580\u2580\u2588\u2588\u2588\u2584 \u2588\u2588\u2588\u2588"," \u2580\u2588\u2584 \u2584 \u2580\u2588\u2588\u2588\u2588\u2588\u2580"," \u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2584\u2580\u2580\u2580\u2580\u2580"],Xc=22,fT=120,mT="#6185f6";function mh({panelWidth:e}){let t=uT(e),[n,r]=dT(0);cT(()=>{let l=setInterval(()=>{t.current-=1,t.current<=-Xc&&(t.current=e),r(c=>c+1)},fT);return()=>clearInterval(l)},[e]);let o=t.current;if(o>=e)return null;let s=Math.max(0,-o),i=Math.max(0,o+Xc-e),a=Math.max(0,o);return gT(aT,{flexDirection:"column",alignItems:"flex-start",children:pT.map((l,c)=>hT(lT,{color:mT,bold:!0,children:[" ".repeat(a),l.slice(s,Xc-i)]},c))})}p();import{Box as ki,Text as Qe,useInput as yT}from"ink";import{useState as xT}from"react";import{jsx as gt,jsxs as Sr}from"react/jsx-runtime";var Eo=[{number:"1",value:"yes",label:"Yes \u4EC5\u672C\u6B21",color:"green"},{number:"2",value:"no",label:"No \u62D2\u7EDD",color:"red"},{number:"3",value:"always",label:"Always \u672C\u4F1A\u8BDD\u540C\u7C7B\u64CD\u4F5C\u81EA\u52A8\u653E\u884C",color:"cyan"}];function hh({pending:e,onResponse:t}){let[n,r]=xT(0);if(yT((s,i)=>{if(e){if(i.escape){t("no");return}if(i.return){let a=Eo[n];a&&t(a.value);return}if(i.leftArrow){r(a=>(a-1+Eo.length)%Eo.length);return}if(i.rightArrow){r(a=>(a+1)%Eo.length);return}if(s==="1"){t("yes");return}if(s==="2"){t("no");return}if(s==="3"){t("always");return}}},{isActive:!!e}),!e)return null;let{ctx:o}=e;return Sr(ki,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,marginTop:1,children:[gt(Qe,{bold:!0,color:"yellow",children:"\u{1F510} \u6743\u9650\u5BA1\u6279"}),Sr(ki,{flexDirection:"column",marginLeft:2,marginTop:1,children:[Sr(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u5DE5\u5177\uFF1A"}),gt(Qe,{bold:!0,children:o.toolName}),gt(Qe,{dimColor:!0,children:" \uFF08\u5199\u64CD\u4F5C\u786E\u8BA4\uFF09"})]}),Sr(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u539F\u56E0\uFF1A"}),gt(Qe,{children:o.reason})]}),o.toolName==="bash"&&Sr(Qe,{children:[gt(Qe,{dimColor:!0,children:"\u547D\u4EE4\uFF1A"}),gt(Qe,{color:"cyan",children:bT(o)})]})]}),gt(ki,{flexDirection:"row",marginTop:1,gap:2,children:Eo.map((s,i)=>Sr(Qe,{color:i===n?s.color:"gray",bold:i===n,inverse:i===n,children:[" ","[",s.number,"] ",s.label," "]},s.value))}),gt(ki,{marginTop:1,children:gt(Qe,{dimColor:!0,children:"\u2190/\u2192 \u5207\u6362 \xB7 1/2/3 \u76F4\u63A5\u9009 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u62D2\u7EDD"})})]})}function bT(e){if(typeof e.args!="object"||e.args===null)return"(\u65E0\u53C2\u6570)";let n=e.args.command;return typeof n!="string"?"(\u975E\u547D\u4EE4)":n.length<=60?n:n.slice(0,57)+"..."}p();p();import{EventEmitter as CT}from"events";import{randomUUID as yh}from"crypto";import _T from"ws";p();import{gunzipSync as wT,gzipSync as Jc}from"zlib";var kT=1,ST=1,mn={FULL_REQUEST:1,AUDIO_ONLY:2,SERVER_RESPONSE:9,ERROR:15},Hn={NO_SEQUENCE:0,POSITIVE_SEQUENCE:1,LAST_PACKET_NO_SEQ:2,NEGATIVE_SEQUENCE:3,HAS_EVENT:4},Zc={JSON:1},Yc={GZIP:1};function Si(e,t,n,r){let o=Buffer.alloc(4);o[0]=kT<<4|ST,o[1]=e<<4|t&15,o[2]=Zc.JSON<<4|Yc.GZIP,o[3]=0;let s=Buffer.alloc(4);s.writeInt32BE(n);let i=Buffer.alloc(4);return i.writeUInt32BE(r.length),Buffer.concat([o,s,i,r])}function Qc(e,t){let n=Buffer.from(JSON.stringify(e),"utf8"),r=Jc(n);return Si(mn.FULL_REQUEST,Hn.POSITIVE_SEQUENCE,t,r)}function eu(e,t){return Si(mn.AUDIO_ONLY,Hn.POSITIVE_SEQUENCE,t,Jc(e))}function tu(e){return Si(mn.AUDIO_ONLY,Hn.NEGATIVE_SEQUENCE,-Math.abs(e),Jc(Buffer.alloc(0)))}function nu(e){let t={messageType:"unknown",seq:0,isLast:!1,event:0,code:0,body:null,raw:e};if(e.length<4)return t;let n=e[0],r=e[1],o=e[2],s=n&15,i=r>>4,a=r&15,l=o>>4,c=o&15,u=i===mn.SERVER_RESPONSE?"full_response":i===mn.AUDIO_ONLY?"audio_only":i===mn.ERROR?"error":"unknown",d=e.subarray(s*4),m=0;a&Hn.POSITIVE_SEQUENCE&&(m=d.readInt32BE(0),d=d.subarray(4));let h=(a&Hn.LAST_PACKET_NO_SEQ)!==0,f=0;a&Hn.HAS_EVENT&&(f=d.readInt32BE(0),d=d.subarray(4));let g=0;i===mn.ERROR&&(g=d.readInt32BE(0),d=d.subarray(4)),d.length>=4&&(d=d.subarray(4));let b=TT(d,c,l);return{messageType:u,seq:m,isLast:h,event:f,code:g,body:b,raw:e}}function TT(e,t,n){if(e.length===0)return null;let r=e;if(t===Yc.GZIP)try{r=wT(e)}catch{return null}return n===Zc.JSON||r.length>0&&r[0]===123?gh(r):null}function gh(e){try{return JSON.parse(e.toString("utf8"))}catch{return null}}function ru(e){return{user:{uid:e.user.uid,platform:e.user.platform??"Linux",sdk_version:e.user.sdkVersion??"0.1.x"},audio:{format:e.audio.format,codec:e.audio.codec,rate:e.audio.rate,bits:e.audio.bits,channel:e.audio.channel},request:{model_name:e.request.modelName,enable_itn:e.request.enableItn,enable_punc:e.request.enablePunc,enable_ddc:e.request.enableDdc,show_utterances:e.request.showUtterances}}}var vT="wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async",RT="volc.bigasr.sauc.duration",AT=(e,t)=>Reflect.construct(_T,[e,t]),Ti=class extends CT{config;url;resourceId;ws=null;seq=1;started=!1;ended=!1;opened=!1;constructor(t){super(),this.config=t,this.url=t.url??vT,this.resourceId=t.resourceId??RT}connect(){return new Promise((t,n)=>{if(this.ws){n(new Error("VolcAsrClient: \u91CD\u590D\u8C03\u7528 connect()"));return}let r={"X-Api-Resource-Id":this.resourceId,"X-Api-Request-Id":yh(),"X-Api-Access-Key":this.config.accessKey,"X-Api-App-Key":this.config.appId,"X-Api-Sequence":"-1"},o=this.config.wsFactory??AT,s;try{s=o(this.url,{headers:r})}catch(l){n(l instanceof Error?l:new Error(String(l)));return}this.ws=s;let i=()=>{if(!this.opened){this.opened=!0;try{this.sendStart(),this.emit("log","\u2705 \u63E1\u624B\u6210\u529F\uFF0C\u8D77\u59CB\u5305\u5DF2\u53D1"),this.emit("open"),t()}catch(l){n(l instanceof Error?l:new Error(String(l)))}}},a=l=>{this.ended||(this.opened?this.emit("error",-1,l.message):n(l))};s.on("open",i),s.on("error",a),s.on("message",l=>this.onMessage(l)),s.on("close",(l,c)=>this.onClose(l,c))})}sendAudio(t){if(!this.ws||!this.started||this.ended)return;let n=eu(t,this.seq++);this.ws.send(n)}end(){if(!this.ws||this.ended)return;this.ended=!0;let t=tu(this.seq);this.ws.send(t),setTimeout(()=>{try{this.ws?.close()}catch{}},1500)}abort(){if(this.ws){this.ended=!0;try{this.ws.close()}catch{}}}sendStart(){if(!this.ws)return;let t=ru({user:{uid:`dskcode-cli-${yh().slice(0,8)}`},audio:{format:this.config.format??"pcm",codec:this.config.codec??"raw",rate:this.config.sampleRate??16e3,bits:this.config.bits??16,channel:this.config.channel??1},request:{modelName:"bigmodel",enableItn:this.config.enableItn??!0,enablePunc:this.config.enablePunc??!0,enableDdc:this.config.enableDdc??!1,showUtterances:this.config.showUtterances??!0}}),n=Qc(t,this.seq++);this.ws.send(n),this.started=!0}onMessage(t){let n=typeof t=="string"?Buffer.from(t):t,r=nu(n);this.handleResponse(r)}handleResponse(t){if(t.messageType==="error"){let r=t.body?.error??`ASR error code=${t.code}`;this.emit("error",t.code,r);return}if(t.messageType!=="full_response")return;let n=t.body?.result;if(n)if(n.utterances&&n.utterances.length>0)for(let r of n.utterances)r.definite?this.emit("final",r.text):this.emit("partial",r.text);else n.text&&this.emit("partial",n.text)}onClose(t,n){this.ws=null,this.emit("close"),this.emit("log",`\u8FDE\u63A5\u5173\u95ED code=${t} reason=${n?.toString("utf8")||""}`)}};function ou(e){return new Ti(e)}p();import{EventEmitter as $T}from"events";p();import{spawn as ET}from"child_process";import{platform as su}from"os";var iu=(e,t)=>ET(e,t,{stdio:["ignore","pipe","pipe"]}),IT={ffmpeg:["D:\\ffmpeg\\ffmpeg-8.1.2-essentials_build\\bin\\ffmpeg.exe","C:\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe","C:\\Program Files (x86)\\ffmpeg\\bin\\ffmpeg.exe","/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg","/usr/bin/ffmpeg"],sox:["C:\\Program Files (x86)\\sox-14-4-2\\sox.exe","/opt/homebrew/bin/sox","/usr/local/bin/sox","/usr/bin/sox"],arecord:["/usr/bin/arecord","/usr/local/bin/arecord"]};function PT(e,t,n){return new Promise(r=>{let o;try{o=t(e,["-version"])}catch{r(!1);return}let s=setTimeout(()=>{try{o.kill()}catch{}r(!1)},n);o.on("close",i=>{clearTimeout(s),r(i===0)}),o.on("error",()=>{clearTimeout(s),r(!1)})})}var xh={name:"ffmpeg",binary:"ffmpeg",buildArgs:e=>{let t=su();return t==="win32"?["-f","dshow","-i",`audio=${e??"Microphone"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:t==="darwin"?["-f","avfoundation","-i",`:${e??"0"}`,"-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]:["-f","alsa","-i",e??"default","-ar","16000","-ac","1","-f","s16le","-acodec","pcm_s16le","-loglevel","quiet","-"]},listWindowsAudioDevices:async(e,t)=>new Promise(n=>{let r="",o;try{o=e(t,["-list_devices","true","-f","dshow","-i","dummy"])}catch{n(null);return}o.stderr?.on("data",s=>{r+=s.toString("utf8")}),o.on("close",()=>{let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)}),o.on("error",()=>n(null)),setTimeout(()=>{try{o.kill()}catch{}let s=r.match(/"([^"]+)"\s*\(audio\)/);n(s&&s[1]?s[1]:null)},1e4)})},bh={name:"sox",binary:"sox",buildArgs:e=>su()==="win32"||e!==void 0?["-q","-r","16000","-c","1","-t","waveaudio",e??"-d","-t","raw","-"]:["-q","-r","16000","-c","1","-t","waveaudio","-d","-t","raw","-"]},wh={name:"arecord",binary:"arecord",buildArgs:e=>["-q","-f","S16_LE","-r","16000","-c","1",e?["-D",e]:[],"-t","raw"].flat()};async function au(e,t){let n=e==="auto"?[xh,bh,wh]:[xh,bh,wh].filter(r=>r.name===e);for(let r of n){let o=await LT(r.binary,t);if(o)return{...r,binary:o}}throw new Error(`\u672A\u627E\u5230\u53EF\u7528\u7684\u5F55\u97F3\u9A71\u52A8\uFF08driver=${e}\uFF09\u3002\u8BF7\u5B89\u88C5 ffmpeg / sox / arecord \u4E4B\u4E00\u3002\u8BE6\u89C1 docs/\u8BED\u97F3\u8BC6\u522Bvoice\u547D\u4EE4\u63A5\u5165.md \xA712.1\u3002`)}async function LT(e,t){let n=IT[e]??[];for(let r of[e,...n])if(await PT(r,t,1500))return r;return null}async function kh(e,t){return su()!=="win32"||!e.listWindowsAudioDevices?null:e.listWindowsAudioDevices(t,e.binary)}var OT=200,DT=60,NT=16e3,MT=16,BT=1,FT=NT*(MT/8)*BT,Ci=class extends $T{options;proc=null;driver=null;buf=[];bufSize=0;chunkBytes;started=!1;stopped=!1;maxDurationTimer=null;constructor(t={}){super(),this.options={chunkMs:t.chunkMs??OT,maxDurationSec:t.maxDurationSec??DT,driver:t.driver??"auto",deviceName:t.deviceName,spawner:t.spawner},this.chunkBytes=Math.floor(FT*this.options.chunkMs/1e3)}async start(){if(this.started)throw new Error("VoiceCapture: \u91CD\u590D\u8C03\u7528 start()");this.started=!0,this.stopped=!1;let t=this.options.spawner??iu;this.driver=await au(this.options.driver,t),this.emit("log",`\u4F7F\u7528\u5F55\u97F3\u9A71\u52A8: ${this.driver.name}`);let n=this.options.deviceName;if(!n){let s=await kh(this.driver,t);s&&(n=s,this.emit("log",`\u68C0\u6D4B\u5230\u9EA6\u514B\u98CE\u8BBE\u5907: ${n}`))}let r=this.driver.buildArgs(n);this.emit("log",`\u542F\u52A8\u5B50\u8FDB\u7A0B: ${this.driver.binary} ${r.join(" ")}`);let o;try{o=t(this.driver.binary,r)}catch(s){throw this.started=!1,s instanceof Error?s:new Error(String(s))}this.proc=o,o.stdout?.on("data",s=>this.ingest(s)),o.on("error",s=>{this.emit("error",s)}),o.on("close",s=>{if(this.bufSize>0){let i=Buffer.concat(this.buf,this.bufSize);this.emit("data",i),this.buf=[],this.bufSize=0}if(this.started=!1,this.proc=null,!this.stopped&&s!==0&&s!==null){this.emit("error",new Error(`\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5F02\u5E38\u9000\u51FA code=${s}\uFF08\u53EF\u80FD\u662F\u8BBE\u5907\u540D\u9519\u8BEF\u6216\u6743\u9650\u88AB\u62D2\uFF09`));return}this.emit("end")}),this.options.maxDurationSec>0&&(this.maxDurationTimer=setTimeout(()=>{this.emit("log",`\u5DF2\u8FBE ${this.options.maxDurationSec}s \u4E0A\u9650\uFF0C\u81EA\u52A8\u505C\u6B62`),this.stop()},this.options.maxDurationSec*1e3))}stop(){if(!(!this.proc||this.stopped)){this.stopped=!0,this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null);try{this.proc.kill()}catch(t){this.emit("error",t instanceof Error?t:new Error(`kill \u5B50\u8FDB\u7A0B\u5931\u8D25: ${String(t)}`))}}}abort(){if(this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.proc)try{this.proc.kill()}catch{}this.started=!1}isRecording(){return this.started}ingest(t){for(this.buf.push(t),this.bufSize+=t.length;this.bufSize>=this.chunkBytes;){let n=Buffer.concat(this.buf),r=n.subarray(0,this.chunkBytes);this.buf=[n.subarray(this.chunkBytes)],this.bufSize=n.length-this.chunkBytes,this.emit("data",r)}}};function lu(e={}){return new Ci(e)}p();import{EventEmitter as GT}from"events";var _i=class extends GT{config;phase="idle";asr=null;cap=null;connecting=!1;lastError=null;constructor(t){super(),this.config=t}async start(){if(this.phase!=="idle"&&this.phase!=="error"){this.emit("log",`\u5DF2\u7ECF\u5728 ${this.phase} \u72B6\u6001\uFF0C\u5FFD\u7565 start()`);return}this.connecting=!0,this.lastError=null,this.setPhase("connecting");let n=(this.config.asrFactory??(()=>jT(this.config.asr)))();this.asr=n,this.bindAsrEvents(n);try{await n.connect()}catch(s){this.lastError=`\u8FDE\u63A5 ASR \u5931\u8D25: ${Sh(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}let o=(this.config.recorderOptions?.captureFactory??UT)();this.cap=o,this.bindCapEvents(o);try{await o.start()}catch(s){this.lastError=`\u542F\u52A8\u5F55\u97F3\u5931\u8D25: ${Sh(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}this.connecting=!1,this.setPhase("recording")}stop(){if(this.phase!=="recording"&&this.phase!=="connecting"&&this.phase!=="finalizing"){this.emit("log",`\u5F53\u524D phase=${this.phase}\uFF0C\u5FFD\u7565 stop()`);return}if(this.phase==="finalizing"){this.abort();return}this.setPhase("finalizing"),this.cap&&this.cap.isRecording()&&this.cap.stop()}abort(){this.setPhase("error"),this.cleanup()}getPhase(){return this.phase}getLastError(){return this.lastError}setPhase(t){this.phase!==t&&(this.phase=t,this.emit("phase",t))}bindAsrEvents(t){t.on("partial",n=>this.emit("partial",n)),t.on("final",n=>this.emit("final",n)),t.on("error",(n,r)=>{this.lastError=`ASR \u9519\u8BEF: ${r}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("close",()=>{this.emit("log","ASR WebSocket \u5DF2\u5173\u95ED"),(this.phase==="recording"||this.phase==="finalizing")&&(this.setPhase("idle"),this.cleanup())}),t.on("log",n=>this.emit("log",`[asr] ${n}`))}bindCapEvents(t){t.on("data",n=>{this.asr&&this.phase==="recording"&&this.asr.sendAudio(n)}),t.on("error",n=>{this.lastError=`\u5F55\u97F3\u9519\u8BEF: ${n.message}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup()}),t.on("end",()=>{if(this.emit("log","\u5F55\u97F3\u5B50\u8FDB\u7A0B\u5DF2\u7ED3\u675F"),this.asr)try{this.asr.end()}catch{}}),t.on("log",n=>this.emit("log",`[rec] ${n}`))}cleanup(){try{this.asr?.abort()}catch{}try{this.cap?.abort()}catch{}this.asr=null,this.cap=null}};function jT(e){return ou({appId:e.appId,accessKey:e.accessKey,resourceId:e.resourceId})}function UT(){return lu()}function Sh(e){return e instanceof Error?e.message:String(e)}function cu(e){return new _i(e)}import{Fragment as vh,jsx as O,jsxs as K}from"react/jsx-runtime";var uu={thinking:{icon:"\u{1F9E0}",label:"\u601D\u8003\u4E2D",color:"#ff9800"},generating:{icon:"\u2728",label:"\u751F\u6210\u4E2D",color:"#00ff41"},calling_tools:{icon:"\u{1F6E0}",label:"\u8C03\u7528\u5DE5\u5177",color:"#f59e0b"},executing_tools:{icon:"\u26A1",label:"\u6267\u884C\u5DE5\u5177",color:"#00ffff"}};function zT(e){return e==="edit_file"||e==="write_file"||e==="multi_edit"||e==="delete_range"}function Ch(e){if(!e)return;let t=e.filter(n=>!n.name.startsWith("todo_"));return t.length>0?t:void 0}var fu=new Map;function $e(e,t){fu.set(e,t)}function Rh(){return fu}$e("/exit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/quit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});$e("/help",{desc:"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F",handler:()=>{let e=Rh(),t=["\u53EF\u7528\u547D\u4EE4\uFF1A"];for(let[n,r]of e)t.push(` ${n.padEnd(16)}${r.desc}`);return{kind:"text",content:t.join(`
|
|
578
|
+
`)}}});$e("/clear",{desc:"\u6E05\u7A7A\u5BF9\u8BDD\u5386\u53F2",handler:()=>({kind:"clear"})});$e("/version",{desc:"\u663E\u793A\u7248\u672C\u4FE1\u606F",handler:()=>({kind:"text",content:`dskcode v${So}`})});$e("/model",{desc:"\u5207\u6362\u6A21\u578B",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /model \u8FDB\u5165\u9009\u62E9\u754C\u9762"})});$e("/thinking",{desc:"\u5207\u6362\u6DF1\u5EA6\u601D\u8003\u6A21\u5F0F",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /thinking \u5207\u6362"})});$e("/effort",{desc:"\u5207\u6362\u63A8\u7406\u7B49\u7EA7 High/Max",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /effort \u5207\u6362"})});$e("/game",{desc:"\u542F\u52A8\u6E38\u620F",handler:()=>({kind:"navigate",target:"game"})});$e("/stock",{desc:"\u67E5\u770B\u80A1\u7968\u884C\u60C5",handler:()=>({kind:"navigate",target:"stock"})});$e("/plan",{desc:"\u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08Shift+Tab\uFF09",handler:()=>({kind:"text",content:"\u8F93\u5165 /plan \u6216\u6309 Shift+Tab \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F"})});$e("/code",{desc:"\u5207\u6362\u56DE\u4EE3\u7801\u6A21\u5F0F\uFF08Shift+Tab\uFF09",handler:()=>({kind:"text",content:"\u8F93\u5165 /code \u6216\u6309 Shift+Tab \u5207\u6362\u56DE\u4EE3\u7801\u6A21\u5F0F"})});$e("/rewind",{desc:"\u56DE\u9000\u5230\u5386\u53F2\u68C0\u67E5\u70B9\uFF081 = \u6700\u65B0\uFF09",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /rewind \u67E5\u770B\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u5217\u8868\uFF0C\u6216 /rewind <\u5E8F\u53F7> \u76F4\u63A5\u56DE\u9000\uFF081 = \u6700\u65B0\uFF0C2 = \u4E0A\u4E00\u6B21\uFF0C\u4F9D\u6B64\u7C7B\u63A8\uFF09"})});$e("/compact",{desc:"\u538B\u7F29\u4E0A\u4E0B\u6587\uFF1A\u6458\u8981\u65E7\u56DE\u5408\u5E76\u4FDD\u7559\u6700\u8FD1 N \u8F6E",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /compact \u624B\u52A8\u538B\u7F29\u4E0A\u4E0B\u6587\uFF08\u9700\u5F53\u524D\u4E0D\u5904\u4E8E\u751F\u6210\u4E2D\uFF09"})});$e("/voice",{desc:"\u8BED\u97F3\u8F93\u5165\uFF08F2 \u6216 /voice \u542F\u52A8\uFF0CESC \u53D6\u6D88\uFF09",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /voice \u6216\u6309 F2 \u542F\u52A8\u8BED\u97F3\u8BC6\u522B"})});$e("/permissions",{desc:"\u67E5\u770B\u5F53\u524D\u6743\u9650\u89C4\u5219\u4E0E\u4F1A\u8BDD grants\uFF08v0.6\uFF09",handler:()=>({kind:"permissions"})});var qT=["\u8BA9\u5B50\u5F39\u98DE\u4E00\u4F1A\u513F...","\u9A6C\u4E0A\u5C31\u597D...","\u6B63\u5728\u618B\u5927\u62DB...","\u7A0D\u7B49\u4E00\u4E0B\u4E0B~","\u7801\u5B57\u4E2D...","\u8111\u5B50\u8F6C\u5F97\u98DE\u5FEB..."],_h=["\u60F3\u5E72\u5565\uFF1F\u76F4\u63A5\u8BF4~","\u6765\u5427\uFF0C\u5429\u5490\u70B9\u5565","\u968F\u65F6\u5F85\u547D...","\u6233\u8FD9\u91CC\u5F00\u804A...","\u7B49\u4F60\u5F00\u53E3...","\u5C3D\u7BA1\u4F7F\u5524~"];function du(e){return e[Math.floor(Math.random()*e.length)]}function mu({skillCount:e,skills:t=[],files:n=[],toolCount:r,verbose:o,apiKey:s,baseUrl:i,costTracker:a,model:l="deepseek-v4-flash",permissionsConfig:c,voiceConfig:u,configReloadEpoch:d,thinkingEnabledFromConfig:m,thinkingEffortFromConfig:h,verboseFromConfig:f,onLaunchGame:g,onLaunchStock:b}){let S=(typeof process.stdout.columns=="number"?process.stdout.columns:80)-2,v=Math.max(Math.floor(S/3),30),_=S-v-1,[E,M]=z(0),[U,T]=z([]),[N,F]=z(0),[q,$]=z(""),[oe,le]=z(null),ee=ae(null),[W,se]=z(null),[ce,zn]=z(!1),[qn,Eu]=z(null),[Pe,hg]=z("idle"),[$i,Oi]=z(""),Oo=ae(null),[Ar,Di]=z(null),[ie,Do]=z(!1),[Er,Pt]=z(null),[hn,Ni]=z(""),[gn,gg]=z(()=>du(_h)),[Mi,Bi]=z([]),No=ae(0),[Fi,Gi]=z([]),Mo=ae(0),[ji,Ui]=z(""),[Wi,Hi]=z([]),[Bo,Vi]=z([]),[yg,Iu]=z(()=>new Map),[Pu,Lu]=z(void 0),[QC,$u]=z(void 0),[Ou,Du]=z(void 0),[tt,zi]=z(l),[Nu,Mu]=z(void 0),[qi,Fo]=z(void 0),[yn,Go]=z([]),[e_,t_]=z(""),[Bu,jo]=z(!0),Xt=ae(null),Ir=ae(-1),[Jt,Uo]=z("code"),[Kn,Fu]=z(!0),[Pr,Gu]=z("high"),[Ki]=z("text"),[Lr,Wo]=z(void 0),ju=Th(()=>U.reduce((C,k)=>k.assistantDetail?.cost?C+k.assistantDetail.cost:C,0),[U]),$r=U.length>0,xg=ie&&Wi.length>0,bt=Array.from(Rh()).filter(([C])=>C!=="/exit"&&C!=="/quit").map(([C,k])=>({name:C,desc:k.desc})),[Ho,bg]=z(0),[Xi,Ji]=z([]),Vo=ae(0),[Or,Zi]=z(0),[Xn,zo]=z(0),[Uu,Yi]=z(0),[xn,qo]=z(!1),[Dr,Ko]=z(0),[bn,wg]=z([]),[Qi,Wu]=z(!1),[Nr,Xo]=z(!1),[Hu,ea]=z("idle"),ta=ae(!1),wt=ae(null),[Zt,na]=z(!1),[Jo,Zo]=z(0),Yt=["deepseek-v4-flash","deepseek-v4-pro"],[Vu,Qt]=z({phase:"idle",progress:null}),Ne=ae(null),Jn=ae(void 0),ue=ae(null),ra=ae(null),zu=ae([]),Yo=ae(""),Qo=ae([]),es=ae([]),ts=ae(new Map),[kg,qu]=z(null),oa=ae(null),sa=ct(C=>new Promise(k=>{oa.current=k,qu({ctx:C,resolve:k})}),[]),Sg=ct(C=>{let k=oa.current;oa.current=null,qu(null),k?.(C)},[]),ia=ae(void 0),aa=ae(void 0),la=ae(void 0),ca=ae(void 0),ns=ae(void 0);Se(()=>{Zi(0),zo(0)},[q]),Se(()=>()=>{wt.current&&(clearTimeout(wt.current),wt.current=null),Ne.current&&(clearTimeout(Ne.current),Ne.current=null),ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),Se(()=>{if(oe==null)return;let C=setTimeout(()=>le(null),5e3);return ee.current=C,()=>clearTimeout(C)},[oe]),Se(()=>{d===void 0||d===0||le(Date.now())},[d]),Se(()=>{l&&zi(l)},[l]),Se(()=>{m!==void 0&&Fu(m)},[m]),Se(()=>{h!==void 0&&Gu(h)},[h]),Se(()=>{let C=()=>{let I=ue.current;if(!I){Di(null);return}try{let V=I.getContextStats();Di({tokens:V.estimatedTokens,ratio:V.ratio,contextWindow:V.contextWindow})}catch{Di(null)}};C();let k=setInterval(C,3e3);return()=>clearInterval(k)},[]),Se(()=>{if(Xt.current&&(clearTimeout(Xt.current),Xt.current=null),yn.length===0){jo(!1);return}yn.some(k=>k.status==="pending"||k.status==="running"||k.status==="failed")?jo(!0):(Ir.current=Math.max(...yn.map(k=>k.id)),Xt.current=setTimeout(()=>{jo(!1),Xt.current=null},2e3))},[yn]);let ua=ct(C=>{let k=C.match(/(?:^|\s)\/([^/]*)$/);if(!k)return[];let I=k[1].toLowerCase().trim();if(!I)return C.startsWith("/")?t.slice(0,3):[];let V=t.filter(P=>P.name.toLowerCase().includes(I)).slice(0,3);return V.some(P=>P.name.toLowerCase()===I)?[]:V},[t]),Ku=ct(C=>bo(C,n)??[],[n]),rs=ct((C,k)=>{let I=bo(C,n);if(!I||I.length===0)return!1;let V=I[k];if(!V)return!1;let P=C.lastIndexOf("@");return P<0?!1:($(C.slice(0,P)+"@"+V+" "),Yi(te=>te+1),zo(0),!0)},[n]);function Tg(C){let k=[];for(let I of C.messages)I.role==="user"?k.push({role:"user",content:I.content}):I.role==="assistant"?k.push({role:"assistant",content:I.content,assistantDetail:{content:I.content,toolCalls:Ch(I.toolCalls)}}):I.role==="tool"&&k.push({role:"tool",content:I.content});T(k),F(I=>I+1)}let da=ct(async(C,k)=>{let I=ue.current;if(I){Wu(!0),Do(!0),Pt("thinking"),Ni("\u23EA \u6B63\u5728\u56DE\u9000\u5230\u68C0\u67E5\u70B9\u2026"),$("");try{let V=await I.rewind(C.index);if(V.ok){Tg(I);let P=V.fileRestored?"\uFF0C\u5DE5\u4F5C\u533A\u6587\u4EF6\u5DF2\u6062\u590D":"\uFF08\u4EC5\u5BF9\u8BDD\u56DE\u9000\uFF0C\u672A\u6062\u590D\u6587\u4EF6\uFF09";T(te=>[...te,{role:"assistant",content:`\u23EA \u5DF2\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #${k}${P}\u3002`}])}else T(P=>[...P,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5931\u8D25\uFF1A${V.error}`}])}catch(V){let P=V instanceof Error?V.message:String(V);T(te=>[...te,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5F02\u5E38\uFF1A${P}`}])}finally{Wu(!1),Do(!1),Pt(null),Ni("")}}},[]),pa=ct(async()=>{if(!u||!u.resolved){let k=u?.missing?.join(", ")??"appId, accessKey";T(I=>[...I,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u672A\u914D\u7F6E\uFF08\u7F3A ${k}\uFF09\u3002
|
|
584
579
|
\u8BF7\u5230\u706B\u5C71\u63A7\u5236\u53F0 https://console.volcengine.com/speech \u5F00\u901A\u201C\u8BED\u97F3\u8BC6\u522B-\u5927\u6A21\u578B\u7248\u201D\uFF0C
|
|
585
580
|
\u7136\u540E\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF VOLC_ASR_APP_ID \u548C VOLC_ASR_ACCESS_KEY\uFF0C
|
|
586
|
-
\u6216\u5728 ~/.dskcode/settings.json \u6DFB\u52A0 voice \u6BB5\u3002`}]);return}if(
|
|
581
|
+
\u6216\u5728 ~/.dskcode/settings.json \u6DFB\u52A0 voice \u6BB5\u3002`}]);return}if(Pe!=="idle"&&Pe!=="error")return;Oi("");let C=cu({asr:{appId:u.config.appId,accessKey:u.config.accessKey,resourceId:u.config.resourceId}});C.on("phase",k=>hg(k)),C.on("partial",k=>Oi(k)),C.on("final",k=>{$(I=>I?I+k:k),Oi("")}),C.on("error",k=>{T(I=>[...I,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u51FA\u9519: ${k}`}])}),C.on("log",k=>{o&&console.error(`[voice] ${k}`)}),Oo.current=C,await C.start()},[u,Pe,o]),fa=ct(()=>{Oo.current?.stop()},[]),ma=ct(()=>{Pe==="recording"||Pe==="connecting"?fa():(Pe==="idle"||Pe==="error")&&pa()},[Pe,pa,fa]),{doubleCtrlC:Cg,handleCtrlC:Xu}=Sn(()=>{if(Oo.current)try{Oo.current.abort()}catch{}let C=ue.current;C?C.flushLog().finally(()=>process.exit(0)):process.exit(0)});WT(ct((C,k)=>{if(Nr){k.ctrl&&C==="p"&&Xo(!1);return}if(xn){if(k.upArrow)Ko(P=>(P-1+bn.length)%bn.length);else if(k.downArrow)Ko(P=>(P+1)%bn.length);else if(k.return){let P=bn[Dr];qo(!1),P&&da(P,Dr+1)}else k.escape&&(qo(!1),T(P=>[...P,{role:"assistant",content:"\u5DF2\u53D6\u6D88\u56DE\u9000\u3002"}]));return}if(Zt){if(k.upArrow)Zo(P=>(P-1+Yt.length)%Yt.length);else if(k.downArrow)Zo(P=>(P+1)%Yt.length);else if(k.return){let P=Yt[Jo];P===tt?T(te=>[...te,{role:"assistant",content:`\u5DF2\u7ECF\u5728\u4F7F\u7528 ${kn[P].displayName}`}]):(zi(P),ue.current?.reset(),Yu(P).catch(()=>{}),T(te=>[...te,{role:"assistant",content:`\u6A21\u578B\u5DF2\u5207\u6362\u4E3A ${kn[P].displayName}\uFF08${P}\uFF09`}])),na(!1)}else k.escape&&na(!1);return}let I=Ku(q),V=I.length===0?ua(q):[];if(I.length>0){if(k.upArrow){zo(P=>(P-1+I.length)%I.length);return}if(k.downArrow){zo(P=>(P+1)%I.length);return}if(k.tab){rs(q,Xn);return}}if(V.length>0){if(k.upArrow){Zi(P=>(P-1+V.length)%V.length);return}if(k.downArrow){Zi(P=>(P+1)%V.length);return}if(k.tab){let P=V[Or];if(P){let te=q.lastIndexOf("/");te>=0&&($(q.slice(0,te)+"/"+P.name+" "),Yi(D=>D+1))}return}}if(Zt){k.upArrow||k.downArrow;return}if(k.ctrl&&C==="c"){ie?ra.current?.abort():Xu();return}if(k.ctrl&&C==="p"&&!ie&&!xn&&!Zt){Xo(!0);return}if(k.escape&&(Pe==="recording"||Pe==="connecting"||Pe==="finalizing")){fa();return}if(k.shift&&k.tab){if(!ie){let P=Jt==="plan"?"code":"plan";Uo(P),ue.current?.setMode(P),Wo(void 0),ue.current?.reset(),T(te=>[...te,{role:"assistant",content:P==="plan"?`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**\uFF08Shift+Tab\uFF09
|
|
587
582
|
|
|
588
583
|
\u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C\u6211\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u4F1A\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u3002`:`\u{1F6E0} \u5DF2\u5207\u6362\u4E3A **\u4EE3\u7801\u6A21\u5F0F**\uFF08Shift+Tab\uFF09
|
|
589
584
|
|
|
590
|
-
\u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002`}])}return}!
|
|
591
|
-
\u53EA\u6709\u5728 git \u4ED3\u5E93\u5185\u4E14\u53D1\u751F\u8FC7\u5BF9\u8BDD\u540E\u624D\u4F1A\u751F\u6210\u68C0\u67E5\u70B9\u3002`}])
|
|
592
|
-
\u26A0 \u6458\u8981\u4E3A\u672C\u5730\u5151\u5E95\uFF08LLM \u4E0D\u53EF\u7528\uFF09`:"";
|
|
585
|
+
\u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002`}])}return}!q&&!ie&&C&&$(C)},[Zt,Jo,Yt,tt,ie,Xu,q,t,Or,Xn,ua,Ku,rs,Jt,Uo,xn,Dr,bn,da,ma])),Se(()=>{if(!process.stdin.isTTY)return;let C=Buffer.alloc(0),k=[Buffer.from([27,79,81]),Buffer.from([27,91,49,50,126]),Buffer.from([27,91,91,66])],I=V=>{let P=Buffer.isBuffer(V)?V:Buffer.from(V,"binary");C=Buffer.concat([C,P]),C.length>16&&(C=C.subarray(C.length-16));for(let te of k)if(C.includes(te)){C=Buffer.alloc(0),!ie&&!xn&&!Zt&&ma();return}};return process.stdin.on("data",I),()=>{process.stdin.off("data",I)}},[ie,xn,Zt,ma]),Se(()=>{if(bt.length<=1)return;let C=setInterval(()=>{bg(k=>(k+1)%bt.length)},2e3);return()=>clearInterval(C)},[bt.length]),Se(()=>{let C=bt[Ho%bt.length];if(!C){Ji([]);return}let k=`${C.name} ${C.desc}`;Vo.current=0,Ji(Wn(k,1,qc));let I=setInterval(()=>{Vo.current=(Vo.current+Un.cmdTipPhaseStep)%1,Ji(Wn(k,1-Vo.current,qc))},Un.cmdTipInterval);return()=>clearInterval(I)},[Ho,bt.length]),Se(()=>{let C=setInterval(()=>{M(k=>(k+1)%Gr.length)},500);return()=>clearInterval(C)},[]),Se(()=>{let C=!1;if(!s||!i)return;let k=yc({name:"deepseek",apiKey:s,baseUrl:i,model:tt}),I=a??new Me,V=new un;return V.registerAll(Vc),(async()=>{let P=new jn,te=[];try{let{loadAllSkills:D}=await import("./loader-GPVLJCXF.js"),R=await D(process.cwd());if(te=R.skills,zu.current=R.skills,o&&R.errors.length>0)for(let L of R.errors)console.warn(` \u26A0 ${L.message} (${L.skillFilePath})`)}catch(D){o&&console.warn(` \u26A0 \u52A0\u8F7D skill \u5931\u8D25\uFF1A${D instanceof Error?D.message:String(D)}`)}if(c){let{permissionsFromConfig:D}=await import("./permissions-loader-YST5MXNS.js"),{InteractiveGate:R}=await import("./interactive-gate-XKNHF4ZY.js"),L=D(c);if(!C){let j=new R({engine:L.engine,grants:void 0,prompt:sa,defaultDecision:"confirm"}),Z=new Ao(k,V,I,{cwd:process.cwd(),gate:new fn([new jn,j]),skills:te});ue.current=Z,is.register({id:Z.id,cwd:process.cwd(),chat:(ft,Zn)=>Z.chat(ft,Zn)},()=>Z.flushLog(),{onRemoteUserInput:async(ft,Zn)=>{if(!Mr.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await Mr.current(ft,Zn,{displayText:ft})}})}if(o&&L.warnings.length>0)for(let j of L.warnings)console.warn(` \u26A0 ${j}`)}else{let{WriteConfirmGate:D}=await import("./write-gate-HEFJJQX6.js");if(!C){let R=new D(V,sa),L=new Ao(k,V,I,{cwd:process.cwd(),gate:new fn([P,R]),skills:te});ue.current=L,is.register({id:L.id,cwd:process.cwd(),chat:(j,Z)=>L.chat(j,Z)},()=>L.flushLog(),{onRemoteUserInput:async(j,Z)=>{if(!Mr.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await Mr.current(j,Z,{displayText:j})}})}}})(),()=>{C=!0,ue.current&&is.unregister(ue.current.id),ue.current=null}},[s,i,tt,a,sa,o]),Se(()=>{if(!s||!i)return;let C=!1;return zn(!0),import("./deepseek-X6USE3PW.js").then(({DeepSeekProvider:k})=>new k({apiKey:s,baseUrl:i,model:"deepseek-v4-flash"}).getBalance()).then(k=>{if(C)return;let I=k.balances.find(V=>V.currency==="CNY");I&&se(I.totalBalance)}).catch(()=>{}).finally(()=>{C||zn(!1)}),()=>{C=!0}},[s,i]),Se(()=>{if(!a)return;let C=!1,k,I=()=>{Eu(a.todayTotalCost)};return a.load().then(()=>{C||(I(),k=setInterval(I,5e3))}).catch(()=>{}),()=>{C=!0,k&&clearInterval(k)}},[a]),Se(()=>{if(ie||!gn){Bi([]);return}No.current=0,Bi(Wn(gn,1,zc));let C=setInterval(()=>{No.current=(No.current+Un.idlePhaseStep)%1,Bi(Wn(gn,1-No.current,zc))},Un.idleInterval);return()=>clearInterval(C)},[ie,gn]),Se(()=>{if(!ie||!hn){Gi([]);return}Mo.current=0,Gi(Wn(hn,1,Kc));let C=setInterval(()=>{Mo.current=(Mo.current+Un.streamingPhaseStep)%1,Gi(Wn(hn,1-Mo.current,Kc))},Un.streamingInterval);return()=>clearInterval(C)},[ie,hn]);let os=ct(async(C,k,I)=>{let V=ue.current;if(!V){T(D=>[...D,{role:"user",content:I.displayText},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]);return}let P=k==="chrome"?`\u{1F310} [chrome] ${I.displayText}`:k==="api"?`\u{1F50C} [api] ${I.displayText}`:k==="test"?`\u{1F9EA} [test] ${I.displayText}`:I.displayText;T(D=>[...D,{role:"user",content:P}]),Do(!0),Pt("thinking"),Ni(du(qT)),Ui(""),Hi([]),Vi([]),Lu(void 0),$u(void 0),Du(void 0),Mu(void 0),Fo(void 0),Iu(new Map),ts.current=new Map,Yo.current="",Qo.current=[],es.current=[],ia.current=void 0,aa.current=void 0,la.current=void 0,ca.current=void 0,ns.current=void 0,ta.current=!1,ea("idle"),wt.current&&(clearTimeout(wt.current),wt.current=null),Go([]),Xt.current&&(clearTimeout(Xt.current),Xt.current=null),jo(!1),Qt({phase:"idle",progress:null}),Jn.current=void 0,Ne.current&&(clearTimeout(Ne.current),Ne.current=null);let te=new AbortController;ra.current=te;try{for await(let D of V.chat(C,{thinkingAllowed:I.thinkingAllowed,thinkingEffort:I.thinkingEffort,...I.responseFormat?{responseFormat:I.responseFormat}:{},...I.toolChoice?{toolChoice:I.toolChoice}:{}})){if(te.signal.aborted)break;switch(D.type){case"text_delta":Pt("generating"),Ui(R=>{let L=R+D.content;return Yo.current=L,L});break;case"reasoning_delta":Pt("thinking"),Hi(R=>{let L=R[R.length-1],j=L!==void 0?[...R.slice(0,-1),L+D.content]:[...R,D.content];return Qo.current=j,j});break;case"tool_calls":Pt("calling_tools"),Vi(R=>{let L=[...R,...D.calls];return es.current=L,L});for(let R of D.calls)if(zT(R.name)){ta.current=!0;break}break;case"tool_result":Pt("executing_tools"),setTimeout(()=>Pt("thinking"),300),Ui(""),Yo.current="",Hi(R=>{let L=[...R,""];return Qo.current=L,L}),Vi([]),es.current=[];{let R=D.callId??`${D.name}#${D.result.data.length}`;Iu(L=>{let j=new Map(L);return j.set(R,{success:D.result.success,...D.result.error?{error:D.result.error}:{},...D.result.denial?{denial:D.result.denial}:{}}),ts.current=j,j})}{let R=D.result;if(D.name.startsWith("todo_")&&D.todoSnapshot){let L=[...D.todoSnapshot];L.length>0&&L.every(Z=>Z.status==="done"||Z.status==="failed"||Z.status==="skipped")?(Ir.current=Math.max(...L.map(Z=>Z.id)),Go(L)):Ir.current>=0?Go(L.filter(Z=>Z.id>Ir.current)):Go(L)}else{let L=R.success?R.summary??`\u2705 ${D.name}: ${R.data.slice(0,500)}${R.data.length>500?"...":""}`:`\u274C ${D.name}: ${R.error??"\u6267\u884C\u5931\u8D25"}`;T(j=>[...j,{role:"tool",content:L,diff:R.diff}])}}break;case"usage":Lu(D.usage),Mu(D.model),ia.current=D.usage,ca.current=D.model;{let R=kt(D.usage,D.model);Du(R.totalCost),la.current=R.totalCost}break;case"done":$u(D.elapsed),aa.current=D.elapsed;break;case"error":Fo(D.error.message),ns.current=D.error.message;break}}}catch(D){let R=D instanceof Error?D.message:String(D);Fo(R),ns.current=R}finally{Do(!1),Pt(null),gg(du(_h)),ra.current=null;let D=Yo.current,R=Qo.current.map(Z=>Z.trim()).filter(Z=>Z.length>0),L=Ch(es.current),j=ns.current;if(D||L||j){let Z={content:j?`\u26A0 \u8BF7\u6C42\u51FA\u9519\uFF1A${j}`:D||"",...R.length>0?{reasoning:R}:{},toolCalls:L,toolResults:ts.current.size>0?new Map(ts.current):void 0,usage:ia.current,elapsed:aa.current,cost:la.current,model:ca.current};T(ft=>[...ft,{role:"assistant",content:Z.content,assistantDetail:Z}])}ta.current&&!j&&(ea("pending"),wt.current&&clearTimeout(wt.current),wt.current=setTimeout(()=>{ea(Z=>Z==="pending"?"visible":Z),wt.current=null},2e3))}},[]),Mr=ae(null);Se(()=>{Mr.current=os},[os]);let Ju=ct(async C=>{if(rs(C,Xn))return;let k=C.trim();if(!k)return;let I=k;if(k.startsWith("/")&&k.length>1){let P=k.toLowerCase();if(P==="/rewind"||P.startsWith("/rewind ")){if(ie||Qi){let j=Qi?"\u56DE\u9000\u4E2D":"\u751F\u6210\u4E2D";T(Z=>[...Z,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u6B63\u5728${j}\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /rewind\u3002`}]),$("");return}if(!ue.current){T(j=>[...j,{role:"user",content:k},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u56DE\u9000\u3002"}]),$("");return}let R=ue.current.listCheckpoints();if(R.length===0){T(j=>[...j,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u6CA1\u6709\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u3002
|
|
586
|
+
\u53EA\u6709\u5728 git \u4ED3\u5E93\u5185\u4E14\u53D1\u751F\u8FC7\u5BF9\u8BDD\u540E\u624D\u4F1A\u751F\u6210\u68C0\u67E5\u70B9\u3002`}]),$("");return}let L=k.split(/\s+/);if(L.length>=2){let j=Number(L[1]);if(!Number.isInteger(j)||j<1||j>R.length){T(ft=>[...ft,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u65E0\u6548\u7684\u5E8F\u53F7\u300C${L[1]}\u300D\u3002\u53EF\u7528\u8303\u56F4 1~${R.length}\uFF081 \u8868\u793A\u6700\u65B0\uFF09\u3002`}]),$("");return}let Z=R[R.length-j];$(""),await da(Z,j);return}wg([...R].reverse()),Ko(0),qo(!0),T(j=>[...j,{role:"user",content:k},{role:"assistant",content:`\u23F7\u2191\u2193 \u9009\u62E9\u68C0\u67E5\u70B9\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88\uFF08\u5171 ${R.length} \u4E2A\u53EF\u56DE\u9000\u4F4D\u7F6E\uFF09`}]),$("");return}if(P==="/compact"){if(ie){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u26A0 \u6B63\u5728\u751F\u6210\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /compact\u3002"}]),$("");return}if(!ue.current){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u538B\u7F29\u3002"}]),$("");return}$(""),T(R=>[...R,{role:"user",content:k}]),Qt({phase:"running",progress:null,beforeTokens:void 0,afterTokens:void 0,droppedTurns:void 0,keptTurns:void 0,strategy:void 0,errorMessage:void 0});try{let R=await ue.current.compact(L=>{Qt(j=>{if(L.type==="start")return{...j,phase:"running",progress:L,beforeTokens:L.beforeTokens,droppedTurns:L.droppedTurns};if(L.type==="summary_delta")return{...j,phase:"running",progress:L};if(L.type==="fallback")return Jn.current="fallback",{...j,phase:"running",progress:L,strategy:"fallback"};if(L.type==="done"){let Z=Jn.current==="fallback"?"fallback":"summary";return Jn.current=Z,{...j,phase:"done",progress:L,droppedTurns:L.droppedTurns,keptTurns:L.keptTurns,beforeTokens:L.beforeTokens,afterTokens:L.afterTokens,strategy:Z}}return j})});R.droppedTurns===0?(Qt(L=>({...L,phase:"done",progress:L.progress,droppedTurns:0,keptTurns:R.keptTurns,beforeTokens:R.beforeTokens,afterTokens:R.afterTokens,strategy:void 0})),Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{Qt({phase:"idle",progress:null}),T(L=>[...L,{role:"assistant",content:"\u2139 \u5F53\u524D\u5BF9\u8BDD\u592A\u77ED\uFF0C\u65E0\u9700\u538B\u7F29\uFF08\u5C11\u4E8E\u6700\u5C0F\u56DE\u5408\u6570 \u6216 \u90FD\u5728\u4FDD\u7559\u533A\u5185\uFF09\u3002"}])},2500)):(Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{let L=((R.beforeTokens-R.afterTokens)/Math.max(R.beforeTokens,1)*100).toFixed(1),j=Jn.current==="fallback"?`
|
|
587
|
+
\u26A0 \u6458\u8981\u4E3A\u672C\u5730\u5151\u5E95\uFF08LLM \u4E0D\u53EF\u7528\uFF09`:"";Qt({phase:"idle",progress:null}),Jn.current=void 0,T(Z=>[...Z,{role:"assistant",content:`\u2714 \u538B\u7F29\u5B8C\u6210\uFF1A${R.droppedTurns} \u56DE\u5408 \u2192 ${R.keptTurns} \u56DE\u5408\uFF08\u8282\u7701 ${L}% token\uFF09${j}`}])},4e3))}catch(R){let L=R instanceof Error?R.message:String(R);Qt(j=>({...j,phase:"error",errorMessage:L})),Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{Qt({phase:"idle",progress:null}),T(j=>[...j,{role:"assistant",content:`\u26A0 \u538B\u7F29\u5931\u8D25\uFF1A${L}`}])},3e3)}return}if(P==="/model"){let R=Yt.indexOf(tt);Zo(R>=0?R:0),na(!0),$("");return}if(P==="/voice"){$(""),pa();return}if(P==="/thinking"){Fu(R=>!R),T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u6DF1\u5EA6\u601D\u8003\u5DF2${Kn?"\u5173\u95ED":"\u5F00\u542F"}`}]),$("");return}if(P==="/effort"){let R=Pr==="high"?"max":"high";Gu(R),T(L=>[...L,{role:"user",content:k},{role:"assistant",content:`\u63A8\u7406\u7B49\u7EA7\u5DF2\u5207\u6362\u4E3A ${R==="high"?"High":"Max"}`}]),$("");return}if(P==="/plan"){Jt==="plan"?T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u8BA1\u5212\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002"}]):(Uo("plan"),ue.current?.setMode("plan"),Wo(void 0),T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**
|
|
593
588
|
|
|
594
589
|
\u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C\u6211\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u4F1A\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u3002
|
|
595
|
-
\u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002`}]),ue.current?.reset())
|
|
590
|
+
\u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002`}]),ue.current?.reset()),$("");return}if(P==="/code"){Jt==="code"?T(R=>[...R,{role:"user",content:k},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u4EE3\u7801\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /plan \u5207\u56DE\u8BA1\u5212\u6A21\u5F0F\u3002"}]):(Uo("code"),ue.current?.setMode("code"),Wo(void 0),T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u{1F6E0} \u5DF2\u5207\u6362\u4E3A **\u4EE3\u7801\u6A21\u5F0F**
|
|
596
591
|
|
|
597
592
|
\u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002
|
|
598
|
-
\u8F93\u5165 /plan \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08\u53EA\u8BFB\u5206\u6790\uFF09\u3002`}]),ue.current?.reset())
|
|
599
|
-
`)}]),I("");return}}}let oe=await ym(k,Hu.current);if(oe.kind==="no-match"){S(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u672A\u77E5\u547D\u4EE4\uFF1A${k}\u3002\u8F93\u5165 /help \u67E5\u770B\u3002`}]),I("");return}if(oe.kind==="error"){S(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u6FC0\u6D3B skill \u5931\u8D25\uFF1A${oe.message}`}]),I("");return}P=oe.text}if(!ue.current){S($=>[...$,{role:"user",content:k},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]),I("");return}let V=P!==k?(()=>{let $=/^\/(\S+)(?:\s+(.*))?$/.exec(k),de=$?.[1]??"",oe=($?.[2]??"").trim();return oe?`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${de} \u2014 ${oe}`:`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${de}`})():k;S($=>[...$,{role:"user",content:V}]),I(""),Do(!0),$t("thinking"),Di(du(lC)),ji(""),Wi([]),Hi([]),Pu(void 0),Lu(void 0),Ou(void 0),Mu(void 0),Fo(void 0),Eu(new Map),ts.current=new Map,Yo.current="",Qo.current=[],es.current=[],oa.current=void 0,sa.current=void 0,ia.current=void 0,aa.current=void 0,ns.current=void 0,Qi.current=!1,Yi("idle"),St.current&&(clearTimeout(St.current),St.current=null),Go([]),Zt.current&&(clearTimeout(Zt.current),Zt.current=null),jo(!1),tn({phase:"idle",progress:null}),Jn.current=void 0,Me.current&&(clearTimeout(Me.current),Me.current=null);let N=ue.current,ne=new AbortController;ta.current=ne;try{for await(let $ of N.chat(P,{thinkingAllowed:Kn||void 0,thinkingEffort:Kn?Pr:void 0,responseFormat:zi!=="text"?zi:void 0,toolChoice:Lr})){if(ne.signal.aborted)break;switch($.type){case"text_delta":$t("generating"),ji(R=>{let O=R+$.content;return Yo.current=O,O});break;case"reasoning_delta":$t("thinking"),Wi(R=>{let O=R[R.length-1],K=O!==void 0?[...R.slice(0,-1),O+$.content]:[...R,$.content];return Qo.current=K,K});break;case"tool_calls":$t("calling_tools"),Hi(R=>{let O=[...R,...$.calls];return es.current=O,O});for(let R of $.calls)if(aC(R.name)){Qi.current=!0;break}break;case"tool_result":$t("executing_tools"),setTimeout(()=>$t("thinking"),300),ji(""),Yo.current="",Wi(R=>{let O=[...R,""];return Qo.current=O,O}),Hi([]),es.current=[];let de=$.callId??`${$.name}#${$.result.data.length}`;Eu(R=>{let O=new Map(R);return O.set(de,{success:$.result.success,...$.result.error?{error:$.result.error}:{},...$.result.denial?{denial:$.result.denial}:{}}),ts.current=O,O});let oe=$.result;if($.name.startsWith("todo_")&&$.todoSnapshot){let R=[...$.todoSnapshot];R.length>0&&R.every(K=>K.status==="done"||K.status==="failed"||K.status==="skipped")?(Ir.current=Math.max(...R.map(K=>K.id)),Go(R)):Ir.current>=0?Go(R.filter(K=>K.id>Ir.current)):Go(R)}else{let R=oe.success?oe.summary??`\u2705 ${$.name}: ${oe.data.slice(0,500)}${oe.data.length>500?"...":""}`:`\u274C ${$.name}: ${oe.error??"\u6267\u884C\u5931\u8D25"}`;S(O=>[...O,{role:"tool",content:R,diff:oe.diff}])}break;case"usage":Pu($.usage),Mu($.model),oa.current=$.usage,aa.current=$.model;{let R=Tt($.usage,$.model);Ou(R.totalCost),ia.current=R.totalCost}break;case"done":Lu($.elapsed),sa.current=$.elapsed;break;case"error":Fo($.error.message),ns.current=$.error.message;break}}}catch($){let de=$ instanceof Error?$.message:String($);Fo(de),ns.current=de}finally{Do(!1),$t(null),yg(du(Ah)),ta.current=null;let $=Yo.current,de=Qo.current.map(O=>O.trim()).filter(O=>O.length>0),oe=Rh(es.current),R=ns.current;if($||oe||R){let O={content:R?`\u26A0 \u8BF7\u6C42\u51FA\u9519\uFF1A${R}`:$||"",...de.length>0?{reasoning:de}:{},toolCalls:oe,toolResults:ts.current.size>0?new Map(ts.current):void 0,usage:oa.current,elapsed:sa.current,cost:ia.current,model:aa.current};S(K=>[...K,{role:"assistant",content:O.content,assistantDetail:O}])}Qi.current&&!R&&(Yi("pending"),St.current&&clearTimeout(St.current),St.current=setTimeout(()=>{Yi(O=>O==="pending"?"visible":O),St.current=null},2e3))}},[m,h,Gi,Ui,Bo,t,Or,la,Kn,Pr,zi,Lr,rt,Yt,ie,Zi,rs,Xn]);Ne(()=>{!ie&&a&&se(a.todayTotalCost)},[ie,a]);let Ag=vh(()=>W(G,{flexDirection:"column",flexGrow:1,children:[W(G,{flexDirection:"column",flexGrow:1,children:[!$r&&W(G,{flexDirection:"column",alignItems:"flex-start",flexGrow:1,paddingBottom:1,children:[kt.length>0&&(()=>{let C=kt[Ho%kt.length];if(!C)return null;let k=`${C.name} ${C.desc}`;return W(G,{marginTop:1,alignSelf:"center",children:[L(F,{color:"#808080",children:"\u{1F4A1} "}),qi.length>0?k.split("").map((P,V)=>L(F,{color:qi[V]||void 0,children:P},V)):L(F,{color:"#808080",children:k})]})})(),L(G,{flexGrow:1}),L(yh,{panelWidth:x})]}),W(G,{flexDirection:"column",marginTop:1,children:[L(sC,{items:_,children:(C,k)=>{if(C.role==="user")return W(G,{marginTop:1,flexDirection:"row",children:[L(G,{width:1,backgroundColor:"#FF8C00",flexShrink:0}),L(G,{flexGrow:1,paddingLeft:1,children:W(G,{flexDirection:"row",children:[L(G,{width:4,flexShrink:0,children:L(F,{bold:!0,color:"#FF8C00",children:"\u{1F4AC}"})}),L(G,{flexGrow:1,children:L(F,{wrap:"wrap",children:C.content})})]})})]},k);if(C.role==="tool")return W(G,{marginTop:1,flexDirection:"row",children:[L(G,{width:1,backgroundColor:"#666666",flexShrink:0}),W(G,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[W(G,{flexDirection:"row",children:[L(G,{width:4,flexShrink:0,children:L(F,{dimColor:!0,children:"\u{1F527}"})}),L(G,{flexGrow:1,children:L(F,{dimColor:!0,wrap:"wrap",children:C.content})})]}),C.diff&&L(Ga,{diff:C.diff})]})]},k);let P=C.assistantDetail;return L(ds,{content:C.content,toolCalls:P?.toolCalls,isStreaming:!1,usage:P?.usage,elapsed:P?.elapsed,cost:P?.cost,model:P?.model,toolResults:P?.toolResults},k)}},D),ie&&L(ds,{content:Gi,toolCalls:Bo.length>0?Bo:void 0,isStreaming:!0,usage:Iu,cost:$u,model:Nu,toolResults:bg}),Wu.phase!=="idle"&&L(fc,{state:Wu,contentWidth:x}),B!==null&&L(G,{borderStyle:"single",borderColor:"cyan",paddingX:1,marginBottom:1,children:L(F,{color:"cyan",children:"\u27F3 \u914D\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D\uFF08\u8FD0\u884C\u65F6\u751F\u6548\uFF09"})}),L(bh,{pending:Cg,onResponse:_g}),!ie&&Vi&&L(G,{marginTop:1,marginLeft:3,children:W(F,{color:"red",children:["\u26A0 ",Vi]})})]}),Bu&&bn.length>0&&L(pc,{items:bn})]}),Qt?W(G,{marginTop:1,flexDirection:"column",children:[L(F,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(x)}),W(G,{flexDirection:"column",marginTop:1,children:[L(F,{bold:!0,color:"#00ffff",children:"\u9009\u62E9\u6A21\u578B\uFF1A"}),en.map((C,k)=>{let P=Sn[C],V=C===rt,N=k===Jo,ne=N?" > ":" ",$=V?" (\u5F53\u524D)":"";return W(G,{children:[W(F,{color:N?"#00ff41":void 0,bold:N,children:[ne,P.displayName,$]}),N&&W(F,{color:"#808080",children:[" \u2014 ",C]})]},C)}),L(G,{marginTop:1,children:L(F,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),L(F,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(x)})]}):xn?W(G,{marginTop:1,flexDirection:"column",children:[L(F,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(x)}),W(G,{flexDirection:"column",marginTop:1,children:[L(F,{bold:!0,color:"#ff9800",children:"\u9009\u62E9\u8981\u56DE\u9000\u7684\u68C0\u67E5\u70B9\uFF1A"}),wn.map((C,k)=>{let P=k===Dr,V=P?" > ":" ",N=new Date(C.timestamp).toLocaleTimeString(),ne=C.preview||"(\u7A7A)",$=C.isGitRepo?"":" [\u975E git\uFF0C\u4EC5\u5BF9\u8BDD]";return L(G,{children:W(F,{color:P?"#ff9800":void 0,bold:P,children:[V,"#",k+1," ",N," `",ne,$,"`"]})},C.index)}),L(G,{marginTop:1,children:L(F,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),L(F,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(x)})]}):W(Eh,{children:[($r||Yt==="plan")&&ie&&Er?L(G,{marginTop:1,justifyContent:"center",children:W(F,{bold:!0,color:uu[Er].color,children:[uu[Er].icon," ",uu[Er].label," ",L(iC,{type:"dots"})]})}):Uu==="visible"?L(G,{marginTop:1,justifyContent:"center",children:L(F,{color:"#808080",children:"\u21A9 /rewind 1 \u53EF\u64A4\u56DE\u672C\u6B21\u4FEE\u6539"})}):Ar&&Ar.ratio>.85?L(G,{marginTop:1,justifyContent:"center",children:W(F,{color:"#ff9800",children:["\u{1F4DA} \u4E0A\u4E0B\u6587\u5DF2\u7528 ",(Ar.ratio*100).toFixed(0),"%\uFF0C\u8F93\u5165 /compact \u53EF\u624B\u52A8\u538B\u7F29"]})}):null,L(G,{marginTop:1,children:L(F,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(x)})}),W(G,{children:[L(G,{width:4,flexShrink:0,children:L(F,{bold:!0,color:"#00ff41",children:"\u26A1"})}),W(G,{flexGrow:1,children:[Nr?L(F,{color:"#808080",children:"Ctrl+P \u6587\u4EF6\u641C\u7D22\u4E2D\u2026\uFF08Esc \u53D6\u6D88\uFF09"}):!E&&!ie&&yn&&Ni.length>0?L(F,{children:yn.split("").map((C,k)=>L(F,{color:Ni[k]??void 0,children:C},k))}):!E&&ie&&gn&&Bi.length>0?L(F,{children:gn.split("").map((C,k)=>L(F,{color:Bi[k]??void 0,children:C},k))}):L(gm,{value:E,onChange:I,onSubmit:Ku,placeholder:"",focus:!Nr},Gu),he!=="idle"&&W(G,{children:[W(F,{color:he==="error"?"red":"cyan",children:[he==="connecting"&&"\u25CC \u6B63\u5728\u8FDE\u63A5 ASR \u670D\u52A1...",he==="recording"&&`\u25CF \u5F55\u97F3\u4E2D ${Li}`,he==="finalizing"&&`\u25CC \u7B49\u5F85\u670D\u52A1\u7AEF\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C ${Li}`,he==="error"&&`\u2717 \u9519\u8BEF ${Li}`]}),L(F,{dimColor:!0,children:" (\u518D\u6309 F2 \u7ED3\u675F\uFF0CESC \u53D6\u6D88)"})]})]})]}),L(G,{children:L(F,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(x)})}),L(Wa,{skills:t,input:E,selectedIndex:Or}),L(lc,{files:n,input:E,selectedIndex:Xn,cwd:process.cwd(),width:x})]})]}),[_,D,ie,Gi,Bo,Iu,$u,Nu,Vi,bn,Bu,Qt,en,rt,Jo,Du,Zo,xn,wn,Dr,qo,Ko,Uu,$r,Yt,Er,yn,Ni,gn,Bi,E,I,x,Ku,t,Or,n,Xn,Gu,kt,Ho,qi]),Eg=typeof process.stdout.rows=="number"?Math.max(process.stdout.rows-4,10):24,Ig=C=>{I(k=>`${k.endsWith(" ")||k.length===0?k:k+" "}@${C} `),Ji(k=>k+1),Xo(!1)};return W(G,{flexDirection:"column",paddingLeft:1,paddingRight:1,children:[Nr&&L(mm,{files:n,cwd:process.cwd(),width:g,height:Eg,onPick:Ig,onClose:()=>Xo(!1)}),!Nr&&W(Eh,{children:[W(G,{flexDirection:"row",flexGrow:1,children:[L(G,{width:w,flexShrink:0,flexDirection:"column",children:L(G,{paddingX:1,flexDirection:"column",flexGrow:1,justifyContent:$r?"flex-end":"center",children:$r?kg?L(F,{dimColor:!0,wrap:"wrap",children:(()=>{let C=gh(Ui),k=11,V=C.split(`
|
|
593
|
+
\u8F93\u5165 /plan \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08\u53EA\u8BFB\u5206\u6790\uFF09\u3002`}]),ue.current?.reset()),$("");return}if(P==="/tools"){let R=Lr===void 0?"none":Lr==="none"?"required":Lr==="required"?"auto":void 0;Wo(R);let L=R===void 0?"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09":R==="none"?"\u7981\u6B62\u8C03\u7528":R==="required"?"\u5F3A\u5236\u8C03\u7528":"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09";T(j=>[...j,{role:"user",content:k},{role:"assistant",content:`\u5DE5\u5177\u8C03\u7528\u7B56\u7565\u5DF2\u5207\u6362\u4E3A ${L}`}]),$("");return}let te=fu.get(P);if(te){let R=te.handler();switch(R.kind){case"exit":await ue.current?.flushLog(),process.exit(0);return;case"clear":T([]),F(L=>L+1),$(""),Fo(void 0),process.stdout.write("\x1B[2J\x1B[H\x1B[3J"),ue.current?.reset(),Ir.current=-1;return;case"navigate":$(""),R.target==="game"?g?.():R.target==="stock"&&b?.();return;case"text":T(L=>[...L,{role:"user",content:k},{role:"assistant",content:R.content}]),$("");return;case"permissions":{let L=ue.current;if(!L){T(nt=>[...nt,{role:"user",content:k},{role:"assistant",content:"Session \u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}]),$("");return}let j=L.gate,Z=[],ft=0,Zn="",ss="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09";if(j instanceof fn){let nt=j.gates;Zn=nt.length===0?"(\u7A7A)":`\u5171 ${nt.length} \u4E2A`;try{let ha=(await import("./interactive-gate-XKNHF4ZY.js")).InteractiveGate;for(let Br of nt)Br instanceof ha&&(Z=Br.engine.rules,ft=Br.grants.size,ss="\u89C4\u5219\u5F15\u64CE")}catch{}Z.length===0&&(ss="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09")}else ss="\u672A\u77E5";let mt=[];if(mt.push("\u{1F4CB} \u5F53\u524D\u6743\u9650\u7CFB\u7EDF\u72B6\u6001\uFF1A"),mt.push(` Gate \u94FE\uFF1A${Zn}`),mt.push(` \u6A21\u5F0F\uFF1A${ss??"\u672A\u77E5"}`),Z.length===0)mt.push(" \u89C4\u5219\u6570\uFF1A0\uFF08\u9ED8\u8BA4\u6A21\u5F0F\uFF1A\u8BFB/\u7EC8\u7AEF\u76F4\u63A5\u653E\u884C\uFF0C\u6539\u6587\u4EF6\u9700\u786E\u8BA4\uFF09");else{mt.push(` \u89C4\u5219\u6570\uFF1A${Z.length}`);for(let nt=0;nt<Z.length;nt++){let wn=Z[nt],ha=wn.match?JSON.stringify(wn.match):"(\u5168\u90E8\u5339\u914D)",Br=wn.reason?` \u2014 ${wn.reason}`:"";mt.push(` ${nt+1}. ${wn.tool} \u2192 ${wn.action}\uFF08${ha}\uFF09${Br}`)}}mt.push(` \u4F1A\u8BDD grants\uFF1A${ft} \u4E2A\uFF08"always" \u6279\u51C6\u7684\u5DE5\u5177\u8C03\u7528\uFF09`),mt.push(""),mt.push("\u914D\u7F6E\u6587\u4EF6\uFF1A~/.dskcode/permissions.json\uFF08\u5168\u5C40\uFF09"),mt.push(" .dskcode/permissions.json\uFF08\u9879\u76EE\u7EA7\uFF0C\u9879\u76EE\u7EA7\u4F18\u5148\uFF09"),T(nt=>[...nt,{role:"user",content:k},{role:"assistant",content:mt.join(`
|
|
594
|
+
`)}]),$("");return}}}let D=await xm(k,zu.current);if(D.kind==="no-match"){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u672A\u77E5\u547D\u4EE4\uFF1A${k}\u3002\u8F93\u5165 /help \u67E5\u770B\u3002`}]),$("");return}if(D.kind==="error"){T(R=>[...R,{role:"user",content:k},{role:"assistant",content:`\u26A0 \u6FC0\u6D3B skill \u5931\u8D25\uFF1A${D.message}`}]),$("");return}I=D.text}if(!ue.current){T(P=>[...P,{role:"user",content:k},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]),$("");return}let V=I!==k?(()=>{let P=/^\/(\S+)(?:\s+(.*))?$/.exec(k),te=P?.[1]??"",D=(P?.[2]??"").trim();return D?`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${te} \u2014 ${D}`:`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${te}`})():k;await os(I,"local",{displayText:V,thinkingAllowed:Kn||void 0,thinkingEffort:Kn?Pr:void 0,responseFormat:Ki!=="text"?Ki:void 0,toolChoice:Lr})},[g,b,ji,Wi,Bo,t,Or,ua,Kn,Pr,Ki,Lr,tt,Jt,ie,Qi,rs,Xn,os]);Se(()=>{!ie&&a&&Eu(a.todayTotalCost)},[ie,a]);let _g=Th(()=>K(H,{flexDirection:"column",flexGrow:1,children:[K(H,{flexDirection:"column",flexGrow:1,children:[!$r&&K(H,{flexDirection:"column",alignItems:"flex-start",flexGrow:1,paddingBottom:1,children:[bt.length>0&&(()=>{let C=bt[Ho%bt.length];if(!C)return null;let k=`${C.name} ${C.desc}`;return K(H,{marginTop:1,alignSelf:"center",children:[O(G,{color:"#808080",children:"\u{1F4A1} "}),Xi.length>0?k.split("").map((I,V)=>O(G,{color:Xi[V]||void 0,children:I},V)):O(G,{color:"#808080",children:k})]})})(),O(H,{flexGrow:1}),O(mh,{panelWidth:_})]}),K(H,{flexDirection:"column",marginTop:1,children:[O(HT,{items:U,children:(C,k)=>{if(C.role==="user")return K(H,{marginTop:1,flexDirection:"row",children:[O(H,{width:1,backgroundColor:"#FF8C00",flexShrink:0}),O(H,{flexGrow:1,paddingLeft:1,children:K(H,{flexDirection:"row",children:[O(H,{width:4,flexShrink:0,children:O(G,{bold:!0,color:"#FF8C00",children:"\u{1F4AC}"})}),O(H,{flexGrow:1,children:O(G,{wrap:"wrap",children:C.content})})]})})]},k);if(C.role==="tool")return K(H,{marginTop:1,flexDirection:"row",children:[O(H,{width:1,backgroundColor:"#666666",flexShrink:0}),K(H,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[K(H,{flexDirection:"row",children:[O(H,{width:4,flexShrink:0,children:O(G,{dimColor:!0,children:"\u{1F527}"})}),O(H,{flexGrow:1,children:O(G,{dimColor:!0,wrap:"wrap",children:C.content})})]}),C.diff&&O(Ua,{diff:C.diff})]})]},k);let I=C.assistantDetail;return O(ps,{content:C.content,toolCalls:I?.toolCalls,isStreaming:!1,usage:I?.usage,elapsed:I?.elapsed,cost:I?.cost,model:I?.model,toolResults:I?.toolResults},k)}},N),ie&&O(ps,{content:ji,toolCalls:Bo.length>0?Bo:void 0,isStreaming:!0,usage:Pu,cost:Ou,model:Nu,toolResults:yg}),Vu.phase!=="idle"&&O(hc,{state:Vu,contentWidth:_}),oe!==null&&O(H,{borderStyle:"single",borderColor:"cyan",paddingX:1,marginBottom:1,children:O(G,{color:"cyan",children:"\u27F3 \u914D\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D\uFF08\u8FD0\u884C\u65F6\u751F\u6548\uFF09"})}),O(hh,{pending:kg,onResponse:Sg}),!ie&&qi&&O(H,{marginTop:1,marginLeft:3,children:K(G,{color:"red",children:["\u26A0 ",qi]})})]}),Bu&&yn.length>0&&O(mc,{items:yn})]}),Zt?K(H,{marginTop:1,flexDirection:"column",children:[O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)}),K(H,{flexDirection:"column",marginTop:1,children:[O(G,{bold:!0,color:"#00ffff",children:"\u9009\u62E9\u6A21\u578B\uFF1A"}),Yt.map((C,k)=>{let I=kn[C],V=C===tt,P=k===Jo,te=P?" > ":" ",D=V?" (\u5F53\u524D)":"";return K(H,{children:[K(G,{color:P?"#00ff41":void 0,bold:P,children:[te,I.displayName,D]}),P&&K(G,{color:"#808080",children:[" \u2014 ",C]})]},C)}),O(H,{marginTop:1,children:O(G,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})]}):xn?K(H,{marginTop:1,flexDirection:"column",children:[O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)}),K(H,{flexDirection:"column",marginTop:1,children:[O(G,{bold:!0,color:"#ff9800",children:"\u9009\u62E9\u8981\u56DE\u9000\u7684\u68C0\u67E5\u70B9\uFF1A"}),bn.map((C,k)=>{let I=k===Dr,V=I?" > ":" ",P=new Date(C.timestamp).toLocaleTimeString(),te=C.preview||"(\u7A7A)",D=C.isGitRepo?"":" [\u975E git\uFF0C\u4EC5\u5BF9\u8BDD]";return O(H,{children:K(G,{color:I?"#ff9800":void 0,bold:I,children:[V,"#",k+1," ",P," `",te,D,"`"]})},C.index)}),O(H,{marginTop:1,children:O(G,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})]}):K(vh,{children:[($r||Jt==="plan")&&ie&&Er?O(H,{marginTop:1,justifyContent:"center",children:K(G,{bold:!0,color:uu[Er].color,children:[uu[Er].icon," ",uu[Er].label," ",O(VT,{type:"dots"})]})}):Hu==="visible"?O(H,{marginTop:1,justifyContent:"center",children:O(G,{color:"#808080",children:"\u21A9 /rewind 1 \u53EF\u64A4\u56DE\u672C\u6B21\u4FEE\u6539"})}):Ar&&Ar.ratio>.85?O(H,{marginTop:1,justifyContent:"center",children:K(G,{color:"#ff9800",children:["\u{1F4DA} \u4E0A\u4E0B\u6587\u5DF2\u7528 ",(Ar.ratio*100).toFixed(0),"%\uFF0C\u8F93\u5165 /compact \u53EF\u624B\u52A8\u538B\u7F29"]})}):null,O(H,{marginTop:1,children:O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})}),K(H,{children:[O(H,{width:4,flexShrink:0,children:O(G,{bold:!0,color:"#00ff41",children:"\u26A1"})}),K(H,{flexGrow:1,children:[Nr?O(G,{color:"#808080",children:"Ctrl+P \u6587\u4EF6\u641C\u7D22\u4E2D\u2026\uFF08Esc \u53D6\u6D88\uFF09"}):!q&&!ie&&gn&&Mi.length>0?O(G,{children:gn.split("").map((C,k)=>O(G,{color:Mi[k]??void 0,children:C},k))}):!q&&ie&&hn&&Fi.length>0?O(G,{children:hn.split("").map((C,k)=>O(G,{color:Fi[k]??void 0,children:C},k))}):O(ym,{value:q,onChange:$,onSubmit:Ju,placeholder:"",focus:!Nr},Uu),Pe!=="idle"&&K(H,{children:[K(G,{color:Pe==="error"?"red":"cyan",children:[Pe==="connecting"&&"\u25CC \u6B63\u5728\u8FDE\u63A5 ASR \u670D\u52A1...",Pe==="recording"&&`\u25CF \u5F55\u97F3\u4E2D ${$i}`,Pe==="finalizing"&&`\u25CC \u7B49\u5F85\u670D\u52A1\u7AEF\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C ${$i}`,Pe==="error"&&`\u2717 \u9519\u8BEF ${$i}`]}),O(G,{dimColor:!0,children:" (\u518D\u6309 F2 \u7ED3\u675F\uFF0CESC \u53D6\u6D88)"})]})]})]}),O(H,{children:O(G,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(_)})}),O(Va,{skills:t,input:q,selectedIndex:Or}),O(uc,{files:n,input:q,selectedIndex:Xn,cwd:process.cwd(),width:_})]})]}),[U,N,ie,ji,Bo,Pu,Ou,Nu,qi,yn,Bu,Zt,Yt,tt,Jo,zi,Zo,xn,bn,Dr,qo,Ko,Hu,$r,Jt,Er,gn,Mi,hn,Fi,q,$,_,Ju,t,Or,n,Xn,Uu,bt,Ho,Xi]),vg=typeof process.stdout.rows=="number"?Math.max(process.stdout.rows-4,10):24,Rg=C=>{$(k=>`${k.endsWith(" ")||k.length===0?k:k+" "}@${C} `),Yi(k=>k+1),Xo(!1)};return K(H,{flexDirection:"column",paddingLeft:1,paddingRight:1,children:[Nr&&O(hm,{files:n,cwd:process.cwd(),width:S,height:vg,onPick:Rg,onClose:()=>Xo(!1)}),!Nr&&K(vh,{children:[K(H,{flexDirection:"row",flexGrow:1,children:[O(H,{width:v,flexShrink:0,flexDirection:"column",children:O(H,{paddingX:1,flexDirection:"column",flexGrow:1,justifyContent:$r?"flex-end":"center",children:$r?xg?O(G,{dimColor:!0,wrap:"wrap",children:(()=>{let C=fh(Wi),k=11,V=C.split(`
|
|
600
595
|
`).slice(-k);for(;V.length<k;)V.unshift("");return V.join(`
|
|
601
|
-
`)})()}):
|
|
602
|
-
`)}function kC({onExit:e}){let[t,n]=gu(1),[r,o]=gu(!0),s=$h(Dh(t)),[i,a]=gu(0),l=$h(e);l.current=e,yC(()=>{if(r)return;let g=setInterval(()=>{xC(s.current),a(w=>w+1)},80);return()=>clearInterval(g)},[r]);let c=yu(g=>{let w=g??s.current.level;s.current=Dh(w),n(w),o(!1),a(0)},[]),u=yu(()=>{o(!0)},[]);hC(yu((g,w)=>{let x=s.current;if(r){g>="1"&&g<="9"?c(Number(g)):g==="0"?c(10):(w.escape||g==="q")&&l.current();return}w.leftArrow?(x.paddleX=Math.max(0,x.paddleX-1),a(T=>T+1)):w.rightArrow?(x.paddleX=Math.min(dt-Tr,x.paddleX+1),a(T=>T+1)):g==="p"||g===" "?x.paused=!x.paused:g==="r"?(x.gameOver||x.win)&&c():g==="l"?(x.gameOver||x.win)&&u():(g==="q"||w.escape)&&l.current()},[r,c,u]));let d=s.current,m=d.bricks.filter(g=>g.alive).length,h=wC(d),f=xu(d.level);return Ke(qe,{flexDirection:"column",children:[Ke(qe,{flexDirection:"row",children:[me(qe,{width:20,children:Ke(we,{children:["\u5173\u5361 ",d.level,": ",me(we,{color:"cyan",children:f.desc})]})}),me(qe,{width:12,children:Ke(we,{children:["\u5206\u6570: ",me(we,{color:"yellow",children:String(d.score).padStart(3,"0")})]})}),me(qe,{width:12,children:Ke(we,{children:["\u751F\u547D: ",me(we,{color:"red",children:"\u2665".repeat(Math.max(0,d.lives))})]})}),me(qe,{width:10,children:Ke(we,{children:["\u7816\u5757: ",me(we,{color:"cyan",children:m})]})}),me(qe,{children:Ke(we,{color:d.paused?"gray":"green",children:["[",d.paused?"\u6682\u505C":"\u8FD0\u884C\u4E2D","]"]})})]}),Ke(qe,{flexDirection:"column",children:[Ke(we,{children:["\u250C","\u2500".repeat(dt),"\u2510"]}),me(we,{children:r?" \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m":h}),Ke(we,{children:["\u2514","\u2500".repeat(dt),"\u2518"]})]}),r&&Ke(qe,{marginTop:1,flexDirection:"column",children:[me(we,{bold:!0,color:"yellow",children:"\u9009\u62E9\u5173\u5361"}),me(qe,{flexDirection:"row",flexWrap:"wrap",children:bu.map((g,w)=>me(qe,{width:22,children:Ke(we,{children:[me(we,{color:t===w+1?"green":"white",children:w+1===10?"0":String(w+1)}),". ",g.desc," (",g.rows,"\xD7",g.cols,")"]})},w))}),me(qe,{marginTop:1,children:me(we,{dimColor:!0,children:"\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA"})})]}),!r&&(d.gameOver||d.win)&&Ke(qe,{marginTop:1,children:[me(we,{bold:!0,color:d.gameOver?"red":"green",children:d.gameOver?"\u6E38\u620F\u7ED3\u675F\uFF01":"\u606D\u559C\u901A\u5173\uFF01"}),Ke(we,{children:[" \u5206\u6570: ",me(we,{color:"yellow",children:d.score})]})]}),!r&&me(qe,{marginTop:1,children:d.gameOver||d.win?me(we,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA"}):me(we,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA"})})]})}var Nh={id:"brick-breaker",name:"Brick Breaker",description:"\u7ECF\u5178\u6253\u7816\u5757\u6E38\u620F\uFF0C10 \u4E2A\u5173\u5361\u53EF\u9009\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=gC(me(kC,{onExit:()=>{t(),e()}}))})}};p();import{Box as Cr,Text as nt,useInput as SC,render as TC}from"ink";import{useState as Mh,useEffect as Bh,useRef as Fh,useCallback as CC}from"react";import{jsx as xt,jsxs as Jt}from"react/jsx-runtime";var pt=66,Wh=20,ku=6,_C=10,_r=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Gh={0:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],1:[" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],2:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],3:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],4:["\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],5:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],6:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],7:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],8:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],9:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "]};function vC(e){let t=["","","","",""];for(let r of e){let o=Gh[r]??Gh[0];for(let s=0;s<5;s++)t[s]+=" "+(o[s]??"")}let n=6;return t.map(r=>" ".repeat(n)+r)}function wu(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return`${t};${n};${r}`}var jh=["react","vue","next","node","axios","express","lodash","jquery","webpack","vite","babel","eslint","prettier","tailwind","bootstrap","sass","less","postcss","redux","pinia","vuex","router","nestjs","socket","graphql","rest","grpc","prisma","typeorm","html","css","jsx","tsx","dom","spa","ssr","csr","pwa","component","prop","hook","composable","directive","filter","mixin","template","render","virtual","diff","patch","hydration","responsive","flexbox","grid","animation","transition","api","route","middleware","controller","service","module","dto","entity","schema","migration","seeder","factory","auth","jwt","oauth","session","cookie","token","cors","cache","redis","mq","rabbit","kafka","nats","sql","mysql","pg","sqlite","mongo","redis","orm","table","index","query","join","union","group","order","where","having","limit","offset","insert","update","delete","docker","nginx","linux","bash","shell","yaml","toml","ci","cd","deploy","rollback","release","build","test","lint","format","stage","commit","branch","merge","rebase","array","stack","queue","tree","graph","list","map","set","sort","search","filter","reduce","map","async","await","promise","callback","closure","proxy","reflect","decorator","create","read","update","delete","crud","parse","stringify","encode","decode","transform","validate","format","parse","upload","download","export","import","backup","restore","string","number","boolean","object","array","tuple","enum","interface","type","class","function","method","property","public","private","static","readonly","optional","abstract","const","let","var","void","null","undef","never","any","config","logger","monitor","metric","alert","webhook","endpoint","payload","header","status","timeout","retry","fallback","circuit","breaker","throttle","debounce","scroll","resize","click","hover","focus","blur"];function RC(e){let t;do t=jh[Math.floor(Math.random()*jh.length)];while(e.has(t));return t}function Uh(){return{words:[],score:0,lives:3,speed:.3,spawnTimer:0,gameOver:!1,paused:!1,typed:"",target:null,combo:0,message:"",messageTimer:0,usedWords:new Set}}function Ri(e){let t=null;for(let n of e.words)(!t||n.col<t.col)&&(t=n);return t?.text??null}function AC(e){if(e.paused||e.gameOver)return;if(e.spawnTimer++,e.spawnTimer>=Math.max(20,50-Math.floor(e.speed*15))&&(e.spawnTimer=0,e.words.length<_C)){let r=new Set(e.usedWords);for(let a of e.words)r.add(a.text);let o=RC(r),s=new Set(e.words.map(a=>a.row)),i=-1;for(let a=ku;a<Wh;a++)if(!s.has(a)){i=a;break}i>=0&&(e.words.push({text:o,row:i,col:pt-1}),e.usedWords.add(o))}for(let r of e.words)r.col-=e.speed;let t=e.words.length;e.words=e.words.filter(r=>r.col>-r.text.length);let n=t-e.words.length;n>0&&(e.lives-=n,e.typed="",e.target=Ri(e),e.lives<=0&&(e.gameOver=!0,e.words=[])),e.target=Ri(e),e.messageTimer>0&&(e.messageTimer--,e.messageTimer<=0&&(e.message=""))}function EC(e,t,n,r){let o=[];for(let s=0;s<Wh;s++){let i="";if(s<ku){if(s<5){let a=(t[s]??"").padEnd(pt);i=`\x1B[38;2;${wu(n)}m${a}\x1B[0m`}else if(s===5){if(e.combo>=3){let a=`${e.combo}\u8FDE\u51FB!`,l=Math.floor((pt-a.length)/2),c=_r[e.combo%_r.length],u=" ".repeat(l)+a+" ".repeat(pt-l-a.length);i=`\x1B[38;2;${wu(c)}m${u}\x1B[0m`}else if(e.paused){let l=Math.floor((pt-2)/2);i=" ".repeat(l)+"\u6682\u505C",i=i.padEnd(pt)}}i=i.padEnd(pt)}else if(s===ku&&r){let a=Math.floor((pt-r.length)/2),l=" ".repeat(a)+r+" ".repeat(pt-a-r.length),c=_r[Math.floor(Math.random()*_r.length)];i=`\x1B[38;2;${wu(c)}m${l}\x1B[0m`}else for(let a=0;a<pt;a++){let l=e.words.find(c=>{let u=a-Math.floor(c.col);return u>=0&&u<c.text.length&&c.row===s});if(l){let c=a-Math.floor(l.col),u=l.text[c],d=l.text===e.target,m=e.target===l.text?e.typed.length:0,h=d&&c<m;d?i+=h?`\x1B[92m${u}\x1B[0m`:`\x1B[97m${u}\x1B[0m`:i+=`\x1B[90m${u}\x1B[0m`}else i+=" "}o.push(i)}return o}function IC({onExit:e}){let t=Fh(Uh()),[n,r]=Mh(0),[o,s]=Mh(0),i=Fh(e);i.current=e,Bh(()=>{let m=setInterval(()=>{s(h=>(h+1)%_r.length)},400);return()=>clearInterval(m)},[]),Bh(()=>{let m=setInterval(()=>{AC(t.current),r(h=>h+1)},60);return()=>clearInterval(m)},[]),SC(CC((m,h)=>{let f=t.current;if(f.gameOver){m==="r"?(t.current=Uh(),r(0)):(m==="q"||h.escape)&&i.current();return}if(m==="p"&&h.ctrl||m===" "){f.paused=!f.paused;return}if(m==="q"&&h.ctrl||h.escape){i.current();return}if(!f.paused&&m.length===1&&m>="a"&&m<="z"&&(f.target||(f.target=Ri(f)),f.target))if(f.target[f.typed.length]===m){if(f.typed+=m,f.typed===f.target){f.words=f.words.filter(S=>S.text!==f.target),f.combo++;let w=f.score,x=f.target.length,T=f.combo>=3?f.score:0;f.score+=x+T,f.speed=f.speed+.02;let v=Math.floor(w/500);Math.floor(f.score/500)>v&&(f.speed+=.15),f.score>=1e5&&w<1e5&&(f.message="\u606D\u559C\u901A\u5173! \u96BE\u5EA6\u6700\u5927\u5316!",f.messageTimer=100),f.typed="",f.target=Ri(f)}}else f.combo=0},[]));let a=t.current,l=_r[o],c=String(a.score).padStart(5,"0"),u=vC(c),d=EC(a,u,l,a.message);return Jt(Cr,{flexDirection:"column",paddingX:1,children:[xt(Cr,{flexDirection:"row",children:Jt(nt,{children:["\u751F\u547D ",xt(nt,{color:"red",children:"\u2665".repeat(Math.max(0,a.lives))})," ","\u901F\u5EA6 ",Jt(nt,{color:"cyan",children:["Lv.",Math.floor(a.speed*10)]})]})}),!a.gameOver&&a.target&&xt(Cr,{marginTop:1,children:Jt(nt,{children:["\u6253\u5B57: ",xt(nt,{color:"green",children:a.typed}),xt(nt,{color:"white",children:a.target.slice(a.typed.length)})]})}),Jt(Cr,{flexDirection:"column",marginTop:1,children:[Jt(nt,{children:["\u250C","\u2500".repeat(pt),"\u2510"]}),d.map((m,h)=>xt(nt,{children:`\u2502${m}\u2502`},h)),Jt(nt,{children:["\u2514","\u2500".repeat(pt),"\u2518"]})]}),a.gameOver&&Jt(Cr,{marginTop:1,children:[xt(nt,{bold:!0,color:"red",children:"\u6E38\u620F\u7ED3\u675F\uFF01"}),Jt(nt,{children:[" \u5F97\u5206: ",xt(nt,{color:"yellow",children:a.score})," r \u91CD\u5F00 q \u9000\u51FA"]})]}),xt(Cr,{marginTop:1,children:xt(nt,{dimColor:!0,children:"\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA"})})]})}var Hh={id:"coder-check",name:"Coder Check",description:"\u6781\u901F\u6253\u5B57\u6E38\u620F\uFF0C\u8F93\u5165\u5355\u8BCD\u6D88\u9664\u5B83\u4EEC\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=TC(xt(IC,{onExit:()=>{t(),e()}}))})}};p();p();function PC(e,t){return e==="UP"&&t==="DOWN"||e==="DOWN"&&t==="UP"||e==="LEFT"&&t==="RIGHT"||e==="RIGHT"&&t==="LEFT"}function Su(e,t){return e.x===t.x&&e.y===t.y}function LC(e,t){switch(t){case"UP":return{x:e.x,y:e.y-1};case"DOWN":return{x:e.x,y:e.y+1};case"LEFT":return{x:e.x-1,y:e.y};case"RIGHT":return{x:e.x+1,y:e.y}}}function $C(e,t){return{x:(e.x%t.width+t.width)%t.width,y:(e.y%t.height+t.height)%t.height}}function Tu(e,t,n,r=[]){let o=new Set(e.map(a=>`${a.x},${a.y}`));for(let a of r)o.add(`${a.x},${a.y}`);let s=t.width*t.height;if(o.size>=s)return null;let i;do i={x:Math.floor(Math.random()*t.width),y:Math.floor(Math.random()*t.height)};while(o.has(`${i.x},${i.y}`));return{position:i,type:n,...n==="special"?{spawnedAt:Date.now()}:{}}}function Cu(e){let t=Math.floor(e.width/2),n=Math.floor(e.height/2),r=[{x:t,y:n},{x:t-1,y:n},{x:t-2,y:n}],o=Tu(r,e,"normal");return{snake:r,direction:"RIGHT",nextDirection:"RIGHT",food:o,specialFood:null,score:0,speedLevel:1,isGameOver:!1,isPaused:!1,wallWrap:Math.random()<.5,tickInterval:e.initialSpeed}}function zh(e,t){e.direction=e.nextDirection;let n=e.snake[0],r=LC(n,e.direction);if(r.x<0||r.x>=t.width||r.y<0||r.y>=t.height)if(e.wallWrap)r=$C(r,t);else{e.isGameOver=!0;return}let s=Su(r,e.food.position),i=e.specialFood!==null&&Su(r,e.specialFood.position),l=s||i?e.snake:e.snake.slice(0,-1);for(let c of l)if(Su(r,c)){e.isGameOver=!0;return}if(e.snake.unshift(r),s){e.score+=1,Vh(e,t);let c=e.specialFood?[e.specialFood.position]:[],u=Tu(e.snake,t,"normal",c);if(u)e.food=u;else{e.isGameOver=!0;return}e.specialFood===null&&Math.random()<.25&&(e.specialFood=Tu(e.snake,t,"special",[e.food.position]))}else i?(e.score+=3,Vh(e,t),e.specialFood=null):e.snake.pop();e.specialFood?.spawnedAt!==void 0&&Date.now()-e.specialFood.spawnedAt>5e3&&(e.specialFood=null)}function Vh(e,t){let n=Math.floor(e.score/t.scorePerLevel)+1;e.speedLevel=n,e.tickInterval=Math.max(t.minSpeed,t.initialSpeed-(n-1)*t.speedDecrement)}function qh(e,t){PC(t,e.direction)||(e.nextDirection=t)}p();import Ie from"chalk";var Kh=2,OC=" ",DC="\u2593",NC="\u2593",MC="\u25C6",BC="\u2605",Po="\x1B[",FC=`${Po}?25l`,GC=`${Po}?25h`,Xh=`${Po}H`;function Jh(){process.stdout.write(FC)}function Zh(){process.stdout.write(GC)}function Yh(){process.stdout.write(`${Po}2J${Xh}`)}function jC(e,t){switch(t){case"snake-head":return Ie.greenBright(e);case"snake-body":return Ie.green(e);case"normal-food":return Ie.red(e);case"special-food":return Ie.yellow(e);case"empty":return e}}function Qh(e,t){let n=UC(e,t);process.stdout.write(`${Po}2J${Xh}`+n.join(`
|
|
603
|
-
`))}function
|
|
604
|
-
`)}return
|
|
596
|
+
`)})()}):K(H,{flexDirection:"column",alignItems:"center",children:[O(G,{color:"#00ffff",bold:!0,children:"\u{1F4AC} \u5BF9\u8BDD\u8FDB\u884C\u4E2D"}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#00ff41",children:["\u{1F4DD} \u6D88\u606F ",U.length," \u6761"]}),ju>0&&K(G,{color:"cyan",children:["\u{1F4B0} \u4F1A\u8BDD \xA5",ju.toFixed(4)]}),Ar&&O(JT,{stats:Ar})]}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#808080",children:["\u{1F527} ",kn[tt]?.displayName??tt]}),Kn&&K(G,{color:"#ff9800",children:["\u{1F9E0} ",Pr==="max"?"Max":"High"]})]}),W!==null&&O(H,{marginTop:1,children:K(G,{color:"yellow",children:["\u{1F4B0} \xA5",W.toFixed(2)]})})]}):K(H,{flexDirection:"column",alignItems:"center",children:[Ia.map((C,k)=>{let I=(k+E)%Gr.length;return O(G,{bold:!0,color:Gr[I],children:C},k)}),O(H,{marginTop:1,children:K(G,{color:"#808080",children:["\u{1F4E6} v",So]})}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[K(G,{color:"#00ff41",children:["\u2714 ",e," Skills"]}),K(G,{color:"#00ffff",children:["\u2139 ",r," \u5DE5\u5177"]}),K(G,{color:"#00ffff",children:["\u{1F527} ",kn[tt]?.displayName??tt]}),Kn&&K(G,{color:"#ff9800",children:["\u{1F9E0} \u6DF1\u5EA6\u601D\u8003 ",Pr==="max"?"Max":"High"]}),Jt==="plan"&&O(G,{color:"#ff69b4",bold:!0,children:"\u{1F4CB} \u8BA1\u5212\u6A21\u5F0F"})]}),K(H,{marginTop:1,flexDirection:"column",alignItems:"center",children:[W!==null?K(G,{color:"yellow",children:["\u{1F4B0} \u4F59\u989D \xA5",W.toFixed(2)]}):ce?O(G,{color:"yellow",children:"\u23F3 \u67E5\u8BE2\u4F59\u989D..."}):null,qn!==null&&K(G,{color:"cyan",children:["\u{1F4CA} \u4ECA\u65E5 \xA5",qn.toFixed(2)]})]}),o&&O(G,{color:"#ff1493",children:"\u26A1 Verbose"})]})})}),_g]}),Cg&&!ie&&O(H,{marginTop:1,children:O(G,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})}),ie&&O(H,{marginTop:1,children:O(G,{color:"yellow",dimColor:!0,children:" \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42"})})]})]})}var pu=12;function KT(e){return e>=.85?"danger":e>=.6?"warning":"safe"}function XT(e){switch(e){case"danger":return"#ff6347";case"warning":return"#ffcc00";case"safe":return"#00ff41"}}function JT({stats:e}){let t=KT(e.ratio),n=XT(t),r=Math.min(pu,Math.max(e.ratio>0?1:0,Math.round(e.ratio*pu))),o=pu-r;return K(G,{color:n,children:["\u{1F4DA} ",O(G,{color:n,children:"\u2588".repeat(r)}),O(G,{color:"#444444",children:"\u2591".repeat(o)})," ",(e.ratio*100).toFixed(1),"%"]})}p();import{Box as qt,Text as Vn,useInput as ZT}from"ink";import{useState as YT,useCallback as QT}from"react";import{jsx as He,jsxs as Ah}from"react/jsx-runtime";function vi({games:e,onSelect:t,onExit:n,onBackToChat:r}){let[o,s]=YT(0),i=r??n??(()=>process.exit(0)),{doubleCtrlC:a,handleCtrlC:l}=Sn(i);return ZT(QT((c,u)=>{if(c==="c"&&u.ctrl){l();return}if(e.length!==0)if(u.upArrow||c==="k")s(d=>d>0?d-1:e.length-1);else if(u.downArrow||c==="j")s(d=>d<e.length-1?d+1:0);else if(u.return){let d=e[o];d&&t(d)}else(u.escape||c==="q")&&(r?r():n?.())},[e,o,t,n,r,l])),Ah(qt,{flexDirection:"column",children:[He(qt,{marginBottom:1,children:He(Vn,{bold:!0,color:"#00ffff",children:"\u{1F3AE} \u6E38\u620F\u5217\u8868"})}),He(qt,{flexDirection:"column",children:e.map((c,u)=>{let d=u===o;return Ah(qt,{flexDirection:"row",children:[He(qt,{width:3,flexShrink:0,children:d?He(Vn,{bold:!0,color:"#00ff41",children:"\u25B8 "}):He(Vn,{children:" "})}),He(qt,{width:20,flexShrink:0,children:He(Vn,{bold:!0,color:d?"#00ff41":"#ffffff",children:c.name})}),He(qt,{children:He(Vn,{color:"#888888",children:c.description})})]},c.id)})}),He(qt,{marginTop:1,children:He(Vn,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE"})}),a&&He(qt,{marginTop:1,children:He(Vn,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}p();p();var hu=new Map;function Ri(e){hu.set(e.id,e)}function Eh(e){return hu.get(e)}function Io(){return Array.from(hu.values())}p();import{Box as Ve,Text as xe,useInput as eC,render as tC}from"ink";import{useState as gu,useEffect as nC,useRef as Ih,useCallback as yu}from"react";import{jsx as fe,jsxs as ze}from"react/jsx-runtime";var ut=40,Tr=18,Cr=9,Ph=[166,214,76,69],xu=[{rows:4,cols:8,bw:3,desc:"\u7ECF\u5178 4\xD78",pattern:()=>!0},{rows:3,cols:8,bw:3,desc:"\u8F7B\u677E 3 \u5C42",pattern:()=>!0},{rows:6,cols:8,bw:3,desc:"\u539A\u5899 6 \u5C42",pattern:()=>!0},{rows:4,cols:8,bw:3,desc:"\u68CB\u76D8\u683C",pattern:(e,t)=>(e+t)%2===0},{rows:4,cols:8,bw:3,desc:"\u91D1\u5B57\u5854",pattern:(e,t,n,r)=>e>=t&&e<r-t},{rows:4,cols:8,bw:3,desc:"\u4EA4\u9519\u6392\u5217",pattern:(e,t)=>t%2===0||e>=1&&e<=6},{rows:4,cols:8,bw:3,desc:"\u4E2D\u7A7A\u8FB9\u6846",pattern:(e,t,n,r)=>t===0||t===n-1||e===0||e===r-1},{rows:4,cols:10,bw:2,desc:"\u5BC6\u96C6 10 \u5217",pattern:()=>!0},{rows:7,cols:8,bw:3,desc:"\u9AD8\u5899 7 \u5C42",pattern:()=>!0},{rows:8,cols:8,bw:3,desc:"\u6EE1\u5C4F 8 \u5C42",pattern:()=>!0}];function bu(e){return xu[(e-1)%xu.length]}function rC(e){let t=bu(e),n=[],r=2,o=t.cols*t.bw+(t.cols-1)*r,s=Math.floor((ut-o)/2),i=t.bw+r;for(let a=0;a<t.rows;a++)for(let l=0;l<t.cols;l++)t.pattern(l,a,t.rows,t.cols)&&n.push({x:s+l*i,y:2+a*2,w:t.bw,alive:!0});return n}function Lh(e){let t=bu(e),n=t.cols*t.bw+(t.cols-1)*2,r=Math.floor((ut-n)/2);return{level:e,bricks:rC(e),paddleX:Math.floor(ut/2)-Math.floor(Cr/2),ball:{x:ut/2,y:Tr-3},ballDir:{x:1,y:-1},score:0,lives:3,gameOver:!1,win:!1,paused:!1}}function oC(e){if(e.paused||e.gameOver||e.win)return;if(e.ball.x+=e.ballDir.x,e.ball.y+=e.ballDir.y,e.ball.x<=0&&(e.ball.x=0,e.ballDir.x=1),e.ball.x>=ut-1&&(e.ball.x=ut-1,e.ballDir.x=-1),e.ball.y<=0&&(e.ball.y=0,e.ballDir.y=1),e.ball.y===Tr-1&&e.ball.x>=e.paddleX&&e.ball.x<=e.paddleX+Cr){e.ballDir.y=-1;let n=(e.ball.x-e.paddleX)/Cr;e.ballDir.x=n<.5?-1:1}e.ball.y>Tr&&(e.lives--,e.lives<=0?e.gameOver=!0:(e.ball={x:ut/2,y:Tr-3},e.ballDir={x:1,y:-1},e.paddleX=Math.floor(ut/2)-Math.floor(Cr/2)));let t=e.bricks.find(n=>n.alive?e.ball.x>=n.x&&e.ball.x<n.x+n.w&&e.ball.y>=n.y&&e.ball.y<n.y+1:!1);t&&(t.alive=!1,e.score+=10,e.ballDir.y=-e.ballDir.y),e.bricks.every(n=>!n.alive)&&(e.win=!0)}function sC(e){let t=[];function n(r,o){let s=Math.floor((o-2)/2);if(s>=0&&e.bricks.find(a=>a.y===o&&a.alive&&r>=a.x&&r<a.x+a.w))return s%Ph.length}for(let r=0;r<Tr;r++){let o="";for(let s=0;s<ut;s++){let i=e.ball.x===s&&e.ball.y===r,a=r===Tr-1&&s>=e.paddleX&&s<e.paddleX+Cr,l=n(s,r);i?o+="\x1B[97m\u25CF\x1B[0m":a?o+="\x1B[94m\u2584\x1B[0m":l!==void 0?o+=`\x1B[38;5;${Ph[l]}m\u2580\x1B[0m`:o+=" "}t.push(o)}return t.map(r=>`\u2502${r}\u2502`).join(`
|
|
597
|
+
`)}function iC({onExit:e}){let[t,n]=gu(1),[r,o]=gu(!0),s=Ih(Lh(t)),[i,a]=gu(0),l=Ih(e);l.current=e,nC(()=>{if(r)return;let g=setInterval(()=>{oC(s.current),a(b=>b+1)},80);return()=>clearInterval(g)},[r]);let c=yu(g=>{let b=g??s.current.level;s.current=Lh(b),n(b),o(!1),a(0)},[]),u=yu(()=>{o(!0)},[]);eC(yu((g,b)=>{let w=s.current;if(r){g>="1"&&g<="9"?c(Number(g)):g==="0"?c(10):(b.escape||g==="q")&&l.current();return}b.leftArrow?(w.paddleX=Math.max(0,w.paddleX-1),a(S=>S+1)):b.rightArrow?(w.paddleX=Math.min(ut-Cr,w.paddleX+1),a(S=>S+1)):g==="p"||g===" "?w.paused=!w.paused:g==="r"?(w.gameOver||w.win)&&c():g==="l"?(w.gameOver||w.win)&&u():(g==="q"||b.escape)&&l.current()},[r,c,u]));let d=s.current,m=d.bricks.filter(g=>g.alive).length,h=sC(d),f=bu(d.level);return ze(Ve,{flexDirection:"column",children:[ze(Ve,{flexDirection:"row",children:[fe(Ve,{width:20,children:ze(xe,{children:["\u5173\u5361 ",d.level,": ",fe(xe,{color:"cyan",children:f.desc})]})}),fe(Ve,{width:12,children:ze(xe,{children:["\u5206\u6570: ",fe(xe,{color:"yellow",children:String(d.score).padStart(3,"0")})]})}),fe(Ve,{width:12,children:ze(xe,{children:["\u751F\u547D: ",fe(xe,{color:"red",children:"\u2665".repeat(Math.max(0,d.lives))})]})}),fe(Ve,{width:10,children:ze(xe,{children:["\u7816\u5757: ",fe(xe,{color:"cyan",children:m})]})}),fe(Ve,{children:ze(xe,{color:d.paused?"gray":"green",children:["[",d.paused?"\u6682\u505C":"\u8FD0\u884C\u4E2D","]"]})})]}),ze(Ve,{flexDirection:"column",children:[ze(xe,{children:["\u250C","\u2500".repeat(ut),"\u2510"]}),fe(xe,{children:r?" \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m":h}),ze(xe,{children:["\u2514","\u2500".repeat(ut),"\u2518"]})]}),r&&ze(Ve,{marginTop:1,flexDirection:"column",children:[fe(xe,{bold:!0,color:"yellow",children:"\u9009\u62E9\u5173\u5361"}),fe(Ve,{flexDirection:"row",flexWrap:"wrap",children:xu.map((g,b)=>fe(Ve,{width:22,children:ze(xe,{children:[fe(xe,{color:t===b+1?"green":"white",children:b+1===10?"0":String(b+1)}),". ",g.desc," (",g.rows,"\xD7",g.cols,")"]})},b))}),fe(Ve,{marginTop:1,children:fe(xe,{dimColor:!0,children:"\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA"})})]}),!r&&(d.gameOver||d.win)&&ze(Ve,{marginTop:1,children:[fe(xe,{bold:!0,color:d.gameOver?"red":"green",children:d.gameOver?"\u6E38\u620F\u7ED3\u675F\uFF01":"\u606D\u559C\u901A\u5173\uFF01"}),ze(xe,{children:[" \u5206\u6570: ",fe(xe,{color:"yellow",children:d.score})]})]}),!r&&fe(Ve,{marginTop:1,children:d.gameOver||d.win?fe(xe,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA"}):fe(xe,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA"})})]})}var $h={id:"brick-breaker",name:"Brick Breaker",description:"\u7ECF\u5178\u6253\u7816\u5757\u6E38\u620F\uFF0C10 \u4E2A\u5173\u5361\u53EF\u9009\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=tC(fe(iC,{onExit:()=>{t(),e()}}))})}};p();import{Box as _r,Text as et,useInput as aC,render as lC}from"ink";import{useState as Oh,useEffect as Dh,useRef as Nh,useCallback as cC}from"react";import{jsx as yt,jsxs as Kt}from"react/jsx-runtime";var dt=66,Gh=20,ku=6,uC=10,vr=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Mh={0:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],1:[" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],2:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],3:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],4:["\u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],5:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "],6:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],7:[" \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "],8:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "],9:[" \u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588 "]};function dC(e){let t=["","","","",""];for(let r of e){let o=Mh[r]??Mh[0];for(let s=0;s<5;s++)t[s]+=" "+(o[s]??"")}let n=6;return t.map(r=>" ".repeat(n)+r)}function wu(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return`${t};${n};${r}`}var Bh=["react","vue","next","node","axios","express","lodash","jquery","webpack","vite","babel","eslint","prettier","tailwind","bootstrap","sass","less","postcss","redux","pinia","vuex","router","nestjs","socket","graphql","rest","grpc","prisma","typeorm","html","css","jsx","tsx","dom","spa","ssr","csr","pwa","component","prop","hook","composable","directive","filter","mixin","template","render","virtual","diff","patch","hydration","responsive","flexbox","grid","animation","transition","api","route","middleware","controller","service","module","dto","entity","schema","migration","seeder","factory","auth","jwt","oauth","session","cookie","token","cors","cache","redis","mq","rabbit","kafka","nats","sql","mysql","pg","sqlite","mongo","redis","orm","table","index","query","join","union","group","order","where","having","limit","offset","insert","update","delete","docker","nginx","linux","bash","shell","yaml","toml","ci","cd","deploy","rollback","release","build","test","lint","format","stage","commit","branch","merge","rebase","array","stack","queue","tree","graph","list","map","set","sort","search","filter","reduce","map","async","await","promise","callback","closure","proxy","reflect","decorator","create","read","update","delete","crud","parse","stringify","encode","decode","transform","validate","format","parse","upload","download","export","import","backup","restore","string","number","boolean","object","array","tuple","enum","interface","type","class","function","method","property","public","private","static","readonly","optional","abstract","const","let","var","void","null","undef","never","any","config","logger","monitor","metric","alert","webhook","endpoint","payload","header","status","timeout","retry","fallback","circuit","breaker","throttle","debounce","scroll","resize","click","hover","focus","blur"];function pC(e){let t;do t=Bh[Math.floor(Math.random()*Bh.length)];while(e.has(t));return t}function Fh(){return{words:[],score:0,lives:3,speed:.3,spawnTimer:0,gameOver:!1,paused:!1,typed:"",target:null,combo:0,message:"",messageTimer:0,usedWords:new Set}}function Ai(e){let t=null;for(let n of e.words)(!t||n.col<t.col)&&(t=n);return t?.text??null}function fC(e){if(e.paused||e.gameOver)return;if(e.spawnTimer++,e.spawnTimer>=Math.max(20,50-Math.floor(e.speed*15))&&(e.spawnTimer=0,e.words.length<uC)){let r=new Set(e.usedWords);for(let a of e.words)r.add(a.text);let o=pC(r),s=new Set(e.words.map(a=>a.row)),i=-1;for(let a=ku;a<Gh;a++)if(!s.has(a)){i=a;break}i>=0&&(e.words.push({text:o,row:i,col:dt-1}),e.usedWords.add(o))}for(let r of e.words)r.col-=e.speed;let t=e.words.length;e.words=e.words.filter(r=>r.col>-r.text.length);let n=t-e.words.length;n>0&&(e.lives-=n,e.typed="",e.target=Ai(e),e.lives<=0&&(e.gameOver=!0,e.words=[])),e.target=Ai(e),e.messageTimer>0&&(e.messageTimer--,e.messageTimer<=0&&(e.message=""))}function mC(e,t,n,r){let o=[];for(let s=0;s<Gh;s++){let i="";if(s<ku){if(s<5){let a=(t[s]??"").padEnd(dt);i=`\x1B[38;2;${wu(n)}m${a}\x1B[0m`}else if(s===5){if(e.combo>=3){let a=`${e.combo}\u8FDE\u51FB!`,l=Math.floor((dt-a.length)/2),c=vr[e.combo%vr.length],u=" ".repeat(l)+a+" ".repeat(dt-l-a.length);i=`\x1B[38;2;${wu(c)}m${u}\x1B[0m`}else if(e.paused){let l=Math.floor((dt-2)/2);i=" ".repeat(l)+"\u6682\u505C",i=i.padEnd(dt)}}i=i.padEnd(dt)}else if(s===ku&&r){let a=Math.floor((dt-r.length)/2),l=" ".repeat(a)+r+" ".repeat(dt-a-r.length),c=vr[Math.floor(Math.random()*vr.length)];i=`\x1B[38;2;${wu(c)}m${l}\x1B[0m`}else for(let a=0;a<dt;a++){let l=e.words.find(c=>{let u=a-Math.floor(c.col);return u>=0&&u<c.text.length&&c.row===s});if(l){let c=a-Math.floor(l.col),u=l.text[c],d=l.text===e.target,m=e.target===l.text?e.typed.length:0,h=d&&c<m;d?i+=h?`\x1B[92m${u}\x1B[0m`:`\x1B[97m${u}\x1B[0m`:i+=`\x1B[90m${u}\x1B[0m`}else i+=" "}o.push(i)}return o}function hC({onExit:e}){let t=Nh(Fh()),[n,r]=Oh(0),[o,s]=Oh(0),i=Nh(e);i.current=e,Dh(()=>{let m=setInterval(()=>{s(h=>(h+1)%vr.length)},400);return()=>clearInterval(m)},[]),Dh(()=>{let m=setInterval(()=>{fC(t.current),r(h=>h+1)},60);return()=>clearInterval(m)},[]),aC(cC((m,h)=>{let f=t.current;if(f.gameOver){m==="r"?(t.current=Fh(),r(0)):(m==="q"||h.escape)&&i.current();return}if(m==="p"&&h.ctrl||m===" "){f.paused=!f.paused;return}if(m==="q"&&h.ctrl||h.escape){i.current();return}if(!f.paused&&m.length===1&&m>="a"&&m<="z"&&(f.target||(f.target=Ai(f)),f.target))if(f.target[f.typed.length]===m){if(f.typed+=m,f.typed===f.target){f.words=f.words.filter(E=>E.text!==f.target),f.combo++;let b=f.score,w=f.target.length,S=f.combo>=3?f.score:0;f.score+=w+S,f.speed=f.speed+.02;let v=Math.floor(b/500);Math.floor(f.score/500)>v&&(f.speed+=.15),f.score>=1e5&&b<1e5&&(f.message="\u606D\u559C\u901A\u5173! \u96BE\u5EA6\u6700\u5927\u5316!",f.messageTimer=100),f.typed="",f.target=Ai(f)}}else f.combo=0},[]));let a=t.current,l=vr[o],c=String(a.score).padStart(5,"0"),u=dC(c),d=mC(a,u,l,a.message);return Kt(_r,{flexDirection:"column",paddingX:1,children:[yt(_r,{flexDirection:"row",children:Kt(et,{children:["\u751F\u547D ",yt(et,{color:"red",children:"\u2665".repeat(Math.max(0,a.lives))})," ","\u901F\u5EA6 ",Kt(et,{color:"cyan",children:["Lv.",Math.floor(a.speed*10)]})]})}),!a.gameOver&&a.target&&yt(_r,{marginTop:1,children:Kt(et,{children:["\u6253\u5B57: ",yt(et,{color:"green",children:a.typed}),yt(et,{color:"white",children:a.target.slice(a.typed.length)})]})}),Kt(_r,{flexDirection:"column",marginTop:1,children:[Kt(et,{children:["\u250C","\u2500".repeat(dt),"\u2510"]}),d.map((m,h)=>yt(et,{children:`\u2502${m}\u2502`},h)),Kt(et,{children:["\u2514","\u2500".repeat(dt),"\u2518"]})]}),a.gameOver&&Kt(_r,{marginTop:1,children:[yt(et,{bold:!0,color:"red",children:"\u6E38\u620F\u7ED3\u675F\uFF01"}),Kt(et,{children:[" \u5F97\u5206: ",yt(et,{color:"yellow",children:a.score})," r \u91CD\u5F00 q \u9000\u51FA"]})]}),yt(_r,{marginTop:1,children:yt(et,{dimColor:!0,children:"\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA"})})]})}var jh={id:"coder-check",name:"Coder Check",description:"\u6781\u901F\u6253\u5B57\u6E38\u620F\uFF0C\u8F93\u5165\u5355\u8BCD\u6D88\u9664\u5B83\u4EEC\uFF01",play:async()=>{await new Promise(e=>{let{unmount:t}=lC(yt(hC,{onExit:()=>{t(),e()}}))})}};p();p();function gC(e,t){return e==="UP"&&t==="DOWN"||e==="DOWN"&&t==="UP"||e==="LEFT"&&t==="RIGHT"||e==="RIGHT"&&t==="LEFT"}function Su(e,t){return e.x===t.x&&e.y===t.y}function yC(e,t){switch(t){case"UP":return{x:e.x,y:e.y-1};case"DOWN":return{x:e.x,y:e.y+1};case"LEFT":return{x:e.x-1,y:e.y};case"RIGHT":return{x:e.x+1,y:e.y}}}function xC(e,t){return{x:(e.x%t.width+t.width)%t.width,y:(e.y%t.height+t.height)%t.height}}function Tu(e,t,n,r=[]){let o=new Set(e.map(a=>`${a.x},${a.y}`));for(let a of r)o.add(`${a.x},${a.y}`);let s=t.width*t.height;if(o.size>=s)return null;let i;do i={x:Math.floor(Math.random()*t.width),y:Math.floor(Math.random()*t.height)};while(o.has(`${i.x},${i.y}`));return{position:i,type:n,...n==="special"?{spawnedAt:Date.now()}:{}}}function Cu(e){let t=Math.floor(e.width/2),n=Math.floor(e.height/2),r=[{x:t,y:n},{x:t-1,y:n},{x:t-2,y:n}],o=Tu(r,e,"normal");return{snake:r,direction:"RIGHT",nextDirection:"RIGHT",food:o,specialFood:null,score:0,speedLevel:1,isGameOver:!1,isPaused:!1,wallWrap:Math.random()<.5,tickInterval:e.initialSpeed}}function Wh(e,t){e.direction=e.nextDirection;let n=e.snake[0],r=yC(n,e.direction);if(r.x<0||r.x>=t.width||r.y<0||r.y>=t.height)if(e.wallWrap)r=xC(r,t);else{e.isGameOver=!0;return}let s=Su(r,e.food.position),i=e.specialFood!==null&&Su(r,e.specialFood.position),l=s||i?e.snake:e.snake.slice(0,-1);for(let c of l)if(Su(r,c)){e.isGameOver=!0;return}if(e.snake.unshift(r),s){e.score+=1,Uh(e,t);let c=e.specialFood?[e.specialFood.position]:[],u=Tu(e.snake,t,"normal",c);if(u)e.food=u;else{e.isGameOver=!0;return}e.specialFood===null&&Math.random()<.25&&(e.specialFood=Tu(e.snake,t,"special",[e.food.position]))}else i?(e.score+=3,Uh(e,t),e.specialFood=null):e.snake.pop();e.specialFood?.spawnedAt!==void 0&&Date.now()-e.specialFood.spawnedAt>5e3&&(e.specialFood=null)}function Uh(e,t){let n=Math.floor(e.score/t.scorePerLevel)+1;e.speedLevel=n,e.tickInterval=Math.max(t.minSpeed,t.initialSpeed-(n-1)*t.speedDecrement)}function Hh(e,t){gC(t,e.direction)||(e.nextDirection=t)}p();import Ee from"chalk";var Vh=2,bC=" ",wC="\u2593",kC="\u2593",SC="\u25C6",TC="\u2605",Po="\x1B[",CC=`${Po}?25l`,_C=`${Po}?25h`,zh=`${Po}H`;function qh(){process.stdout.write(CC)}function Kh(){process.stdout.write(_C)}function Xh(){process.stdout.write(`${Po}2J${zh}`)}function vC(e,t){switch(t){case"snake-head":return Ee.greenBright(e);case"snake-body":return Ee.green(e);case"normal-food":return Ee.red(e);case"special-food":return Ee.yellow(e);case"empty":return e}}function Jh(e,t){let n=RC(e,t);process.stdout.write(`${Po}2J${zh}`+n.join(`
|
|
598
|
+
`))}function RC(e,t){let{width:n,height:r}=t,o=[],s=Array.from({length:r},()=>Array(n).fill("empty"));for(let l=1;l<e.snake.length;l++){let c=e.snake[l];c.y>=0&&c.y<r&&c.x>=0&&c.x<n&&(s[c.y][c.x]="snake-body")}let i=e.snake[0];i.y>=0&&i.y<r&&i.x>=0&&i.x<n&&(s[i.y][i.x]="snake-head");let a=e.food.position;if(s[a.y][a.x]==="empty"&&(s[a.y][a.x]="normal-food"),e.specialFood){let l=e.specialFood.position;s[l.y][l.x]==="empty"&&(s[l.y][l.x]="special-food")}o.push(" "+Ee.gray("\u2554"+"\u2550\u2550".repeat(n)+"\u2557"));for(let l=0;l<r;l++){let c=" "+Ee.gray("\u2551");for(let u=0;u<n;u++){let d=s[l][u],m;switch(d){case"snake-head":m=kC.repeat(Vh);break;case"snake-body":m=wC.repeat(Vh);break;case"normal-food":m=SC+" ";break;case"special-food":m=TC+" ";break;default:m=bC}c+=vC(m,d)}c+=Ee.gray("\u2551"),o.push(c)}if(o.push(" "+Ee.gray("\u255A"+"\u2550\u2550".repeat(n)+"\u255D")),o.push(""),o.push(` ${Ee.cyan("\u5206\u6570")}: ${e.score} ${Ee.cyan("\u957F\u5EA6")}: ${e.snake.length} ${Ee.cyan("\u901F\u5EA6")}: Lv.${e.speedLevel} ${Ee.cyan("\u8FB9\u754C")}: ${e.wallWrap?"\u7A7F\u5899":"\u649E\u5899"}`),e.specialFood?.spawnedAt!==void 0){let l=Math.ceil((5e3-(Date.now()-e.specialFood.spawnedAt))/1e3);l>0&&o.push(` ${Ee.yellow(`\u2B50 \u7279\u6B8A\u98DF\u7269 ${l} \u79D2\u540E\u6D88\u5931`)}`)}return o.push(` ${Ee.gray("W/A/S/D \u6216 \u65B9\u5411\u952E\u79FB\u52A8 | P \u6682\u505C | M \u5207\u6362\u6A21\u5F0F | Q \u9000\u51FA")}`),e.isPaused&&(o.push(""),o.push(` ${Ee.yellow("\u23F8 \u5DF2\u6682\u505C \u2014 \u6309 P \u7EE7\u7EED")}`)),e.isGameOver&&(o.push(""),o.push(` ${Ee.red.bold("\u{1F480} \u6E38\u620F\u7ED3\u675F!")} ${Ee.cyan("\u6700\u7EC8\u5206\u6570: "+e.score)}`),o.push(` ${Ee.gray("\u6309 R \u91CD\u65B0\u5F00\u59CB | \u6309 Q \u9000\u51FA")}`)),o}p();import*as Zh from"readline";var AC={up:"UP",w:"UP",W:"UP",down:"DOWN",s:"DOWN",S:"DOWN",left:"LEFT",a:"LEFT",A:"LEFT",right:"RIGHT",d:"RIGHT",D:"RIGHT"};function Yh(e,t,n){Zh.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0);let r=(o,s)=>{if(!s||!s.name)return;let{name:i,ctrl:a}=s;if(a&&(i==="c"||i==="d")){t();return}if(i==="q"){t();return}let l=e.state;if(l.isGameOver){i==="r"&&(e.state=n());return}if(i==="p"){l.isPaused=!l.isPaused;return}if(i==="m"){l.wallWrap=!l.wallWrap;return}let c=AC[i];c&&Hh(l,c)};return process.stdin.on("keypress",r),()=>{process.stdin.removeListener("keypress",r),process.stdin.isTTY&&process.stdin.setRawMode(!1)}}var Ei={width:20,height:16,initialSpeed:180,minSpeed:60,speedDecrement:10,scorePerLevel:5},EC=200,IC={id:"snake",name:"Big Snake",description:"\u7ECF\u5178\u8D2A\u5403\u86C7\uFF0C\u53CC\u98DF\u7269\u7CFB\u7EDF\u3001\u96BE\u5EA6\u9012\u589E\u3001\u7A7F\u5899/\u649E\u5899\u6A21\u5F0F",play:async()=>{let e={state:Cu(Ei)};return new Promise(t=>{let n=Yh(e,()=>{r=!0,clearTimeout(o),Kh(),n(),t()},()=>Cu(Ei));Xh(),qh();let r=!1,o;function s(){if(r)return;let i=e.state;!i.isGameOver&&!i.isPaused&&Wh(i,Ei),Jh(i,Ei);let a=i.isGameOver||i.isPaused?EC:i.tickInterval;o=setTimeout(s,a)}o=setTimeout(s,0)})}},Qh=IC;function _u(){return Ri($h),Ri(jh),Ri(Qh),Io()}import{render as pg}from"ink";import xt from"chalk";p();p();import{Box as Y,Text as Q,useInput as PC}from"ink";import{useState as pt,useCallback as eg,useEffect as Lo,useMemo as LC}from"react";import vu from"asciichart";import $C from"os";import{join as OC}from"path";import{jsx as B,jsxs as Ie}from"react/jsx-runtime";var tg=OC($C.homedir(),".dskcode","settings.json");function DC(e){let t=e.replace(/\\/g,"/");return process.platform==="win32"?"file://"+t.replace(/^([a-zA-Z]:)/,"/$1"):"file://"+t}function NC(e,t){return`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`}var MC="https://web.ifzq.gtimg.cn/appstock/app/minute/query?code={code}&r=0.1";function ng(e){return e.startsWith("sh")||e.startsWith("sz")?e:/^60|^68|^51/.test(e)?"sh"+e:/^00|^30|^39/.test(e)?"sz"+e:"sh"+e}async function rg(e){let t=MC.replace("{code}",ng(e));try{let r=await(await fetch(t)).json();if(r.code!==0)return null;let o=ng(e),s=r.data?.[o];if(!s)return null;let i=s.data?.data??[],a=[];for(let d of i){let m=d.split(" ");if(m.length>=2){let h=parseFloat(m[1]);isNaN(h)||a.push(h)}}let l=o,c=s.qt?.[l],u=null;return c&&c.length>=35&&(u={code:e,name:c[1]??"",price:parseFloat(c[3]??"0"),changePercent:parseFloat(c[32]??"0"),changeAmount:parseFloat(c[31]??"0"),high:parseFloat(c[33]??"0"),low:parseFloat(c[34]??"0"),volume:parseInt(c[6]??"0",10),amount:parseFloat(c[37]??"0")*1e4}),{prices:a,quote:u,date:s.data?.date??""}}catch{return null}}var og=new Map;function sg(e,t){og.set(e,t)}var BC=[{code:"000001",name:"\u4E0A\u8BC1\u6307\u6570",price:3150,changePercent:.35,changeAmount:11.02,high:3160,low:3140,volume:28543e4,amount:156e10},{code:"601899",name:"\u7D2B\u91D1\u77FF\u4E1A",price:18.2,changePercent:1.85,changeAmount:.33,high:18.45,low:17.9,volume:59615384,amount:1085e7},{code:"399006",name:"\u521B\u4E1A\u677F\u6307",price:1820,changePercent:-.52,changeAmount:-9.5,high:1835,low:1815,volume:9865e4,amount:1824e7}];async function FC(e){let n=(await Promise.all(e.map(async r=>{let o=await rg(r);return o?.quote?(o.prices.length>0&&sg(r,o.prices),o.quote):null}))).filter(r=>r!==null);return n.length>0?n:BC}function Ii(e){return e>=100?e.toFixed(2):e.toFixed(3)}function GC(e){return e>=1e12?(e/1e12).toFixed(2)+"\u4E07\u4EBF":e>=1e8?(e/1e8).toFixed(2)+"\u4EBF":e>=1e4?(e/1e4).toFixed(1)+"\u4E07":e.toLocaleString()}function jC(e,t=60){return e.length<=t?e:e.slice(e.length-t)}function Pi({codes:e,onExit:t,onBackToChat:n}){let[r,o]=pt([]),[s,i]=pt(0),[a,l]=pt(!0),[c,u]=pt(""),[d,m]=pt(null),[h,f]=pt(null),[g,b]=pt(!1),[w,S]=pt(10),[v,_]=pt(5),[E,M]=pt(()=>new Date().toLocaleTimeString("zh-CN",{hour12:!1})),[U,T]=pt(!1),[N,F]=pt("default"),q=LC(()=>N==="default"?r:[...r].toSorted((W,se)=>N==="desc"?se.changePercent-W.changePercent:W.changePercent-se.changePercent),[r,N]),{doubleCtrlC:$,handleCtrlC:oe}=Sn(t);Lo(()=>{let W=setInterval(()=>{M(new Date().toLocaleTimeString("zh-CN",{hour12:!1}))},1e3);return()=>clearInterval(W)},[]);let le=eg(async()=>{l(!0);try{let W=await FC(e??[]);o(W),u(new Date().toLocaleTimeString())}catch{}l(!1)},[e]);if(Lo(()=>{le()},[le]),Lo(()=>{let W=setInterval(()=>{_(se=>se<=1?(le(),5):se-1)},1e3);return()=>clearInterval(W)},[le]),Lo(()=>{if(d){let W=()=>{og.delete(d.code),rg(d.code).then(ce=>{ce&&ce.prices.length>0&&(sg(d.code,ce.prices),f(ce.prices))})};W(),S(10);let se=setInterval(W,1e4);return()=>clearInterval(se)}f(null),b(!1)},[d]),Lo(()=>{if(!d)return;let W=setInterval(()=>{S(se=>se>0?se-1:10)},1e3);return()=>clearInterval(W)},[d]),PC(eg((W,se)=>{if(W==="c"&&se.ctrl){oe();return}if(d){(se.escape||W==="q"||W===" ")&&m(null);return}if(r.length!==0)if(se.upArrow||W==="k")i(ce=>ce>0?ce-1:r.length-1);else if(se.downArrow||W==="j")i(ce=>ce<r.length-1?ce+1:0);else if(se.return){let ce=r[s];ce&&m(ce)}else se.escape||W==="q"?n?n():t():W==="r"?(_(5),le()):W==="o"?F(ce=>ce==="default"?"desc":ce==="desc"?"asc":"default"):W==="h"&&T(ce=>!ce)},[r,s,d,t,n,le,oe,T])),d)return g?B(Y,{paddingLeft:1,children:B(Q,{dimColor:!0,children:" \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..."})}):UC(d,()=>m(null),h??void 0,w,E);let ee=W=>U?{dimColor:!0}:{color:W};return Ie(Y,{flexDirection:"column",children:[Ie(Y,{marginBottom:1,justifyContent:"space-between",children:[B(Q,{bold:!0,...ee("#00ffff"),children:" \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7"}),Ie(Q,{dimColor:!0,children:[" \u{1F550} ",E]}),B(Q,{dimColor:!0,children:a?" \u27F3 \u5237\u65B0\u4E2D...":` ${v}s \u540E\u81EA\u52A8\u5237\u65B0`})]}),Ie(Y,{children:[B(Y,{width:3}),B(Y,{width:9,children:B(Q,{dimColor:!0,children:"\u4EE3\u7801"})}),B(Y,{width:16,children:B(Q,{dimColor:!0,children:"\u540D\u79F0"})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6700\u65B0\u4EF7"})}),B(Y,{width:12,children:Ie(Q,{dimColor:!0,children:["\u6DA8\u8DCC\u5E45",N==="desc"?" \u25BC":N==="asc"?" \u25B2":""]})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6DA8\u8DCC\u989D"})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6700\u9AD8"})}),B(Y,{width:12,children:B(Q,{dimColor:!0,children:"\u6700\u4F4E"})}),B(Y,{children:B(Q,{dimColor:!0,children:"\u6210\u4EA4\u989D"})})]}),B(Y,{children:B(Q,{dimColor:!0,children:" "+"\u2500".repeat(100)})}),B(Y,{flexDirection:"column",children:q.map((W,se)=>{let ce=se===s,zn=W.changePercent>=0,qn=zn?"#ff1493":"#00ff41";return Ie(Y,{children:[B(Y,{width:3,flexShrink:0,children:ce?B(Q,{bold:!0,...ee("#00ffff"),children:"\u25B8 "}):B(Q,{children:" "})}),B(Y,{width:9,children:B(Q,{bold:!0,...ee(ce?"#00ffff":"#ffffff"),children:W.code})}),B(Y,{width:16,children:B(Q,{...ee(ce?"#ffffff":"#cccccc"),children:W.name})}),B(Y,{width:12,children:B(Q,{bold:!0,...ee(qn),children:Ii(W.price)})}),B(Y,{width:12,children:Ie(Q,{...ee(qn),children:[zn?"+":"",W.changePercent.toFixed(2),"%"]})}),B(Y,{width:12,children:Ie(Q,{...ee(qn),children:[zn?"+":"",W.changeAmount.toFixed(3)]})}),B(Y,{width:12,children:B(Q,{...ee("#cccccc"),children:Ii(W.high)})}),B(Y,{width:12,children:B(Q,{...ee("#888888"),children:Ii(W.low)})}),B(Y,{children:B(Q,{...ee("#888888"),children:GC(W.amount)})})]},W.code)})}),B(Y,{marginTop:1,children:B(Q,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u8BE6\u60C5 r \u624B\u52A8\u5237\u65B0 o \u6392\u5E8F h \u7F6E\u7070/\u6062\u590D q \u8FD4\u56DE"})}),Ie(Y,{children:[B(Q,{dimColor:!0,children:` \u6700\u540E\u66F4\u65B0: ${c} \u7F16\u8F91\u81EA\u9009\u80A1: `}),B(Q,{...ee("#c792ea"),children:NC(DC(tg),tg)})]}),$&&B(Y,{marginTop:1,children:B(Q,{bold:!0,...ee("#ff1493"),children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}function UC(e,t,n,r=10,o){let s=e.changePercent>=0,i=s?"#ff1493":"#00ff41",a=s?"\u25B2":"\u25BC",l=[];if(n&&n.length>0){let c=s?vu.red:vu.green,u=jC(n,60),d=vu.plot(u,{height:10,colors:[c]});d=d.replaceAll("\u256D","\u250C").replaceAll("\u256E","\u2510").replaceAll("\u2570","\u2514").replaceAll("\u256F","\u2518"),l=d.split(`
|
|
599
|
+
`)}return Ie(Y,{flexDirection:"column",paddingLeft:1,children:[Ie(Y,{marginBottom:1,justifyContent:"space-between",children:[Ie(Y,{children:[Ie(Q,{bold:!0,color:"#00ffff",children:[" \u{1F4CA} ",e.name," "]}),B(Q,{dimColor:!0,children:e.code}),o&&Ie(Q,{dimColor:!0,children:[" \u{1F550} ",o]})]}),B(Q,{dimColor:!0,children:`${r}s \u540E\u5237\u65B0`})]}),Ie(Y,{children:[B(Y,{width:16,children:B(Q,{bold:!0,color:"#888888",children:"\u5F53\u524D\u4EF7"})}),B(Y,{children:Ie(Q,{bold:!0,color:i,children:[a," ",Ii(e.price)]})})]}),Ie(Y,{children:[B(Y,{width:16,children:B(Q,{color:"#888888",children:"\u6DA8\u8DCC\u5E45"})}),B(Y,{children:Ie(Q,{color:i,children:[s?"+":"",e.changePercent.toFixed(2),"%"," ",s?"+":"",e.changeAmount.toFixed(3)]})})]}),l.length>0&&B(Y,{marginTop:1,flexDirection:"column",children:l.map((c,u)=>B(Y,{children:B(Q,{color:i,children:c||" "})},u))}),B(Y,{marginTop:1,children:B(Q,{dimColor:!0,children:" Space/q \u8FD4\u56DE\u5217\u8868"})})]})}p();import{readdir as WC,realpath as HC}from"fs/promises";import{join as ig,relative as VC}from"path";var zC=new Set(["node_modules",".git",".svn",".hg",".dskcode",".claude","dist","build",".next",".turbo",".nx","coverage",".cache",".nyc_output",".vscode",".idea","__pycache__",".venv","venv",".tox","target","vendor","bower_components","jspm_packages"]);async function ag(e,t,n=1/0,r){let o=t??e,s=r??new Set;try{let d=await HC(o);if(s.has(d))return[];s.add(d)}catch{}let i;try{i=await WC(o,{withFileTypes:!0})}catch{return[]}let a=[],l=[];for(let d of i){let m=d.name;zC.has(m)||m.startsWith(".")||(d.isDirectory()?l.push(m):d.isFile()&&a.push(VC(e,ig(o,m))))}let c=t===void 0?n:Math.max(0,n-1),u=c<=1?[]:await Promise.all(l.map(d=>ag(e,ig(o,d),c,s)));for(let d of u)a.push(...d);return a}var qC=8;async function lg(e){return ag(e,void 0,qC)}import{jsx as Rr}from"react/jsx-runtime";var ZC=["chat","run","setup","init","completion","game","stock","config-ui"];function fg(){let e=new KC;return e.exitOverride(),e.name("dskcode").description("\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\u7EC8\u7AEF\u5DE5\u5177").version(So,"-V, --version","\u663E\u793A\u7248\u672C\u53F7").option("--verbose","\u5F00\u542F\u8BE6\u7EC6\u65E5\u5FD7\u8F93\u51FA").option("--config <path>","\u6307\u5B9A\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84").option("--dir <path>","\u6307\u5B9A\u5DE5\u4F5C\u5B50\u76EE\u5F55\uFF0C@ \u63D0\u793A\u4EC5\u663E\u793A\u8BE5\u76EE\u5F55\u4E0B\u7684\u6587\u4EF6").option("--no-config-ui","\u4E0D\u62C9\u8D77\u672C\u5730 ws server\uFF08\u9ED8\u8BA4\u4E0E chat \u5E76\u53D1\u62C9\u8D77\uFF09").option("--ws","\u8DF3\u8FC7 chat\uFF0C\u76F4\u63A5\u542F\u52A8\u672C\u5730 WebSocket \u670D\u52A1\uFF08\u9ED8\u8BA4 54006 \u7AEF\u53E3\uFF0C\u4F9B Chrome \u6269\u5C55\u8FDE\u63A5\uFF09"),e.helpInformation=()=>od(e),e.hook("preAction",async(t,n)=>{let r=await rd.call(t);n.dskcodeCtx=r}),e.command("chat").description("\u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD\u4F1A\u8BDD(\u65E0\u53C2\u8FD0\u884C `dskcode` \u7B49\u4EF7\u4E8E\u6B64\u547D\u4EE4)").action(async function(){await ug(this)}),e.action(async function(){let t=this;if(t.opts().ws){let{startConfigUi:r}=await import("./config-ui-LWC4GWEV.js");await r({});return}await ug(t)}),e.command("run").description("\u6267\u884C\u4E00\u6B21\u6027\u4EFB\u52A1").argument("[prompt...]","\u4EFB\u52A1\u63CF\u8FF0").option("--model <name>","\u6307\u5B9A\u4F7F\u7528\u7684\u6A21\u578B").action(async function(t){console.log("dskcode run \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C07\u7AE0\uFF09")}),e.command("setup").description("\u8FD0\u884C\u914D\u7F6E\u5411\u5BFC").option("--export","\u4EE5 JSON \u683C\u5F0F\u5BFC\u51FA\u914D\u7F6E").option("--test","\u6D4B\u8BD5 API Key \u8FDE\u901A\u6027").action(async function(){console.log("dskcode setup \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C14\u7AE0\uFF09")}),e.command("init").description("\u5728\u5F53\u524D\u9879\u76EE\u4E0B\u751F\u6210\u9879\u76EE\u8BB0\u5FC6\u6587\u4EF6\uFF08AGENTS.md\uFF09").action(async function(){console.log("dskcode init \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C11\u7AE0\uFF09")}),e.command("completion").description("\u8F93\u51FA shell \u81EA\u52A8\u8865\u5168\u914D\u7F6E\u8BF4\u660E\uFF08bash/zsh\uFF09").argument("[shell]","shell \u7C7B\u578B",/^(bash|zsh)$/i).action(async function(t){if(!t){console.log("\u8BF7\u6307\u5B9A shell \u7C7B\u578B\uFF1Adskcode completion bash \u6216 dskcode completion zsh");return}console.log(t==="bash"?`# dskcode bash \u81EA\u52A8\u8865\u5168
|
|
605
600
|
_dskcode_completion() {
|
|
606
601
|
local cur=\${COMP_WORDS[COMP_CWORD]}
|
|
607
602
|
if [[ \${COMP_CWORD} -eq 1 ]]; then
|
|
608
|
-
COMPREPLY=( $(compgen -W "${
|
|
603
|
+
COMPREPLY=( $(compgen -W "${ZC.join(" ")}" -- "\${cur}") )
|
|
609
604
|
return 0
|
|
610
605
|
fi
|
|
611
606
|
COMPREPLY=( $(compgen -W "--verbose --config --model" -- "\${cur}") )
|
|
@@ -624,15 +619,15 @@ _dskcode_completion() {
|
|
|
624
619
|
)
|
|
625
620
|
_describe 'dskcode commands' commands
|
|
626
621
|
}
|
|
627
|
-
compdef _dskcode_completion dskcode`)}),e.command("stock").description("\u67E5\u770B\u81EA\u9009\u80A1\u5B9E\u65F6\u884C\u60C5").argument("[codes...]","\u80A1\u7968\u4EE3\u7801\uFF08\u7A7A\u683C\u5206\u9694\uFF09\uFF0C\u5982 513090 600519").action(async function(t){let n=this.dskcodeCtx,r=process.env.HOME??process.env.USERPROFILE??"~",o=
|
|
628
|
-
`)}let i=await
|
|
629
|
-
`),await n.play()}else{let n=Io();if(n.length===0){console.log("\u6682\u65E0\u53EF\u7528\u6E38\u620F\u3002");return}let r=await new Promise(o=>{let{unmount:s}=
|
|
630
|
-
\u542F\u52A8\u6E38\u620F: ${
|
|
631
|
-
`),await r.play())}}),e.command("config-ui").description("\u542F\u52A8\u672C\u5730 WebSocket \u670D\u52A1\uFF0C\u5141\u8BB8 Chrome \u6269\u5C55\u7F16\u8F91 settings.json (\u9ED8\u8BA4\u7AEF\u53E3 54006)").option("--host <host>","\u76D1\u542C host\uFF0C\u9ED8\u8BA4 127.0.0.1\uFF08\u5FC5\u987B\u4FDD\u7559 loopback\uFF09","127.0.0.1").option("--port <port>","\u76D1\u542C\u7AEF\u53E3\uFF0C\u9ED8\u8BA4 54006 (\u4E0E Chrome \u6269\u5C55\u540C\u6B65)",t=>Number.parseInt(t,10),54006).action(async function(){let t=this.opts(),{startConfigUi:n}=await import("./config-ui-
|
|
632
|
-
`);let m=await
|
|
633
|
-
`);let h=await
|
|
634
|
-
\u27F3 dskcode \u8FD0\u884C\u65F6\u8BBE\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D (source: ${
|
|
635
|
-
`))}).catch(
|
|
622
|
+
compdef _dskcode_completion dskcode`)}),e.command("stock").description("\u67E5\u770B\u81EA\u9009\u80A1\u5B9E\u65F6\u884C\u60C5").argument("[codes...]","\u80A1\u7968\u4EE3\u7801\uFF08\u7A7A\u683C\u5206\u9694\uFF09\uFF0C\u5982 513090 600519").action(async function(t){let n=this.dskcodeCtx,r=process.env.HOME??process.env.USERPROFILE??"~",o=dg(r,".dskcode","settings.json"),s=!1;try{let c=await JC(o,"utf-8"),d=JSON.parse(c).stock;s=Array.isArray(d?.symbols)&&d.symbols.length>0}catch{}if(!s){let u=await ba([{code:"sh000001"},{code:"sz399300"},{code:"sh601899"}]);console.log(`${xt.green("\u2714")} \u5DF2\u751F\u6210\u81EA\u9009\u80A1\u914D\u7F6E: ${xt.dim(u)}`),console.log(`${xt.dim(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u81EA\u5B9A\u4E49\u81EA\u9009\u80A1\u5217\u8868")}
|
|
623
|
+
`)}let i=await Lt(),a=t&&t.length>0?t:i.config.stock?.symbols?.map(c=>c.code)??["sh000001","sz399006","sh601688"];await Fr(Rr(Pi,{codes:a,onExit:()=>process.exit(0)})).waitUntilExit}),_u(),e.command("game").description("\u542F\u52A8\u5185\u7F6E\u5C0F\u6E38\u620F").argument("[name]","\u6E38\u620F\u540D\u79F0\uFF0C\u4E0D\u6307\u5B9A\u5219\u663E\u793A\u4EA4\u4E92\u5F0F\u6E38\u620F\u5217\u8868").action(async function(t){if(t){let n=Eh(t);n||(console.error(`\u672A\u627E\u5230\u6E38\u620F "${t}"\u3002\u4F7F\u7528 dskcode game \u67E5\u770B\u53EF\u7528\u6E38\u620F\u5217\u8868\u3002`),process.exit(1)),console.log(`\u6B63\u5728\u542F\u52A8: ${n.name} \u2014 ${n.description}
|
|
624
|
+
`),await n.play()}else{let n=Io();if(n.length===0){console.log("\u6682\u65E0\u53EF\u7528\u6E38\u620F\u3002");return}let r=await new Promise(o=>{let{unmount:s}=pg(Rr(vi,{games:n,onSelect:i=>{s(),o(i)},onExit:()=>{s(),o(null)}}),{exitOnCtrlC:!1})});r&&(console.log(`
|
|
625
|
+
\u542F\u52A8\u6E38\u620F: ${xt.green(r.name)}
|
|
626
|
+
`),await r.play())}}),e.command("config-ui").description("\u542F\u52A8\u672C\u5730 WebSocket \u670D\u52A1\uFF0C\u5141\u8BB8 Chrome \u6269\u5C55\u7F16\u8F91 settings.json (\u9ED8\u8BA4\u7AEF\u53E3 54006)").option("--host <host>","\u76D1\u542C host\uFF0C\u9ED8\u8BA4 127.0.0.1\uFF08\u5FC5\u987B\u4FDD\u7559 loopback\uFF09","127.0.0.1").option("--port <port>","\u76D1\u542C\u7AEF\u53E3\uFF0C\u9ED8\u8BA4 54006 (\u4E0E Chrome \u6269\u5C55\u540C\u6B65)",t=>Number.parseInt(t,10),54006).action(async function(){let t=this.opts(),{startConfigUi:n}=await import("./config-ui-LWC4GWEV.js");await n({host:t.host??"127.0.0.1",port:t.port??54006})}),e}async function ug(e){let t="opts"in e?e.opts():{},n=t.dir??process.cwd();process.stdin.isTTY||(console.error("dskcode chat \u9700\u8981\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\u3002\u5982\u9700\u6267\u884C\u4E00\u6B21\u6027\u4EFB\u52A1\uFF0C\u8BF7\u4F7F\u7528 dskcode run\u3002"),process.exit(1));let r=e.dskcodeCtx;if(r&&!id(r.config.providers)){let u=await ad();u||process.exit(1);let d=await xa(u);console.log(` ${xt.green("\u2714")} API Key \u5DF2\u4FDD\u5B58\u5230 ${xt.dim(d)}
|
|
627
|
+
`);let m=await Lt();r={...r,config:m.config}}await dd(process.cwd());let o=await wa();if(o){let u=await Lt();r={...r,config:u.config},console.log(" \u2714 \u5DF2\u751F\u6210\u6743\u9650\u914D\u7F6E: "+o),console.log(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u6DFB\u52A0 permissions \u89C4\u5219")}let s=cs(r?.config.voice);if(s.resolved)(s.source.appId==="env"||s.source.accessKey==="env")&&console.log(` ${xt.dim("\u2139 \u8BED\u97F3\u51ED\u636E\u4ECE\u73AF\u5883\u53D8\u91CF\u8BFB\u53D6\uFF08\u672A\u6301\u4E45\u5316\u5230 settings.json\uFF09")}`);else{let u=await ld();if(!u)console.log(" "+xt.yellow("\u26A0 \u672A\u914D\u7F6E\u8BED\u97F3\u8BC6\u522B\u51ED\u636E\uFF0C/voice \u547D\u4EE4\u4E0D\u53EF\u7528\uFF08\u5176\u4F59\u529F\u80FD\u6B63\u5E38\uFF09"));else{let d=process.env.HOME??process.env.USERPROFILE??"~",m=dg(d,".dskcode","settings.json");await _a(m,u.appId,u.accessKey),console.log(` ${xt.green("\u2714")} \u8BED\u97F3\u51ED\u636E\u5DF2\u4FDD\u5B58\u5230 ${xt.dim(m)}
|
|
628
|
+
`);let h=await Lt();r=r?{...r,config:h.config}:{config:h.config,verbose:!1},s=cs(h.config.voice)}}let i=new Me({budgetLimit:r?.config.budgetLimit??0,tokenBudgetLimit:r?.config.tokenBudgetLimit??0}),l=process.env.DSKCODE_CONFIG_UI==="0"?!1:t.configUi??!0,c=null;if(l){let{startConfigServerBackground:u}=await import("./config-ui-LWC4GWEV.js");c=await u({})}Li(r,i,n,s,c)}async function Li(e,t,n=process.cwd(),r,o=null){let[s,i,a,l]=await Promise.all([ud(),Ea(process.cwd()),pd(process.cwd()),lg(n)]),c=s+i;function u(m){let[h,f]=cg(e),[g,b]=cg(0),w=o;XC(()=>w?w.onConfigChanged(q=>{Lt().then($=>{e&&(e.config=$.config,f({...e,config:$.config})),b(oe=>oe+1),console.error(xt.cyan(`
|
|
629
|
+
\u27F3 dskcode \u8FD0\u884C\u65F6\u8BBE\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D (source: ${q.source})
|
|
630
|
+
`))}).catch($=>{console.error(` \u26A0 \u91CD\u65B0\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25: ${$.message}`)})}):void 0,[w]);let S=h??e,v=S?.config.providers.find(F=>F.name===(S?.config.defaultProvider??"deepseek")),_=v?.model??"deepseek-v4-flash",E=v?.apiKey,M=v?.baseUrl??"https://api.deepseek.com",U=S?.verbose??!1,T=S?.config.thinking?.enabled??!1,N=S?.config.thinking?.effort??"high";return Rr(mu,{...m,model:_,apiKey:E,baseUrl:M,verbose:U,thinkingEnabledFromConfig:T,thinkingEffortFromConfig:N,configReloadEpoch:g})}let d=Fr(Rr(u,{skillCount:c,skills:a,files:l,toolCount:e?.config.tools.length??0,costTracker:t,permissionsConfig:e?.config.permissions,voiceConfig:r,onLaunchGame:()=>{d.unmount(),setImmediate(()=>{_u();let m=Io(),{unmount:h}=pg(Rr(vi,{games:m,onSelect:async f=>{h(),await f.play(),Li(e,t,n,r,o)},onBackToChat:()=>{h(),setImmediate(()=>Li(e,t,n,r,o))}}),{exitOnCtrlC:!1})})},onLaunchStock:()=>{d.unmount(),setImmediate(()=>{let m=e?.config.stock?.symbols?.map(f=>f.code)??["sh000001","sz399006","sh601688"],h=Fr(Rr(Pi,{codes:m,onBackToChat:()=>{h.unmount(),setImmediate(()=>Li(e,t,n,r))},onExit:()=>process.exit(0)}))})}}))}p();var $o={SUCCESS:0,GENERAL_ERROR:1,CONFIG_ERROR:2,SIGINT:130};var Ru=0,Au=null;async function mg(e){try{await Promise.all([Me.flushAll(),en.endAllAndFlush()])}catch{}process.exit(e)}process.on("SIGINT",()=>{if(Ru++,Ru>=2){mg($o.SIGINT);return}process.stdout.write(`
|
|
636
631
|
\u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode
|
|
637
|
-
`),Au&&clearTimeout(Au),Au=setTimeout(()=>{Ru=0},1500)});process.on("SIGTERM",()=>{
|
|
632
|
+
`),Au&&clearTimeout(Au),Au=setTimeout(()=>{Ru=0},1500)});process.on("SIGTERM",()=>{mg($o.SIGINT)});var YC=fg();try{await YC.parseAsync(process.argv),await Promise.all([Me.flushAll(),en.endAllAndFlush()])}catch(e){let t=e;(t.code==="commander.helpDisplayed"||t.code==="commander.version")&&(await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit(t.exitCode??$o.SUCCESS)),typeof t.exitCode=="number"&&(await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit(t.exitCode)),console.error(String(e)),await Promise.all([Me.flushAll(),en.endAllAndFlush()]),process.exit($o.GENERAL_ERROR)}
|
|
638
633
|
//# sourceMappingURL=index.js.map
|