dskcode 0.1.53 → 0.1.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +126 -117
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import{a as wn,b as al,c as kn,d as Sr,e as Mt,f as ll,h as cl}from"./chunk-V3LN4R4P.js";import{a as ep}from"./chunk-XW3DXEJJ.js";import{a as il,b as Jd,c as co}from"./chunk-FJL5WURJ.js";import{a as je,b as Vn,c as ul}from"./chunk-5Z3DMHRQ.js";import{a as Qd}from"./chunk-5NFOBNG6.js";import{a as Hd,b as Vd,c as xn,f as zd,g as qd,h as Kd,i as Xd,k as bn}from"./chunk-EEH2ZJA5.js";import{a as Zd,b as Yd,c as Us,f as Ws}from"./chunk-O3L436MU.js";import{a as js}from"./chunk-XAWVLVWL.js";import{a as zy,b as Wd,c as qy,d as p}from"./chunk-LPD7BHH5.js";var uf=zy((e1,cf)=>{"use strict";p();var Ol,{defineProperty:Ub,getPrototypeOf:Wb,setPrototypeOf:lf,create:Hb,keys:Vb}=Object,mt="",{round:ri,max:zb}=Math,Dl=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]},rf=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)+(zb(n,r,o)>4?60:0)},of={open:mt,close:mt},sf=(e,{open:t="",close:n="",f:r})=>{let o=(e.open||mt)+t,s=n+(e.close||mt),i=(a,...l)=>{if(!a){if(!n)return t;if((a??mt)===mt)return mt}let c,u=r?r(a,...l):a.raw?String.raw({raw:a},...l):mt+a,d=i;if(u.includes("\x1B"))for(;d=d.p;){let{t:f,o:h}=d,m=h.length,g=mt,w=0;if(m)for(;~(c=u.indexOf(h,w));w=c+m)g+=u.slice(w,c)+f;u=g+u.slice(w)}return o+(u.includes(`
3
- `)?u.replace(/(\r?\n)/g,s+"$1"+o):u)+s};return lf(i,Wb(e)).p={t,o:n,p:e.p},i.open=o,i.close=s,i},af=new function e(t=globalThis){let n=typeof t=="number"?t:(I=>{let R=I.process??{},D=R.argv??[],F=R.env??{},P=0;try{P=((ne,Q,V)=>(Ol=Q.TERM,{"24bit":3,truecolor:3,ansi256:2,ansi:1}[Q.COLORTERM]||(Q.CI?/,GITHUB/.test(V)?3:1:(Q.PM2_HOME||/edge/.test(Q.NEXT_RUNTIME)||ne.stdout?.isTTY)&&Ol!=="dumb"?ne.platform==="win32"?3:/-256/.test(Ol)?2:1:0)))(R,F,","+Vb(F).join(","))}catch{F={}}let z,j=P||1,N="FORCE_COLOR",A={false:0,0:0,1:1,2:2,3:3}[F[N]]??j,ie=-1;for(z of D)/^--color=?(true|always)?$/.test(z)&&(ie=j),/^--(no-color|color=(false|never))$/.test(z)&&(ie=0);return I.window?.chrome?3:N in F?A:~ie?ie:F.NO_COLOR?0:P})(t),r={},o={Ansis:e,level:n,isSupported:()=>l,strip:I=>I.replace(/][^]*|[›][[()#;?]*(?:\d+(?:;\d*)*)?[\dA-ORZcf-nqry=><]/g,mt),extend(I){for(let R in I){let D=I[R];(typeof D)[0]==="s"&&(s(u(R),b(...Dl(D))),D=w(...Dl(D))),s(R,D)}return lf(o,Hb({},r))}},s=(I,R)=>{r[I]={get(){return Ub(this,I,{value:R.call?(...D)=>sf(this,R(...D)):sf(this,R)})[I]}}},i=1^n,a=n>2,l=n>0,c=(I,R)=>l?{open:`\x1B[${I}m`,close:R?`\x1B[${R}m`:mt}:of,u=I=>"bg"+I[0].toUpperCase()+I.slice(1),d=I=>R=>I(...Dl(R)),f=(I,R)=>(D,F,P)=>c(`${I}8;2;${D};${F};${P}`,R),h=I=>(R,D,F)=>I(((P,z,j)=>P^z|z^j?16+36*ri(P/51)+6*ri(z/51)+ri(j/51):8>P?16:P>248?231:ri(24*(P-8)/247)+232)(R,D,F)),m=I=>c(i?"38;5;"+I:rf(I),39),g=I=>c(i?"48;5;"+I:rf(I)+10,49),w=a?f(3,39):h(m),b=a?f(4,49):h(g),k={fg:m,bg:g,rgb:w,bgRgb:b,hex:d(w),bgHex:d(b),visible:of,reset:c(0,mt),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:(I,R=I)=>l?`\x1B]8;;${I}\x07${R}\x1B]8;;\x07`:R!=I?R+` (\u200B${I}\u200B)`:I}},v=(I,R)=>{k[I]=c(R,39),k[u(I)]=c(R+10,49)};return"gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((I,R)=>{R?v(I+"Bright",89+R):R=61,v(I,29+R)})),o.extend(k)};cf.exports=af.default=af});p();p();import{Command as Rv}from"commander";import{useEffect as Av,useState as Cy}from"react";p();async function tp(){let e=this.optsWithGlobals(),t=e.verbose??!1,n,r=[];try{let o=await xn(e.config);if(n=o.config,o.errors.length>0)for(let s of o.errors)r.push(s.message)}catch{n=structuredClone(Hd)}if(n=Vd(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 Le from"chalk";function np(e){let t=[];t.push(""),t.push(Le.bold("\u7528\u6CD5:")),t.push(` ${Le.cyan("dskcode")} ${Le.dim("[global-options]")} ${Le.green("<command>")} ${Le.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(Le.bold("\u5168\u5C40\u9009\u9879:"));for(let o of n){let s=[o.short,o.long].filter(Boolean).join(", ");t.push(` ${Le.cyan(s.padEnd(24))} ${o.description??""}`)}t.push("")}t.push(Le.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(` ${Le.cyan(o.padEnd(24))} ${s.description??""}`)}t.push("");let r=e.commands.filter(o=>!o.name().startsWith("help"));if(r.length>0){t.push(Le.bold("\u547D\u4EE4:"));for(let o of r)t.push(` ${Le.green(o.name().padEnd(24))} ${o.description()}`);t.push("")}return t.push(Le.bold("\u793A\u4F8B:")),t.push(` ${Le.dim("# \u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD(\u65E0\u53C2\u9ED8\u8BA4\u884C\u4E3A)")}`),t.push(" dskcode"),t.push(` ${Le.dim("# \u8BA9 AI \u6267\u884C\u4E00\u4E2A\u4EFB\u52A1")}`),t.push(" dskcode run \u4FEE\u6539\u6240\u6709 TODO \u6CE8\u91CA"),t.push(` ${Le.dim("# \u8FD0\u884C\u914D\u7F6E\u5411\u5BFC")}`),t.push(" dskcode setup"),t.push(` ${Le.dim("# \u751F\u6210 shell \u81EA\u52A8\u8865\u5168")}`),t.push(" dskcode completion"),t.push(` ${Le.dim("# \u67E5\u770B\u81EA\u9009\u80A1\u884C\u60C5")}`),t.push(" dskcode stock"),t.push(` ${Le.dim("# \u67E5\u770B\u6307\u5B9A\u80A1\u7968\u884C\u60C5")}`),t.push(" dskcode stock sh513090 sz000001"),t.push(""),t.join(`
4
- `)}p();import{createInterface as rp}from"readline";import we from"chalk";function op(e){return!!(e.some(t=>t.apiKey)||process.env.DEEPSEEK_API_KEY)}var dl=10;async function sp(){console.log(we.yellow(`
2
+ import{a as wn,b as fl,c as Tn,d as _r,e as Mt,f as ml,h as hl}from"./chunk-V3LN4R4P.js";import{a as xp}from"./chunk-XW3DXEJJ.js";import{a as pl,b as mp,c as go}from"./chunk-FJL5WURJ.js";import{a as je,b as qn,c as gl}from"./chunk-5Z3DMHRQ.js";import{a as yp}from"./chunk-5NFOBNG6.js";import{a as lp,b as cp,c as bn,f as up,g as dp,h as pp,i as fp,k as kn}from"./chunk-EEH2ZJA5.js";import{a as hp,b as gp,c as Xs,f as Js}from"./chunk-O3L436MU.js";import{a as Ks}from"./chunk-XAWVLVWL.js";import{a as px,b as ap,c as fx,d as p}from"./chunk-LPD7BHH5.js";var Ef=px((vE,Af)=>{"use strict";p();var Hl,{defineProperty:pk,getPrototypeOf:fk,setPrototypeOf:Rf,create:mk,keys:hk}=Object,gt="",{round:ui,max:gk}=Math,Vl=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]},Sf=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)+(gk(n,r,o)>4?60:0)},Cf={open:gt,close:gt},_f=(e,{open:t="",close:n="",f:r})=>{let o=(e.open||gt)+t,s=n+(e.close||gt),i=(a,...l)=>{if(!a){if(!n)return t;if((a??gt)===gt)return gt}let c,u=r?r(a,...l):a.raw?String.raw({raw:a},...l):gt+a,d=i;if(u.includes("\x1B"))for(;d=d.p;){let{t:f,o:h}=d,m=h.length,g=gt,b=0;if(m)for(;~(c=u.indexOf(h,b));b=c+m)g+=u.slice(b,c)+f;u=g+u.slice(b)}return o+(u.includes(`
3
+ `)?u.replace(/(\r?\n)/g,s+"$1"+o):u)+s};return Rf(i,fk(e)).p={t,o:n,p:e.p},i.open=o,i.close=s,i},vf=new function e(t=globalThis){let n=typeof t=="number"?t:(E=>{let I=E.process??{},F=I.argv??[],M=I.env??{},C=0;try{C=((fe,ne,K)=>(Hl=ne.TERM,{"24bit":3,truecolor:3,ansi256:2,ansi:1}[ne.COLORTERM]||(ne.CI?/,GITHUB/.test(K)?3:1:(ne.PM2_HOME||/edge/.test(ne.NEXT_RUNTIME)||fe.stdout?.isTTY)&&Hl!=="dumb"?fe.platform==="win32"?3:/-256/.test(Hl)?2:1:0)))(I,M,","+hk(M).join(","))}catch{M={}}let N,oe=C||1,j="FORCE_COLOR",O={false:0,0:0,1:1,2:2,3:3}[M[j]]??oe,ce=-1;for(N of F)/^--color=?(true|always)?$/.test(N)&&(ce=oe),/^--(no-color|color=(false|never))$/.test(N)&&(ce=0);return E.window?.chrome?3:j in M?O:~ce?ce:M.NO_COLOR?0:C})(t),r={},o={Ansis:e,level:n,isSupported:()=>l,strip:E=>E.replace(/][^]*|[›][[()#;?]*(?:\d+(?:;\d*)*)?[\dA-ORZcf-nqry=><]/g,gt),extend(E){for(let I in E){let F=E[I];(typeof F)[0]==="s"&&(s(u(I),k(...Vl(F))),F=b(...Vl(F))),s(I,F)}return Rf(o,mk({},r))}},s=(E,I)=>{r[E]={get(){return pk(this,E,{value:I.call?(...F)=>_f(this,I(...F)):_f(this,I)})[E]}}},i=1^n,a=n>2,l=n>0,c=(E,I)=>l?{open:`\x1B[${E}m`,close:I?`\x1B[${I}m`:gt}:Cf,u=E=>"bg"+E[0].toUpperCase()+E.slice(1),d=E=>I=>E(...Vl(I)),f=(E,I)=>(F,M,C)=>c(`${E}8;2;${F};${M};${C}`,I),h=E=>(I,F,M)=>E(((C,N,oe)=>C^N|N^oe?16+36*ui(C/51)+6*ui(N/51)+ui(oe/51):8>C?16:C>248?231:ui(24*(C-8)/247)+232)(I,F,M)),m=E=>c(i?"38;5;"+E:Sf(E),39),g=E=>c(i?"48;5;"+E:Sf(E)+10,49),b=a?f(3,39):h(m),k=a?f(4,49):h(g),T={fg:m,bg:g,rgb:b,bgRgb:k,hex:d(b),bgHex:d(k),visible:Cf,reset:c(0,gt),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,I=E)=>l?`\x1B]8;;${E}\x07${I}\x1B]8;;\x07`:I!=E?I+` (\u200B${E}\u200B)`:E}},A=(E,I)=>{T[E]=c(I,39),T[u(E)]=c(I+10,49)};return"gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((E,I)=>{I?A(E+"Bright",89+I):I=61,A(E,29+I)})),o.extend(T)};Af.exports=vf.default=vf});p();p();import{Command as Qv}from"commander";import{useEffect as eR,useState as Wy}from"react";p();async function bp(){let e=this.optsWithGlobals(),t=e.verbose??!1,n,r=[];try{let o=await bn(e.config);if(n=o.config,o.errors.length>0)for(let s of o.errors)r.push(s.message)}catch{n=structuredClone(lp)}if(n=cp(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 $e from"chalk";function kp(e){let t=[];t.push(""),t.push($e.bold("\u7528\u6CD5:")),t.push(` ${$e.cyan("dskcode")} ${$e.dim("[global-options]")} ${$e.green("<command>")} ${$e.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($e.bold("\u5168\u5C40\u9009\u9879:"));for(let o of n){let s=[o.short,o.long].filter(Boolean).join(", ");t.push(` ${$e.cyan(s.padEnd(24))} ${o.description??""}`)}t.push("")}t.push($e.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(` ${$e.cyan(o.padEnd(24))} ${s.description??""}`)}t.push("");let r=e.commands.filter(o=>!o.name().startsWith("help"));if(r.length>0){t.push($e.bold("\u547D\u4EE4:"));for(let o of r)t.push(` ${$e.green(o.name().padEnd(24))} ${o.description()}`);t.push("")}return t.push($e.bold("\u793A\u4F8B:")),t.push(` ${$e.dim("# \u542F\u52A8\u4EA4\u4E92\u5F0F\u5BF9\u8BDD(\u65E0\u53C2\u9ED8\u8BA4\u884C\u4E3A)")}`),t.push(" dskcode"),t.push(` ${$e.dim("# \u8BA9 AI \u6267\u884C\u4E00\u4E2A\u4EFB\u52A1")}`),t.push(" dskcode run \u4FEE\u6539\u6240\u6709 TODO \u6CE8\u91CA"),t.push(` ${$e.dim("# \u8FD0\u884C\u914D\u7F6E\u5411\u5BFC")}`),t.push(" dskcode setup"),t.push(` ${$e.dim("# \u751F\u6210 shell \u81EA\u52A8\u8865\u5168")}`),t.push(" dskcode completion"),t.push(` ${$e.dim("# \u67E5\u770B\u81EA\u9009\u80A1\u884C\u60C5")}`),t.push(" dskcode stock"),t.push(` ${$e.dim("# \u67E5\u770B\u6307\u5B9A\u80A1\u7968\u884C\u60C5")}`),t.push(" dskcode stock sh513090 sz000001"),t.push(""),t.join(`
4
+ `)}p();import{createInterface as wp}from"readline";import we from"chalk";function Tp(e){return!!(e.some(t=>t.apiKey)||process.env.DEEPSEEK_API_KEY)}var yl=10;async function Sp(){console.log(we.yellow(`
5
5
  \u26A0 \u672A\u68C0\u6D4B\u5230 API Key \u914D\u7F6E`)),console.log(we.dim(" \u4F60\u53EF\u4EE5\u901A\u8FC7\u4EE5\u4E0B\u4EFB\u4E00\u65B9\u5F0F\u914D\u7F6E\uFF1A")),console.log(we.dim(" \xB7 \u73AF\u5883\u53D8\u91CF: export DEEPSEEK_API_KEY=sk-xxx")),console.log(we.dim(" \xB7 \u914D\u7F6E\u6587\u4EF6: ~/.dskcode/settings.json")),console.log(we.dim(` \xB7 \u4E0B\u9762\u76F4\u63A5\u8F93\u5165\uFF0C\u81EA\u52A8\u4FDD\u5B58\u5230\u5168\u5C40\u914D\u7F6E
6
- `));let e=rp({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(` ${we.cyan("\u{1F511}")} ${we.bold("\u8BF7\u8F93\u5165\u4F60\u7684 DeepSeek API Key:")} `,s=>{r();let i=s.trim();if(!i){console.log(we.red(" \u2716 API Key \u4E0D\u80FD\u4E3A\u7A7A")),t(null);return}if(i.length<dl){console.log(we.red(" \u2716 API Key \u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u957F\u5EA6\u81F3\u5C11 10 \u4F4D")),t(null);return}t(i)})})}async function ip(){console.log(we.yellow(`
6
+ `));let e=wp({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(` ${we.cyan("\u{1F511}")} ${we.bold("\u8BF7\u8F93\u5165\u4F60\u7684 DeepSeek API Key:")} `,s=>{r();let i=s.trim();if(!i){console.log(we.red(" \u2716 API Key \u4E0D\u80FD\u4E3A\u7A7A")),t(null);return}if(i.length<yl){console.log(we.red(" \u2716 API Key \u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u957F\u5EA6\u81F3\u5C11 10 \u4F4D")),t(null);return}t(i)})})}async function Cp(){console.log(we.yellow(`
7
7
  \u26A0 \u672A\u68C0\u6D4B\u5230\u706B\u5C71 ASR \u51ED\u636E`)),console.log(we.dim(" \u4F60\u53EF\u4EE5\u901A\u8FC7\u4EE5\u4E0B\u4EFB\u4E00\u65B9\u5F0F\u914D\u7F6E\uFF1A")),console.log(we.dim(" \xB7 \u73AF\u5883\u53D8\u91CF: export VOLC_ASR_APP_ID=... VOLC_ASR_ACCESS_KEY=...")),console.log(we.dim(" \xB7 \u914D\u7F6E\u6587\u4EF6: ~/.dskcode/settings.json \u7684 voice \u6BB5")),console.log(we.dim(` \xB7 \u4E0B\u9762\u76F4\u63A5\u8F93\u5165\uFF0C\u81EA\u52A8\u4FDD\u5B58\u5230\u5168\u5C40\u914D\u7F6E
8
8
  `)),console.log(we.dim(` \u51ED\u636E\u83B7\u53D6\u8DEF\u5F84\uFF1A\u706B\u5C71\u63A7\u5236\u53F0 \u2192 \u8BED\u97F3\u6280\u672F \u2192 \u6211\u7684\u5E94\u7528
9
- `));let e=rp({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(` ${we.cyan("\u{1F194}")} ${we.bold("\u8BF7\u8F93\u5165 APP ID\uFF08\u7EAF\u6570\u5B57\uFF09:")} `,s=>{let i=s.trim();if(!/^\d+$/.test(i)){r(),console.log(we.red(" \u2716 APP ID \u5FC5\u987B\u662F\u7EAF\u6570\u5B57")),t(null);return}e.question(` ${we.cyan("\u{1F511}")} ${we.bold("\u8BF7\u8F93\u5165 Access Key:")} `,a=>{r();let l=a.trim();if(l.length<dl){console.log(we.red(` \u2716 Access Key \u957F\u5EA6\u81F3\u5C11 ${dl} \u4F4D`)),t(null);return}t({appId:i,accessKey:l})})})})}p();import{createInterface as Ky}from"readline";import{existsSync as zt,statSync as Tr,lstatSync as Xy}from"fs";import{mkdir as Jy,readdir as Cr,cp as Zy,access as Yy,realpath as Qy,readFile as ex}from"fs/promises";import{join as ot}from"path";import rt from"chalk";function pl(){let e=process.env.HOME??process.env.USERPROFILE??"~";return ot(e,".claude","skills")}function _r(){return Zd()}async function vr(e){try{return await Yy(ot(e,"SKILL.md")),!0}catch{return!1}}async function tx(){let e=pl();if(!zt(e))return[];let t;try{t=await Cr(e)}catch{return[]}let n=[];for(let r of t){let o=ot(e,r);Tr(o).isDirectory()&&await vr(o)&&n.push(r)}return n}function nx(e){let t=Ky({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 rx(e){let t=pl(),n=_r();await Jy(n,{recursive:!0});let r=[],o=[];for(let s of e){let i=ot(t,s),a=ot(n,s);if(zt(a)){o.push(s);continue}let l=Xy(i).isSymbolicLink()?await Qy(i):i;await Zy(l,a,{recursive:!0,dereference:!0}),r.push(s)}return{imported:r,skipped:o}}async function lp(){let e=_r();if(!zt(e))return 0;let t;try{t=await Cr(e)}catch{return 0}let n=0;for(let r of t){let o=ot(e,r);Tr(o).isDirectory()&&await vr(o)&&n++}return n}function fl(e){return Yd(e)}async function ox(e){return await ml(e)>0}async function ml(e){let t=fl(e);if(!zt(t))return 0;let n;try{n=await Cr(t)}catch{return 0}let r=0;for(let o of n){let s=ot(t,o);Tr(s).isDirectory()&&await vr(s)&&r++}return r}async function sx(){let e=_r();if(!zt(e))return!1;let t;try{t=await Cr(e)}catch{return!1}for(let n of t){let r=ot(e,n);if(Tr(r).isDirectory()&&await vr(r))return!0}return!1}async function cp(e){if(e&&await ox(e)){console.log(rt.dim(` \u68C0\u6D4B\u5230\u9879\u76EE\u672C\u5730 .dskcode/skill\uFF0C\u8DF3\u8FC7\u5BFC\u5165 Claude Code skill
10
- `));return}if(await sx())return;let n=await tx();if(n.length===0)return;console.log(rt.cyan(`
11
- \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=>rt.dim(` \xB7 ${s}`)).join(`
12
- `);if(console.log(r),n.length>5&&console.log(rt.dim(` \xB7 ...\u7B49 ${String(n.length)} \u4E2A`)),console.log(rt.dim(` \u6E90\u76EE\u5F55: ${pl()}`)),console.log(rt.dim(` \u76EE\u6807\u76EE\u5F55: ${_r()}
13
- `)),!await nx(` ${rt.cyan("\u{1F4E6}")} \u662F\u5426\u5C06\u8FD9\u4E9B skill \u5BFC\u5165\u5230 dskcode\uFF1F${rt.dim("[y/N] ")} `)){console.log(rt.dim(` \u5DF2\u8DF3\u8FC7 skill \u5BFC\u5165
14
- `));return}try{let{imported:s,skipped:i}=await rx(n);s.length>0&&console.log(rt.green(` \u2714 \u5DF2\u5BFC\u5165 ${String(s.length)} \u4E2A skill \u5230 ~/.dskcode/skills`)),i.length>0&&console.log(rt.yellow(` \u26A0 ${String(i.length)} \u4E2A skill \u5DF2\u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${i.join(", ")}`)),console.log("")}catch(s){console.log(rt.red(` \u2716 \u5BFC\u5165 skill \u5931\u8D25: ${s instanceof Error?s.message:String(s)}`)),console.log(rt.dim(` \u4F60\u53EF\u4EE5\u7A0D\u540E\u624B\u52A8\u590D\u5236 ~/.claude/skills \u5230 ~/.dskcode/skills
15
- `))}}async function ix(){let e=_r();if(!zt(e))return[];let t;try{t=await Cr(e)}catch{return[]}let n=[];for(let r of t){let o=ot(e,r);Tr(o).isDirectory()&&await vr(o)&&n.push(r)}return n}async function ax(e){let t=fl(e);if(!zt(t))return[];let n;try{n=await Cr(t)}catch{return[]}let r=[];for(let o of n){let s=ot(t,o);Tr(s).isDirectory()&&await vr(s)&&r.push(o)}return r}async function ap(e){try{let n=(await ex(ot(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 up(e){let[t,n]=await Promise.all([ix(),ax(e)]),r=new Set,o=[];for(let l of[...n,...t])r.has(l)||(r.add(l),o.push(l));let s=_r(),i=fl(e),a=[];for(let l of o){let c=ot(i,l),u=null;if(zt(c)&&(u=await ap(c)),!u){let d=ot(s,l);zt(d)&&(u=await ap(d))}a.push(u??{name:l,description:""})}return a}import{readFile as Ev}from"fs/promises";import{join as vy}from"path";p();p();import{render as lx}from"ink";function uo(e){let{waitUntilExit:t,clear:n,unmount:r}=lx(e,{exitOnCtrlC:!1});return{waitUntilExit:t(),clear:n,unmount:r}}p();import{Text as nR}from"ink";import oR from"ink-spinner";import{jsx as aR,jsxs as lR}from"react/jsx-runtime";p();import{Box as dR,Text as pR}from"ink";import{jsxs as hR}from"react/jsx-runtime";p();import{Box as xR,Text as bR}from"ink";import{useEffect as kR,useState as SR}from"react";import{jsx as _R}from"react/jsx-runtime";p();import{Box as q,Text as Z,useInput as v_,Static as R_}from"ink";import{useEffect as ge,useState as H,useCallback as xt,useMemo as ha,useRef as de}from"react";p();import{useState as cx,useCallback as ux,useEffect as dx,useRef as dp}from"react";var px=1500;function zn(e){let[t,n]=cx(!1),r=dp(null),o=dp(e);o.current=e,dx(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=ux(()=>{if(t){o.current();return}n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},px)},[t]);return{doubleCtrlC:t,handleCtrlC:s}}p();import{Box as Dt,Text as qt}from"ink";import{useEffect as Wx,useRef as Tp,useState as Cp}from"react";p();import{mkdir as fx,readFile as mx,writeFile as hx}from"fs/promises";import{join as hl}from"path";var ze=class e{static#e=new Set;static async flushAll(){await Promise.allSettled([...e.#e].map(t=>t.flush()))}#t;#r;#o;#n;#a;#c;#i=[];#p;#s;#l=!1;#m=!1;constructor(t={}){let n=process.env.HOME??process.env.USERPROFILE??"~";this.#t=t.costDir??hl(n,".dskcode","costs"),this.#r=t.budgetLimit??0,this.#o=t.tokenBudgetLimit??0,this.#n=t.onBudgetExceeded,this.#a=pp(),this.#c=new Date().toISOString();let r=gl();this.#p=r,this.#s=fp(r),e.#e.add(this)}record(t,n){let r=Mt(t,n),o={timestamp:new Date().toISOString(),model:n,usage:{...t},cost:{...r}};return this.#i.push(o),this.#f(),this.#u(o),this.#l=!0,this.#x(),r}get sessionId(){return this.#a}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.#a,startedAt:this.#c,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.#s}}get todayTotalCost(){return this.#f(),this.#s.totalCost}get todayCallCount(){return this.#f(),this.#s.totalCalls}get isBudgetExceeded(){return this.#r>0&&this.todayTotalCost>=this.#r||this.#o>0&&this.#s.totalPromptTokens+this.#s.totalCompletionTokens>=this.#o}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=gl();t.daily[n]&&(this.#s=t.daily[n],this.#p=n)}async flush(){if(!(!this.#l||this.#m)){this.#m=!0,this.#l=!1;try{await this.#g(),await this.#d()}catch(t){this.#l=!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.#a=pp(),this.#c=new Date().toISOString(),this.#i.length=0}async dispose(){e.#e.delete(this),await this.flush()}#f(){let t=gl();t!==this.#p&&(this.#p=t,this.#s=fp(t),this.#l=!0)}#u(t){this.#s.totalPromptTokens+=t.usage.promptTokens,this.#s.totalCompletionTokens+=t.usage.completionTokens,this.#s.totalCachedTokens+=t.usage.cachedPromptTokens??0,this.#s.totalCost+=t.cost.totalCost,this.#s.totalCalls+=1;let n=t.model;this.#s.byModel[n]||(this.#s.byModel[n]={model:t.model,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0});let r=this.#s.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.#n?.(this)}async#h(){let t=hl(this.#t,"history.json");try{let n=await mx(t,"utf-8");return JSON.parse(n)}catch{return{version:1,daily:{}}}}async#g(){await fx(this.#t,{recursive:!0})}async#d(){let t=await this.#h();t.daily[this.#p]=this.#s;let n=gx(90),r=Object.keys(t.daily).filter(s=>s<n);for(let s of r)delete t.daily[s];let o=hl(this.#t,"history.json");await hx(o,JSON.stringify(t,null,2),"utf-8")}};function pp(){let e=Date.now().toString(36),t=Math.random().toString(36).slice(2,8);return`${e}-${t}`}function gl(){return new Date().toISOString().slice(0,10)}function gx(e){let t=new Date;return t.setDate(t.getDate()-e),t.toISOString().slice(0,10)}function fp(e){return{date:e,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0,byModel:{}}}function Rr(e){return`\xA5${e.toFixed(4)}`}p();import{Box as fo,Text as Ot}from"ink";p();var yx=new Set(["password","token","apikey","api_key","secret","authorization","auth","credential","credentials","private_key","privatekey"]);function Hs(e,t){if(!hp(t))return`${e}()`;switch(e){case"read_file":return`${e}(path=${pt(t.path)})`;case"write_file":return`${e}(path=${pt(t.path)})`;case"edit_file":return`${e}(path=${pt(t.path)}, old_text=${pt(t.old_text,30)})`;case"multi_edit":{let s=Array.isArray(t.edits)?t.edits.length:0;return`${e}(path=${pt(t.path)}, edits=${s})`}case"delete_range":return`${e}(path=${pt(t.path)})`;case"bash":return`${e}(command=${pt(t.command,60)})`;case"ls":return`${e}(path=${pt(t.path??".")})`;case"glob":return`${e}(pattern=${pt(t.pattern)})`;case"grep":return`${e}(pattern=${pt(t.pattern)}, path=${pt(t.path??".")})`;case"fetch":return`${e}(url=${pt(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 po(e){return yl(e,new WeakSet)}function yl(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=>yl(o,t));let r={};for(let[o,s]of Object.entries(n))yx.has(o.toLowerCase())?r[o]="****":r[o]=yl(s,t);return r}function mp(e,t={}){let n=t.valueMaxLen??80,r=t.maskSensitive!==!1,o=t.maxKeys??6;if(!hp(e))return xl(e,n);let s=r?po(e):e,i=Object.entries(s),l=i.slice(0,o).map(([c,u])=>`${c}: ${xl(u,n)}`);return i.length>o&&l.push(`+${i.length-o} more`),l.join(`
16
- `)}function xl(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 pt(e,t=40){return e==null?String(e):typeof e!="string"?xl(e,t):e.length===0?"(\u7A7A)":e.length>t?e.slice(0,t-1)+"\u2026":e}function hp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}p();function Ar(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=xx(e);try{return{ok:!0,args:JSON.parse(n),fixed:n}}catch{let o=t instanceof Error?t.message:String(t);return bx(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 xx(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 bx(e,t){return!!(e.includes("Unexpected end of JSON")||e.includes("Unterminated string")||t.length<5)}import{jsx as bl,jsxs as st}from"react/jsx-runtime";function wl({call:e,parsedArgs:t,schemaIssues:n,denial:r}){let o=t??Sx(e.arguments),s=po(o),i=Hs(e.name,s),a=mp(s);return st(fo,{flexDirection:"column",marginLeft:3,marginTop:1,children:[st(fo,{children:[st(Ot,{dimColor:!0,children:["\u{1F4E6} ",e.name]}),st(Ot,{dimColor:!0,children:[" ","\u2500".repeat(Math.max(1,30-e.name.length))]})]}),st(fo,{flexDirection:"column",marginLeft:2,children:[bl(Ot,{dimColor:!0,children:i}),bl(Ot,{dimColor:!0,children:a})]}),n&&n.length>0&&st(fo,{flexDirection:"column",marginLeft:2,children:[st(Ot,{color:"yellow",children:["\u26A0 schema \u95EE\u9898\uFF08",n.length,"\uFF09"]}),n.slice(0,3).map((l,c)=>st(Ot,{color:"yellow",children:[" - ",l.message]},c)),n.length>3&&st(Ot,{color:"yellow",children:[" ...\u8FD8\u6709 ",n.length-3," \u6761"]})]}),r&&bl(wx,{denial:r})]})}function wx({denial:e}){let t=kx[e.source]??e.source,n=e.source==="hardcoded_blacklist"?"\u{1F6AB}":"\u{1F6D1}";return st(fo,{flexDirection:"column",marginLeft:2,marginTop:1,borderStyle:"round",borderColor:"red",paddingX:1,children:[st(Ot,{color:"red",bold:!0,children:[n," \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\uFF08",t,"\uFF09"]}),st(Ot,{color:"red",children:[" \u539F\u56E0\uFF1A",e.reason]}),e.hint&&st(Ot,{color:"yellow",children:[" \u63D0\u793A\uFF1A",e.hint]})]})}var kx={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 Sx(e){if(!e)return{};let t=Ar(e);return t.ok?t.args:{}}p();import{Box as Vs,Text as Be}from"ink";p();function gp(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 mo(e){let t=0;for(let n of e){let r=n.codePointAt(0);r!==void 0&&r!==8205&&(r>=65024&&r<=65039||(t+=gp(r)))}return t}function*Tx(e){for(let t of e){let n=t.codePointAt(0);n!==void 0&&n!==8205&&(n>=65024&&n<=65039||(yield{ch:t,width:gp(n)}))}}function Cx(e,t){if(t<=0)return[e];let n=[];for(let r of e.split(`
17
- `)){if(r.length===0){n.push("");continue}let o=_x(r,t);for(let s of o)n.push(s)}return n.length===0?[""]:n}function _x(e,t){if(mo(e)<=t)return[e];let n=[],r="",o=0,s=-1,i=0;for(let{ch:a,width:l}of Tx(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=mo(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 vx(e,t,n){return e.map((r,o)=>{let s=t[o]??3;return Cx(r,s).map(a=>Rx(a,s,n[o]??"left"))})}function Rx(e,t,n="left"){let r=mo(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 kl(e){let t=e.trim();return!t.startsWith("|")||!t.endsWith("|")?[]:t.slice(1,t.length-1).split("|").map(r=>r.trim())}function Ax(e){return kl(e).map(t=>{let n=t.startsWith(":"),r=t.endsWith(":");return n&&r?"center":r?"right":"left"})}function yp(e,t={}){let n=t.termWidth??80,r=t.outerMargin??0,o=Math.max(n-r,20),s=e.split(`
18
- `).filter(P=>P.trim().length>0);if(s.length<2)return{lines:s,colWidths:[],totalWidth:0};let i=-1;for(let P=0;P<s.length;P++){let z=(s[P]??"").trim();if(/^\|[-: |]+\|$/.test(z)&&z.includes("-")){i=P;break}}if(i===-1)return{lines:s,colWidths:[],totalWidth:0};let a=kl(s.slice(0,i).join("")),l=Ax(s[i]??""),c=s.slice(i+1).map(kl),u=a.length;if(u===0)return{lines:s,colWidths:[],totalWidth:0};let d=[];for(let P=0;P<u;P++){let z=mo(a[P]??"");for(let j of c){let N=mo(j[P]??"");N>z&&(z=N)}d.push(Math.max(z,3))}let f=2,h=d.reduce((P,z)=>P+z+f,1),m;if(h<=o)m=d;else{let P=o-1-f*u,z=d.reduce((N,A)=>N+A,0);m=d.map(N=>Math.max(3,Math.floor(N/z*P)));let j=m.reduce((N,A)=>N+A+f,1);for(;j>o&&m.length>0;){let N=m.length-1,A=m[N]??3;if(A<=3)break;m[N]=A-1,j=m.reduce((ie,ne)=>ie+ne+f,1)}}let g="\u2500",w=(P,z,j)=>P+m.map(N=>g.repeat(N+f)).join(z)+j,b=w("\u250C","\u252C","\u2510"),k=w("\u251C","\u253C","\u2524"),v=w("\u2514","\u2534","\u2518");function I(P){let z=vx(P,m,l),j=Math.max(1,...z.map(A=>A.length)),N=[];for(let A=0;A<j;A++){let ie="\u2502";for(let ne=0;ne<u;ne++){let V=(z[ne]??[])[A]??" ".repeat(m[ne]??3);ie+=" "+V+" ",ne<u-1&&(ie+="\u2502")}ie+="\u2502",N.push(ie)}return N}let R=I(a),D=c.map(I),F=m.reduce((P,z)=>P+z+f,1);return{lines:[b,...R,k,...D.flat(),v],colWidths:m,totalWidth:F}}function xp(){let e=process.stdout?.columns;return typeof e=="number"&&e>0?e:void 0}import{jsx as _e,jsxs as Tl}from"react/jsx-runtime";function Ex(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 Sl(e){let t=e.trim();return/^\|.+\|$/.test(t)}function Ix(e){let t=e.trim();return/^\|[-: |]+\|$/.test(t)&&t.includes("-")}function Px(e){let t=e.split(`
19
- `),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(Sl(i)&&s+1<t.length&&Ix(t[s+1]??"")&&s+2<t.length&&Sl(t[s+2]??"")){o();let a=[],l=s;for(;l<t.length&&Sl(t[l]??"");)a.push(t[l]),l++;n.push({text:a.join(`
9
+ `));let e=wp({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(` ${we.cyan("\u{1F194}")} ${we.bold("\u8BF7\u8F93\u5165 APP ID\uFF08\u7EAF\u6570\u5B57\uFF09:")} `,s=>{let i=s.trim();if(!/^\d+$/.test(i)){r(),console.log(we.red(" \u2716 APP ID \u5FC5\u987B\u662F\u7EAF\u6570\u5B57")),t(null);return}e.question(` ${we.cyan("\u{1F511}")} ${we.bold("\u8BF7\u8F93\u5165 Access Key:")} `,a=>{r();let l=a.trim();if(l.length<yl){console.log(we.red(` \u2716 Access Key \u957F\u5EA6\u81F3\u5C11 ${yl} \u4F4D`)),t(null);return}t({appId:i,accessKey:l})})})})}p();import{createInterface as mx}from"readline";import{existsSync as zt,statSync as vr,lstatSync as hx}from"fs";import{mkdir as gx,readdir as Rr,cp as yx,access as xx,realpath as bx,readFile as kx}from"fs/promises";import{join as st}from"path";import ot from"chalk";function xl(){let e=process.env.HOME??process.env.USERPROFILE??"~";return st(e,".claude","skills")}function Ar(){return hp()}async function Er(e){try{return await xx(st(e,"SKILL.md")),!0}catch{return!1}}async function wx(){let e=xl();if(!zt(e))return[];let t;try{t=await Rr(e)}catch{return[]}let n=[];for(let r of t){let o=st(e,r);vr(o).isDirectory()&&await Er(o)&&n.push(r)}return n}function Tx(e){let t=mx({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 Sx(e){let t=xl(),n=Ar();await gx(n,{recursive:!0});let r=[],o=[];for(let s of e){let i=st(t,s),a=st(n,s);if(zt(a)){o.push(s);continue}let l=hx(i).isSymbolicLink()?await bx(i):i;await yx(l,a,{recursive:!0,dereference:!0}),r.push(s)}return{imported:r,skipped:o}}async function vp(){let e=Ar();if(!zt(e))return 0;let t;try{t=await Rr(e)}catch{return 0}let n=0;for(let r of t){let o=st(e,r);vr(o).isDirectory()&&await Er(o)&&n++}return n}function bl(e){return gp(e)}async function Cx(e){return await kl(e)>0}async function kl(e){let t=bl(e);if(!zt(t))return 0;let n;try{n=await Rr(t)}catch{return 0}let r=0;for(let o of n){let s=st(t,o);vr(s).isDirectory()&&await Er(s)&&r++}return r}async function _x(){let e=Ar();if(!zt(e))return!1;let t;try{t=await Rr(e)}catch{return!1}for(let n of t){let r=st(e,n);if(vr(r).isDirectory()&&await Er(r))return!0}return!1}async function Rp(e){if(e&&await Cx(e)){console.log(ot.dim(` \u68C0\u6D4B\u5230\u9879\u76EE\u672C\u5730 .dskcode/skill\uFF0C\u8DF3\u8FC7\u5BFC\u5165 Claude Code skill
10
+ `));return}if(await _x())return;let n=await wx();if(n.length===0)return;console.log(ot.cyan(`
11
+ \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=>ot.dim(` \xB7 ${s}`)).join(`
12
+ `);if(console.log(r),n.length>5&&console.log(ot.dim(` \xB7 ...\u7B49 ${String(n.length)} \u4E2A`)),console.log(ot.dim(` \u6E90\u76EE\u5F55: ${xl()}`)),console.log(ot.dim(` \u76EE\u6807\u76EE\u5F55: ${Ar()}
13
+ `)),!await Tx(` ${ot.cyan("\u{1F4E6}")} \u662F\u5426\u5C06\u8FD9\u4E9B skill \u5BFC\u5165\u5230 dskcode\uFF1F${ot.dim("[y/N] ")} `)){console.log(ot.dim(` \u5DF2\u8DF3\u8FC7 skill \u5BFC\u5165
14
+ `));return}try{let{imported:s,skipped:i}=await Sx(n);s.length>0&&console.log(ot.green(` \u2714 \u5DF2\u5BFC\u5165 ${String(s.length)} \u4E2A skill \u5230 ~/.dskcode/skills`)),i.length>0&&console.log(ot.yellow(` \u26A0 ${String(i.length)} \u4E2A skill \u5DF2\u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${i.join(", ")}`)),console.log("")}catch(s){console.log(ot.red(` \u2716 \u5BFC\u5165 skill \u5931\u8D25: ${s instanceof Error?s.message:String(s)}`)),console.log(ot.dim(` \u4F60\u53EF\u4EE5\u7A0D\u540E\u624B\u52A8\u590D\u5236 ~/.claude/skills \u5230 ~/.dskcode/skills
15
+ `))}}async function vx(){let e=Ar();if(!zt(e))return[];let t;try{t=await Rr(e)}catch{return[]}let n=[];for(let r of t){let o=st(e,r);vr(o).isDirectory()&&await Er(o)&&n.push(r)}return n}async function Rx(e){let t=bl(e);if(!zt(t))return[];let n;try{n=await Rr(t)}catch{return[]}let r=[];for(let o of n){let s=st(t,o);vr(s).isDirectory()&&await Er(s)&&r.push(o)}return r}async function _p(e){try{let n=(await kx(st(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 Ap(e){let[t,n]=await Promise.all([vx(),Rx(e)]),r=new Set,o=[];for(let l of[...n,...t])r.has(l)||(r.add(l),o.push(l));let s=Ar(),i=bl(e),a=[];for(let l of o){let c=st(i,l),u=null;if(zt(c)&&(u=await _p(c)),!u){let d=st(s,l);zt(d)&&(u=await _p(d))}a.push(u??{name:l,description:""})}return a}import{readFile as tR}from"fs/promises";import{join as Vy}from"path";p();p();import{render as Ax}from"ink";function yo(e){let{waitUntilExit:t,clear:n,unmount:r}=Ax(e,{exitOnCtrlC:!1});return{waitUntilExit:t(),clear:n,unmount:r}}p();import{Text as AR}from"ink";import IR from"ink-spinner";import{jsx as LR,jsxs as MR}from"react/jsx-runtime";p();import{Box as NR,Text as BR}from"ink";import{jsxs as jR}from"react/jsx-runtime";p();import{Box as HR,Text as VR}from"ink";import{useEffect as qR,useState as KR}from"react";import{jsx as ZR}from"react/jsx-runtime";p();import{Box as X,Text as ee,useInput as J_,Static as Z_}from"ink";import{useEffect as ye,useState as W,useCallback as dt,useMemo as Ta,useRef as pe}from"react";p();import{useState as Ex,useCallback as Ix,useEffect as Px,useRef as Ep}from"react";var $x=1500;function Kn(e){let[t,n]=Ex(!1),r=Ep(null),o=Ep(e);o.current=e,Px(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Ix(()=>{if(t){o.current();return}n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},$x)},[t]);return{doubleCtrlC:t,handleCtrlC:s}}p();import{Box as Dt,Text as qt}from"ink";import{useEffect as cb,useRef as jp,useState as Up}from"react";p();import{mkdir as Lx,readFile as Mx,writeFile as Ox}from"fs/promises";import{join as wl}from"path";var ze=class e{static#e=new Set;static async flushAll(){await Promise.allSettled([...e.#e].map(t=>t.flush()))}#t;#r;#o;#n;#a;#u;#i=[];#p;#s;#l=!1;#g=!1;constructor(t={}){let n=process.env.HOME??process.env.USERPROFILE??"~";this.#t=t.costDir??wl(n,".dskcode","costs"),this.#r=t.budgetLimit??0,this.#o=t.tokenBudgetLimit??0,this.#n=t.onBudgetExceeded,this.#a=Ip(),this.#u=new Date().toISOString();let r=Tl();this.#p=r,this.#s=Pp(r),e.#e.add(this)}record(t,n){let r=Mt(t,n),o={timestamp:new Date().toISOString(),model:n,usage:{...t},cost:{...r}};return this.#i.push(o),this.#h(),this.#c(o),this.#l=!0,this.#k(),r}get sessionId(){return this.#a}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.#a,startedAt:this.#u,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.#h(),{...this.#s}}get todayTotalCost(){return this.#h(),this.#s.totalCost}get todayCallCount(){return this.#h(),this.#s.totalCalls}get isBudgetExceeded(){return this.#r>0&&this.todayTotalCost>=this.#r||this.#o>0&&this.#s.totalPromptTokens+this.#s.totalCompletionTokens>=this.#o}get remainingBudget(){return this.#r<=0?1/0:Math.max(0,this.#r-this.todayTotalCost)}async load(){await this.#x();let t=await this.#y(),n=Tl();t.daily[n]&&(this.#s=t.daily[n],this.#p=n)}async flush(){if(!(!this.#l||this.#g)){this.#g=!0,this.#l=!1;try{await this.#x(),await this.#d()}catch(t){this.#l=!0,console.error("[CostTracker] flush \u5931\u8D25:",t)}finally{this.#g=!1}}}async queryRange(t,n){let r=await this.#y(),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.#a=Ip(),this.#u=new Date().toISOString(),this.#i.length=0}async dispose(){e.#e.delete(this),await this.flush()}#h(){let t=Tl();t!==this.#p&&(this.#p=t,this.#s=Pp(t),this.#l=!0)}#c(t){this.#s.totalPromptTokens+=t.usage.promptTokens,this.#s.totalCompletionTokens+=t.usage.completionTokens,this.#s.totalCachedTokens+=t.usage.cachedPromptTokens??0,this.#s.totalCost+=t.cost.totalCost,this.#s.totalCalls+=1;let n=t.model;this.#s.byModel[n]||(this.#s.byModel[n]={model:t.model,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0});let r=this.#s.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}#k(){this.isBudgetExceeded&&this.#n?.(this)}async#y(){let t=wl(this.#t,"history.json");try{let n=await Mx(t,"utf-8");return JSON.parse(n)}catch{return{version:1,daily:{}}}}async#x(){await Lx(this.#t,{recursive:!0})}async#d(){let t=await this.#y();t.daily[this.#p]=this.#s;let n=Dx(90),r=Object.keys(t.daily).filter(s=>s<n);for(let s of r)delete t.daily[s];let o=wl(this.#t,"history.json");await Ox(o,JSON.stringify(t,null,2),"utf-8")}};function Ip(){let e=Date.now().toString(36),t=Math.random().toString(36).slice(2,8);return`${e}-${t}`}function Tl(){return new Date().toISOString().slice(0,10)}function Dx(e){let t=new Date;return t.setDate(t.getDate()-e),t.toISOString().slice(0,10)}function Pp(e){return{date:e,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalCalls:0,byModel:{}}}function Ir(e){return`\xA5${e.toFixed(4)}`}p();import{Box as bo,Text as Ot}from"ink";p();var Nx=new Set(["password","token","apikey","api_key","secret","authorization","auth","credential","credentials","private_key","privatekey"]);function Zs(e,t){if(!Lp(t))return`${e}()`;switch(e){case"read_file":return`${e}(path=${mt(t.path)})`;case"write_file":return`${e}(path=${mt(t.path)})`;case"edit_file":return`${e}(path=${mt(t.path)}, old_text=${mt(t.old_text,30)})`;case"multi_edit":{let s=Array.isArray(t.edits)?t.edits.length:0;return`${e}(path=${mt(t.path)}, edits=${s})`}case"delete_range":return`${e}(path=${mt(t.path)})`;case"bash":return`${e}(command=${mt(t.command,60)})`;case"ls":return`${e}(path=${mt(t.path??".")})`;case"glob":return`${e}(pattern=${mt(t.pattern)})`;case"grep":return`${e}(pattern=${mt(t.pattern)}, path=${mt(t.path??".")})`;case"fetch":return`${e}(url=${mt(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 xo(e){return Sl(e,new WeakSet)}function Sl(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=>Sl(o,t));let r={};for(let[o,s]of Object.entries(n))Nx.has(o.toLowerCase())?r[o]="****":r[o]=Sl(s,t);return r}function $p(e,t={}){let n=t.valueMaxLen??80,r=t.maskSensitive!==!1,o=t.maxKeys??6;if(!Lp(e))return Cl(e,n);let s=r?xo(e):e,i=Object.entries(s),l=i.slice(0,o).map(([c,u])=>`${c}: ${Cl(u,n)}`);return i.length>o&&l.push(`+${i.length-o} more`),l.join(`
16
+ `)}function Cl(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 mt(e,t=40){return e==null?String(e):typeof e!="string"?Cl(e,t):e.length===0?"(\u7A7A)":e.length>t?e.slice(0,t-1)+"\u2026":e}function Lp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}p();function Pr(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=Bx(e);try{return{ok:!0,args:JSON.parse(n),fixed:n}}catch{let o=t instanceof Error?t.message:String(t);return Gx(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 Bx(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 Gx(e,t){return!!(e.includes("Unexpected end of JSON")||e.includes("Unterminated string")||t.length<5)}import{jsx as _l,jsxs as it}from"react/jsx-runtime";function vl({call:e,parsedArgs:t,schemaIssues:n,denial:r}){let o=t??Ux(e.arguments),s=xo(o),i=Zs(e.name,s),a=$p(s);return it(bo,{flexDirection:"column",marginLeft:3,marginTop:1,children:[it(bo,{children:[it(Ot,{dimColor:!0,children:["\u{1F4E6} ",e.name]}),it(Ot,{dimColor:!0,children:[" ","\u2500".repeat(Math.max(1,30-e.name.length))]})]}),it(bo,{flexDirection:"column",marginLeft:2,children:[_l(Ot,{dimColor:!0,children:i}),_l(Ot,{dimColor:!0,children:a})]}),n&&n.length>0&&it(bo,{flexDirection:"column",marginLeft:2,children:[it(Ot,{color:"yellow",children:["\u26A0 schema \u95EE\u9898\uFF08",n.length,"\uFF09"]}),n.slice(0,3).map((l,c)=>it(Ot,{color:"yellow",children:[" - ",l.message]},c)),n.length>3&&it(Ot,{color:"yellow",children:[" ...\u8FD8\u6709 ",n.length-3," \u6761"]})]}),r&&_l(Fx,{denial:r})]})}function Fx({denial:e}){let t=jx[e.source]??e.source,n=e.source==="hardcoded_blacklist"?"\u{1F6AB}":"\u{1F6D1}";return it(bo,{flexDirection:"column",marginLeft:2,marginTop:1,borderStyle:"round",borderColor:"red",paddingX:1,children:[it(Ot,{color:"red",bold:!0,children:[n," \u88AB\u6743\u9650\u7CFB\u7EDF\u62D2\u7EDD\uFF08",t,"\uFF09"]}),it(Ot,{color:"red",children:[" \u539F\u56E0\uFF1A",e.reason]}),e.hint&&it(Ot,{color:"yellow",children:[" \u63D0\u793A\uFF1A",e.hint]})]})}var jx={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 Ux(e){if(!e)return{};let t=Pr(e);return t.ok?t.args:{}}p();import{Box as Ys,Text as Ge}from"ink";p();function Mp(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 ko(e){let t=0;for(let n of e){let r=n.codePointAt(0);r!==void 0&&r!==8205&&(r>=65024&&r<=65039||(t+=Mp(r)))}return t}function*Wx(e){for(let t of e){let n=t.codePointAt(0);n!==void 0&&n!==8205&&(n>=65024&&n<=65039||(yield{ch:t,width:Mp(n)}))}}function Hx(e,t){if(t<=0)return[e];let n=[];for(let r of e.split(`
17
+ `)){if(r.length===0){n.push("");continue}let o=Vx(r,t);for(let s of o)n.push(s)}return n.length===0?[""]:n}function Vx(e,t){if(ko(e)<=t)return[e];let n=[],r="",o=0,s=-1,i=0;for(let{ch:a,width:l}of Wx(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=ko(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 zx(e,t,n){return e.map((r,o)=>{let s=t[o]??3;return Hx(r,s).map(a=>qx(a,s,n[o]??"left"))})}function qx(e,t,n="left"){let r=ko(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 Rl(e){let t=e.trim();return!t.startsWith("|")||!t.endsWith("|")?[]:t.slice(1,t.length-1).split("|").map(r=>r.trim())}function Kx(e){return Rl(e).map(t=>{let n=t.startsWith(":"),r=t.endsWith(":");return n&&r?"center":r?"right":"left"})}function Op(e,t={}){let n=t.termWidth??80,r=t.outerMargin??0,o=Math.max(n-r,20),s=e.split(`
18
+ `).filter(C=>C.trim().length>0);if(s.length<2)return{lines:s,colWidths:[],totalWidth:0};let i=-1;for(let C=0;C<s.length;C++){let N=(s[C]??"").trim();if(/^\|[-: |]+\|$/.test(N)&&N.includes("-")){i=C;break}}if(i===-1)return{lines:s,colWidths:[],totalWidth:0};let a=Rl(s.slice(0,i).join("")),l=Kx(s[i]??""),c=s.slice(i+1).map(Rl),u=a.length;if(u===0)return{lines:s,colWidths:[],totalWidth:0};let d=[];for(let C=0;C<u;C++){let N=ko(a[C]??"");for(let oe of c){let j=ko(oe[C]??"");j>N&&(N=j)}d.push(Math.max(N,3))}let f=2,h=d.reduce((C,N)=>C+N+f,1),m;if(h<=o)m=d;else{let C=o-1-f*u,N=d.reduce((j,O)=>j+O,0);m=d.map(j=>Math.max(3,Math.floor(j/N*C)));let oe=m.reduce((j,O)=>j+O+f,1);for(;oe>o&&m.length>0;){let j=m.length-1,O=m[j]??3;if(O<=3)break;m[j]=O-1,oe=m.reduce((ce,fe)=>ce+fe+f,1)}}let g="\u2500",b=(C,N,oe)=>C+m.map(j=>g.repeat(j+f)).join(N)+oe,k=b("\u250C","\u252C","\u2510"),T=b("\u251C","\u253C","\u2524"),A=b("\u2514","\u2534","\u2518");function E(C){let N=zx(C,m,l),oe=Math.max(1,...N.map(O=>O.length)),j=[];for(let O=0;O<oe;O++){let ce="\u2502";for(let fe=0;fe<u;fe++){let K=(N[fe]??[])[O]??" ".repeat(m[fe]??3);ce+=" "+K+" ",fe<u-1&&(ce+="\u2502")}ce+="\u2502",j.push(ce)}return j}let I=E(a),F=c.map(E),M=m.reduce((C,N)=>C+N+f,1);return{lines:[k,...I,T,...F.flat(),A],colWidths:m,totalWidth:M}}function Dp(){let e=process.stdout?.columns;return typeof e=="number"&&e>0?e:void 0}import{jsx as ve,jsxs as El}from"react/jsx-runtime";function Xx(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 Al(e){let t=e.trim();return/^\|.+\|$/.test(t)}function Jx(e){let t=e.trim();return/^\|[-: |]+\|$/.test(t)&&t.includes("-")}function Zx(e){let t=e.split(`
19
+ `),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(Al(i)&&s+1<t.length&&Jx(t[s+1]??"")&&s+2<t.length&&Al(t[s+2]??"")){o();let a=[],l=s;for(;l<t.length&&Al(t[l]??"");)a.push(t[l]),l++;n.push({text:a.join(`
20
20
  `),type:"table"}),s=l-1}else r?r+=`
21
- `+i:r=i}return o(),n}function Lx(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 $x(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 Mx(e){let t=[];for(let n of e){if(n.type==="code_block"||n.type==="table"){t.push(n);continue}let r=$x(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 Ox="#22c55e",Dx="#ef4444",Nx="#00cccc";function Bx({code:e}){let t=e.split(`
22
- `),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?_e(Vs,{marginLeft:2,children:Tl(Be,{color:"#888888",children:["\u250C ",o]})}):null:Tl(Vs,{flexDirection:"column",marginLeft:2,marginTop:1,children:[o&&Tl(Be,{color:"#888888",children:["\u250C ",o]}),s.map((i,a)=>i.startsWith("+")?_e(Be,{color:Ox,children:i},a):i.startsWith("-")?_e(Be,{color:Dx,children:i},a):i.startsWith("@@")?_e(Be,{color:Nx,children:i},a):_e(Be,{children:i},a))]})}function Fx({text:e}){let t=xp(),n=yp(e,{termWidth:t});return n.colWidths.length===0?_e(Be,{children:e}):_e(Vs,{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 _e(Be,{color:s||i||a?"#888888":void 0,children:r},o)})})}var Gx=/[\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 jx(e){return Gx.test(e)}function Ux(e){try{return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(e)].map(r=>({text:r.segment,isEmoji:jx(r.segment)}))}catch{return[{text:e,isEmoji:!1}]}}function bp(e,t){let n=Ux(e);if(n.length===1&&!n[0].isEmoji)return _e(Be,{color:kp,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 _e(Be,{children:r.map((o,s)=>o.isEmoji?o.text:_e(Be,{color:kp,children:o.text},s))},t)}var wp="#00BFFF",kp="#A855F7";function Sp({children:e}){let t=Ex(e),n=[];for(let c of t)c.type==="code_block"?n.push(c):n.push(...Px(c.text));let r=[];for(let c of n)c.type==="code_block"||c.type==="table"?r.push(c):r.push(...Lx(c.text));let o=Mx(r);if(!o.some(c=>c.type==="code_block"||c.type==="table"))return o.length===1&&o[0].type==="plain"?_e(Be,{wrap:"wrap",children:e}):_e(Be,{wrap:"wrap",children:o.map((u,d)=>u.type==="code"?_e(Be,{color:wp,children:u.text},d):u.type==="bold"?bp(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(_e(Be,{wrap:"wrap",children:a[0].text},c)):i.push(_e(Be,{wrap:"wrap",children:a.map((d,f)=>d.type==="code"?_e(Be,{color:wp,children:d.text},f):d.type==="bold"?bp(d.text,f):d.text)},c)),a=[]}for(let c of o)c.type==="code_block"?(l(i.length),i.push(_e(Bx,{code:c.text},`b${i.length}`))):c.type==="table"?(l(i.length),i.push(_e(Fx,{text:c.text},`t${i.length}`))):a.push(c);return l(i.length),_e(Vs,{flexDirection:"column",children:i})}import{Fragment as Vx,jsx as Nt,jsxs as it}from"react/jsx-runtime";function zs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Hx({usage:e,cost:t}){let n=e?e.promptTokens+e.completionTokens:0,r=t??0,[o,s]=Cp(n),[i,a]=Cp(r),l=Tp(null),c=Tp(null);return Wx(()=>{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,f=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:f},c.current&&clearInterval(c.current),c.current=setInterval(()=>{let h=l.current;if(!h)return;let m=Date.now()-h.startMs;if(m>=h.durationMs){s(h.toTokens),a(h.toCost),c.current&&(clearInterval(c.current),c.current=null);return}let g=m/h.durationMs,w=1-Math.pow(1-g,3),b=h.fromTokens+(h.toTokens-h.fromTokens)*w,k=h.fromCost+(h.toCost-h.fromCost)*w;s(b),a(k)},33),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[n,r]),it(Vx,{children:[e&&it(qt,{color:"#888888",children:[Math.round(o).toLocaleString()," tokens"]}),t!==void 0&&t>0&&it(qt,{color:"#888888",children:[" \xB7 ","\xA5",i.toFixed(4)]})]})}function qs({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:it(Dt,{flexDirection:"row",marginTop:1,children:[Nt(Dt,{width:1,backgroundColor:"#E040FB",flexShrink:0}),it(Dt,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[it(Dt,{flexDirection:"row",children:[Nt(Dt,{width:4,flexShrink:0,children:Nt(qt,{bold:!0,color:"#ff00ff",children:"\u{1F916}"})}),it(Dt,{flexGrow:1,flexDirection:"column",children:[e&&Nt(Sp,{children:e}),n&&!e&&Nt(qt,{color:"#888888",children:"..."})]})]}),t&&t.length>0&&Nt(Dt,{flexDirection:"column",children:t.map((l,c)=>Nt(wl,{call:l,denial:a?.get(l.id??"")?.denial},l.id??c))}),n&&(r||s!==void 0)&&Nt(Dt,{flexDirection:"row",marginTop:1,marginLeft:3,children:it(qt,{color:"#666666",dimColor:!0,children:["\u23F3 \u5DF2\u6D88\u8017 ",Nt(Hx,{usage:r,cost:s})]})}),!n&&(r||o!==void 0)&&it(Dt,{flexDirection:"column",marginTop:1,marginLeft:3,children:[Nt(qt,{color:"#555555",children:"\u2500".repeat(36)}),it(Dt,{flexDirection:"row",gap:2,children:[s!==void 0&&s>0&&it(qt,{color:"yellow",children:["\u{1F4B0} \u672C\u6B21 ",Rr(s)]}),o!==void 0&&it(qt,{color:"cyan",children:["\u{1F550} ",zs(o)]}),r&&it(qt,{color:"#888888",children:["\u{1F4E6} ",(r.promptTokens+r.completionTokens).toLocaleString()," tokens"]})]})]})]})]})}p();import{Box as _p,Text as ae}from"ink";import{useMemo as zx}from"react";import{Fragment as Rp,jsx as se,jsxs as ve}from"react/jsx-runtime";var ue={accent:"#5fbedb",warn:"#d4a017",danger:"#c9605a",text:"#b8b8b8",muted:"#6a6a6a",dot:"#404040"},qx=.85,Kx=5;function vp(e){switch(e){case"thinking":return"\u{1F9E0} \u601D\u8003\u4E2D";case"generating":return"\u2728 \u751F\u6210\u4E2D";case"calling_tools":return"\u{1F6E0} \u8C03\u7528\u5DE5\u5177";case"executing_tools":return"\u26A1 \u6267\u884C\u5DE5\u5177"}}function Ks(e){return e<1e3?`${e}`:e<1e4?`${(e/1e3).toFixed(1)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}m`}function Ke(){return se(ae,{color:ue.dot,children:" \xB7 "})}function ho({k:e,v:t,color:n}){return ve(ae,{children:[se(ae,{color:ue.muted,children:e}),ve(ae,{color:n??ue.text,children:[" ",t]})]})}function Ap(e){let{activeModel:t,thinkingEnabled:n,thinkingEffort:r,balance:o,todayCost:s,sessionCost:i,hasConversationStarted:a,isStreaming:l,streamingPhase:c,currentUsage:u,currentCost:d,currentElapsed:f,currentToolCalls:h,currentToolResults:m,contextStats:g,lastRound:w}=e,b=wn[t]?.displayName??t,k=zx(()=>{if(!a)return null;if(l&&c){let I=u?Ks(u.promptTokens+u.completionTokens):"0",R=d!==void 0?Rr(d):"\xA50",D=f!==void 0?zs(f):"0ms";if(c==="calling_tools"||c==="executing_tools"){let F=h?.length??0,P=m?.size??0,z=F>0?h?.[F-1]?.name??"\u5DE5\u5177":"\u5DE5\u5177";return ve(ae,{children:[se(ae,{color:ue.accent,bold:!0,children:vp(c)}),se(Ke,{}),ve(ae,{color:ue.text,children:[z,F>1?` (+${F-1})`:""]}),se(Ke,{}),se(ae,{color:ue.muted,children:"\u8FDB\u5EA6"}),ve(ae,{color:ue.text,children:[" ",P,"/",F]}),se(Ke,{}),se(ae,{color:ue.muted,children:"\u7D2F\u8BA1"}),ve(ae,{color:ue.text,children:[" ",I," tokens \xB7 ",R," \xB7 ",D]})]})}return ve(ae,{children:[se(ae,{color:ue.accent,bold:!0,children:vp(c)}),se(Ke,{}),se(ae,{color:ue.muted,children:"\u5DF2\u7528"}),ve(ae,{color:ue.text,children:[" ",I," tokens"]}),se(Ke,{}),se(ae,{color:ue.muted,children:"\u8D39\u7528"}),ve(ae,{color:ue.text,children:[" ",R]}),se(Ke,{}),se(ae,{color:ue.muted,children:"\u8017\u65F6"}),ve(ae,{color:ue.text,children:[" ",D]})]})}if(g&&g.ratio>=qx)return ve(ae,{color:ue.danger,bold:!0,children:["\u{1F4DA} \u4E0A\u4E0B\u6587\u5DF2\u7528 ",(g.ratio*100).toFixed(0),"%"," \xB7 ","\u8F93\u5165 /compact \u53EF\u624B\u52A8\u538B\u7F29"]});let v=g?`${(g.ratio*100).toFixed(0)}% \xB7 ${Ks(g.tokens)}/${Ks(g.contextWindow)}`:"\u2014";return ve(ae,{children:[w?ve(Rp,{children:[se(ae,{color:ue.muted,children:"\u5F53\u8F6E"}),ve(ae,{color:ue.text,children:[" ",Rr(w.cost)]}),se(Ke,{}),se(ae,{color:ue.muted,children:"\u7528\u65F6"}),ve(ae,{color:ue.text,children:[" ",zs(w.elapsed)]}),se(Ke,{}),se(ae,{color:ue.muted,children:"tokens"}),ve(ae,{color:ue.text,children:[" ",Ks(w.tokens)]}),se(Ke,{})]}):null,se(ae,{color:ue.muted,children:"\u4E0A\u4E0B\u6587"}),ve(ae,{color:g&&g.ratio>=.6?ue.warn:ue.text,children:[" ",v]})]})},[a,l,c,u,d,f,h,m,g,w]);return ve(_p,{flexDirection:"column",paddingX:1,marginBottom:1,children:[ve(_p,{children:[se(ae,{color:ue.accent,bold:!0,children:"DSK"}),se(Ke,{}),se(ho,{k:"\u6A21\u578B",v:b}),n&&ve(Rp,{children:[se(Ke,{}),se(ho,{k:"\u601D\u8003",v:r==="max"?"Max":"High"})]}),se(Ke,{}),se(ho,{k:"\u4F59\u989D",v:o!==null?`\xA5${o.toFixed(2)}`:"\u2014",color:o!==null&&o<Kx?ue.warn:void 0}),se(Ke,{}),se(ho,{k:"\u4ECA\u65E5",v:s!==null?`\xA5${s.toFixed(2)}`:"\u2014"}),se(Ke,{}),se(ho,{k:"\u4F1A\u8BDD",v:i>0?`\xA5${i.toFixed(4)}`:"\u2014"})]}),k]})}p();import{Box as Xx,Text as Jx}from"ink";import{useEffect as Zx,useRef as Yx,useState as Qx}from"react";import{jsx as Ep}from"react/jsx-runtime";var eb=[" \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"],Cl=22,tb=120,nb="#6185f6";function Ip({panelWidth:e}){let t=Yx(e),[n,r]=Qx(0);Zx(()=>{let l=setInterval(()=>{t.current-=1,t.current<=-Cl&&(t.current=e),r(c=>c+1)},tb);return()=>clearInterval(l)},[e]);let o=t.current;if(o>=e)return null;let s=Math.max(0,-o),i=Math.max(0,o+Cl-e),a=Math.max(0,o);return Ep(Xx,{alignSelf:"flex-start",width:e,flexDirection:"column",alignItems:"flex-start",marginLeft:a,children:eb.map((l,c)=>Ep(Jx,{color:nb,bold:!0,children:l.slice(s,Cl-i)},c))})}p();import{Box as Bc,Text as Vo}from"ink";import{useEffect as LS,useState as $S}from"react";p();p();p();p();function rb(e){return Ml(e)}function Ml(e){return Array.isArray(e)?ob(e):e instanceof RegExp?e:typeof e=="object"?sb(e):e}function ob(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Ml(e[n]);return t}function sb(e){let t={};for(let n in e)t[n]=Ml(e[n]);return t}function Fp(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function Gp(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Gp(e.substring(0,e.length-1)):e.substr(~t+1)}var _l=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Xs=class{static hasCaptures(e){return e===null?!1:(_l.lastIndex=0,_l.test(e))}static replaceCaptures(e,t,n){return e.replace(_l,(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 jp(e,t){return e<t?-1:e>t?1:0}function Up(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=jp(e[o],t[o]);if(s!==0)return s}return 0}return n-r}function Pp(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 Wp(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Hp=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}},xo=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(lb(e),t)}static createFromParsedTheme(e,t){return ub(e,t)}_cachedMatchRoot=new Hp(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=>ib(e.parent,o.parentScopes));return r?new Vp(r.fontStyle,r.foreground,r.background):null}},vl=class Js{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(let r of n)t=new Js(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Js(n,t[r]);return n}push(t){return new Js(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 ib(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&&!ab(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function ab(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Vp=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function lb(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 f=0,h=d.length;f<h;f++)switch(d[f]){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"&&Pp(i.settings.foreground)&&(c=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Pp(i.settings.background)&&(u=i.settings.background);for(let d=0,f=a.length;d<f;d++){let m=a[d].trim().split(" "),g=m[m.length-1],w=null;m.length>1&&(w=m.slice(0,m.length-1),w.reverse()),n[r++]=new cb(g,w,o,l,c,u)}}return n}var cb=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}},ye=(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))(ye||{});function ub(e,t){e.sort((l,c)=>{let u=jp(l.scope,c.scope);return u!==0||(u=Up(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 db(t),i=new Vp(n,s.getId(r),s.getId(o)),a=new fb(new Al(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 xo(s,i,a)}var db=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)}},pb=Object.freeze([]),Al=class zp{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,o,s){this.scopeDepth=t,this.parentScopes=n||pb,this.fontStyle=r,this.foreground=o,this.background=s}clone(){return new zp(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)}},fb=class El{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(El._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 El(this._mainRule.clone(),Al.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(Up(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 Al(t,n,r,o,s))}},Sn=class ft{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let n=ft.getLanguageId(t),r=ft.getTokenType(t),o=ft.getFontStyle(t),s=ft.getForeground(t),i=ft.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=ft.getLanguageId(t),c=ft.getTokenType(t),u=ft.containsBalancedBrackets(t)?1:0,d=ft.getFontStyle(t),f=ft.getForeground(t),h=ft.getBackground(t);return n!==0&&(l=n),r!==8&&(c=r),o!==null&&(u=o?1:0),s!==-1&&(d=s),i!==0&&(f=i),a!==0&&(h=a),(l<<0|c<<8|u<<10|d<<11|f<<15|h<<24)>>>0}};function Ys(e,t){let n=[],r=mb(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(Lp(o)){let l=[];do l.push(o),o=r.next();while(Lp(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 Lp(e){return!!e&&!!e.match(/[\w\.:]+/)}function mb(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 qp(e){typeof e.dispose=="function"&&e.dispose()}var bo=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},hb=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},gb=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))}},yb=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new bo(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new gb;for(let n of e)xb(n,this.initialScopeName,this.repo,t);for(let n of t.references)if(n instanceof bo){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 xb(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 bo?Zs({baseGrammar:s,selfGrammar:o},r):Il(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 bo(a))}function Il(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Qs([r],t,n)}}function Zs(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Qs(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Qs(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Qs(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let o=r.repository?Fp({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Qs(r.patterns,{...t,repository:o},n);let s=r.include;if(!s)continue;let i=Kp(s);switch(i.kind){case 0:Zs({...t,selfGrammar:t.baseGrammar},n);break;case 1:Zs(t,n);break;case 2:Il(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?Il(i.ruleName,l,n):Zs(l,n)}else i.kind===4?n.add(new hb(i.scopeName,i.ruleName)):n.add(new bo(i.scopeName));break}}}var bb=class{kind=0},wb=class{kind=1},kb=class{constructor(e){this.ruleName=e}kind=2},Sb=class{constructor(e){this.scopeName=e}kind=3},Tb=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Kp(e){if(e==="$base")return new bb;if(e==="$self")return new wb;let t=e.indexOf("#");if(t===-1)return new Sb(e);if(t===0)return new kb(e.substring(1));{let n=e.substring(0,t),r=e.substring(t+1);return new Tb(n,r)}}var Cb=/\\(\d+)/,$p=/\\(\d+)/g;var _b=-1,Xp=-2;var So=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Xs.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Xs.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Gp(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:Xs.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Xs.replaceCaptures(this._contentName,e,t)}},vb=class extends So{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!")}},Rb=class extends So{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,null),this._match=new wo(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 ko,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Mp=class extends So{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 ko,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Pl=class extends So{_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 wo(o,this.id),this.beginCaptures=s,this._end=new wo(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 ko;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}},ei=class extends So{_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 wo(o,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new wo(i,Xp),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 ko;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 ko,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Jp=class Ue{static createCaptureRule(t,n,r,o,s){return t.registerRule(i=>new vb(n,i,r,o,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(o=>{if(t.id=o,t.match)return new Rb(t.$vscodeTextmateLocation,t.id,t.name,t.match,Ue._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Fp({},r,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Mp(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Ue._compilePatterns(s,n,r))}return t.while?new ei(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ue._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Ue._compileCaptures(t.whileCaptures||t.captures,n,r),Ue._compilePatterns(t.patterns,n,r)):new Pl(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ue._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Ue._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Ue._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=Ue.getCompiledRuleId(t[i],n,r)),o[a]=Ue.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=Kp(a.include);switch(c.kind){case 0:case 1:l=Ue.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=Ue.getCompiledRuleId(u,n,r));break;case 3:case 4:let d=c.scopeName,f=c.kind===4?c.ruleName:null,h=n.getExternalGrammar(d,r);if(h)if(f){let m=h.repository[f];m&&(l=Ue.getCompiledRuleId(m,n,h.repository))}else l=Ue.getCompiledRuleId(h.repository.$self,n,h.repository);break}}else l=Ue.getCompiledRuleId(a,n,r);if(l!==-1){let c=n.getRule(l),u=!1;if((c instanceof Mp||c instanceof Pl||c instanceof ei)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;o.push(l)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},wo=class Zp{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=Cb.test(this.source):this.hasBackReferences=!1}clone(){return new Zp(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 $p.lastIndex=0,this.source.replace($p,(o,s)=>Wp(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}},ko=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 Op(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 Op(e,r,this._items.map(o=>o.ruleId))}},Op=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(`
23
- `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Rl=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Ab=class Ll{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Rl(t,8),this._embeddedLanguagesMatcher=new Eb(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Ll._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Rl(0,0);_getBasicScopeAttributes=new Hp(t=>{let n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Rl(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let n=t.match(Ll.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/},Eb=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])=>Wp(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])}},bA={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Yp=!1,Dp=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Qp(e,t,n,r,o,s,i,a){let l=t.content.length,c=!1,u=-1;if(i){let h=Ib(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 Dp(o,!0);f()}return new Dp(o,!1);function f(){let h=Pb(e,t,n,r,o,u);if(!h){s.produce(o,l),c=!0;return}let m=h.captureIndices,g=h.matchedRuleId,w=m&&m.length>0?m[0].end>r:!1;if(g===_b){let b=o.getRule(e);s.produce(o,m[0].start),o=o.withContentNameScopesList(o.nameScopesList),go(e,t,n,o,s,b.endCaptures,m),s.produce(o,m[0].end);let k=o;if(o=o.parent,u=k.getAnchorPos(),!w&&k.getEnterPos()===r){o=k,s.produce(o,l),c=!0;return}}else{let b=e.getRule(g);s.produce(o,m[0].start);let k=o,v=b.getName(t.content,m),I=o.contentNameScopesList.pushAttributed(v,e);if(o=o.push(g,r,u,m[0].end===l,null,I,I),b instanceof Pl){let R=b;go(e,t,n,o,s,R.beginCaptures,m),s.produce(o,m[0].end),u=m[0].end;let D=R.getContentName(t.content,m),F=I.pushAttributed(D,e);if(o=o.withContentNameScopesList(F),R.endHasBackReferences&&(o=o.withEndRule(R.getEndWithResolvedBackReferences(t.content,m))),!w&&k.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(b instanceof ei){let R=b;go(e,t,n,o,s,R.beginCaptures,m),s.produce(o,m[0].end),u=m[0].end;let D=R.getContentName(t.content,m),F=I.pushAttributed(D,e);if(o=o.withContentNameScopesList(F),R.whileHasBackReferences&&(o=o.withEndRule(R.getWhileWithResolvedBackReferences(t.content,m))),!w&&k.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(go(e,t,n,o,s,b.captures,m),s.produce(o,m[0].end),o=o.pop(),!w){o=o.safePop(),s.produce(o,l),c=!0;return}}m[0].end>r&&(r=m[0].end,n=!1)}}function Ib(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 ei&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){let{ruleScanner:c,findOptions:u}=Mb(l.rule,e,l.stack.endRule,n,r===i),d=c.findNextMatchSync(t,r,u);if(d){if(d.ruleId!==Xp){o=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),go(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 Pb(e,t,n,r,o,s){let i=Lb(e,t,n,r,o,s),a=e.getInjections();if(a.length===0)return i;let l=$b(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 Lb(e,t,n,r,o,s){let i=o.getRule(e),{ruleScanner:a,findOptions:l}=ef(i,e,o.endRule,n,r===s),c=a.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function $b(e,t,n,r,o,s,i){let a=Number.MAX_VALUE,l=null,c,u=0,d=s.contentNameScopesList.getScopeNames();for(let f=0,h=e.length;f<h;f++){let m=e[f];if(!m.matcher(d))continue;let g=t.getRule(m.ruleId),{ruleScanner:w,findOptions:b}=ef(g,t,null,r,o===i),k=w.findNextMatchSync(n,o,b);if(!k)continue;let v=k.captureIndices[0].start;if(!(v>=a)&&(a=v,l=k.captureIndices,c=k.ruleId,u=m.priority,a===o))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function ef(e,t,n,r,o){if(Yp){let i=e.compile(t,n),a=tf(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileAG(t,n,r,o),findOptions:0}}function Mb(e,t,n,r,o){if(Yp){let i=e.compileWhile(t,n),a=tf(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileWhileAG(t,n,r,o),findOptions:0}}function tf(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function go(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 f=s[d];if(f===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),f.retokenizeCapturedWithRuleId){let g=f.getName(a,i),w=r.contentNameScopesList.pushAttributed(g,e),b=f.getContentName(a,i),k=w.pushAttributed(b,e),v=r.push(f.retokenizeCapturedWithRuleId,h.start,-1,!1,null,w,k),I=e.createOnigString(a.substring(0,h.end));Qp(e,I,n&&h.start===0,h.start,v,o,!1,0),qp(I);continue}let m=f.getName(a,i);if(m!==null){let w=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(m,e);c.push(new Ob(w,h.end))}}for(;c.length>0;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var Ob=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Db(e,t,n,r,o,s,i,a){return new Bb(e,t,n,r,o,s,i,a)}function Np(e,t,n,r,o){let s=Ys(t,ti),i=Jp.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 ti(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(Nb(t[o],r))return n=o+1,!0;return!1})}function Nb(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 Bb=class{constructor(e,t,n,r,o,s,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new Ab(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Bp(t,null),this._injections=null,this._tokenTypeMatchers=[],o)for(let l of Object.keys(o)){let c=Ys(l,ti);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)Np(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&&Np(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]=Bp(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=Jp.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!t||t===$l.NULL){o=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),d=Sn.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null),h;f?h=yo.createRootAndLookUpScopeName(f,d,this):h=yo.createRoot("unknown",d),t=new $l(null,this._rootId,-1,-1,!1,null,h,h)}else o=!1,t.reset();e=e+`
24
- `;let s=this.createOnigString(e),i=s.content.length,a=new Gb(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Qp(this,s,o,0,t,a,!0,r);return qp(s),{lineLength:i,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Bp(e,t){return e=rb(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 yo=class Bt{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=vl.push(o,s.scopeNames),r=new Bt(r,o,s.encodedTokenAttributes);return r}static createRoot(t,n){return new Bt(null,new vl(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let o=r.getMetadataForScope(t),s=new vl(null,t),i=r.themeProvider.themeMatch(s),a=Bt.mergeAttributes(n,o,i);return new Bt(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Bt.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),Sn.set(t,n.languageId,n.tokenType,null,o,s,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Bt._pushAttributed(this,t,n);let r=t.split(/ /g),o=this;for(let s of r)o=Bt._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=Bt.mergeAttributes(t.tokenAttributes,o,i);return new Bt(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}},$l=class qn{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 qn(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:qn._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?yo.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(){qn._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,o,s,i,a){return new qn(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 qn(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=yo.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new qn(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,yo.fromExtension(r,n.contentNameScopesList))}},Fb=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Ys(n,ti).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Ys(n,ti).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}},Gb=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=Sn.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(s))}if(o&&(r=Sn.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}},jb=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,Db(e,s,t,n,r,o,this,this._onigLib))}return this._grammars.get(e)}},nf=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new jb(xo.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(xo.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 Fb(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,o){let s=new yb(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)}},ni=$l.NULL;p();var Nl=qy(uf(),1),Er=Nl.default,{Ansis:n1,fg:r1,bg:o1,rgb:s1,bgRgb:i1,hex:a1,bgHex:l1,reset:c1,inverse:u1,hidden:d1,visible:p1,link:f1,bold:m1,dim:h1,italic:g1,underline:y1,strikethrough:x1,black:b1,red:w1,green:k1,yellow:S1,blue:T1,magenta:C1,cyan:_1,white:v1,gray:R1,redBright:A1,greenBright:E1,yellowBright:I1,blueBright:P1,magentaBright:L1,cyanBright:$1,whiteBright:M1,bgBlack:O1,bgRed:D1,bgGreen:N1,bgYellow:B1,bgBlue:F1,bgMagenta:G1,bgCyan:j1,bgWhite:U1,bgGray:W1,bgRedBright:H1,bgGreenBright:V1,bgYellowBright:z1,bgBlueBright:q1,bgMagentaBright:K1,bgCyanBright:X1,bgWhiteBright:J1}=Nl.default;p();p();var Bl=Object.defineProperty,qb=Object.getOwnPropertyDescriptor,Kb=Object.getOwnPropertyNames,Xb=Object.prototype.hasOwnProperty,Ir=(e,t)=>{let n={};for(var r in e)Bl(n,r,{get:e[r],enumerable:!0});return t||Bl(n,Symbol.toStringTag,{value:"Module"}),n},df=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=Kb(t),s=0,i=o.length,a;s<i;s++)a=o[s],!Xb.call(e,a)&&a!==n&&Bl(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=qb(t,a))||r.enumerable});return e},oi=(e,t,n)=>(df(e,t,"default"),n&&df(n,t,"default"));p();var Pr=[{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"))}],To=Object.fromEntries(Pr.map(e=>[e.id,e.import])),Co=Object.fromEntries(Pr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),_o={...To,...Co};p();var vo=[{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"))}],Ro=Object.fromEntries(vo.map(e=>[e.id,e.import]));p();p();var Wl={};Wd(Wl,{createOnigurumaEngine:()=>Ul,getDefaultWasmLoader:()=>dw,loadWasm:()=>li,setDefaultWasmLoader:()=>uw});p();var jl=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Jb(){return 2147483648}function Zb(){return typeof performance<"u"?performance.now():Date.now()}var Yb=(e,t)=>e+(t-e%t)%t;async function Qb(e){let t,n,r={};function o(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function s(h,m,g){r.HEAPU8.copyWithin(h,m,m+g)}function i(h){try{return t.grow(h-n.byteLength+65535>>>16),o(t.buffer),1}catch{}}function a(h){let m=r.HEAPU8.length;h=h>>>0;let g=Jb();if(h>g)return!1;for(let w=1;w<=4;w*=2){let b=m*(1+.2/w);b=Math.min(b,h+100663296);let k=Math.min(g,Yb(Math.max(h,b),65536));if(i(k))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function c(h,m,g=1024){let w=m+g,b=m;for(;h[b]&&!(b>=w);)++b;if(b-m>16&&h.buffer&&l)return l.decode(h.subarray(m,b));let k="";for(;m<b;){let v=h[m++];if(!(v&128)){k+=String.fromCharCode(v);continue}let I=h[m++]&63;if((v&224)===192){k+=String.fromCharCode((v&31)<<6|I);continue}let R=h[m++]&63;if((v&240)===224?v=(v&15)<<12|I<<6|R:v=(v&7)<<18|I<<12|R<<6|h[m++]&63,v<65536)k+=String.fromCharCode(v);else{let D=v-65536;k+=String.fromCharCode(55296|D>>10,56320|D&1023)}}return k}function u(h,m){return h?c(r.HEAPU8,h,m):""}let d={emscripten_get_now:Zb,emscripten_memcpy_big:s,emscripten_resize_heap:a,fd_write:()=>0};async function f(){let m=await e({env:d,wasi_snapshot_preview1:d});t=m.memory,o(t.buffer),Object.assign(r,m),r.UTF8ToString=u}return await f(),r}var ew=Object.defineProperty,tw=(e,t,n)=>t in e?ew(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ee=(e,t,n)=>tw(e,typeof t!="symbol"?t+"":t,n),$e=null;function nw(e){throw new jl(e.UTF8ToString(e.getLastOnigError()))}var ii=class e{constructor(t){Ee(this,"utf16Length"),Ee(this,"utf8Length"),Ee(this,"utf16Value"),Ee(this,"utf8Value"),Ee(this,"utf16OffsetToUtf8"),Ee(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,f=!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,f=!0)}o&&(s[c]=l,f&&(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),f&&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}},ai=class Ft{constructor(t){if(Ee(this,"id",++Ft.LAST_ID),Ee(this,"_onigBinding"),Ee(this,"content"),Ee(this,"utf16Length"),Ee(this,"utf8Length"),Ee(this,"utf16OffsetToUtf8"),Ee(this,"utf8OffsetToUtf16"),Ee(this,"ptr"),!$e)throw new jl("Must invoke loadWasm first.");this._onigBinding=$e,this.content=t;let n=new ii(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ft._sharedPtrInUse?(Ft._sharedPtr||(Ft._sharedPtr=$e.omalloc(1e4)),Ft._sharedPtrInUse=!0,$e.HEAPU8.set(n.utf8Value,Ft._sharedPtr),this.ptr=Ft._sharedPtr):this.ptr=n.createString($e)}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===Ft._sharedPtr?Ft._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Ee(ai,"LAST_ID",0);Ee(ai,"_sharedPtr",0);Ee(ai,"_sharedPtrInUse",!1);var pf=ai,Gl=class{constructor(t){if(Ee(this,"_onigBinding"),Ee(this,"_ptr"),!$e)throw new jl("Must invoke loadWasm first.");let n=[],r=[];for(let a=0,l=t.length;a<l;a++){let c=new ii(t[a]);n[a]=c.createString($e),r[a]=c.utf8Length}let o=$e.omalloc(4*t.length);$e.HEAPU32.set(n,o/4);let s=$e.omalloc(4*t.length);$e.HEAPU32.set(r,s/4);let i=$e.createOnigScanner(o,s,t.length);for(let a=0,l=t.length;a<l;a++)$e.ofree(n[a]);$e.ofree(s),$e.ofree(o),i===0&&nw($e),this._onigBinding=$e,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 pf(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 f=0;f<u;f++){let h=t.convertUtf8OffsetToUtf16(a[l++]),m=t.convertUtf8OffsetToUtf16(a[l++]);d[f]={start:h,end:m,length:m-h}}return{index:c,captureIndices:d}}};function rw(e){return typeof e.instantiator=="function"}function ow(e){return typeof e.default=="function"}function sw(e){return typeof e.data<"u"}function iw(e){return typeof Response<"u"&&e instanceof Response}function aw(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 si;function li(e){if(si)return si;async function t(){$e=await Qb(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),rw(r)?r=await r.instantiator(n):ow(r)?r=await r.default(n):(sw(r)&&(r=r.data),iw(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await lw(r)(n):r=await cw(r)(n):aw(r)?r=await Fl(r)(n):r instanceof WebAssembly.Module?r=await Fl(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Fl(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return si=t(),si}function Fl(e){return t=>WebAssembly.instantiate(e,t)}function lw(e){return t=>WebAssembly.instantiateStreaming(e,t)}function cw(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var ff;function uw(e){ff=e}function dw(){return ff}async function Ul(e){return e&&await li(e),{createScanner(t){return new Gl(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new pf(t)}}}var Hl=Ir({});oi(Hl,Wl);p();p();var ce=class extends Error{constructor(e){super(e),this.name="ShikiError"}};p();function Eo(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 Kt(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function xf(e){return Array.isArray(e)?e:[e]}async function Vl(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Io(e){return!e||["plaintext","txt","text","plain"].includes(e)}function zl(e){return e==="ansi"||Io(e)}function Po(e){return e==="none"}function ql(e){return Po(e)}var pw=/(\r?\n)/g;function Lr(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(pw),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 mf={light:"#333333",dark:"#bbbbbb"},hf={light:"#fffffe",dark:"#1e1e1e"},gf="__shiki_resolved";function ci(e){if(e?.[gf])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"?mf.light:mf.dark),n||(n=t.type==="light"?hf.light:hf.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,gf,{enumerable:!1,writable:!1,value:!0}),t}async function bf(e){return[...new Set((await Promise.all(e.filter(t=>!zl(t)).map(async t=>await Vl(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function wf(e){return(await Promise.all(e.map(async t=>ql(t)?null:ci(await Vl(t))))).filter(t=>!!t)}function kf(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 ce(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var fw=class extends nf{_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=ci(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=xo.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=kf(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 ce(`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))}},mw=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}},Ao=0;function Kl(e){Ao+=1,e.warnings!==!1&&Ao>=10&&Ao%10===0&&console.warn(`[Shiki] ${Ao} 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 ce("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(ci),o=new fw(new mw(e.engine,n),r,n,e.langAlias),s;function i(k){return kf(k,e.langAlias)}function a(k){w();let v=o.getGrammar(typeof k=="string"?k:k.name);if(!v)throw new ce(`Language \`${k}\` not found, you may need to load it first`);return v}function l(k){if(k==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};w();let v=o.getTheme(k);if(!v)throw new ce(`Theme \`${k}\` not found, you may need to load it first`);return v}function c(k){w();let v=l(k);return s!==k&&(o.setTheme(v),s=k),{theme:v,colorMap:o.getColorMap()}}function u(){return w(),o.getLoadedThemes()}function d(){return w(),o.getLoadedLanguages()}function f(...k){w(),o.loadLanguages(k.flat(1))}async function h(...k){return f(await bf(k))}function m(...k){w();for(let v of k.flat(1))o.loadTheme(v)}async function g(...k){return w(),m(await wf(k))}function w(){if(t)throw new ce("Shiki instance has been disposed")}function b(){t||(t=!0,o.dispose(),Ao-=1)}return{setTheme:c,getTheme:l,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:f,loadTheme:g,loadThemeSync:m,dispose:b,[Symbol.dispose]:b}}async function Xl(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([wf(e.themes||[]),bf(e.langs||[]),e.engine]);return Kl({...e,themes:t,langs:n,engine:r})}var Sf=new WeakMap;function Lo(e,t){Sf.set(e,t)}function $r(e){return Sf.get(e)}var ui=class Tf{_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 Tf(Object.fromEntries(xf(n).map(r=>[r,ni])),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 hw(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function hw(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 gw(e,t){if(!(e instanceof ui))throw new ce("Invalid grammar state");return e.getInternalStack(t)}var yw=/,/,xw=/ /;function Jl(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Io(e.resolveLangAlias(n.lang||"text"))||Po(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 ce(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new ce(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return _f(t,i,o,s,n)}function Cf(...e){if(e.length===2)return $r(e[1]);let[t,n,r={}]=e,{lang:o="text",theme:s=t.getLoadedThemes()[0]}=r;if(Io(o)||Po(s))throw new ce("Plain language does not have grammar state");if(o==="ansi")throw new ce("ANSI language does not have grammar state");let{theme:i,colorMap:a}=t.setTheme(s),l=t.getLanguage(o);return new ui(Zl(n,l,i,a,r).stateStack,l.name,i.name)}function _f(e,t,n,r,o){let s=Zl(e,t,n,r,o),i=new ui(s.stateStack,t.name,n.name);return Lo(s.tokens,i),s.tokens}function Zl(e,t,n,r,o){let s=Eo(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=o,c=Lr(e),u=o.grammarState?gw(o.grammarState,n.name)??ni:o.grammarContextCode!=null?Zl(o.grammarContextCode,t,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:ni,d=[],f=[];for(let h=0,m=c.length;h<m;h++){let[g,w]=c[h];if(g===""){d=[],f.push([]);continue}if(i>0&&g.length>=i){d=[],f.push([{content:g,offset:w,color:"",fontStyle:0}]);continue}let b,k,v;l&&l!=="tokenType"&&(b=t.tokenizeLine(g,u,a),k=b.tokens,v=0);let I=t.tokenizeLine2(g,u,a),R=I.tokens.length/2;for(let D=0;D<R;D++){let F=I.tokens[2*D],P=D+1<R?I.tokens[2*D+2]:g.length;if(F===P)continue;let z=I.tokens[2*D+1],j=Kt(r[Sn.getForeground(z)],s),N=Sn.getFontStyle(z),A={content:g.substring(F,P),offset:w+F,color:j,fontStyle:N};if(l==="tokenType")A.type=Sn.getTokenType(z);else if(l){let ie=[];if(l!=="scopeName")for(let Q of n.settings){let V;switch(typeof Q.scope){case"string":V=Q.scope.split(yw).map(fe=>fe.trim());break;case"object":V=Q.scope;break;default:continue}ie.push({settings:Q,selectors:V.map(fe=>fe.split(xw))})}A.explanation=[];let ne=0;for(;F+ne<P;){let Q=k[v],V=g.substring(Q.startIndex,Q.endIndex);ne+=V.length,A.explanation.push({content:V,scopes:l==="scopeName"?bw(Q.scopes):ww(ie,Q.scopes)}),v+=1}}d.push(A)}f.push(d),d=[],u=I.ruleStack}return{tokens:f,stateStack:u}}function bw(e){return e.map(t=>({scopeName:t}))}function ww(e,t){let n=[];for(let r=0,o=t.length;r<o;r++){let s=t[r];n[r]={scopeName:s,themeMatches:Sw(e,s,t.slice(0,r))}}return n}function yf(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function kw(e,t,n){if(!yf(e.at(-1),t))return!1;let r=e.length-2,o=n.length-1;for(;r>=0&&o>=0;)yf(e[r],n[o])&&(r-=1),o-=1;return r===-1}function Sw(e,t,n){let r=[];for(let{selectors:o,settings:s}of e)for(let i of o)if(kw(i,t,n)){r.push(s);break}return r}function di(e,t,n,r=Jl){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:$r(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=Tw(...s.map(c=>c.tokens)),a=i[0].map((c,u)=>c.map((d,f)=>{let h={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=d.explanation),i.forEach((m,g)=>{let{content:w,explanation:b,offset:k,...v}=m[u][f];h.variants[o[g].color]=v}),h})),l=s[0].state?new ui(Object.fromEntries(s.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),s[0].state.lang):void 0;return l&&Lo(a,l),a}function Tw(...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 vf=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];p();p();p();var Xt=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Xt.prototype.normal={};Xt.prototype.property={};Xt.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 Xt(n,r,t)}p();p();p();function $o(e){return e.toLowerCase()}p();p();var Me=class{constructor(t,n){this.attribute=n,this.property=t}};Me.prototype.attribute="";Me.prototype.booleanish=!1;Me.prototype.boolean=!1;Me.prototype.commaOrSpaceSeparated=!1;Me.prototype.commaSeparated=!1;Me.prototype.defined=!1;Me.prototype.mustUseProperty=!1;Me.prototype.number=!1;Me.prototype.overloadedBoolean=!1;Me.prototype.property="";Me.prototype.spaceSeparated=!1;Me.prototype.space=void 0;var Mo={};Wd(Mo,{boolean:()=>K,booleanish:()=>xe,commaOrSpaceSeparated:()=>Xe,commaSeparated:()=>Jt,number:()=>L,overloadedBoolean:()=>pi,spaceSeparated:()=>le});p();var Cw=0,K=Kn(),xe=Kn(),pi=Kn(),L=Kn(),le=Kn(),Jt=Kn(),Xe=Kn();function Kn(){return 2**++Cw}var Ql=Object.keys(Mo),Xn=class extends Me{constructor(t,n,r,o){let s=-1;if(super(t,n),Rf(this,"space",o),typeof r=="number")for(;++s<Ql.length;){let i=Ql[s];Rf(this,Ql[s],(r&Mo[i])===Mo[i])}}};Xn.prototype.defined=!0;function Rf(e,t,n){n&&(e[t]=n)}function ht(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let s=new Xn(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[$o(r)]=r,n[$o(s.attribute)]=r}return new Xt(t,n,e.space)}var ec=ht({properties:{ariaActiveDescendant:null,ariaAtomic:xe,ariaAutoComplete:null,ariaBusy:xe,ariaChecked:xe,ariaColCount:L,ariaColIndex:L,ariaColSpan:L,ariaControls:le,ariaCurrent:null,ariaDescribedBy:le,ariaDetails:null,ariaDisabled:xe,ariaDropEffect:le,ariaErrorMessage:null,ariaExpanded:xe,ariaFlowTo:le,ariaGrabbed:xe,ariaHasPopup:null,ariaHidden:xe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:le,ariaLevel:L,ariaLive:null,ariaModal:xe,ariaMultiLine:xe,ariaMultiSelectable:xe,ariaOrientation:null,ariaOwns:le,ariaPlaceholder:null,ariaPosInSet:L,ariaPressed:xe,ariaReadOnly:xe,ariaRelevant:null,ariaRequired:xe,ariaRoleDescription:le,ariaRowCount:L,ariaRowIndex:L,ariaRowSpan:L,ariaSelected:xe,ariaSetSize:L,ariaSort:null,ariaValueMax:L,ariaValueMin:L,ariaValueNow:L,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});p();p();p();function fi(e,t){return t in e?e[t]:t}function mi(e,t){return fi(e,t.toLowerCase())}var Af=ht({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Jt,acceptCharset:le,accessKey:le,action:null,allow:null,allowFullScreen:K,allowPaymentRequest:K,allowUserMedia:K,alpha:K,alt:null,as:null,async:K,autoCapitalize:null,autoComplete:le,autoFocus:K,autoPlay:K,blocking:le,capture:null,charSet:null,checked:K,cite:null,className:le,closedBy:null,colorSpace:null,cols:L,colSpan:L,command:null,commandFor:null,content:null,contentEditable:xe,controls:K,controlsList:le,coords:L|Jt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:K,defer:K,dir:null,dirName:null,disabled:K,download:pi,draggable:xe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:K,formTarget:null,headers:le,height:L,hidden:pi,high:L,href:null,hrefLang:null,htmlFor:le,httpEquiv:le,id:null,imageSizes:null,imageSrcSet:null,inert:K,inputMode:null,integrity:null,is:null,isMap:K,itemId:null,itemProp:le,itemRef:le,itemScope:K,itemType:le,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:K,low:L,manifest:null,max:null,maxLength:L,media:null,method:null,min:null,minLength:L,multiple:K,muted:K,name:null,nonce:null,noModule:K,noValidate:K,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:K,optimum:L,pattern:null,ping:le,placeholder:null,playsInline:K,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:K,referrerPolicy:null,rel:le,required:K,reversed:K,rows:L,rowSpan:L,sandbox:le,scope:null,scoped:K,seamless:K,selected:K,shadowRootClonable:K,shadowRootCustomElementRegistry:K,shadowRootDelegatesFocus:K,shadowRootMode:null,shadowRootSerializable:K,shape:null,size:L,sizes:null,slot:null,span:L,spellCheck:xe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:L,step:null,style:null,tabIndex:L,target:null,title:null,translate:null,type:null,typeMustMatch:K,useMap:null,value:xe,width:L,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:le,axis:null,background:null,bgColor:null,border:L,borderColor:null,bottomMargin:L,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:K,declare:K,event:null,face:null,frame:null,frameBorder:null,hSpace:L,leftMargin:L,link:null,longDesc:null,lowSrc:null,marginHeight:L,marginWidth:L,noResize:K,noHref:K,noShade:K,noWrap:K,object:null,profile:null,prompt:null,rev:null,rightMargin:L,rules:null,scheme:null,scrolling:xe,standby:null,summary:null,text:null,topMargin:L,valueType:null,version:null,vAlign:null,vLink:null,vSpace:L,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:K,disablePictureInPicture:K,disableRemotePlayback:K,exportParts:Jt,part:le,prefix:null,property:null,results:L,security:null,unselectable:null},space:"html",transform:mi});p();var Ef=ht({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:Xe,accentHeight:L,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:L,amplitude:L,arabicForm:null,ascent:L,attributeName:null,attributeType:null,azimuth:L,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:L,by:null,calcMode:null,capHeight:L,className:le,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:L,diffuseConstant:L,direction:null,display:null,dur:null,divisor:L,dominantBaseline:null,download:K,dx:null,dy:null,edgeMode:null,editable:null,elevation:L,enableBackground:null,end:null,event:null,exponent:L,externalResourcesRequired:null,fill:null,fillOpacity:L,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:Jt,g2:Jt,glyphName:Jt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:L,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:L,horizOriginX:L,horizOriginY:L,id:null,ideographic:L,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:L,k:L,k1:L,k2:L,k3:L,k4:L,kernelMatrix:Xe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:L,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:L,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:L,overlineThickness:L,paintOrder:null,panose1:null,path:null,pathLength:L,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:le,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:L,pointsAtY:L,pointsAtZ:L,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xe,rev:Xe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xe,requiredFeatures:Xe,requiredFonts:Xe,requiredFormats:Xe,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:L,specularExponent:L,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:L,strikethroughThickness:L,string:null,stroke:null,strokeDashArray:Xe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:L,strokeOpacity:L,strokeWidth:null,style:null,surfaceScale:L,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xe,tabIndex:L,tableValues:null,target:null,targetX:L,targetY:L,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:L,underlineThickness:L,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:L,values:null,vAlphabetic:L,vMathematical:L,vectorEffect:null,vHanging:L,vIdeographic:L,version:null,vertAdvY:L,vertOriginX:L,vertOriginY:L,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:L,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:fi});p();var tc=ht({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 nc=ht({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:mi});p();var rc=ht({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});p();var _w=/[A-Z]/g,If=/-[a-z]/g,vw=/^data[-\w.:]+$/i;function oc(e,t){let n=$o(t),r=t,o=Me;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&vw.test(t)){if(t.charAt(4)==="-"){let s=t.slice(5).replace(If,Aw);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{let s=t.slice(4);if(!If.test(s)){let i=s.replace(_w,Rw);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=Xn}return new o(r,t)}function Rw(e){return"-"+e.toLowerCase()}function Aw(e){return e.charAt(1).toUpperCase()}var Pf=Yl([ec,Af,tc,nc,rc],"html"),hi=Yl([ec,Ef,tc,nc,rc],"svg");p();p();var Lf={}.hasOwnProperty;function $f(e,t){let n=t||{};function r(o,...s){let i=r.invalid,a=r.handlers;if(o&&Lf.call(o,e)){let l=String(o[e]);i=Lf.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 Ew=/["&'<>`]/g,Iw=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Pw=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Lw=/[|\\{}()[\]^$+*?.]/g,Mf=new WeakMap;function Of(e,t){if(e=e.replace(t.subset?$w(t.subset):Ew,r),t.subset||t.escapeOnly)return e;return e.replace(Iw,n).replace(Pw,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 $w(e){let t=Mf.get(e);return t||(t=Mw(e),Mf.set(e,t)),t}function Mw(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(Lw,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}p();p();var Ow=/[\dA-Fa-f]/;function Df(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!Ow.test(String.fromCharCode(t))?r:r+";"}p();var Dw=/\d/;function Nf(e,t,n){let r="&#"+String(e);return n&&t&&!Dw.test(String.fromCharCode(t))?r:r+";"}p();p();var Bf=["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 gi={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 Ff=["cent","copy","divide","gt","lt","not","para","times"];var Gf={}.hasOwnProperty,sc={},yi;for(yi in gi)Gf.call(gi,yi)&&(sc[gi[yi]]=yi);var Nw=/[^\dA-Za-z]/;function jf(e,t,n,r){let o=String.fromCharCode(e);if(Gf.call(sc,o)){let s=sc[o],i="&"+s;return n&&Bf.includes(s)&&!Ff.includes(s)&&(!r||t&&t!==61&&Nw.test(String.fromCharCode(t)))?i:i+";"}return""}function Uf(e,t,n){let r=Df(e,t,n.omitOptionalSemicolons),o;if((n.useNamedReferences||n.useShortestReferences)&&(o=jf(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!o)&&n.useShortestReferences){let s=Nf(e,t,n.omitOptionalSemicolons);s.length<r.length&&(r=s)}return o&&(!n.useShortestReferences||o.length<r.length)?o:r}function Zt(e,t){return Of(e,Object.assign({format:Uf},t))}var Bw=/^>|^->|<!--|-->|--!>|<!-$/g,Fw=[">"],Gw=["<",">"];function Wf(e,t,n,r){return r.settings.bogusComments?"<?"+Zt(e.value,Object.assign({},r.settings.characterReferences,{subset:Fw}))+">":"<!--"+e.value.replace(Bw,o)+"-->";function o(s){return Zt(s,Object.assign({},r.settings.characterReferences,{subset:Gw}))}}p();function Hf(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}p();p();function ic(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 Vf(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}p();function zf(e){return e.join(" ").trim()}p();p();p();var jw=/[ \t\n\f\r]/g;function Jn(e){return typeof e=="object"?e.type==="text"?qf(e.value):!1:qf(e)}function qf(e){return e.replace(jw,"")===""}p();var ke=Kf(1),ac=Kf(-1),Uw=[];function Kf(e){return t;function t(n,r,o){let s=n?n.children:Uw,i=(r||0)+e,a=s[i];if(!o)for(;a&&Jn(a);)i+=e,a=s[i];return a}}p();var Ww={}.hasOwnProperty;function xi(e){return t;function t(n,r,o){return Ww.call(e,n.tagName)&&e[n.tagName](n,r,o)}}var Oo=xi({body:Vw,caption:lc,colgroup:lc,dd:Xw,dt:Kw,head:lc,html:Hw,li:qw,optgroup:Jw,option:Zw,p:zw,rp:Xf,rt:Xf,tbody:Qw,td:Jf,tfoot:ek,th:Jf,thead:Yw,tr:tk});function lc(e,t,n){let r=ke(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Jn(r.value.charAt(0)))}function Hw(e,t,n){let r=ke(n,t);return!r||r.type!=="comment"}function Vw(e,t,n){let r=ke(n,t);return!r||r.type!=="comment"}function zw(e,t,n){let r=ke(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 qw(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&r.tagName==="li"}function Kw(e,t,n){let r=ke(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Xw(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Xf(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function Jw(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function Zw(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Yw(e,t,n){let r=ke(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Qw(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function ek(e,t,n){return!ke(n,t)}function tk(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Jf(e,t,n){let r=ke(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}p();var Zf=xi({body:ok,colgroup:sk,head:rk,html:nk,tbody:ik});function nk(e){let t=ke(e,-1);return!t||t.type!=="comment"}function rk(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 ok(e){let t=ke(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Jn(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function sk(e,t,n){let r=ac(n,t),o=ke(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Oo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function ik(e,t,n){let r=ac(n,t),o=ke(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Oo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}var bi={name:[[`
21
+ `+i:r=i}return o(),n}function Yx(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 Qx(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 eb(e){let t=[];for(let n of e){if(n.type==="code_block"||n.type==="table"){t.push(n);continue}let r=Qx(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 tb="#22c55e",nb="#ef4444",rb="#00cccc";function ob({code:e}){let t=e.split(`
22
+ `),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?ve(Ys,{marginLeft:2,children:El(Ge,{color:"#888888",children:["\u250C ",o]})}):null:El(Ys,{flexDirection:"column",marginLeft:2,marginTop:1,children:[o&&El(Ge,{color:"#888888",children:["\u250C ",o]}),s.map((i,a)=>i.startsWith("+")?ve(Ge,{color:tb,children:i},a):i.startsWith("-")?ve(Ge,{color:nb,children:i},a):i.startsWith("@@")?ve(Ge,{color:rb,children:i},a):ve(Ge,{children:i},a))]})}function sb({text:e}){let t=Dp(),n=Op(e,{termWidth:t});return n.colWidths.length===0?ve(Ge,{children:e}):ve(Ys,{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 ve(Ge,{color:s||i||a?"#888888":void 0,children:r},o)})})}var ib=/[\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 ab(e){return ib.test(e)}function lb(e){try{return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(e)].map(r=>({text:r.segment,isEmoji:ab(r.segment)}))}catch{return[{text:e,isEmoji:!1}]}}function Np(e,t){let n=lb(e);if(n.length===1&&!n[0].isEmoji)return ve(Ge,{color:Gp,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 ve(Ge,{children:r.map((o,s)=>o.isEmoji?o.text:ve(Ge,{color:Gp,children:o.text},s))},t)}var Bp="#00BFFF",Gp="#A855F7";function Fp({children:e}){let t=Xx(e),n=[];for(let c of t)c.type==="code_block"?n.push(c):n.push(...Zx(c.text));let r=[];for(let c of n)c.type==="code_block"||c.type==="table"?r.push(c):r.push(...Yx(c.text));let o=eb(r);if(!o.some(c=>c.type==="code_block"||c.type==="table"))return o.length===1&&o[0].type==="plain"?ve(Ge,{wrap:"wrap",children:e}):ve(Ge,{wrap:"wrap",children:o.map((u,d)=>u.type==="code"?ve(Ge,{color:Bp,children:u.text},d):u.type==="bold"?Np(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(ve(Ge,{wrap:"wrap",children:a[0].text},c)):i.push(ve(Ge,{wrap:"wrap",children:a.map((d,f)=>d.type==="code"?ve(Ge,{color:Bp,children:d.text},f):d.type==="bold"?Np(d.text,f):d.text)},c)),a=[]}for(let c of o)c.type==="code_block"?(l(i.length),i.push(ve(ob,{code:c.text},`b${i.length}`))):c.type==="table"?(l(i.length),i.push(ve(sb,{text:c.text},`t${i.length}`))):a.push(c);return l(i.length),ve(Ys,{flexDirection:"column",children:i})}import{Fragment as db,jsx as Nt,jsxs as at}from"react/jsx-runtime";function Qs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function ub({usage:e,cost:t}){let n=e?e.promptTokens+e.completionTokens:0,r=t??0,[o,s]=Up(n),[i,a]=Up(r),l=jp(null),c=jp(null);return cb(()=>{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,f=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:f},c.current&&clearInterval(c.current),c.current=setInterval(()=>{let h=l.current;if(!h)return;let m=Date.now()-h.startMs;if(m>=h.durationMs){s(h.toTokens),a(h.toCost),c.current&&(clearInterval(c.current),c.current=null);return}let g=m/h.durationMs,b=1-Math.pow(1-g,3),k=h.fromTokens+(h.toTokens-h.fromTokens)*b,T=h.fromCost+(h.toCost-h.fromCost)*b;s(k),a(T)},33),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[n,r]),at(db,{children:[e&&at(qt,{color:"#888888",children:[Math.round(o).toLocaleString()," tokens"]}),t!==void 0&&t>0&&at(qt,{color:"#888888",children:[" \xB7 ","\xA5",i.toFixed(4)]})]})}function ei({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:at(Dt,{flexDirection:"row",marginTop:1,children:[Nt(Dt,{width:1,backgroundColor:"#E040FB",flexShrink:0}),at(Dt,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[at(Dt,{flexDirection:"row",children:[Nt(Dt,{width:4,flexShrink:0,children:Nt(qt,{bold:!0,color:"#ff00ff",children:"\u{1F916}"})}),at(Dt,{flexGrow:1,flexDirection:"column",children:[e&&Nt(Fp,{children:e}),n&&!e&&Nt(qt,{color:"#888888",children:"..."})]})]}),t&&t.length>0&&Nt(Dt,{flexDirection:"column",children:t.map((l,c)=>Nt(vl,{call:l,denial:a?.get(l.id??"")?.denial},l.id??c))}),n&&(r||s!==void 0)&&Nt(Dt,{flexDirection:"row",marginTop:1,marginLeft:3,children:at(qt,{color:"#666666",dimColor:!0,children:["\u23F3 \u5DF2\u6D88\u8017 ",Nt(ub,{usage:r,cost:s})]})}),!n&&(r||o!==void 0)&&at(Dt,{flexDirection:"column",marginTop:1,marginLeft:3,children:[Nt(qt,{color:"#555555",children:"\u2500".repeat(36)}),at(Dt,{flexDirection:"row",gap:2,children:[s!==void 0&&s>0&&at(qt,{color:"yellow",children:["\u{1F4B0} \u672C\u6B21 ",Ir(s)]}),o!==void 0&&at(qt,{color:"cyan",children:["\u{1F550} ",Qs(o)]}),r&&at(qt,{color:"#888888",children:["\u{1F4E6} ",(r.promptTokens+r.completionTokens).toLocaleString()," tokens"]})]})]})]})]})}p();import{Box as Xn,Text as q}from"ink";import{useEffect as Wp,useMemo as pb,useRef as fb,useState as Hp}from"react";import{Fragment as $l,jsx as Z,jsxs as se}from"react/jsx-runtime";var V={accent:"#5fbedb",warn:"#d4a017",danger:"#c9605a",success:"#7ec890",condition:"#9a9a9a",trackEmpty:"#2a2a2a",text:"#b8b8b8",muted:"#6a6a6a",dot:"#404040"},mb=.85,hb=5,gb=30;function Vp(e){switch(e){case"thinking":return"\u{1F9E0} \u601D\u8003\u4E2D";case"generating":return"\u2728 \u751F\u6210\u4E2D";case"calling_tools":return"\u{1F6E0} \u8C03\u7528\u5DE5\u5177";case"executing_tools":return"\u26A1 \u6267\u884C\u5DE5\u5177"}}function To(e){return e<1e3?`${e}`:e<1e4?`${(e/1e3).toFixed(1)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}m`}function Il(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return`${n}m${String(r).padStart(2,"0")}s`;let o=Math.floor(n/60),s=n%60;return`${o}h${String(s).padStart(2,"0")}m`}function zp(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function yb(e,t,n,r){let o=zp(e),s=Math.round(o*t),i=t-s;return{filled:"\u2588".repeat(s),empty:"\u2591".repeat(i),pct:o}}function ti(e,t){let n=zp(e);return t==="turn"?n<.8?V.accent:V.success:n<.8?V.accent:n<.95?V.warn:V.danger}function Pl(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}function xb(e,t,n,r){if(!e)return null;if(e.status==="achieved")return se(q,{children:[Z(q,{color:V.success,bold:!0,children:"\u2713 GOAL achieved"}),se(q,{color:V.muted,children:[" ","(",e.turnCount," turns)"]}),e.lastEval&&e.lastEval.ok?se(q,{color:V.condition,children:[" ","\xB7 ",Pl(e.lastEval.reason,80)]}):null]});if(e.status==="paused"||e.status==="active"){let o=e.status==="paused",s=o?"\u25CC":"\u25C9",i=o?"GOAL paused":"GOAL active",a=o?V.warn:V.accent,l=t-e.wallBaseline,c=l/Math.max(1,e.maxWallMs),u=!o&&n&&r!==null?Math.max(0,t-r):0,f=Math.min(1,u/9e4),m=(e.turnCount+f)/Math.max(1,e.maxTurns),g=yb(m,gb,ti(m,"turn"),V.trackEmpty);return se(Xn,{flexDirection:"column",children:[se(Xn,{children:[se(q,{color:a,bold:!0,children:[s," ",i]}),se(q,{color:V.text,children:[" ",e.turnCount,"/",e.maxTurns," turns"]}),!o&&n&&u>0?se($l,{children:[Z(q,{color:V.muted,children:" \xB7 "}),se(q,{color:V.condition,children:["\u672C\u8F6E ",Il(u)]})]}):null,Z(q,{color:V.muted,children:" \xB7 "}),se(q,{color:ti(c,"wall"),children:[Il(l),"/",Il(e.maxWallMs)]}),Z(q,{color:V.muted,children:" \xB7 "}),Z(q,{color:V.text,children:To(e.tokenBaseline)}),Z(q,{color:V.muted,children:" tokens"})]}),se(Xn,{children:[Z(q,{color:V.muted,children:" ["}),Z(q,{color:ti(m,"turn"),children:g.filled}),Z(q,{color:V.trackEmpty,children:g.empty}),Z(q,{color:V.muted,children:"] "}),se(q,{color:ti(m,"turn"),children:[(g.pct*100).toFixed(0),"%"]})]}),se(Xn,{children:[Z(q,{color:V.muted,children:" \u25B8 "}),se(q,{color:V.condition,children:['"',Pl(e.condition,60),'"']})]}),e.lastEval?se(Xn,{children:[Z(q,{color:V.muted,children:" \u25B8 last eval "}),Z(q,{color:e.lastEval.ok?V.success:V.danger,bold:!0,children:e.lastEval.ok?"\u2713":"\u2717"}),se(q,{color:V.condition,children:[" ",Pl(e.lastEval.reason,120)]})]}):null]})}return null}function Ke(){return Z(q,{color:V.dot,children:" \xB7 "})}function wo({k:e,v:t,color:n}){return se(q,{children:[Z(q,{color:V.muted,children:e}),se(q,{color:n??V.text,children:[" ",t]})]})}function qp(e){let{activeModel:t,thinkingEnabled:n,thinkingEffort:r,balance:o,todayCost:s,sessionCost:i,hasConversationStarted:a,isStreaming:l,streamingPhase:c,currentUsage:u,currentCost:d,currentElapsed:f,currentToolCalls:h,currentToolResults:m,contextStats:g,lastRound:b}=e,k=wn[t]?.displayName??t,[T,A]=Hp(()=>Date.now());Wp(()=>{if(!e.goal||e.goal.status==="achieved"||e.goal.status==="cleared")return;let N=setInterval(()=>A(Date.now()),1e3);return()=>clearInterval(N)},[e.goal]);let E=fb(null),[I,F]=Hp(null);Wp(()=>{if(e.isStreaming&&E.current===null){let N=Date.now();E.current=N,F(N)}else!e.isStreaming&&E.current!==null&&(E.current=null,F(null))},[e.isStreaming]);let M=xb(e.goal,T,e.isStreaming,I),C=pb(()=>{if(!a)return null;if(M)return M;if(l&&c){let oe=u?To(u.promptTokens+u.completionTokens):"0",j=d!==void 0?Ir(d):"\xA50",O=f!==void 0?Qs(f):"0ms";if(c==="calling_tools"||c==="executing_tools"){let ce=h?.length??0,fe=m?.size??0,ne=ce>0?h?.[ce-1]?.name??"\u5DE5\u5177":"\u5DE5\u5177";return se(q,{children:[Z(q,{color:V.accent,bold:!0,children:Vp(c)}),Z(Ke,{}),se(q,{color:V.text,children:[ne,ce>1?` (+${ce-1})`:""]}),Z(Ke,{}),Z(q,{color:V.muted,children:"\u8FDB\u5EA6"}),se(q,{color:V.text,children:[" ",fe,"/",ce]}),Z(Ke,{}),Z(q,{color:V.muted,children:"\u7D2F\u8BA1"}),se(q,{color:V.text,children:[" ",oe," tokens \xB7 ",j," \xB7 ",O]})]})}return se(q,{children:[Z(q,{color:V.accent,bold:!0,children:Vp(c)}),Z(Ke,{}),Z(q,{color:V.muted,children:"\u5DF2\u7528"}),se(q,{color:V.text,children:[" ",oe," tokens"]}),Z(Ke,{}),Z(q,{color:V.muted,children:"\u8D39\u7528"}),se(q,{color:V.text,children:[" ",j]}),Z(Ke,{}),Z(q,{color:V.muted,children:"\u8017\u65F6"}),se(q,{color:V.text,children:[" ",O]})]})}if(g&&g.ratio>=mb)return se(q,{color:V.danger,bold:!0,children:["\u{1F4DA} \u4E0A\u4E0B\u6587\u5DF2\u7528 ",(g.ratio*100).toFixed(0),"%"," \xB7 ","\u8F93\u5165 /compact \u53EF\u624B\u52A8\u538B\u7F29"]});let N=g?`${(g.ratio*100).toFixed(0)}% \xB7 ${To(g.tokens)}/${To(g.contextWindow)}`:"\u2014";return se(q,{children:[b?se($l,{children:[Z(q,{color:V.muted,children:"\u5F53\u8F6E"}),se(q,{color:V.text,children:[" ",Ir(b.cost)]}),Z(Ke,{}),Z(q,{color:V.muted,children:"\u7528\u65F6"}),se(q,{color:V.text,children:[" ",Qs(b.elapsed)]}),Z(Ke,{}),Z(q,{color:V.muted,children:"tokens"}),se(q,{color:V.text,children:[" ",To(b.tokens)]}),Z(Ke,{})]}):null,Z(q,{color:V.muted,children:"\u4E0A\u4E0B\u6587"}),se(q,{color:g&&g.ratio>=.6?V.warn:V.text,children:[" ",N]})]})},[a,l,c,u,d,f,h,m,g,b,M]);return se(Xn,{flexDirection:"column",paddingX:1,marginBottom:1,children:[se(Xn,{children:[Z(q,{color:V.accent,bold:!0,children:"DSK"}),Z(Ke,{}),Z(wo,{k:"\u6A21\u578B",v:k}),n&&se($l,{children:[Z(Ke,{}),Z(wo,{k:"\u601D\u8003",v:r==="max"?"Max":"High"})]}),Z(Ke,{}),Z(wo,{k:"\u4F59\u989D",v:o!==null?`\xA5${o.toFixed(2)}`:"\u2014",color:o!==null&&o<hb?V.warn:void 0}),Z(Ke,{}),Z(wo,{k:"\u4ECA\u65E5",v:s!==null?`\xA5${s.toFixed(2)}`:"\u2014"}),Z(Ke,{}),Z(wo,{k:"\u4F1A\u8BDD",v:i>0?`\xA5${i.toFixed(4)}`:"\u2014"})]}),C]})}p();import{Box as bb,Text as kb}from"ink";import{useEffect as wb,useRef as Tb,useState as Sb}from"react";import{jsx as Kp}from"react/jsx-runtime";var Cb=[" \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"],Ll=22,_b=120,vb="#6185f6";function Xp({panelWidth:e}){let t=Tb(e),[n,r]=Sb(0);wb(()=>{let l=setInterval(()=>{t.current-=1,t.current<=-Ll&&(t.current=e),r(c=>c+1)},_b);return()=>clearInterval(l)},[e]);let o=t.current;if(o>=e)return null;let s=Math.max(0,-o),i=Math.max(0,o+Ll-e),a=Math.max(0,o);return Kp(bb,{alignSelf:"flex-start",width:e,flexDirection:"column",alignItems:"flex-start",marginLeft:a,children:Cb.map((l,c)=>Kp(kb,{color:vb,bold:!0,children:l.slice(s,Ll-i)},c))})}p();import{Box as qc,Text as Yo}from"ink";import{useEffect as nS,useState as rS}from"react";p();p();p();p();function Rb(e){return Wl(e)}function Wl(e){return Array.isArray(e)?Ab(e):e instanceof RegExp?e:typeof e=="object"?Eb(e):e}function Ab(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Wl(e[n]);return t}function Eb(e){let t={};for(let n in e)t[n]=Wl(e[n]);return t}function of(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function sf(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?sf(e.substring(0,e.length-1)):e.substr(~t+1)}var Ml=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ni=class{static hasCaptures(e){return e===null?!1:(Ml.lastIndex=0,Ml.test(e))}static replaceCaptures(e,t,n){return e.replace(Ml,(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 af(e,t){return e<t?-1:e>t?1:0}function lf(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=af(e[o],t[o]);if(s!==0)return s}return 0}return n-r}function Jp(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 cf(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var uf=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}},_o=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme($b(e),t)}static createFromParsedTheme(e,t){return Mb(e,t)}_cachedMatchRoot=new uf(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=>Ib(e.parent,o.parentScopes));return r?new df(r.fontStyle,r.foreground,r.background):null}},Ol=class ri{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(let r of n)t=new ri(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new ri(n,t[r]);return n}push(t){return new ri(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 Ib(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&&!Pb(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Pb(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var df=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function $b(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 f=0,h=d.length;f<h;f++)switch(d[f]){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"&&Jp(i.settings.foreground)&&(c=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Jp(i.settings.background)&&(u=i.settings.background);for(let d=0,f=a.length;d<f;d++){let m=a[d].trim().split(" "),g=m[m.length-1],b=null;m.length>1&&(b=m.slice(0,m.length-1),b.reverse()),n[r++]=new Lb(g,b,o,l,c,u)}}return n}var Lb=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}},xe=(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))(xe||{});function Mb(e,t){e.sort((l,c)=>{let u=af(l.scope,c.scope);return u!==0||(u=lf(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 Ob(t),i=new df(n,s.getId(r),s.getId(o)),a=new Nb(new Nl(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 _o(s,i,a)}var Ob=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)}},Db=Object.freeze([]),Nl=class pf{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,o,s){this.scopeDepth=t,this.parentScopes=n||Db,this.fontStyle=r,this.foreground=o,this.background=s}clone(){return new pf(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)}},Nb=class Bl{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(Bl._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 Bl(this._mainRule.clone(),Nl.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(lf(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 Nl(t,n,r,o,s))}},Sn=class ht{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let n=ht.getLanguageId(t),r=ht.getTokenType(t),o=ht.getFontStyle(t),s=ht.getForeground(t),i=ht.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=ht.getLanguageId(t),c=ht.getTokenType(t),u=ht.containsBalancedBrackets(t)?1:0,d=ht.getFontStyle(t),f=ht.getForeground(t),h=ht.getBackground(t);return n!==0&&(l=n),r!==8&&(c=r),o!==null&&(u=o?1:0),s!==-1&&(d=s),i!==0&&(f=i),a!==0&&(h=a),(l<<0|c<<8|u<<10|d<<11|f<<15|h<<24)>>>0}};function si(e,t){let n=[],r=Bb(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(Zp(o)){let l=[];do l.push(o),o=r.next();while(Zp(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 Zp(e){return!!e&&!!e.match(/[\w\.:]+/)}function Bb(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 ff(e){typeof e.dispose=="function"&&e.dispose()}var vo=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Gb=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Fb=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))}},jb=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new vo(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Fb;for(let n of e)Ub(n,this.initialScopeName,this.repo,t);for(let n of t.references)if(n instanceof vo){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 Ub(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 vo?oi({baseGrammar:s,selfGrammar:o},r):Gl(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 vo(a))}function Gl(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];ii([r],t,n)}}function oi(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ii(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ii(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ii(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let o=r.repository?of({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&ii(r.patterns,{...t,repository:o},n);let s=r.include;if(!s)continue;let i=mf(s);switch(i.kind){case 0:oi({...t,selfGrammar:t.baseGrammar},n);break;case 1:oi(t,n);break;case 2:Gl(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?Gl(i.ruleName,l,n):oi(l,n)}else i.kind===4?n.add(new Gb(i.scopeName,i.ruleName)):n.add(new vo(i.scopeName));break}}}var Wb=class{kind=0},Hb=class{kind=1},Vb=class{constructor(e){this.ruleName=e}kind=2},zb=class{constructor(e){this.scopeName=e}kind=3},qb=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function mf(e){if(e==="$base")return new Wb;if(e==="$self")return new Hb;let t=e.indexOf("#");if(t===-1)return new zb(e);if(t===0)return new Vb(e.substring(1));{let n=e.substring(0,t),r=e.substring(t+1);return new qb(n,r)}}var Kb=/\\(\d+)/,Yp=/\\(\d+)/g;var Xb=-1,hf=-2;var Eo=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=ni.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=ni.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${sf(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:ni.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ni.replaceCaptures(this._contentName,e,t)}},Jb=class extends Eo{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!")}},Zb=class extends Eo{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,o){super(e,t,n,null),this._match=new Ro(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 Ao,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Qp=class extends Eo{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 Ao,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Fl=class extends Eo{_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 Ro(o,this.id),this.beginCaptures=s,this._end=new Ro(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 Ao;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}},ai=class extends Eo{_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 Ro(o,this.id),this.beginCaptures=s,this.whileCaptures=a,this._while=new Ro(i,hf),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 Ao;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 Ao,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},gf=class Ue{static createCaptureRule(t,n,r,o,s){return t.registerRule(i=>new Jb(n,i,r,o,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(o=>{if(t.id=o,t.match)return new Zb(t.$vscodeTextmateLocation,t.id,t.name,t.match,Ue._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=of({},r,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Qp(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Ue._compilePatterns(s,n,r))}return t.while?new ai(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ue._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Ue._compileCaptures(t.whileCaptures||t.captures,n,r),Ue._compilePatterns(t.patterns,n,r)):new Fl(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ue._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Ue._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Ue._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=Ue.getCompiledRuleId(t[i],n,r)),o[a]=Ue.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=mf(a.include);switch(c.kind){case 0:case 1:l=Ue.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=Ue.getCompiledRuleId(u,n,r));break;case 3:case 4:let d=c.scopeName,f=c.kind===4?c.ruleName:null,h=n.getExternalGrammar(d,r);if(h)if(f){let m=h.repository[f];m&&(l=Ue.getCompiledRuleId(m,n,h.repository))}else l=Ue.getCompiledRuleId(h.repository.$self,n,h.repository);break}}else l=Ue.getCompiledRuleId(a,n,r);if(l!==-1){let c=n.getRule(l),u=!1;if((c instanceof Qp||c instanceof Fl||c instanceof ai)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;o.push(l)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},Ro=class yf{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=Kb.test(this.source):this.hasBackReferences=!1}clone(){return new yf(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 Yp.lastIndex=0,this.source.replace(Yp,(o,s)=>cf(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}},Ao=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 ef(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 ef(e,r,this._items.map(o=>o.ruleId))}},ef=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(`
23
+ `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Dl=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Yb=class jl{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Dl(t,8),this._embeddedLanguagesMatcher=new Qb(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?jl._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Dl(0,0);_getBasicScopeAttributes=new uf(t=>{let n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Dl(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let n=t.match(jl.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/},Qb=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])=>cf(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])}},VA={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},xf=!1,tf=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function bf(e,t,n,r,o,s,i,a){let l=t.content.length,c=!1,u=-1;if(i){let h=ek(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 tf(o,!0);f()}return new tf(o,!1);function f(){let h=tk(e,t,n,r,o,u);if(!h){s.produce(o,l),c=!0;return}let m=h.captureIndices,g=h.matchedRuleId,b=m&&m.length>0?m[0].end>r:!1;if(g===Xb){let k=o.getRule(e);s.produce(o,m[0].start),o=o.withContentNameScopesList(o.nameScopesList),So(e,t,n,o,s,k.endCaptures,m),s.produce(o,m[0].end);let T=o;if(o=o.parent,u=T.getAnchorPos(),!b&&T.getEnterPos()===r){o=T,s.produce(o,l),c=!0;return}}else{let k=e.getRule(g);s.produce(o,m[0].start);let T=o,A=k.getName(t.content,m),E=o.contentNameScopesList.pushAttributed(A,e);if(o=o.push(g,r,u,m[0].end===l,null,E,E),k instanceof Fl){let I=k;So(e,t,n,o,s,I.beginCaptures,m),s.produce(o,m[0].end),u=m[0].end;let F=I.getContentName(t.content,m),M=E.pushAttributed(F,e);if(o=o.withContentNameScopesList(M),I.endHasBackReferences&&(o=o.withEndRule(I.getEndWithResolvedBackReferences(t.content,m))),!b&&T.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(k instanceof ai){let I=k;So(e,t,n,o,s,I.beginCaptures,m),s.produce(o,m[0].end),u=m[0].end;let F=I.getContentName(t.content,m),M=E.pushAttributed(F,e);if(o=o.withContentNameScopesList(M),I.whileHasBackReferences&&(o=o.withEndRule(I.getWhileWithResolvedBackReferences(t.content,m))),!b&&T.hasSameRuleAs(o)){o=o.pop(),s.produce(o,l),c=!0;return}}else if(So(e,t,n,o,s,k.captures,m),s.produce(o,m[0].end),o=o.pop(),!b){o=o.safePop(),s.produce(o,l),c=!0;return}}m[0].end>r&&(r=m[0].end,n=!1)}}function ek(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 ai&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){let{ruleScanner:c,findOptions:u}=ok(l.rule,e,l.stack.endRule,n,r===i),d=c.findNextMatchSync(t,r,u);if(d){if(d.ruleId!==hf){o=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),So(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 tk(e,t,n,r,o,s){let i=nk(e,t,n,r,o,s),a=e.getInjections();if(a.length===0)return i;let l=rk(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 nk(e,t,n,r,o,s){let i=o.getRule(e),{ruleScanner:a,findOptions:l}=kf(i,e,o.endRule,n,r===s),c=a.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function rk(e,t,n,r,o,s,i){let a=Number.MAX_VALUE,l=null,c,u=0,d=s.contentNameScopesList.getScopeNames();for(let f=0,h=e.length;f<h;f++){let m=e[f];if(!m.matcher(d))continue;let g=t.getRule(m.ruleId),{ruleScanner:b,findOptions:k}=kf(g,t,null,r,o===i),T=b.findNextMatchSync(n,o,k);if(!T)continue;let A=T.captureIndices[0].start;if(!(A>=a)&&(a=A,l=T.captureIndices,c=T.ruleId,u=m.priority,a===o))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function kf(e,t,n,r,o){if(xf){let i=e.compile(t,n),a=wf(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileAG(t,n,r,o),findOptions:0}}function ok(e,t,n,r,o){if(xf){let i=e.compileWhile(t,n),a=wf(r,o);return{ruleScanner:i,findOptions:a}}return{ruleScanner:e.compileWhileAG(t,n,r,o),findOptions:0}}function wf(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function So(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 f=s[d];if(f===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),f.retokenizeCapturedWithRuleId){let g=f.getName(a,i),b=r.contentNameScopesList.pushAttributed(g,e),k=f.getContentName(a,i),T=b.pushAttributed(k,e),A=r.push(f.retokenizeCapturedWithRuleId,h.start,-1,!1,null,b,T),E=e.createOnigString(a.substring(0,h.end));bf(e,E,n&&h.start===0,h.start,A,o,!1,0),ff(E);continue}let m=f.getName(a,i);if(m!==null){let b=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(m,e);c.push(new sk(b,h.end))}}for(;c.length>0;)o.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var sk=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function ik(e,t,n,r,o,s,i,a){return new lk(e,t,n,r,o,s,i,a)}function nf(e,t,n,r,o){let s=si(t,li),i=gf.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 li(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(ak(t[o],r))return n=o+1,!0;return!1})}function ak(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 lk=class{constructor(e,t,n,r,o,s,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=a,this._basicScopeAttributesProvider=new Yb(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=rf(t,null),this._injections=null,this._tokenTypeMatchers=[],o)for(let l of Object.keys(o)){let c=si(l,li);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)nf(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&&nf(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]=rf(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=gf.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!t||t===Ul.NULL){o=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),d=Sn.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null),h;f?h=Co.createRootAndLookUpScopeName(f,d,this):h=Co.createRoot("unknown",d),t=new Ul(null,this._rootId,-1,-1,!1,null,h,h)}else o=!1,t.reset();e=e+`
24
+ `;let s=this.createOnigString(e),i=s.content.length,a=new uk(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=bf(this,s,o,0,t,a,!0,r);return ff(s),{lineLength:i,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function rf(e,t){return e=Rb(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 Co=class Bt{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=Ol.push(o,s.scopeNames),r=new Bt(r,o,s.encodedTokenAttributes);return r}static createRoot(t,n){return new Bt(null,new Ol(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let o=r.getMetadataForScope(t),s=new Ol(null,t),i=r.themeProvider.themeMatch(s),a=Bt.mergeAttributes(n,o,i);return new Bt(null,s,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Bt.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),Sn.set(t,n.languageId,n.tokenType,null,o,s,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Bt._pushAttributed(this,t,n);let r=t.split(/ /g),o=this;for(let s of r)o=Bt._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=Bt.mergeAttributes(t.tokenAttributes,o,i);return new Bt(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}},Ul=class Jn{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 Jn(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:Jn._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Co.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(){Jn._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,o,s,i,a){return new Jn(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 Jn(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=Co.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new Jn(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Co.fromExtension(r,n.contentNameScopesList))}},ck=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):si(n,li).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>si(n,li).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}},uk=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=Sn.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(s))}if(o&&(r=Sn.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}},dk=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,ik(e,s,t,n,r,o,this,this._onigLib))}return this._grammars.get(e)}},Tf=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new dk(_o.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(_o.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 ck(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,o){let s=new jb(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)}},ci=Ul.NULL;p();var zl=fx(Ef(),1),$r=zl.default,{Ansis:AE,fg:EE,bg:IE,rgb:PE,bgRgb:$E,hex:LE,bgHex:ME,reset:OE,inverse:DE,hidden:NE,visible:BE,link:GE,bold:FE,dim:jE,italic:UE,underline:WE,strikethrough:HE,black:VE,red:zE,green:qE,yellow:KE,blue:XE,magenta:JE,cyan:ZE,white:YE,gray:QE,redBright:e1,greenBright:t1,yellowBright:n1,blueBright:r1,magentaBright:o1,cyanBright:s1,whiteBright:i1,bgBlack:a1,bgRed:l1,bgGreen:c1,bgYellow:u1,bgBlue:d1,bgMagenta:p1,bgCyan:f1,bgWhite:m1,bgGray:h1,bgRedBright:g1,bgGreenBright:y1,bgYellowBright:x1,bgBlueBright:b1,bgMagentaBright:k1,bgCyanBright:w1,bgWhiteBright:T1}=zl.default;p();p();var ql=Object.defineProperty,yk=Object.getOwnPropertyDescriptor,xk=Object.getOwnPropertyNames,bk=Object.prototype.hasOwnProperty,Lr=(e,t)=>{let n={};for(var r in e)ql(n,r,{get:e[r],enumerable:!0});return t||ql(n,Symbol.toStringTag,{value:"Module"}),n},If=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=xk(t),s=0,i=o.length,a;s<i;s++)a=o[s],!bk.call(e,a)&&a!==n&&ql(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=yk(t,a))||r.enumerable});return e},di=(e,t,n)=>(If(e,t,"default"),n&&If(n,t,"default"));p();var Mr=[{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"))}],Io=Object.fromEntries(Mr.map(e=>[e.id,e.import])),Po=Object.fromEntries(Mr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),$o={...Io,...Po};p();var Lo=[{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"))}],Mo=Object.fromEntries(Lo.map(e=>[e.id,e.import]));p();p();var Yl={};ap(Yl,{createOnigurumaEngine:()=>Zl,getDefaultWasmLoader:()=>Ok,loadWasm:()=>hi,setDefaultWasmLoader:()=>Mk});p();var Jl=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function kk(){return 2147483648}function wk(){return typeof performance<"u"?performance.now():Date.now()}var Tk=(e,t)=>e+(t-e%t)%t;async function Sk(e){let t,n,r={};function o(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function s(h,m,g){r.HEAPU8.copyWithin(h,m,m+g)}function i(h){try{return t.grow(h-n.byteLength+65535>>>16),o(t.buffer),1}catch{}}function a(h){let m=r.HEAPU8.length;h=h>>>0;let g=kk();if(h>g)return!1;for(let b=1;b<=4;b*=2){let k=m*(1+.2/b);k=Math.min(k,h+100663296);let T=Math.min(g,Tk(Math.max(h,k),65536));if(i(T))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function c(h,m,g=1024){let b=m+g,k=m;for(;h[k]&&!(k>=b);)++k;if(k-m>16&&h.buffer&&l)return l.decode(h.subarray(m,k));let T="";for(;m<k;){let A=h[m++];if(!(A&128)){T+=String.fromCharCode(A);continue}let E=h[m++]&63;if((A&224)===192){T+=String.fromCharCode((A&31)<<6|E);continue}let I=h[m++]&63;if((A&240)===224?A=(A&15)<<12|E<<6|I:A=(A&7)<<18|E<<12|I<<6|h[m++]&63,A<65536)T+=String.fromCharCode(A);else{let F=A-65536;T+=String.fromCharCode(55296|F>>10,56320|F&1023)}}return T}function u(h,m){return h?c(r.HEAPU8,h,m):""}let d={emscripten_get_now:wk,emscripten_memcpy_big:s,emscripten_resize_heap:a,fd_write:()=>0};async function f(){let m=await e({env:d,wasi_snapshot_preview1:d});t=m.memory,o(t.buffer),Object.assign(r,m),r.UTF8ToString=u}return await f(),r}var Ck=Object.defineProperty,_k=(e,t,n)=>t in e?Ck(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ee=(e,t,n)=>_k(e,typeof t!="symbol"?t+"":t,n),Le=null;function vk(e){throw new Jl(e.UTF8ToString(e.getLastOnigError()))}var fi=class e{constructor(t){Ee(this,"utf16Length"),Ee(this,"utf8Length"),Ee(this,"utf16Value"),Ee(this,"utf8Value"),Ee(this,"utf16OffsetToUtf8"),Ee(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,f=!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,f=!0)}o&&(s[c]=l,f&&(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),f&&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}},mi=class Gt{constructor(t){if(Ee(this,"id",++Gt.LAST_ID),Ee(this,"_onigBinding"),Ee(this,"content"),Ee(this,"utf16Length"),Ee(this,"utf8Length"),Ee(this,"utf16OffsetToUtf8"),Ee(this,"utf8OffsetToUtf16"),Ee(this,"ptr"),!Le)throw new Jl("Must invoke loadWasm first.");this._onigBinding=Le,this.content=t;let n=new fi(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Gt._sharedPtrInUse?(Gt._sharedPtr||(Gt._sharedPtr=Le.omalloc(1e4)),Gt._sharedPtrInUse=!0,Le.HEAPU8.set(n.utf8Value,Gt._sharedPtr),this.ptr=Gt._sharedPtr):this.ptr=n.createString(Le)}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===Gt._sharedPtr?Gt._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Ee(mi,"LAST_ID",0);Ee(mi,"_sharedPtr",0);Ee(mi,"_sharedPtrInUse",!1);var Pf=mi,Xl=class{constructor(t){if(Ee(this,"_onigBinding"),Ee(this,"_ptr"),!Le)throw new Jl("Must invoke loadWasm first.");let n=[],r=[];for(let a=0,l=t.length;a<l;a++){let c=new fi(t[a]);n[a]=c.createString(Le),r[a]=c.utf8Length}let o=Le.omalloc(4*t.length);Le.HEAPU32.set(n,o/4);let s=Le.omalloc(4*t.length);Le.HEAPU32.set(r,s/4);let i=Le.createOnigScanner(o,s,t.length);for(let a=0,l=t.length;a<l;a++)Le.ofree(n[a]);Le.ofree(s),Le.ofree(o),i===0&&vk(Le),this._onigBinding=Le,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 Pf(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 f=0;f<u;f++){let h=t.convertUtf8OffsetToUtf16(a[l++]),m=t.convertUtf8OffsetToUtf16(a[l++]);d[f]={start:h,end:m,length:m-h}}return{index:c,captureIndices:d}}};function Rk(e){return typeof e.instantiator=="function"}function Ak(e){return typeof e.default=="function"}function Ek(e){return typeof e.data<"u"}function Ik(e){return typeof Response<"u"&&e instanceof Response}function Pk(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 pi;function hi(e){if(pi)return pi;async function t(){Le=await Sk(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),Rk(r)?r=await r.instantiator(n):Ak(r)?r=await r.default(n):(Ek(r)&&(r=r.data),Ik(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await $k(r)(n):r=await Lk(r)(n):Pk(r)?r=await Kl(r)(n):r instanceof WebAssembly.Module?r=await Kl(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Kl(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return pi=t(),pi}function Kl(e){return t=>WebAssembly.instantiate(e,t)}function $k(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Lk(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var $f;function Mk(e){$f=e}function Ok(){return $f}async function Zl(e){return e&&await hi(e),{createScanner(t){return new Xl(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new Pf(t)}}}var Ql=Lr({});di(Ql,Yl);p();p();var ue=class extends Error{constructor(e){super(e),this.name="ShikiError"}};p();function Do(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 Kt(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Nf(e){return Array.isArray(e)?e:[e]}async function ec(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function No(e){return!e||["plaintext","txt","text","plain"].includes(e)}function tc(e){return e==="ansi"||No(e)}function Bo(e){return e==="none"}function nc(e){return Bo(e)}var Dk=/(\r?\n)/g;function Or(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(Dk),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 Lf={light:"#333333",dark:"#bbbbbb"},Mf={light:"#fffffe",dark:"#1e1e1e"},Of="__shiki_resolved";function gi(e){if(e?.[Of])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"?Lf.light:Lf.dark),n||(n=t.type==="light"?Mf.light:Mf.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,Of,{enumerable:!1,writable:!1,value:!0}),t}async function Bf(e){return[...new Set((await Promise.all(e.filter(t=>!tc(t)).map(async t=>await ec(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Gf(e){return(await Promise.all(e.map(async t=>nc(t)?null:gi(await ec(t))))).filter(t=>!!t)}function Ff(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 ue(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Nk=class extends Tf{_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=gi(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=_o.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Ff(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 ue(`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))}},Bk=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}},Oo=0;function rc(e){Oo+=1,e.warnings!==!1&&Oo>=10&&Oo%10===0&&console.warn(`[Shiki] ${Oo} 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 ue("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(gi),o=new Nk(new Bk(e.engine,n),r,n,e.langAlias),s;function i(T){return Ff(T,e.langAlias)}function a(T){b();let A=o.getGrammar(typeof T=="string"?T:T.name);if(!A)throw new ue(`Language \`${T}\` not found, you may need to load it first`);return A}function l(T){if(T==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};b();let A=o.getTheme(T);if(!A)throw new ue(`Theme \`${T}\` not found, you may need to load it first`);return A}function c(T){b();let A=l(T);return s!==T&&(o.setTheme(A),s=T),{theme:A,colorMap:o.getColorMap()}}function u(){return b(),o.getLoadedThemes()}function d(){return b(),o.getLoadedLanguages()}function f(...T){b(),o.loadLanguages(T.flat(1))}async function h(...T){return f(await Bf(T))}function m(...T){b();for(let A of T.flat(1))o.loadTheme(A)}async function g(...T){return b(),m(await Gf(T))}function b(){if(t)throw new ue("Shiki instance has been disposed")}function k(){t||(t=!0,o.dispose(),Oo-=1)}return{setTheme:c,getTheme:l,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:f,loadTheme:g,loadThemeSync:m,dispose:k,[Symbol.dispose]:k}}async function oc(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Gf(e.themes||[]),Bf(e.langs||[]),e.engine]);return rc({...e,themes:t,langs:n,engine:r})}var jf=new WeakMap;function Go(e,t){jf.set(e,t)}function Dr(e){return jf.get(e)}var yi=class Uf{_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 Uf(Object.fromEntries(Nf(n).map(r=>[r,ci])),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 Gk(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Gk(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 Fk(e,t){if(!(e instanceof yi))throw new ue("Invalid grammar state");return e.getInternalStack(t)}var jk=/,/,Uk=/ /;function sc(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(No(e.resolveLangAlias(n.lang||"text"))||Bo(r))return Or(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 ue(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new ue(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return Hf(t,i,o,s,n)}function Wf(...e){if(e.length===2)return Dr(e[1]);let[t,n,r={}]=e,{lang:o="text",theme:s=t.getLoadedThemes()[0]}=r;if(No(o)||Bo(s))throw new ue("Plain language does not have grammar state");if(o==="ansi")throw new ue("ANSI language does not have grammar state");let{theme:i,colorMap:a}=t.setTheme(s),l=t.getLanguage(o);return new yi(ic(n,l,i,a,r).stateStack,l.name,i.name)}function Hf(e,t,n,r,o){let s=ic(e,t,n,r,o),i=new yi(s.stateStack,t.name,n.name);return Go(s.tokens,i),s.tokens}function ic(e,t,n,r,o){let s=Do(n,o),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=o,c=Or(e),u=o.grammarState?Fk(o.grammarState,n.name)??ci:o.grammarContextCode!=null?ic(o.grammarContextCode,t,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:ci,d=[],f=[];for(let h=0,m=c.length;h<m;h++){let[g,b]=c[h];if(g===""){d=[],f.push([]);continue}if(i>0&&g.length>=i){d=[],f.push([{content:g,offset:b,color:"",fontStyle:0}]);continue}let k,T,A;l&&l!=="tokenType"&&(k=t.tokenizeLine(g,u,a),T=k.tokens,A=0);let E=t.tokenizeLine2(g,u,a),I=E.tokens.length/2;for(let F=0;F<I;F++){let M=E.tokens[2*F],C=F+1<I?E.tokens[2*F+2]:g.length;if(M===C)continue;let N=E.tokens[2*F+1],oe=Kt(r[Sn.getForeground(N)],s),j=Sn.getFontStyle(N),O={content:g.substring(M,C),offset:b+M,color:oe,fontStyle:j};if(l==="tokenType")O.type=Sn.getTokenType(N);else if(l){let ce=[];if(l!=="scopeName")for(let ne of n.settings){let K;switch(typeof ne.scope){case"string":K=ne.scope.split(jk).map(he=>he.trim());break;case"object":K=ne.scope;break;default:continue}ce.push({settings:ne,selectors:K.map(he=>he.split(Uk))})}O.explanation=[];let fe=0;for(;M+fe<C;){let ne=T[A],K=g.substring(ne.startIndex,ne.endIndex);fe+=K.length,O.explanation.push({content:K,scopes:l==="scopeName"?Wk(ne.scopes):Hk(ce,ne.scopes)}),A+=1}}d.push(O)}f.push(d),d=[],u=E.ruleStack}return{tokens:f,stateStack:u}}function Wk(e){return e.map(t=>({scopeName:t}))}function Hk(e,t){let n=[];for(let r=0,o=t.length;r<o;r++){let s=t[r];n[r]={scopeName:s,themeMatches:zk(e,s,t.slice(0,r))}}return n}function Df(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Vk(e,t,n){if(!Df(e.at(-1),t))return!1;let r=e.length-2,o=n.length-1;for(;r>=0&&o>=0;)Df(e[r],n[o])&&(r-=1),o-=1;return r===-1}function zk(e,t,n){let r=[];for(let{selectors:o,settings:s}of e)for(let i of o)if(Vk(i,t,n)){r.push(s);break}return r}function xi(e,t,n,r=sc){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:Dr(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=qk(...s.map(c=>c.tokens)),a=i[0].map((c,u)=>c.map((d,f)=>{let h={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=d.explanation),i.forEach((m,g)=>{let{content:b,explanation:k,offset:T,...A}=m[u][f];h.variants[o[g].color]=A}),h})),l=s[0].state?new yi(Object.fromEntries(s.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),s[0].state.lang):void 0;return l&&Go(a,l),a}function qk(...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 Vf=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];p();p();p();var Xt=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Xt.prototype.normal={};Xt.prototype.property={};Xt.prototype.space=void 0;function ac(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Xt(n,r,t)}p();p();p();function Fo(e){return e.toLowerCase()}p();p();var Me=class{constructor(t,n){this.attribute=n,this.property=t}};Me.prototype.attribute="";Me.prototype.booleanish=!1;Me.prototype.boolean=!1;Me.prototype.commaOrSpaceSeparated=!1;Me.prototype.commaSeparated=!1;Me.prototype.defined=!1;Me.prototype.mustUseProperty=!1;Me.prototype.number=!1;Me.prototype.overloadedBoolean=!1;Me.prototype.property="";Me.prototype.spaceSeparated=!1;Me.prototype.space=void 0;var jo={};ap(jo,{boolean:()=>J,booleanish:()=>be,commaOrSpaceSeparated:()=>Xe,commaSeparated:()=>Jt,number:()=>L,overloadedBoolean:()=>bi,spaceSeparated:()=>le});p();var Kk=0,J=Zn(),be=Zn(),bi=Zn(),L=Zn(),le=Zn(),Jt=Zn(),Xe=Zn();function Zn(){return 2**++Kk}var lc=Object.keys(jo),Yn=class extends Me{constructor(t,n,r,o){let s=-1;if(super(t,n),zf(this,"space",o),typeof r=="number")for(;++s<lc.length;){let i=lc[s];zf(this,lc[s],(r&jo[i])===jo[i])}}};Yn.prototype.defined=!0;function zf(e,t,n){n&&(e[t]=n)}function yt(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let s=new Yn(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Fo(r)]=r,n[Fo(s.attribute)]=r}return new Xt(t,n,e.space)}var cc=yt({properties:{ariaActiveDescendant:null,ariaAtomic:be,ariaAutoComplete:null,ariaBusy:be,ariaChecked:be,ariaColCount:L,ariaColIndex:L,ariaColSpan:L,ariaControls:le,ariaCurrent:null,ariaDescribedBy:le,ariaDetails:null,ariaDisabled:be,ariaDropEffect:le,ariaErrorMessage:null,ariaExpanded:be,ariaFlowTo:le,ariaGrabbed:be,ariaHasPopup:null,ariaHidden:be,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:le,ariaLevel:L,ariaLive:null,ariaModal:be,ariaMultiLine:be,ariaMultiSelectable:be,ariaOrientation:null,ariaOwns:le,ariaPlaceholder:null,ariaPosInSet:L,ariaPressed:be,ariaReadOnly:be,ariaRelevant:null,ariaRequired:be,ariaRoleDescription:le,ariaRowCount:L,ariaRowIndex:L,ariaRowSpan:L,ariaSelected:be,ariaSetSize:L,ariaSort:null,ariaValueMax:L,ariaValueMin:L,ariaValueNow:L,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});p();p();p();function ki(e,t){return t in e?e[t]:t}function wi(e,t){return ki(e,t.toLowerCase())}var qf=yt({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Jt,acceptCharset:le,accessKey:le,action:null,allow:null,allowFullScreen:J,allowPaymentRequest:J,allowUserMedia:J,alpha:J,alt:null,as:null,async:J,autoCapitalize:null,autoComplete:le,autoFocus:J,autoPlay:J,blocking:le,capture:null,charSet:null,checked:J,cite:null,className:le,closedBy:null,colorSpace:null,cols:L,colSpan:L,command:null,commandFor:null,content:null,contentEditable:be,controls:J,controlsList:le,coords:L|Jt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:J,defer:J,dir:null,dirName:null,disabled:J,download:bi,draggable:be,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:J,formTarget:null,headers:le,height:L,hidden:bi,high:L,href:null,hrefLang:null,htmlFor:le,httpEquiv:le,id:null,imageSizes:null,imageSrcSet:null,inert:J,inputMode:null,integrity:null,is:null,isMap:J,itemId:null,itemProp:le,itemRef:le,itemScope:J,itemType:le,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:J,low:L,manifest:null,max:null,maxLength:L,media:null,method:null,min:null,minLength:L,multiple:J,muted:J,name:null,nonce:null,noModule:J,noValidate:J,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:J,optimum:L,pattern:null,ping:le,placeholder:null,playsInline:J,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:J,referrerPolicy:null,rel:le,required:J,reversed:J,rows:L,rowSpan:L,sandbox:le,scope:null,scoped:J,seamless:J,selected:J,shadowRootClonable:J,shadowRootCustomElementRegistry:J,shadowRootDelegatesFocus:J,shadowRootMode:null,shadowRootSerializable:J,shape:null,size:L,sizes:null,slot:null,span:L,spellCheck:be,src:null,srcDoc:null,srcLang:null,srcSet:null,start:L,step:null,style:null,tabIndex:L,target:null,title:null,translate:null,type:null,typeMustMatch:J,useMap:null,value:be,width:L,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:le,axis:null,background:null,bgColor:null,border:L,borderColor:null,bottomMargin:L,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:J,declare:J,event:null,face:null,frame:null,frameBorder:null,hSpace:L,leftMargin:L,link:null,longDesc:null,lowSrc:null,marginHeight:L,marginWidth:L,noResize:J,noHref:J,noShade:J,noWrap:J,object:null,profile:null,prompt:null,rev:null,rightMargin:L,rules:null,scheme:null,scrolling:be,standby:null,summary:null,text:null,topMargin:L,valueType:null,version:null,vAlign:null,vLink:null,vSpace:L,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:J,disablePictureInPicture:J,disableRemotePlayback:J,exportParts:Jt,part:le,prefix:null,property:null,results:L,security:null,unselectable:null},space:"html",transform:wi});p();var Kf=yt({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:Xe,accentHeight:L,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:L,amplitude:L,arabicForm:null,ascent:L,attributeName:null,attributeType:null,azimuth:L,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:L,by:null,calcMode:null,capHeight:L,className:le,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:L,diffuseConstant:L,direction:null,display:null,dur:null,divisor:L,dominantBaseline:null,download:J,dx:null,dy:null,edgeMode:null,editable:null,elevation:L,enableBackground:null,end:null,event:null,exponent:L,externalResourcesRequired:null,fill:null,fillOpacity:L,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:Jt,g2:Jt,glyphName:Jt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:L,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:L,horizOriginX:L,horizOriginY:L,id:null,ideographic:L,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:L,k:L,k1:L,k2:L,k3:L,k4:L,kernelMatrix:Xe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:L,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:L,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:L,overlineThickness:L,paintOrder:null,panose1:null,path:null,pathLength:L,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:le,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:L,pointsAtY:L,pointsAtZ:L,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xe,rev:Xe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xe,requiredFeatures:Xe,requiredFonts:Xe,requiredFormats:Xe,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:L,specularExponent:L,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:L,strikethroughThickness:L,string:null,stroke:null,strokeDashArray:Xe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:L,strokeOpacity:L,strokeWidth:null,style:null,surfaceScale:L,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xe,tabIndex:L,tableValues:null,target:null,targetX:L,targetY:L,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:L,underlineThickness:L,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:L,values:null,vAlphabetic:L,vMathematical:L,vectorEffect:null,vHanging:L,vIdeographic:L,version:null,vertAdvY:L,vertOriginX:L,vertOriginY:L,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:L,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ki});p();var uc=yt({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 dc=yt({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wi});p();var pc=yt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});p();var Xk=/[A-Z]/g,Xf=/-[a-z]/g,Jk=/^data[-\w.:]+$/i;function fc(e,t){let n=Fo(t),r=t,o=Me;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Jk.test(t)){if(t.charAt(4)==="-"){let s=t.slice(5).replace(Xf,Yk);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{let s=t.slice(4);if(!Xf.test(s)){let i=s.replace(Xk,Zk);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}o=Yn}return new o(r,t)}function Zk(e){return"-"+e.toLowerCase()}function Yk(e){return e.charAt(1).toUpperCase()}var Jf=ac([cc,qf,uc,dc,pc],"html"),Ti=ac([cc,Kf,uc,dc,pc],"svg");p();p();var Zf={}.hasOwnProperty;function Yf(e,t){let n=t||{};function r(o,...s){let i=r.invalid,a=r.handlers;if(o&&Zf.call(o,e)){let l=String(o[e]);i=Zf.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 Qk=/["&'<>`]/g,e0=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,t0=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,n0=/[|\\{}()[\]^$+*?.]/g,Qf=new WeakMap;function em(e,t){if(e=e.replace(t.subset?r0(t.subset):Qk,r),t.subset||t.escapeOnly)return e;return e.replace(e0,n).replace(t0,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 r0(e){let t=Qf.get(e);return t||(t=o0(e),Qf.set(e,t)),t}function o0(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(n0,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}p();p();var s0=/[\dA-Fa-f]/;function tm(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!s0.test(String.fromCharCode(t))?r:r+";"}p();var i0=/\d/;function nm(e,t,n){let r="&#"+String(e);return n&&t&&!i0.test(String.fromCharCode(t))?r:r+";"}p();p();var rm=["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 Si={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 om=["cent","copy","divide","gt","lt","not","para","times"];var sm={}.hasOwnProperty,mc={},Ci;for(Ci in Si)sm.call(Si,Ci)&&(mc[Si[Ci]]=Ci);var a0=/[^\dA-Za-z]/;function im(e,t,n,r){let o=String.fromCharCode(e);if(sm.call(mc,o)){let s=mc[o],i="&"+s;return n&&rm.includes(s)&&!om.includes(s)&&(!r||t&&t!==61&&a0.test(String.fromCharCode(t)))?i:i+";"}return""}function am(e,t,n){let r=tm(e,t,n.omitOptionalSemicolons),o;if((n.useNamedReferences||n.useShortestReferences)&&(o=im(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!o)&&n.useShortestReferences){let s=nm(e,t,n.omitOptionalSemicolons);s.length<r.length&&(r=s)}return o&&(!n.useShortestReferences||o.length<r.length)?o:r}function Zt(e,t){return em(e,Object.assign({format:am},t))}var l0=/^>|^->|<!--|-->|--!>|<!-$/g,c0=[">"],u0=["<",">"];function lm(e,t,n,r){return r.settings.bogusComments?"<?"+Zt(e.value,Object.assign({},r.settings.characterReferences,{subset:c0}))+">":"<!--"+e.value.replace(l0,o)+"-->";function o(s){return Zt(s,Object.assign({},r.settings.characterReferences,{subset:u0}))}}p();function cm(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}p();p();function hc(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 um(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}p();function dm(e){return e.join(" ").trim()}p();p();p();var d0=/[ \t\n\f\r]/g;function Qn(e){return typeof e=="object"?e.type==="text"?pm(e.value):!1:pm(e)}function pm(e){return e.replace(d0,"")===""}p();var Te=fm(1),gc=fm(-1),p0=[];function fm(e){return t;function t(n,r,o){let s=n?n.children:p0,i=(r||0)+e,a=s[i];if(!o)for(;a&&Qn(a);)i+=e,a=s[i];return a}}p();var f0={}.hasOwnProperty;function _i(e){return t;function t(n,r,o){return f0.call(e,n.tagName)&&e[n.tagName](n,r,o)}}var Uo=_i({body:h0,caption:yc,colgroup:yc,dd:b0,dt:x0,head:yc,html:m0,li:y0,optgroup:k0,option:w0,p:g0,rp:mm,rt:mm,tbody:S0,td:hm,tfoot:C0,th:hm,thead:T0,tr:_0});function yc(e,t,n){let r=Te(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Qn(r.value.charAt(0)))}function m0(e,t,n){let r=Te(n,t);return!r||r.type!=="comment"}function h0(e,t,n){let r=Te(n,t);return!r||r.type!=="comment"}function g0(e,t,n){let r=Te(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 y0(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&r.tagName==="li"}function x0(e,t,n){let r=Te(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function b0(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function mm(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function k0(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function w0(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function T0(e,t,n){let r=Te(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function S0(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function C0(e,t,n){return!Te(n,t)}function _0(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function hm(e,t,n){let r=Te(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}p();var gm=_i({body:A0,colgroup:E0,head:R0,html:v0,tbody:I0});function v0(e){let t=Te(e,-1);return!t||t.type!=="comment"}function R0(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 A0(e){let t=Te(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Qn(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function E0(e,t,n){let r=gc(n,t),o=Te(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Uo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function I0(e,t,n){let r=gc(n,t),o=Te(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Uo(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}var vi={name:[[`
25
25
  \f\r &/=>`.split(""),`
26
26
  \f\r "&'/=>\``.split("")],[`\0
27
27
  \f\r "&'/<=>`.split(""),`\0
@@ -29,10 +29,10 @@ import{a as wn,b as al,c as kn,d as Sr,e as Mt,f as ll,h as cl}from"./chunk-V3LN
29
29
  \f\r &>`.split(""),`\0
30
30
  \f\r "&'<=>\``.split("")],[`\0
31
31
  \f\r "&'<=>\``.split(""),`\0
32
- \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Yf(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=hi);let c=ak(r,e.properties),u=r.all(o.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=o,u&&(i=!1),(c||!s||!Zf(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||!Oo(e,t,n))&&a.push("</"+e.tagName+">"),a.join("")}function ak(e,t){let n=[],r=-1,o;if(t){for(o in t)if(t[o]!==null&&t[o]!==void 0){let s=lk(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 lk(e,t,n){let r=oc(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=Zt(r.attribute,Object.assign({},e.settings.characterReferences,{subset:bi.name[o][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?Vf:zf)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?l:(e.settings.preferUnquoted&&(a=Zt(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:bi.unquoted[o][s]}))),a!==n&&(e.settings.quoteSmart&&ic(n,i)>ic(n,e.alternative)&&(i=e.alternative),a=i+Zt(n,Object.assign({},e.settings.characterReferences,{subset:(i==="'"?bi.single:bi.double)[o][s],attribute:!0}))+i),l+(a&&"="+a))}p();p();var ck=["<","&"];function wi(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Zt(e.value,Object.assign({},r.settings.characterReferences,{subset:ck}))}function Qf(e,t,n,r){return r.settings.allowDangerousHtml?e.value:wi(e,t,n,r)}p();function em(e,t,n,r){return r.all(e)}var tm=$f("type",{invalid:uk,unknown:dk,handlers:{comment:Wf,doctype:Hf,element:Yf,raw:Qf,root:em,text:wi}});function uk(e){throw new Error("Expected node, not `"+e+"`")}function dk(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var pk={},fk={},mk=[];function cc(e,t){let n=t||pk,r=n.quote||'"',o=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:hk,all:gk,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||vf,characterReferences:n.characterReferences||fk,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?hi:Pf,quote:r,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function hk(e,t,n){return tm(e,t,n,this)}function gk(e){let t=[],n=e&&e.children||mk,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}var nm=/\s+/g;function sm(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(nm)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(nm);for(let r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}var yk=/:?lang=["']([^"']+)["']/g,xk=/(?:```|~~~)([\w-]+)/g,bk=/\\begin\{([\w-]+)\}/g,wk=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function kk(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 im(e,t,n){let r=new Set;for(let s of e.matchAll(yk)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(xk)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(bk)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(wk)){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 Sk=["color","background-color"];function Tk(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 Ck(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?Tk(o,s):o})):e}function _k(e,t,n,r,o="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>ki(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),l={},c=(u,d)=>{let f=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return n+t[u]+(d==="color"?"":f)};return i.forEach((u,d)=>{for(let f of a){let h=u[f]||"inherit";if(d===0&&r&&Sk.includes(f))if(r==="light-dark()"&&i.length>1){let m=t.findIndex(w=>w==="light"),g=t.findIndex(w=>w==="dark");if(m===-1||g===-1)throw new ce('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');l[f]=`light-dark(${i[m][f]||"inherit"}, ${i[g][f]||"inherit"})`,o==="css-vars"&&(l[c(d,f)]=h)}else l[f]=h;else o==="css-vars"&&(l[c(d,f)]=h)}}),s.htmlStyle=l,s}function ki(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&ye.Italic&&(t["font-style"]="italic"),e.fontStyle&ye.Bold&&(t["font-weight"]="bold");let n=[];e.fontStyle&ye.Underline&&n.push("underline"),e.fontStyle&ye.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function dc(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function vk(){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 ce(`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 ce(`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 ce(`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=kk(n.source),i=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));Rk(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 Ck(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 ce(`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,f,h){let m=o[u],g="",w=-1,b=-1;if(d===0&&(w=0),f===0&&(b=0),f===Number.POSITIVE_INFINITY&&(b=m.children.length),w===-1||b===-1)for(let v=0;v<m.children.length;v++)g+=am(m.children[v]),w===-1&&g.length===d&&(w=v+1),b===-1&&g.length===f&&(b=v+1);if(w===-1)throw new ce(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(b===-1)throw new ce(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let k=m.children.slice(w,b);if(!h.alwaysWrap&&k.length===m.children.length)a(m,h,"line");else if(!h.alwaysWrap&&k.length===1&&k[0].type==="element")a(k[0],h,"token");else{let v={type:"element",tagName:"span",properties:{},children:k};a(v,h,"wrapper"),m.children.splice(w,k.length,v)}}function i(u,d){o[u]=a(o[u],d,"line")}function a(u,d,f){let h=d.properties||{},m=d.transform||(g=>g);return u.tagName=d.tagName||"span",u.properties={...u.properties,...h,class:u.properties.class},d.properties?.class&&sm(u,d.properties.class),u=m(u,f)||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:f}=u;if(d.line===f.line)s(d.line,d.character,f.character,u);else if(d.line<f.line){s(d.line,d.character,Number.POSITIVE_INFINITY,u);for(let h=d.line+1;h<f.line;h++)l.unshift(()=>i(h,u));s(f.line,0,f.character,u)}}l.forEach(u=>u())}}}function Rk(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new ce(`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 ce(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function am(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(am).join(""):""}var Ak=[vk()];function Si(e){let t=Ek(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Ak]}function Ek(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 Zn=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],uc={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Ik(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 rm(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 Pk(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)uc[r]&&t.push({type:"setDecoration",value:uc[r]});else if(r<=29){let o=uc[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:Zn[r-30]}});else if(r===38){let o=rm(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:Zn[r-40]}});else if(r===48){let o=rm(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:Zn[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Zn[r-100+8]}})}return t}function Lk(){let e=null,t=null,n=new Set;return{parse(r){let o=[],s=0;do{let i=Ik(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=Pk(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 $k={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 Mk(e=$k){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<Zn.length;c++)r.push(t(Zn[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 Ok=/#([0-9a-f]{3,8})/i,Dk=/var\((--[\w-]+-ansi-[\w-]+)\)/,Nk={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 Bk(e,t,n){let r=Eo(e,n),o=Lr(t),s=Mk(Object.fromEntries(Zn.map(a=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||Nk[a]]}))),i=Lk();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=Kt(c,r),u=Kt(u,r),l.decorations.has("dim")&&(c=Fk(c));let d=ye.None;return l.decorations.has("bold")&&(d|=ye.Bold),l.decorations.has("italic")&&(d|=ye.Italic),l.decorations.has("underline")&&(d|=ye.Underline),l.decorations.has("strikethrough")&&(d|=ye.Strikethrough),{content:l.value,offset:a[1],color:c,bgColor:u,fontStyle:d}}))}function Fk(e){let t=e.match(Ok);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(Dk);return n?`var(${n[1]}-dim)`:e}function pc(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:o=e.getLoadedThemes()[0]}=n;if(!Io(r)&&!Po(o)&&r==="ansi"){let{theme:s}=e.setTheme(o);return Bk(s,t,n)}return Jl(e,t,n)}function Ti(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,f=Object.entries(n.themes).filter(b=>b[1]).map(b=>({color:b[0],theme:b[1]})).sort((b,k)=>b.color===c?-1:k.color===c?1:0);if(f.length===0)throw new ce("`themes` option must not be empty");let h=di(e,t,n,pc);if(l=$r(h),c&&c!=="light-dark()"&&!f.some(b=>b.color===c))throw new ce(`\`themes\` option must contain the defaultColor key \`${c}\``);let m=f.map(b=>e.getTheme(b.theme)),g=f.map(b=>b.color);s=h.map(b=>b.map(k=>_k(k,g,u,c,d))),l&&Lo(s,l);let w=f.map(b=>Eo(b.theme,n));o=om(f,m,w,u,c,"fg",d),r=om(f,m,w,u,c,"bg",d),i=`shiki-themes ${m.map(b=>b.name).join(" ")}`,a=c?void 0:[o,r].join(";")}else if("theme"in n){let c=Eo(n.theme,n);s=pc(e,t,n);let u=e.getTheme(n.theme);r=Kt(u.bg,c),o=Kt(u.fg,c),i=u.name,l=$r(s)}else throw new ce("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:o,bg:r,themeName:i,rootStyle:a,grammarState:l}}function om(e,t,n,r,o,s,i){return e.map((a,l)=>{let c=Kt(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"),f=e.findIndex(h=>h.color==="dark");if(d===-1||f===-1)throw new ce('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Kt(t[d][s],n[d])||"inherit"}, ${Kt(t[f][s],n[f])||"inherit"});${u}`}return c}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}var lm=/^\s+$/,Gk=/^(\s*)(.*?)(\s*)$/;function Ci(e,t,n,r={meta:{},options:n,codeToHast:(o,s)=>Ci(e,o,s),codeToTokens:(o,s)=>Ti(e,o,s)}){let o=t;for(let m of Si(n))o=m.preprocess?.call(r,o,n)||o;let{tokens:s,fg:i,bg:a,themeName:l,rootStyle:c,grammarState:u}=Ti(e,o,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?s=Uk(s):d==="never"&&(s=Wk(s)),f&&(s=Hk(s));let h={...r,get source(){return o}};for(let m of Si(n))s=m.tokens?.call(h,s)||s;return jk(s,{...n,fg:i,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},h,u)}function jk(e,t,n,r=$r(e)){let o=Si(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},f=[],h={...n,structure:a,addClassToHast:sm,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 f}};if(e.forEach((g,w)=>{w&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&s.push({type:"text",value:`
33
- `}));let b={type:"element",tagName:"span",properties:{class:"line"},children:[]},k=0;for(let v of g){let I={type:"element",tagName:"span",properties:{...v.htmlAttrs},children:[{type:"text",value:v.content}]},R=dc(v.htmlStyle||ki(v));R&&(I.properties.style=R);for(let D of o)I=D?.span?.call(h,I,w+1,k,b,v)||I;a==="inline"?i.children.push(I):a==="classic"&&b.children.push(I),k+=v.content.length}if(a==="classic"){for(let v of o)b=v?.line?.call(h,b,w+1)||b;f.push(b),s.push(b)}else a==="inline"&&f.push(b)}),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=[],w={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let k of i.children)k.type==="element"&&k.tagName==="br"?(g.push(w),w={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(k.type==="element"||k.type==="text")&&w.children.push(k);g.push(w);let b={type:"element",tagName:"code",properties:{},children:g};for(let k of o)b=k?.code?.call(h,b)||b;i.children=[];for(let k=0;k<b.children.length;k++){k>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});let v=b.children[k];v.type==="element"&&i.children.push(...v.children)}}let m=i;for(let g of o)m=g?.root?.call(h,m)||m;return r&&Lo(m,r),m}function Uk(e){return e.map(t=>{let n=[],r="",o;return t.forEach((s,i)=>{let a=!(s.fontStyle&&(s.fontStyle&ye.Underline||s.fontStyle&ye.Strikethrough));a&&lm.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 Wk(e){return e.map(t=>t.flatMap(n=>{if(lm.test(n.content))return n;let r=n.content.match(Gk);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 Hk(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=dc(o.htmlStyle||ki(o)),i=dc(r.htmlStyle||ki(r)),a=o.fontStyle&&(o.fontStyle&ye.Underline||o.fontStyle&ye.Strikethrough),l=r.fontStyle&&(r.fontStyle&ye.Underline||r.fontStyle&ye.Strikethrough);!a&&!l&&s===i?o.content+=r.content:n.push({...r})}return n})}var Vk=cc;function zk(e,t,n){let r={meta:{},options:n,codeToHast:(s,i)=>Ci(e,s,i),codeToTokens:(s,i)=>Ti(e,s,i)},o=Vk(Ci(e,t,n,r));for(let s of Si(n))o=s.postprocess?.call(r,o,n)||o;return o}async function qk(e){let t=await Xl(e);return{getLastGrammarState:(...n)=>Cf(t,...n),codeToTokensBase:(n,r)=>pc(t,n,r),codeToTokensWithThemes:(n,r)=>di(t,n,r),codeToTokens:(n,r)=>Ti(t,n,r),codeToHast:(n,r)=>Ci(t,n,r),codeToHtml:(n,r)=>zk(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function cm(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,zl(d))return[];let f=t[d];if(!f)throw new ce(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return f}return d}function a(d){if(ql(d))return"none";if(typeof d=="string"){let f=n[d];if(!f)throw new ce(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return f}return d}let l=(s.themes??[]).map(d=>a(d)),c=(s.langs??[]).map(d=>i(d)),u=await qk({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 Kk(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 um(e,t){let n=Kk(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 dm=Ir({bundledLanguages:()=>_o,bundledLanguagesAlias:()=>Co,bundledLanguagesBase:()=>To,bundledLanguagesInfo:()=>Pr,bundledThemes:()=>Ro,bundledThemesInfo:()=>vo,codeToHast:()=>mc,codeToHtml:()=>fc,codeToTokens:()=>hc,codeToTokensBase:()=>Do,codeToTokensWithThemes:()=>gc,createHighlighter:()=>_i,getLastGrammarState:()=>yc,getSingletonHighlighter:()=>No}),_i=cm({langs:_o,themes:Ro,engine:()=>(0,Hl.createOnigurumaEngine)(import("./wasm-FXCISVGQ.js"))}),{codeToHtml:fc,codeToHast:mc,codeToTokens:hc,codeToTokensBase:Do,codeToTokensWithThemes:gc,getSingletonHighlighter:No,getLastGrammarState:yc}=um(_i,{guessEmbeddedLanguages:im});p();p();var pm=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 Tn(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function fm(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var Bo=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Re=String.raw;function Yt(e,t){if(e==null)throw new Error(t??"Value expected");return e}var bm=Re`\[\^?`,wm=`c.? | C(?:-.?)?|${Re`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Re`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Re`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Re`o\{[^\}]*\}?`}|${Re`\d{1,3}`}`,bc=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,vi=new RegExp(Re`
32
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function ym(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=Ti);let c=P0(r,e.properties),u=r.all(o.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=o,u&&(i=!1),(c||!s||!gm(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||!Uo(e,t,n))&&a.push("</"+e.tagName+">"),a.join("")}function P0(e,t){let n=[],r=-1,o;if(t){for(o in t)if(t[o]!==null&&t[o]!==void 0){let s=$0(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 $0(e,t,n){let r=fc(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=Zt(r.attribute,Object.assign({},e.settings.characterReferences,{subset:vi.name[o][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?um:dm)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?l:(e.settings.preferUnquoted&&(a=Zt(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:vi.unquoted[o][s]}))),a!==n&&(e.settings.quoteSmart&&hc(n,i)>hc(n,e.alternative)&&(i=e.alternative),a=i+Zt(n,Object.assign({},e.settings.characterReferences,{subset:(i==="'"?vi.single:vi.double)[o][s],attribute:!0}))+i),l+(a&&"="+a))}p();p();var L0=["<","&"];function Ri(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Zt(e.value,Object.assign({},r.settings.characterReferences,{subset:L0}))}function xm(e,t,n,r){return r.settings.allowDangerousHtml?e.value:Ri(e,t,n,r)}p();function bm(e,t,n,r){return r.all(e)}var km=Yf("type",{invalid:M0,unknown:O0,handlers:{comment:lm,doctype:cm,element:ym,raw:xm,root:bm,text:Ri}});function M0(e){throw new Error("Expected node, not `"+e+"`")}function O0(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var D0={},N0={},B0=[];function xc(e,t){let n=t||D0,r=n.quote||'"',o=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:G0,all:F0,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||Vf,characterReferences:n.characterReferences||N0,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Ti:Jf,quote:r,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function G0(e,t,n){return km(e,t,n,this)}function F0(e){let t=[],n=e&&e.children||B0,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}var wm=/\s+/g;function Cm(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(wm)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(wm);for(let r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}var j0=/:?lang=["']([^"']+)["']/g,U0=/(?:```|~~~)([\w-]+)/g,W0=/\\begin\{([\w-]+)\}/g,H0=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function V0(e){let t=Or(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 _m(e,t,n){let r=new Set;for(let s of e.matchAll(j0)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(U0)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(W0)){let i=s[1].toLowerCase().trim();i&&r.add(i)}for(let s of e.matchAll(H0)){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 z0=["color","background-color"];function q0(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 K0(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?q0(o,s):o})):e}function X0(e,t,n,r,o="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>Ai(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),l={},c=(u,d)=>{let f=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return n+t[u]+(d==="color"?"":f)};return i.forEach((u,d)=>{for(let f of a){let h=u[f]||"inherit";if(d===0&&r&&z0.includes(f))if(r==="light-dark()"&&i.length>1){let m=t.findIndex(b=>b==="light"),g=t.findIndex(b=>b==="dark");if(m===-1||g===-1)throw new ue('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');l[f]=`light-dark(${i[m][f]||"inherit"}, ${i[g][f]||"inherit"})`,o==="css-vars"&&(l[c(d,f)]=h)}else l[f]=h;else o==="css-vars"&&(l[c(d,f)]=h)}}),s.htmlStyle=l,s}function Ai(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&xe.Italic&&(t["font-style"]="italic"),e.fontStyle&xe.Bold&&(t["font-weight"]="bold");let n=[];e.fontStyle&xe.Underline&&n.push("underline"),e.fontStyle&xe.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function kc(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function J0(){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 ue(`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 ue(`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 ue(`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=V0(n.source),i=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));Z0(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 K0(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 ue(`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,f,h){let m=o[u],g="",b=-1,k=-1;if(d===0&&(b=0),f===0&&(k=0),f===Number.POSITIVE_INFINITY&&(k=m.children.length),b===-1||k===-1)for(let A=0;A<m.children.length;A++)g+=vm(m.children[A]),b===-1&&g.length===d&&(b=A+1),k===-1&&g.length===f&&(k=A+1);if(b===-1)throw new ue(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(k===-1)throw new ue(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let T=m.children.slice(b,k);if(!h.alwaysWrap&&T.length===m.children.length)a(m,h,"line");else if(!h.alwaysWrap&&T.length===1&&T[0].type==="element")a(T[0],h,"token");else{let A={type:"element",tagName:"span",properties:{},children:T};a(A,h,"wrapper"),m.children.splice(b,T.length,A)}}function i(u,d){o[u]=a(o[u],d,"line")}function a(u,d,f){let h=d.properties||{},m=d.transform||(g=>g);return u.tagName=d.tagName||"span",u.properties={...u.properties,...h,class:u.properties.class},d.properties?.class&&Cm(u,d.properties.class),u=m(u,f)||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:f}=u;if(d.line===f.line)s(d.line,d.character,f.character,u);else if(d.line<f.line){s(d.line,d.character,Number.POSITIVE_INFINITY,u);for(let h=d.line+1;h<f.line;h++)l.unshift(()=>i(h,u));s(f.line,0,f.character,u)}}l.forEach(u=>u())}}}function Z0(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new ue(`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 ue(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function vm(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(vm).join(""):""}var Y0=[J0()];function Ei(e){let t=Q0(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Y0]}function Q0(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 er=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],bc={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function ew(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 Tm(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 tw(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)bc[r]&&t.push({type:"setDecoration",value:bc[r]});else if(r<=29){let o=bc[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:er[r-30]}});else if(r===38){let o=Tm(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:er[r-40]}});else if(r===48){let o=Tm(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:er[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:er[r-100+8]}})}return t}function nw(){let e=null,t=null,n=new Set;return{parse(r){let o=[],s=0;do{let i=ew(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=tw(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 rw={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 ow(e=rw){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<er.length;c++)r.push(t(er[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 sw=/#([0-9a-f]{3,8})/i,iw=/var\((--[\w-]+-ansi-[\w-]+)\)/,aw={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 lw(e,t,n){let r=Do(e,n),o=Or(t),s=ow(Object.fromEntries(er.map(a=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||aw[a]]}))),i=nw();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=Kt(c,r),u=Kt(u,r),l.decorations.has("dim")&&(c=cw(c));let d=xe.None;return l.decorations.has("bold")&&(d|=xe.Bold),l.decorations.has("italic")&&(d|=xe.Italic),l.decorations.has("underline")&&(d|=xe.Underline),l.decorations.has("strikethrough")&&(d|=xe.Strikethrough),{content:l.value,offset:a[1],color:c,bgColor:u,fontStyle:d}}))}function cw(e){let t=e.match(sw);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(iw);return n?`var(${n[1]}-dim)`:e}function wc(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:o=e.getLoadedThemes()[0]}=n;if(!No(r)&&!Bo(o)&&r==="ansi"){let{theme:s}=e.setTheme(o);return lw(s,t,n)}return sc(e,t,n)}function Ii(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,f=Object.entries(n.themes).filter(k=>k[1]).map(k=>({color:k[0],theme:k[1]})).sort((k,T)=>k.color===c?-1:T.color===c?1:0);if(f.length===0)throw new ue("`themes` option must not be empty");let h=xi(e,t,n,wc);if(l=Dr(h),c&&c!=="light-dark()"&&!f.some(k=>k.color===c))throw new ue(`\`themes\` option must contain the defaultColor key \`${c}\``);let m=f.map(k=>e.getTheme(k.theme)),g=f.map(k=>k.color);s=h.map(k=>k.map(T=>X0(T,g,u,c,d))),l&&Go(s,l);let b=f.map(k=>Do(k.theme,n));o=Sm(f,m,b,u,c,"fg",d),r=Sm(f,m,b,u,c,"bg",d),i=`shiki-themes ${m.map(k=>k.name).join(" ")}`,a=c?void 0:[o,r].join(";")}else if("theme"in n){let c=Do(n.theme,n);s=wc(e,t,n);let u=e.getTheme(n.theme);r=Kt(u.bg,c),o=Kt(u.fg,c),i=u.name,l=Dr(s)}else throw new ue("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:o,bg:r,themeName:i,rootStyle:a,grammarState:l}}function Sm(e,t,n,r,o,s,i){return e.map((a,l)=>{let c=Kt(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"),f=e.findIndex(h=>h.color==="dark");if(d===-1||f===-1)throw new ue('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Kt(t[d][s],n[d])||"inherit"}, ${Kt(t[f][s],n[f])||"inherit"});${u}`}return c}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}var Rm=/^\s+$/,uw=/^(\s*)(.*?)(\s*)$/;function Pi(e,t,n,r={meta:{},options:n,codeToHast:(o,s)=>Pi(e,o,s),codeToTokens:(o,s)=>Ii(e,o,s)}){let o=t;for(let m of Ei(n))o=m.preprocess?.call(r,o,n)||o;let{tokens:s,fg:i,bg:a,themeName:l,rootStyle:c,grammarState:u}=Ii(e,o,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?s=pw(s):d==="never"&&(s=fw(s)),f&&(s=mw(s));let h={...r,get source(){return o}};for(let m of Ei(n))s=m.tokens?.call(h,s)||s;return dw(s,{...n,fg:i,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},h,u)}function dw(e,t,n,r=Dr(e)){let o=Ei(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},f=[],h={...n,structure:a,addClassToHast:Cm,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 f}};if(e.forEach((g,b)=>{b&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&s.push({type:"text",value:`
33
+ `}));let k={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(let A of g){let E={type:"element",tagName:"span",properties:{...A.htmlAttrs},children:[{type:"text",value:A.content}]},I=kc(A.htmlStyle||Ai(A));I&&(E.properties.style=I);for(let F of o)E=F?.span?.call(h,E,b+1,T,k,A)||E;a==="inline"?i.children.push(E):a==="classic"&&k.children.push(E),T+=A.content.length}if(a==="classic"){for(let A of o)k=A?.line?.call(h,k,b+1)||k;f.push(k),s.push(k)}else a==="inline"&&f.push(k)}),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 T of i.children)T.type==="element"&&T.tagName==="br"?(g.push(b),b={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(T.type==="element"||T.type==="text")&&b.children.push(T);g.push(b);let k={type:"element",tagName:"code",properties:{},children:g};for(let T of o)k=T?.code?.call(h,k)||k;i.children=[];for(let T=0;T<k.children.length;T++){T>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});let A=k.children[T];A.type==="element"&&i.children.push(...A.children)}}let m=i;for(let g of o)m=g?.root?.call(h,m)||m;return r&&Go(m,r),m}function pw(e){return e.map(t=>{let n=[],r="",o;return t.forEach((s,i)=>{let a=!(s.fontStyle&&(s.fontStyle&xe.Underline||s.fontStyle&xe.Strikethrough));a&&Rm.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 fw(e){return e.map(t=>t.flatMap(n=>{if(Rm.test(n.content))return n;let r=n.content.match(uw);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 mw(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=kc(o.htmlStyle||Ai(o)),i=kc(r.htmlStyle||Ai(r)),a=o.fontStyle&&(o.fontStyle&xe.Underline||o.fontStyle&xe.Strikethrough),l=r.fontStyle&&(r.fontStyle&xe.Underline||r.fontStyle&xe.Strikethrough);!a&&!l&&s===i?o.content+=r.content:n.push({...r})}return n})}var hw=xc;function gw(e,t,n){let r={meta:{},options:n,codeToHast:(s,i)=>Pi(e,s,i),codeToTokens:(s,i)=>Ii(e,s,i)},o=hw(Pi(e,t,n,r));for(let s of Ei(n))o=s.postprocess?.call(r,o,n)||o;return o}async function yw(e){let t=await oc(e);return{getLastGrammarState:(...n)=>Wf(t,...n),codeToTokensBase:(n,r)=>wc(t,n,r),codeToTokensWithThemes:(n,r)=>xi(t,n,r),codeToTokens:(n,r)=>Ii(t,n,r),codeToHast:(n,r)=>Pi(t,n,r),codeToHtml:(n,r)=>gw(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Am(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,tc(d))return[];let f=t[d];if(!f)throw new ue(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return f}return d}function a(d){if(nc(d))return"none";if(typeof d=="string"){let f=n[d];if(!f)throw new ue(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return f}return d}let l=(s.themes??[]).map(d=>a(d)),c=(s.langs??[]).map(d=>i(d)),u=await yw({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 xw(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 Em(e,t){let n=xw(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 Im=Lr({bundledLanguages:()=>$o,bundledLanguagesAlias:()=>Po,bundledLanguagesBase:()=>Io,bundledLanguagesInfo:()=>Mr,bundledThemes:()=>Mo,bundledThemesInfo:()=>Lo,codeToHast:()=>Sc,codeToHtml:()=>Tc,codeToTokens:()=>Cc,codeToTokensBase:()=>Wo,codeToTokensWithThemes:()=>_c,createHighlighter:()=>$i,getLastGrammarState:()=>vc,getSingletonHighlighter:()=>Ho}),$i=Am({langs:$o,themes:Mo,engine:()=>(0,Ql.createOnigurumaEngine)(import("./wasm-FXCISVGQ.js"))}),{codeToHtml:Tc,codeToHast:Sc,codeToTokens:Cc,codeToTokensBase:Wo,codeToTokensWithThemes:_c,getSingletonHighlighter:Ho,getLastGrammarState:vc}=Em($i,{guessEmbeddedLanguages:_m});p();p();var Pm=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 Cn(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function $m(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var Vo=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Re=String.raw;function Yt(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Bm=Re`\[\^?`,Gm=`c.? | C(?:-.?)?|${Re`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Re`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Re`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Re`o\{[^\}]*\}?`}|${Re`\d{1,3}`}`,Ac=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Li=new RegExp(Re`
34
34
  \\ (?:
35
- ${wm}
35
+ ${Gm}
36
36
  | [gk]<[^>]*>?
37
37
  | [gk]'[^']*'?
38
38
  | .
@@ -49,20 +49,20 @@ import{a as wn,b as al,c as kn,d as Sr,e as Mt,f as ll,h as cl}from"./chunk-V3LN
49
49
  )?
50
50
  | \*[^\)]*\)?
51
51
  )?
52
- | (?:${bc.source})+
53
- | ${bm}
52
+ | (?:${Ac.source})+
53
+ | ${Bm}
54
54
  | .
55
- `.replace(/\s+/g,""),"gsu"),xc=new RegExp(Re`
55
+ `.replace(/\s+/g,""),"gsu"),Rc=new RegExp(Re`
56
56
  \\ (?:
57
- ${wm}
57
+ ${Gm}
58
58
  | .
59
59
  )
60
60
  | \[:(?:\^?\p{Alpha}+|\^):\]
61
- | ${bm}
61
+ | ${Bm}
62
62
  | &&
63
63
  | .
64
- `.replace(/\s+/g,""),"gsu");function km(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=f0(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(vi.lastIndex=0;a=vi.exec(e);){let d=Xk(s,e,a[0],vi.lastIndex);d.tokens?i.push(...d.tokens):d.token&&i.push(d.token),d.lastIndex!==void 0&&(vi.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,f)=>{d.kind="capturing",d.number=f+1});let u=c||l.length;return{tokens:i.map(d=>d.type==="EscapedNumber"?h0(d,u):d).flat(),flags:r}}function Xk(e,t,n,r){let[o,s]=n;if(n==="["||n==="[^"){let i=Jk(t,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(o==="\\"){if("AbBGyYzZ".includes(s))return{token:mm(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:i0(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Tm(n)}}if(s==="K")return{token:Cm("keep",n)};if(s==="N"||s==="R")return{token:Yn("newline",n,{negate:s==="N"})};if(s==="O")return{token:Yn("any",n)};if(s==="X")return{token:Yn("text_segment",n)};let i=Sm(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(o==="("){if(s==="*")return{token:u0(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:c0(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Mr("group",n)};if(n==="(?>")return{token:Mr("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Mr(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Mr("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Mr("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:r0(n)}}if(e.getCurrentModX()){if(n==="#"){let i=t.indexOf(`
65
- `,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:Yn("dot",n)};if(n==="^"||n==="$"){let i=e.singleline?{"^":Re`\A`,$:Re`\Z`}[n]:n;return{token:mm(i,n)}}return n==="|"?{token:Yk(n)}:bc.test(n)?{tokens:g0(n)}:{token:Qt(Tn(n),n)}}function Jk(e,t,n){let r=[hm(t[1]==="^",t)],o=1,s;for(xc.lastIndex=n;s=xc.exec(e);){let i=s[0];if(i[0]==="["&&i[1]!==":")o++,r.push(hm(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Qt(93,i));else if(o--,r.push(Qk(i)),!o)break}else{let a=Zk(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:xc.lastIndex||e.length}}function Zk(e){if(e[0]==="\\")return Sm(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Bo.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Yn("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?e0(e):e==="&&"?t0(e):Qt(Tn(e),e)}function Sm(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return l0(e);if("dDhHsSwW".includes(n))return d0(e);if(e.startsWith(Re`\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 p0(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 Qt(Tn(i),a)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Qt(m0(e),e);if(gm.has(n))return Qt(gm.get(n),e);if(/\d/.test(n))return n0(t,e);if(e==="\\")throw new Error(Re`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Qt(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Yk(e){return{type:"Alternator",raw:e}}function mm(e,t){return{type:"Assertion",kind:e,raw:t}}function Tm(e){return{type:"Backreference",raw:e}}function Qt(e,t){return{type:"Character",value:e,raw:t}}function Qk(e){return{type:"CharacterClassClose",raw:e}}function e0(e){return{type:"CharacterClassHyphen",raw:e}}function t0(e){return{type:"CharacterClassIntersector",raw:e}}function hm(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Yn(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function Cm(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Yt(n.flags),raw:t}}function n0(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function r0(e){return{type:"GroupClose",raw:e}}function Mr(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function o0(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function s0(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function i0(e){return{type:"Subroutine",raw:e}}var a0=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),gm=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function l0(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 Qt(Tn(t.toUpperCase())-64,e)}function c0(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=xm(n),i=xm(r),a={};if(s&&(a.enable=s),i&&(a.disable=i),e.endsWith(")"))return t.replaceCurrentModX(o),Cm("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,Mr("group",e,{...(s||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function u0(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=a0.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 o0(c,r??null,o?.split(",")??null,e)}function ym(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 s0(t,n,r,e)}function d0(e){let t=e[1].toLowerCase();return Yn({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function p0(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Yn("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function xm(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 f0(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 m0(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 h0(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[Tm(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(Re`Octal encoded byte above 177 unsupported "${n}"`)}else c=Tn(l);s.push(Qt(c,(a===0?"\\":"")+l))}return s}function g0(e){let t=[],n=new RegExp(bc,"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(ym(o.slice(0,-1)));continue}}}t.push(ym(o))}return t}p();function Ri(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 _m(e){return y0.has(e.type)}var y0=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Ei(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=km(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),o=(f,h)=>{let m=r.tokens[s.nextIndex];switch(s.parent=f,s.nextIndex++,m.type){case"Alternator":return en();case"Assertion":return x0(m);case"Backreference":return b0(m,s);case"Character":return Or(m.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return w0(m,s,h);case"CharacterClassOpen":return k0(m,s,h);case"CharacterSet":return S0(m,s);case"Directive":return A0(m.kind,{flags:m.flags});case"GroupOpen":return T0(m,s,h);case"NamedCallout":return I0(m.kind,m.tag,m.arguments);case"Quantifier":return C0(m,s);case"Subroutine":return _0(m,s);default:throw new Error(`Unexpected token type "${m.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=L0(E0(r.flags)),a=i.body[0];for(;s.nextIndex<r.tokens.length;){let f=o(a,{});f.type==="Alternative"?(i.body.push(f),a=f):a.body.push(f)}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:f}of d)if(typeof f=="number"){if(f>l.length)throw new Error("Subroutine uses a group number that's not defined");f&&(l[f-1].isSubroutined=!0)}else if(u.has(f)){if(u.get(f).length>1)throw new Error(Re`Subroutine uses a duplicate group name "\g<${f}>"`);u.get(f)[0].isSubroutined=!0}else throw new Error(Re`Subroutine uses a group name that's not defined "\g<${f}>"`);return i}function x0({kind:e}){return Ii(Yt({"^":"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===Re`\B`||e===Re`\Y`})}function b0({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,Ai(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 Ai(r)}return o(+r)}function w0(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(),R0(i,l);throw new Error("Invalid character class range")}return Or(Tn("-"))}function k0({negate:e},t,n){let{tokens:r,walk:o}=t,s=[Fo()],i=r[t.nextIndex],a=Am(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=Am(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 S0({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i}=r;if(e==="property"){let a=Dr(n);if(Bo.has(a)&&!i?.has(a))e="posix",n=a;else return Qn(n,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i})}return e==="posix"?P0(n,{negate:t}):Pi(e,{negate:t})}function T0(e,t,n){let{tokens:r,capturingGroups:o,namedGroupsByName:s,skipLookbehindValidation:i,walk:a}=t,l=$0(e),c=l.type==="AbsenceFunction",u=Rm(l),d=u&&l.negate;if(l.type==="CapturingGroup"&&(o.push(l),l.name&&fm(s,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=Em(r[t.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")l.body.push(en()),t.nextIndex++;else{let h=l.body.at(-1),m=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(h.body.push(m),(u||n.isInLookbehind)&&!i){let g="Lookbehind includes a pattern not allowed by Oniguruma";if(d||n.isInNegLookbehind){if(vm(m)||m.type==="CapturingGroup")throw new Error(g)}else if(vm(m)||Rm(m)&&m.negate)throw new Error(g)}}f=Em(r[t.nextIndex])}return t.nextIndex++,l}function C0({kind:e,min:t,max:n},r){let o=r.parent,s=o.body.at(-1);if(!s||!_m(s))throw new Error("Quantifier requires a repeatable token");let i=kc(e,t,n,s);return o.body.pop(),i}function _0({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=Sc(o);return r.push(i),i}function v0(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:Go(t?.body)}}function en(e){return{type:"Alternative",body:Im(e?.body)}}function Ii(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function Ai(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function wc(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!M0(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:Go(t?.body)}}function Or(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:Im(e?.body)}}function R0(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Pi(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 A0(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Yt(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function E0(e){return{type:"Flags",...e}}function at(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:Go(e?.body)}}function Cn(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Go(e?.body)}}function I0(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function P0(e,t){let n=!!t?.negate;if(!Bo.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function kc(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 L0(e,t){return{type:"Regex",body:Go(t?.body),flags:e}}function Sc(e){return{type:"Subroutine",ref:e}}function Qn(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=O0(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Re`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function $0({flags:e,kind:t,name:n,negate:r,number:o}){switch(t){case"absence_repeater":return v0("repeater");case"atomic":return at({atomic:!0});case"capturing":return wc(o,{name:n});case"group":return at({flags:e});case"lookahead":case"lookbehind":return Cn({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function Go(e){if(e===void 0)e=[en()];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 Im(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 vm(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Rm(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function M0(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function O0(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 Am(e,t){let n=t;return Yt(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function Em(e){return Yt(e,"Unclosed group")}p();function er(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(){Li(l).splice(Math.max(0,Nr(a)+c),1),c--,u=!0},removeAllNextSiblings(){return Li(l).splice(Nr(a)+1)},removeAllPrevSiblings(){let b=Nr(a)+c;return c-=b,Li(l).splice(0,Math.max(0,b))},replaceWith(b,k={}){let v=!!k.traverse;l?l[Math.max(0,Nr(a)+c)]=b:Yt(i,"Can't replace root node")[a]=b,v&&o(b,i,a,l),u=!0},replaceWithMultiple(b,k={}){let v=!!k.traverse;if(Li(l).splice(Math.max(0,Nr(a)+c),1,...b),c+=b.length-1,v){let I=0;for(let R=0;R<b.length;R++)I+=o(b[R],i,Nr(a)+R+I,l)}u=!0},skip(){u=!0}},{type:f}=s,h=t["*"],m=t[f],g=typeof h=="function"?h:h?.enter,w=typeof m=="function"?m:m?.enter;if(g?.(d,n),w?.(d,n),!u)switch(f){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 "${f}"`)}return m?.exit?.(d,n),h?.exit?.(d,n),c}return o(e),e}function Li(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Nr(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}p();p();p();var Pm=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Lm(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function $m(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}p();var Je=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function jo(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===Je.DEFAULT==!i)){n instanceof Function?a+=n(l,{context:i?Je.CHAR_CLASS:Je.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 Tc(e,t,n,r){jo(e,t,n,r)}function D0(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===Je.DEFAULT==!s))return i;a==="["?s++:a==="]"&&s&&s--,o.lastIndex==i.index&&o.lastIndex++}return null}function Uo(e,t,n){return!!D0(e,t,0,n)}function Mm(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 Om=new RegExp(String.raw`(?<noncapturingStart>${Pm})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function _c(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 f=0,h=0,m=!1,g;for(Om.lastIndex=Number.isNaN(u)?0:u+s.length;g=Om.exec(e);){let{0:w,index:b,groups:{capturingStart:k,noncapturingStart:v}}=g;if(w==="[")f++;else if(f)w==="]"&&f--;else if(w===o&&!m)u=b,m=!0;else if(m&&v)h++;else if(k)m?h++:(l++,i.push(l+c));else if(w===")"&&m){if(!h){c++;let I=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+o.length,b)}))<$$${I}>)${e.slice(b+1)}`,d=!0,a.push(I),Lm(n,I),r.size){let R=new Map;r.forEach((D,F)=>{R.set(F>=I?F+1:F,D.map(P=>P>=I?P+1:P))}),r=R}break}h--}}}while(d);return n.push(...a),e=jo(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:h,wrappedBackrefNum:m}})=>{if(h){let g=+h;if(g>i.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${i[g]}`}return`\\${m}`},Je.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var Dm=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Cc=new RegExp(String.raw`
64
+ `.replace(/\s+/g,""),"gsu");function Fm(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=Nw(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(Li.lastIndex=0;a=Li.exec(e);){let d=bw(s,e,a[0],Li.lastIndex);d.tokens?i.push(...d.tokens):d.token&&i.push(d.token),d.lastIndex!==void 0&&(Li.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,f)=>{d.kind="capturing",d.number=f+1});let u=c||l.length;return{tokens:i.map(d=>d.type==="EscapedNumber"?Gw(d,u):d).flat(),flags:r}}function bw(e,t,n,r){let[o,s]=n;if(n==="["||n==="[^"){let i=kw(t,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(o==="\\"){if("AbBGyYzZ".includes(s))return{token:Lm(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Iw(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Um(n)}}if(s==="K")return{token:Wm("keep",n)};if(s==="N"||s==="R")return{token:tr("newline",n,{negate:s==="N"})};if(s==="O")return{token:tr("any",n)};if(s==="X")return{token:tr("text_segment",n)};let i=jm(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(o==="("){if(s==="*")return{token:Mw(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:Lw(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Nr("group",n)};if(n==="(?>")return{token:Nr("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Nr(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Nr("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Nr("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:Rw(n)}}if(e.getCurrentModX()){if(n==="#"){let i=t.indexOf(`
65
+ `,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:tr("dot",n)};if(n==="^"||n==="$"){let i=e.singleline?{"^":Re`\A`,$:Re`\Z`}[n]:n;return{token:Lm(i,n)}}return n==="|"?{token:Tw(n)}:Ac.test(n)?{tokens:Fw(n)}:{token:Qt(Cn(n),n)}}function kw(e,t,n){let r=[Mm(t[1]==="^",t)],o=1,s;for(Rc.lastIndex=n;s=Rc.exec(e);){let i=s[0];if(i[0]==="["&&i[1]!==":")o++,r.push(Mm(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Qt(93,i));else if(o--,r.push(Sw(i)),!o)break}else{let a=ww(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:Rc.lastIndex||e.length}}function ww(e){if(e[0]==="\\")return jm(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Vo.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return tr("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Cw(e):e==="&&"?_w(e):Qt(Cn(e),e)}function jm(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return $w(e);if("dDhHsSwW".includes(n))return Ow(e);if(e.startsWith(Re`\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 Dw(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 Qt(Cn(i),a)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Qt(Bw(e),e);if(Om.has(n))return Qt(Om.get(n),e);if(/\d/.test(n))return vw(t,e);if(e==="\\")throw new Error(Re`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Qt(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Tw(e){return{type:"Alternator",raw:e}}function Lm(e,t){return{type:"Assertion",kind:e,raw:t}}function Um(e){return{type:"Backreference",raw:e}}function Qt(e,t){return{type:"Character",value:e,raw:t}}function Sw(e){return{type:"CharacterClassClose",raw:e}}function Cw(e){return{type:"CharacterClassHyphen",raw:e}}function _w(e){return{type:"CharacterClassIntersector",raw:e}}function Mm(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function tr(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function Wm(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Yt(n.flags),raw:t}}function vw(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Rw(e){return{type:"GroupClose",raw:e}}function Nr(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function Aw(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Ew(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Iw(e){return{type:"Subroutine",raw:e}}var Pw=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Om=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function $w(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 Qt(Cn(t.toUpperCase())-64,e)}function Lw(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=Nm(n),i=Nm(r),a={};if(s&&(a.enable=s),i&&(a.disable=i),e.endsWith(")"))return t.replaceCurrentModX(o),Wm("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,Nr("group",e,{...(s||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${e}"`)}function Mw(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=Pw.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 Aw(c,r??null,o?.split(",")??null,e)}function Dm(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 Ew(t,n,r,e)}function Ow(e){let t=e[1].toLowerCase();return tr({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Dw(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return tr("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function Nm(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 Nw(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 Bw(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 Gw(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[Um(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(Re`Octal encoded byte above 177 unsupported "${n}"`)}else c=Cn(l);s.push(Qt(c,(a===0?"\\":"")+l))}return s}function Fw(e){let t=[],n=new RegExp(Ac,"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(Dm(o.slice(0,-1)));continue}}}t.push(Dm(o))}return t}p();function Mi(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 Hm(e){return jw.has(e.type)}var jw=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Di(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Fm(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),o=(f,h)=>{let m=r.tokens[s.nextIndex];switch(s.parent=f,s.nextIndex++,m.type){case"Alternator":return en();case"Assertion":return Uw(m);case"Backreference":return Ww(m,s);case"Character":return Br(m.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return Hw(m,s,h);case"CharacterClassOpen":return Vw(m,s,h);case"CharacterSet":return zw(m,s);case"Directive":return Yw(m.kind,{flags:m.flags});case"GroupOpen":return qw(m,s,h);case"NamedCallout":return eT(m.kind,m.tag,m.arguments);case"Quantifier":return Kw(m,s);case"Subroutine":return Xw(m,s);default:throw new Error(`Unexpected token type "${m.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=nT(Qw(r.flags)),a=i.body[0];for(;s.nextIndex<r.tokens.length;){let f=o(a,{});f.type==="Alternative"?(i.body.push(f),a=f):a.body.push(f)}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:f}of d)if(typeof f=="number"){if(f>l.length)throw new Error("Subroutine uses a group number that's not defined");f&&(l[f-1].isSubroutined=!0)}else if(u.has(f)){if(u.get(f).length>1)throw new Error(Re`Subroutine uses a duplicate group name "\g<${f}>"`);u.get(f)[0].isSubroutined=!0}else throw new Error(Re`Subroutine uses a group name that's not defined "\g<${f}>"`);return i}function Uw({kind:e}){return Ni(Yt({"^":"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===Re`\B`||e===Re`\Y`})}function Ww({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,Oi(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 Oi(r)}return o(+r)}function Hw(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(),Zw(i,l);throw new Error("Invalid character class range")}return Br(Cn("-"))}function Vw({negate:e},t,n){let{tokens:r,walk:o}=t,s=[zo()],i=r[t.nextIndex],a=qm(i);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")s.push(zo()),t.nextIndex++;else{let c=s.at(-1);c.body.push(o(c,n))}a=qm(r[t.nextIndex],i)}let l=zo({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 zw({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i}=r;if(e==="property"){let a=Gr(n);if(Vo.has(a)&&!i?.has(a))e="posix",n=a;else return nr(n,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:s,unicodePropertyMap:i})}return e==="posix"?tT(n,{negate:t}):Bi(e,{negate:t})}function qw(e,t,n){let{tokens:r,capturingGroups:o,namedGroupsByName:s,skipLookbehindValidation:i,walk:a}=t,l=rT(e),c=l.type==="AbsenceFunction",u=zm(l),d=u&&l.negate;if(l.type==="CapturingGroup"&&(o.push(l),l.name&&$m(s,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=Km(r[t.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")l.body.push(en()),t.nextIndex++;else{let h=l.body.at(-1),m=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(h.body.push(m),(u||n.isInLookbehind)&&!i){let g="Lookbehind includes a pattern not allowed by Oniguruma";if(d||n.isInNegLookbehind){if(Vm(m)||m.type==="CapturingGroup")throw new Error(g)}else if(Vm(m)||zm(m)&&m.negate)throw new Error(g)}}f=Km(r[t.nextIndex])}return t.nextIndex++,l}function Kw({kind:e,min:t,max:n},r){let o=r.parent,s=o.body.at(-1);if(!s||!Hm(s))throw new Error("Quantifier requires a repeatable token");let i=Ic(e,t,n,s);return o.body.pop(),i}function Xw({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=Pc(o);return r.push(i),i}function Jw(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:qo(t?.body)}}function en(e){return{type:"Alternative",body:Xm(e?.body)}}function Ni(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function Oi(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function Ec(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!oT(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:qo(t?.body)}}function Br(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 zo(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Xm(e?.body)}}function Zw(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Bi(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 Yw(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Yt(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function Qw(e){return{type:"Flags",...e}}function lt(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:qo(e?.body)}}function _n(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:qo(e?.body)}}function eT(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function tT(e,t){let n=!!t?.negate;if(!Vo.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function Ic(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 nT(e,t){return{type:"Regex",body:qo(t?.body),flags:e}}function Pc(e){return{type:"Subroutine",ref:e}}function nr(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(Gr(e));if(!r){if(n.normalizeUnknownPropertyNames)r=sT(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Re`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function rT({flags:e,kind:t,name:n,negate:r,number:o}){switch(t){case"absence_repeater":return Jw("repeater");case"atomic":return lt({atomic:!0});case"capturing":return Ec(o,{name:n});case"group":return lt({flags:e});case"lookahead":case"lookbehind":return _n({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function qo(e){if(e===void 0)e=[en()];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 Xm(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 Vm(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function zm(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function oT(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function sT(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 Gr(e){return e.replace(/[- _]+/g,"").toLowerCase()}function qm(e,t){let n=t;return Yt(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function Km(e){return Yt(e,"Unclosed group")}p();function rr(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(){Gi(l).splice(Math.max(0,Fr(a)+c),1),c--,u=!0},removeAllNextSiblings(){return Gi(l).splice(Fr(a)+1)},removeAllPrevSiblings(){let k=Fr(a)+c;return c-=k,Gi(l).splice(0,Math.max(0,k))},replaceWith(k,T={}){let A=!!T.traverse;l?l[Math.max(0,Fr(a)+c)]=k:Yt(i,"Can't replace root node")[a]=k,A&&o(k,i,a,l),u=!0},replaceWithMultiple(k,T={}){let A=!!T.traverse;if(Gi(l).splice(Math.max(0,Fr(a)+c),1,...k),c+=k.length-1,A){let E=0;for(let I=0;I<k.length;I++)E+=o(k[I],i,Fr(a)+I+E,l)}u=!0},skip(){u=!0}},{type:f}=s,h=t["*"],m=t[f],g=typeof h=="function"?h:h?.enter,b=typeof m=="function"?m:m?.enter;if(g?.(d,n),b?.(d,n),!u)switch(f){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 "${f}"`)}return m?.exit?.(d,n),h?.exit?.(d,n),c}return o(e),e}function Gi(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 Jm=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Zm(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Ym(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}p();var Je=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Ko(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===Je.DEFAULT==!i)){n instanceof Function?a+=n(l,{context:i?Je.CHAR_CLASS:Je.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 $c(e,t,n,r){Ko(e,t,n,r)}function iT(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===Je.DEFAULT==!s))return i;a==="["?s++:a==="]"&&s&&s--,o.lastIndex==i.index&&o.lastIndex++}return null}function Xo(e,t,n){return!!iT(e,t,0,n)}function Qm(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 eh=new RegExp(String.raw`(?<noncapturingStart>${Jm})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Mc(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 f=0,h=0,m=!1,g;for(eh.lastIndex=Number.isNaN(u)?0:u+s.length;g=eh.exec(e);){let{0:b,index:k,groups:{capturingStart:T,noncapturingStart:A}}=g;if(b==="[")f++;else if(f)b==="]"&&f--;else if(b===o&&!m)u=k,m=!0;else if(m&&A)h++;else if(T)m?h++:(l++,i.push(l+c));else if(b===")"&&m){if(!h){c++;let E=l+c;if(e=`${e.slice(0,u)}${s}${e.slice(u+o.length,k)}))<$$${E}>)${e.slice(k+1)}`,d=!0,a.push(E),Zm(n,E),r.size){let I=new Map;r.forEach((F,M)=>{I.set(M>=E?M+1:M,F.map(C=>C>=E?C+1:C))}),r=I}break}h--}}}while(d);return n.push(...a),e=Ko(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:h,wrappedBackrefNum:m}})=>{if(h){let g=+h;if(g>i.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${i[g]}`}return`\\${m}`},Je.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var th=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Lc=new RegExp(String.raw`
66
66
  \\(?: \d+
67
67
  | c[A-Za-z]
68
68
  | [gk]<[^>]+>
@@ -75,9 +75,9 @@ import{a as wn,b as al,c as kn,d as Sr,e as Mt,f as ll,h as cl}from"./chunk-V3LN
75
75
  | [A-Za-z\-]+:
76
76
  | \(DEFINE\)
77
77
  ))?
78
- | (?<qBase>${Dm})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
78
+ | (?<qBase>${th})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
79
79
  | \\?.
80
- `.replace(/\s+/g,""),"gsu");function vc(e){if(!new RegExp(`${Dm}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,o="",s=0,i;for(Cc.lastIndex=0;i=Cc.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 f=-1;if(/^\{\d+\}$/.test(c))e=$m(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)}`;f+=4}Cc.lastIndex+=f}else a[0]==="("?t.push(l):a===")"&&(n=t.length?t.pop():null);o=a}return{pattern:e}}p();p();var gt=String.raw,N0=gt`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Ac=gt`\(\?R=(?<rDepth>[^\)]+)\)|${N0}`,$i=gt`\(\?<(?![=!])(?<captureName>[^>]+)>`,jm=gt`${$i}|(?<unnamed>\()(?!\?)`,tr=new RegExp(gt`${$i}|${Ac}|\(\?|\\?.`,"gsu"),Rc="Cannot use multiple overlapping recursions";function Um(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t},o=t?.captureTransfers??new Map;if(!new RegExp(Ac,"su").test(e))return{pattern:e,captureTransfers:o,hiddenCaptures:n};if(r==="plugin"&&Uo(e,gt`\(\?\(DEFINE\)`,Je.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let s=[],i=Uo(e,gt`\\[1-9]`,Je.DEFAULT),a=new Map,l=[],c=!1,u=0,d=0,f;for(tr.lastIndex=0;f=tr.exec(e);){let{0:h,groups:{captureName:m,rDepth:g,gRNameOrNum:w,gRDepth:b}}=f;if(h==="[")u++;else if(u)h==="]"&&u--;else if(g){if(Nm(g),c)throw new Error(Rc);if(i)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let k=e.slice(0,f.index),v=e.slice(tr.lastIndex);if(Uo(v,Ac,Je.DEFAULT))throw new Error(Rc);let I=+g-1;e=Bm(k,v,I,!1,n,s,d),o=Gm(o,k,I,s.length,0,d);break}else if(w){Nm(b);let k=!1;for(let A of l)if(A.name===w||A.num===+w){if(k=!0,A.hasRecursedWithin)throw new Error(Rc);break}if(!k)throw new Error(gt`Recursive \g cannot be used outside the referenced group "${r==="external"?w:gt`\g<${w}&R=${b}>`}"`);let v=a.get(w),I=Mm(e,v);if(i&&Uo(I,gt`${$i}|\((?!\?)`,Je.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let R=e.slice(v,f.index),D=I.slice(R.length+h.length),F=s.length,P=+b-1,z=Bm(R,D,P,!0,n,s,d);o=Gm(o,R,P,s.length-F,F,d);let j=e.slice(0,v),N=e.slice(v+I.length);e=`${j}${z}${N}`,tr.lastIndex+=z.length-h.length-R.length-D.length,l.forEach(A=>A.hasRecursedWithin=!0),c=!0}else if(m)d++,a.set(String(d),tr.lastIndex),a.set(m,tr.lastIndex),l.push({num:d,name:m});else if(h[0]==="("){let k=h==="(";k&&(d++,a.set(String(d),tr.lastIndex)),l.push(k?{num:d}:{})}else h===")"&&l.pop()}return n.push(...s),{pattern:e,captureTransfers:o,hiddenCaptures:n}}function Nm(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 Bm(e,t,n,r,o,s,i){let a=new Set;r&&Tc(e+t,$i,({groups:{captureName:c}})=>{a.add(c)},Je.DEFAULT);let l=[n,r?a:null,o,s,i];return`${e}${Fm(`(?:${e}`,"forward",...l)}(?:)${Fm(`${t})`,"backward",...l)}${t}`}function Fm(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+=jo(e,gt`${jm}|\\k<(?<backref>[^>]+)>`,({0:f,groups:{captureName:h,unnamed:m,backref:g}})=>{if(g&&r&&!r.has(g))return f;let w=`_$${d}`;if(m||h){let b=i+s.length+1;return s.push(b),B0(o,b),m?f:`(?<${h}${w}>`}return gt`\k<${g}${w}>`},Je.DEFAULT)}return c}function B0(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Gm(e,t,n,r,o,s){if(e.size&&r){let i=0;Tc(t,jm,()=>i++,Je.DEFAULT);let a=s-i+o,l=new Map;return e.forEach((c,u)=>{let d=(r-i*n)/n,f=i*n,h=u>a+i?u+r:u,m=[];for(let g of c)if(g<=a)m.push(g);else if(g>a+i+d)m.push(g+r);else if(g<=a+i)for(let w=0;w<=n;w++)m.push(g+i*w);else for(let w=0;w<=n;w++)m.push(g+f+d*w);l.set(h,m)}),l}return e}var Ie=String.fromCodePoint,X=String.raw,_t={},Oi=globalThis.RegExp;_t.flagGroups=(()=>{try{new Oi("(?i:)")}catch{return!1}return!0})();_t.unicodeSets=(()=>{try{new Oi("[[]]","v")}catch{return!1}return!0})();_t.bugFlagVLiteralHyphenIsRange=_t.unicodeSets?(()=>{try{new Oi(X`[\d\-a]`,"v")}catch{return!0}return!1})():!1;_t.bugNestedClassIgnoresNegation=_t.unicodeSets&&new Oi("[[^a]]","v").test("a");function Mi(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function Wo(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function $c(e,t){return Wm[e]>=Wm[t]}function F0(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Wm={ES2025:2025,ES2024:2024,ES2018:2018},G0={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function Km(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!G0[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=_t.flagGroups?"ES2025":_t.unicodeSets?"ES2024":"ES2018"),t}var j0="[ -\r ]",U0=new Set([Ie(304),Ie(305)]),tn=X`[\p{L}\p{M}\p{N}\p{Pc}]`;function Xm(e){if(U0.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),o=V0.get(n),s=W0.get(n),i=H0.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 Oc=new Map(`C Other
80
+ `.replace(/\s+/g,""),"gsu");function Oc(e){if(!new RegExp(`${th}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,o="",s=0,i;for(Lc.lastIndex=0;i=Lc.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 f=-1;if(/^\{\d+\}$/.test(c))e=Ym(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)}`;f+=4}Lc.lastIndex+=f}else a[0]==="("?t.push(l):a===")"&&(n=t.length?t.pop():null);o=a}return{pattern:e}}p();p();var xt=String.raw,aT=xt`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Nc=xt`\(\?R=(?<rDepth>[^\)]+)\)|${aT}`,Fi=xt`\(\?<(?![=!])(?<captureName>[^>]+)>`,ih=xt`${Fi}|(?<unnamed>\()(?!\?)`,or=new RegExp(xt`${Fi}|${Nc}|\(\?|\\?.`,"gsu"),Dc="Cannot use multiple overlapping recursions";function ah(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t},o=t?.captureTransfers??new Map;if(!new RegExp(Nc,"su").test(e))return{pattern:e,captureTransfers:o,hiddenCaptures:n};if(r==="plugin"&&Xo(e,xt`\(\?\(DEFINE\)`,Je.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let s=[],i=Xo(e,xt`\\[1-9]`,Je.DEFAULT),a=new Map,l=[],c=!1,u=0,d=0,f;for(or.lastIndex=0;f=or.exec(e);){let{0:h,groups:{captureName:m,rDepth:g,gRNameOrNum:b,gRDepth:k}}=f;if(h==="[")u++;else if(u)h==="]"&&u--;else if(g){if(nh(g),c)throw new Error(Dc);if(i)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let T=e.slice(0,f.index),A=e.slice(or.lastIndex);if(Xo(A,Nc,Je.DEFAULT))throw new Error(Dc);let E=+g-1;e=rh(T,A,E,!1,n,s,d),o=sh(o,T,E,s.length,0,d);break}else if(b){nh(k);let T=!1;for(let O of l)if(O.name===b||O.num===+b){if(T=!0,O.hasRecursedWithin)throw new Error(Dc);break}if(!T)throw new Error(xt`Recursive \g cannot be used outside the referenced group "${r==="external"?b:xt`\g<${b}&R=${k}>`}"`);let A=a.get(b),E=Qm(e,A);if(i&&Xo(E,xt`${Fi}|\((?!\?)`,Je.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let I=e.slice(A,f.index),F=E.slice(I.length+h.length),M=s.length,C=+k-1,N=rh(I,F,C,!0,n,s,d);o=sh(o,I,C,s.length-M,M,d);let oe=e.slice(0,A),j=e.slice(A+E.length);e=`${oe}${N}${j}`,or.lastIndex+=N.length-h.length-I.length-F.length,l.forEach(O=>O.hasRecursedWithin=!0),c=!0}else if(m)d++,a.set(String(d),or.lastIndex),a.set(m,or.lastIndex),l.push({num:d,name:m});else if(h[0]==="("){let T=h==="(";T&&(d++,a.set(String(d),or.lastIndex)),l.push(T?{num:d}:{})}else h===")"&&l.pop()}return n.push(...s),{pattern:e,captureTransfers:o,hiddenCaptures:n}}function nh(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 rh(e,t,n,r,o,s,i){let a=new Set;r&&$c(e+t,Fi,({groups:{captureName:c}})=>{a.add(c)},Je.DEFAULT);let l=[n,r?a:null,o,s,i];return`${e}${oh(`(?:${e}`,"forward",...l)}(?:)${oh(`${t})`,"backward",...l)}${t}`}function oh(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+=Ko(e,xt`${ih}|\\k<(?<backref>[^>]+)>`,({0:f,groups:{captureName:h,unnamed:m,backref:g}})=>{if(g&&r&&!r.has(g))return f;let b=`_$${d}`;if(m||h){let k=i+s.length+1;return s.push(k),lT(o,k),m?f:`(?<${h}${b}>`}return xt`\k<${g}${b}>`},Je.DEFAULT)}return c}function lT(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function sh(e,t,n,r,o,s){if(e.size&&r){let i=0;$c(t,ih,()=>i++,Je.DEFAULT);let a=s-i+o,l=new Map;return e.forEach((c,u)=>{let d=(r-i*n)/n,f=i*n,h=u>a+i?u+r:u,m=[];for(let g of c)if(g<=a)m.push(g);else if(g>a+i+d)m.push(g+r);else if(g<=a+i)for(let b=0;b<=n;b++)m.push(g+i*b);else for(let b=0;b<=n;b++)m.push(g+f+d*b);l.set(h,m)}),l}return e}var Ie=String.fromCodePoint,Y=String.raw,_t={},Ui=globalThis.RegExp;_t.flagGroups=(()=>{try{new Ui("(?i:)")}catch{return!1}return!0})();_t.unicodeSets=(()=>{try{new Ui("[[]]","v")}catch{return!1}return!0})();_t.bugFlagVLiteralHyphenIsRange=_t.unicodeSets?(()=>{try{new Ui(Y`[\d\-a]`,"v")}catch{return!0}return!1})():!1;_t.bugNestedClassIgnoresNegation=_t.unicodeSets&&new Ui("[[^a]]","v").test("a");function ji(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function Jo(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Uc(e,t){return lh[e]>=lh[t]}function cT(e,t){if(e==null)throw new Error(t??"Value expected");return e}var lh={ES2025:2025,ES2024:2024,ES2018:2018},uT={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function fh(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!uT[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=_t.flagGroups?"ES2025":_t.unicodeSets?"ES2024":"ES2018"),t}var dT="[ -\r ]",pT=new Set([Ie(304),Ie(305)]),tn=Y`[\p{L}\p{M}\p{N}\p{Pc}]`;function mh(e){if(pT.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),o=hT.get(n),s=fT.get(n),i=mT.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 Hc=new Map(`C Other
81
81
  Cc Control cntrl
82
82
  Cf Format
83
83
  Cn Unassigned
@@ -167,29 +167,29 @@ Uppercase Upper
167
167
  Variation_Selector VS
168
168
  White_Space space
169
169
  XID_Continue XIDC
170
- XID_Start XIDS`.split(/\s/).map(e=>[Dr(e),e])),W0=new Map([["s",Ie(383)],[Ie(383),"s"]]),H0=new Map([[Ie(223),Ie(7838)],[Ie(107),Ie(8490)],[Ie(229),Ie(8491)],[Ie(969),Ie(8486)]]),V0=new Map([_n(453),_n(456),_n(459),_n(498),...Ec(8072,8079),...Ec(8088,8095),...Ec(8104,8111),_n(8124),_n(8140),_n(8188)]),z0=new Map([["alnum",X`[\p{Alpha}\p{Nd}]`],["alpha",X`\p{Alpha}`],["ascii",X`\p{ASCII}`],["blank",X`[\p{Zs}\t]`],["cntrl",X`\p{Cc}`],["digit",X`\p{Nd}`],["graph",X`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",X`\p{Lower}`],["print",X`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",X`[\p{P}\p{S}]`],["space",X`\p{space}`],["upper",X`\p{Upper}`],["word",X`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",X`\p{AHex}`]]);function q0(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function _n(e){let t=Ie(e);return[t.toLowerCase(),t]}function Ec(e,t){return q0(e,t).map(n=>_n(n))}var Jm=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function K0(e,t){let n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};Zm(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:$c(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};er(e,X0,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};er(e,J0,s);let i={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return er(e,Z0,i),e._originMap=s.groupOriginByCopy,e._strategy=r.strategy,e}var X0={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:o}=e;if(o==="repeater"){let s=at();s.body[0].body.push(Cn({negate:!0,body:r}),Qn("Any"));let i=at();i.body[0].body.push(kc("greedy",0,1/0,s)),n(Se(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];Wo(r,i,[]).push(...o)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Qm(t.get(e));if(n){let r=at({flags:n});r.body[0].body=e.body,e.body=[Se(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:f,wordIsAscii:h}=a;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")i(Se(Cn({body:[en({body:[Ii("string_end")]}),en({body:[Or(10)]})]}),t));else if(l==="line_start")i(Se(nn(X`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(l==="search_start")if(f.has(e))o.flags.sticky=!0,s();else{let m=r[n-1];if(m&&rS(m))i(Se(Cn({negate:!0}),t));else{if(d)throw new Error(X`Uses "\G" in a way that requires a subclass`);i(vn(Ii("string_start"),t)),a.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")i(Se(nn(X`(?=\n?\z)`),t));else if(l==="word_boundary"){if(!h&&!u){let m=`(?:(?<=${tn})(?!${tn})|(?<!${tn})(?=${tn}))`,g=`(?:(?<=${tn})(?=${tn})|(?<!${tn})(?!${tn}))`;i(Se(nn(c?g:m),t))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Pc(n)&&(n=Ic(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Pc(r)&&(r=Ic(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=Fo({body:[e]});n(Se(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(vn(Pi("digit",{negate:c}),t));return}if(i&&(l==="space"||u==="space")){n(Se(Lc(nn(j0),c),t));return}if(a&&(l==="word"||u==="word")){n(vn(Pi("word",{negate:c}),t));return}if(l==="any")n(vn(Qn("Any"),t));else if(l==="digit")n(vn(Qn("Nd",{negate:c}),t));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(X`Use of "\X" requires non-strict accuracy`);let d="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=X`\p{RI}{2}|${d}(?:\u200D${d})*`;n(Se(nn(X`(?>\r\n|${o?X`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(l==="hex")n(vn(Qn("AHex",{negate:c}),t));else if(l==="newline")n(Se(nn(c?`[^
170
+ XID_Start XIDS`.split(/\s/).map(e=>[Gr(e),e])),fT=new Map([["s",Ie(383)],[Ie(383),"s"]]),mT=new Map([[Ie(223),Ie(7838)],[Ie(107),Ie(8490)],[Ie(229),Ie(8491)],[Ie(969),Ie(8486)]]),hT=new Map([vn(453),vn(456),vn(459),vn(498),...Bc(8072,8079),...Bc(8088,8095),...Bc(8104,8111),vn(8124),vn(8140),vn(8188)]),gT=new Map([["alnum",Y`[\p{Alpha}\p{Nd}]`],["alpha",Y`\p{Alpha}`],["ascii",Y`\p{ASCII}`],["blank",Y`[\p{Zs}\t]`],["cntrl",Y`\p{Cc}`],["digit",Y`\p{Nd}`],["graph",Y`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",Y`\p{Lower}`],["print",Y`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",Y`[\p{P}\p{S}]`],["space",Y`\p{space}`],["upper",Y`\p{Upper}`],["word",Y`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",Y`\p{AHex}`]]);function yT(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function vn(e){let t=Ie(e);return[t.toLowerCase(),t]}function Bc(e,t){return yT(e,t).map(n=>vn(n))}var hh=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function xT(e,t){let n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};gh(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Uc(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};rr(e,bT,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};rr(e,kT,s);let i={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return rr(e,wT,i),e._originMap=s.groupOriginByCopy,e._strategy=r.strategy,e}var bT={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:o}=e;if(o==="repeater"){let s=lt();s.body[0].body.push(_n({negate:!0,body:r}),nr("Any"));let i=lt();i.body[0].body.push(Ic("greedy",0,1/0,s)),n(Se(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];Jo(r,i,[]).push(...o)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=xh(t.get(e));if(n){let r=lt({flags:n});r.body[0].body=e.body,e.body=[Se(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:f,wordIsAscii:h}=a;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")i(Se(_n({body:[en({body:[Ni("string_end")]}),en({body:[Br(10)]})]}),t));else if(l==="line_start")i(Se(nn(Y`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(l==="search_start")if(f.has(e))o.flags.sticky=!0,s();else{let m=r[n-1];if(m&&RT(m))i(Se(_n({negate:!0}),t));else{if(d)throw new Error(Y`Uses "\G" in a way that requires a subclass`);i(Rn(Ni("string_start"),t)),a.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")i(Se(nn(Y`(?=\n?\z)`),t));else if(l==="word_boundary"){if(!h&&!u){let m=`(?:(?<=${tn})(?!${tn})|(?<!${tn})(?=${tn}))`,g=`(?:(?<=${tn})(?=${tn})|(?<!${tn})(?!${tn}))`;i(Se(nn(c?g:m),t))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Fc(n)&&(n=Gc(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Fc(r)&&(r=Gc(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=zo({body:[e]});n(Se(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(Rn(Bi("digit",{negate:c}),t));return}if(i&&(l==="space"||u==="space")){n(Se(jc(nn(dT),c),t));return}if(a&&(l==="word"||u==="word")){n(Rn(Bi("word",{negate:c}),t));return}if(l==="any")n(Rn(nr("Any"),t));else if(l==="digit")n(Rn(nr("Nd",{negate:c}),t));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(Y`Use of "\X" requires non-strict accuracy`);let d="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=Y`\p{RI}{2}|${d}(?:\u200D${d})*`;n(Se(nn(Y`(?>\r\n|${o?Y`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(l==="hex")n(Rn(nr("AHex",{negate:c}),t));else if(l==="newline")n(Se(nn(c?`[^
171
171
  ]`:`(?>\r
172
172
  ?|[
173
- \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-${Ie(d.codePointAt(0)-1)}${Ie(d.codePointAt(2)+1)}-\u{10FFFF}`),n(Se(nn(`[${d}]`),t))}else n(Se(Lc(nn(z0.get(u)),c),t));else if(l==="property")Oc.has(Dr(u))||(e.key="sc");else if(l==="space")n(vn(Qn("space",{negate:c}),t));else if(l==="word")n(Se(Lc(nn(tn),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=at({flags:l});c.body[0].body=i(),o(Se(c,t),{traverse:!0})}else if(a==="keep"){let c=n.body[0],d=n.body.length===1&&Ri(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 f=Cn({behind:!0});f.body[0].body=s(),o(Se(f,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(Se(Cn({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=at();t.body[0].body.push(e.body),e.body=Se(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=th(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"&&!Pc(n)&&(n=Ic(n,t),e.ref=n)}},J0={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=vn(Hm(e.number),t);l.set(d,a.get(e.number)),n(d);return}a.set(e.number,e),i.set(e.number,[]),e.name&&Wo(i,e.name,[]);let u=i.get(e.name??e.number);for(let d=0;d<u.length;d++){let f=u[d];if(c===f.node||c&&c===f.origin||e===f.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=Wo(s,e.name,new Map),f=!1;if(c)f=!0;else for(let h of d.values())if(!h.hasDuplicateNameToRemove){f=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}},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=Mi(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?Hm(0):Ym(i,r.groupOriginByCopy,null),c=l;if(!a){let u=Qm(eS(i,f=>f.type==="Group"&&!!f.flags)),d=u?Mi(r.globalFlags,u):r.globalFlags;Y0(d,r.currentFlags)||(c=at({flags:tS(d)}),c.body[0].body.push(l))}n(Se(c,t),{traverse:!a})}},Z0={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=>Q0(i,e));if(!s.length)n(Se(Cn({negate:!0}),t));else if(s.length>1){let i=at({atomic:!0,body:s.reverse().map(a=>en({body:[Ai(a.number)]}))});n(Se(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=wc();e.body.at(-1).body.push(o)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Zm(e){er(e,{"*"({node:t,parent:n}){t.parent=n}})}function Y0(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Q0(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=eh(n.parent);for(let o of r){if(o===n)break;if(o===e||nh(o,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Ym(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]=Ym(i,t,o,n):(s==="type"&&i==="CapturingGroup"&&t.set(o,t.get(e)??e),o[s]=i);return o}function Hm(e){let t=Sc(e);return t.isRecursive=!0,t}function eS(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Ic(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 Qm(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 tS({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 eh(e){if(!e)throw new Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function th(e){let t=e.find(n=>n.kind==="search_start"||oS(n,{negate:!1})||!nS(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=th(r.body);if(!o)return null;Array.isArray(o)?n.push(...o):n.push(o)}return n}return null}function nh(e,t){let n=eh(e)??[];for(let r of n)if(r===t||nh(r,t))return!0;return!1}function nS({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function rS(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function oS(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Ri(e.body[0],{type:"Assertion",kind:"search_start"})}function Pc(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function nn(e,t){let r=Ei(e,{...t,unicodePropertyMap:Oc}).body;return r.length>1||r[0].body.length>1?at({body:r}):r[0].body[0]}function Lc(e,t){return e.negate=t,e}function vn(e,t){return e.parent=t,e}function Se(e,t){return Zm(e),e.parent=t,e}function sS(e,t){let n=Km(t),r=$c(n.target,"ES2024"),o=$c(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];er(e,iS,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(m){h.push(m)},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,F0(aS[h.type],`Unexpected node type "${h.type}"`)(h,u,d)}let f={pattern:e.body.map(d).join("|"),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((h,m)=>{h.hidden&&f._hiddenCaptures.push(m),h.transferTo&&Wo(f._captureTransfers,h.transferTo,[]).push(m)}),f}var iS={"*":{enter({node:e},t){if(zm(e)){let n=t.getCurrentModI();t.pushModI(e.flags?Mi({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){zm(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Dc(Ie(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),rh(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&Jm.has(e.value)&&t.setHasCasedChar()}},aS={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=Ie(e),r=Br(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Dc(n)){let o=Xm(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");_t.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(qm)&&(i=[Or(45),...i.filter(c=>!qm(c))]);let a=()=>`[${o?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||_t.bugNestedClassIgnoresNegation)&&!o){let u=i.filter(d=>d.type==="CharacterClass"&&d.kind==="union"&&d.negate);if(u.length){let d=at(),f=d.body[0];return d.parent=s,f.parent=d,i=i.filter(h=>!u.includes(h)),e.body=i,i.length?(e.parent=f,f.body.push(e)):d.body.pop(),u.forEach(h=>{let m=en({body:[h]});h.parent=m,m.parent=d,d.body.push(m)}),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"&&!(_t.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=Br(n,o),i=Br(r,o),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=rh(e);pS(l).forEach(u=>{a.add(Array.isArray(u)?`${Br(u[0],o)}-${Br(u[1],o)}`:Br(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&&Jm.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=Mi(i,n));let a=t.map(s).join("|"),l=!o.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!o.useFlagMods||!n)?a:`(?${fS(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)+mS(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}>`}},lS=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),cS=new Set(["-","\\","]","^","["]),uS=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Vm=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`]]),dS=new RegExp("^\\p{Cased}$","u");function Dc(e){return dS.test(e)}function rh(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=Ie(i);if(!Dc(a))continue;let l=Xm(a).filter(c=>{let u=c.codePointAt(0);return u<r||u>o});if(l.length&&(s.push(...l),n))break}return s}function Br(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Vm.has(e))return Vm.get(e);if(e<32||e>126&&e<160||e>262143||t&&hS(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let o=n?r?uS:cS:lS,s=Ie(e);return(o.has(s)?"\\":"")+s}function pS(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 fS(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 mS({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 zm({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function hS(e){return e>47&&e<58}function qm({type:e,value:t}){return e==="Character"&&t===45}var gS=class Mc 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 Mc&&(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=xS(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 Mc(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&&(yS(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=bS(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 yS(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 xS(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)Wo(n,s,{}).transferTo=r;return n}function bS(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 oh(e,t){let n=wS(e,t);return n.options?new gS(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function wS(e,t){let n=Km(t),r=Ei(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Oc}),o=K0(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=sS(o,n),i=Um(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),a=vc(i.pattern),l=_c(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((m,g)=>m-g),d=Array.from(l.captureTransfers),f=o._strategy,h=c.pattern.length>=n.lazyCompileLength;(u.length||d.length||f||h)&&(c.options={...u.length&&{hiddenCaptures:u},...d.length&&{transfers:d},...f&&{strategy:f},...h&&{lazyCompile:h}})}return c}function Di(e,t){return oh(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=>Di(n,{target:t.target}),{createScanner(n){return new pm(n,t)},createString(n){return{content:n}}}}oi(Ir({bundledLanguages:()=>_o,bundledLanguagesAlias:()=>Co,bundledLanguagesBase:()=>To,bundledLanguagesInfo:()=>Pr,bundledThemes:()=>Ro,bundledThemesInfo:()=>vo,codeToHast:()=>mc,codeToHtml:()=>fc,codeToTokens:()=>hc,codeToTokensBase:()=>Do,codeToTokensWithThemes:()=>gc,createHighlighter:()=>_i,createJavaScriptRegexEngine:()=>Nc,createOnigurumaEngine:()=>Ul,defaultJavaScriptRegexConstructor:()=>Di,getLastGrammarState:()=>yc,getSingletonHighlighter:()=>No,loadWasm:()=>li}),dm);var kS=/#/;function SS(e){return e=e.replace(kS,""),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 TS(e){return e=SS(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 sh(e,t,n){return[e,t,n].map(r=>{let o=r.toString(16);return o.length===1?`0${o}`:o}).join("")}function CS(e,t="dark"){let{r:n,g:r,b:o,a:s}=TS(e);return t==="dark"?sh(n*s,r*s,o*s):sh(n*s+255*(1-s),r*s+255*(1-s),o*s+255*(1-s))}async function Ho(e,t,n){let r="",o=await Do(e,{lang:t,theme:n}),s=(await No()).getTheme(n);for(let i of o){for(let a of i){let l=a.content,c=a.color||s.fg;c&&(l=Er.hex(CS(c,s.type))(l)),a.fontStyle&&(a.fontStyle&ye.Bold&&(l=Er.bold(l)),a.fontStyle&ye.Italic&&(l=Er.italic(l)),a.fontStyle&ye.Underline&&(l=Er.underline(l)),a.fontStyle&ye.Strikethrough&&(l=Er.strikethrough(l))),r+=l}r+=`
174
- `}return r}p();var ah={".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"},ih={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",".bashrc":"bash",".zshrc":"bash",".profile":"bash"};function Ni(e){let t=e.split(/[\\/]/).pop()??"";if(ih[t])return ih[t];let n=t.lastIndexOf(".");if(n<0)return;let r=t.slice(n).toLowerCase();return ah[r]}var Z$=new Set(Object.keys(ah));var _S="github-dark",vS="\x1B[32m+\x1B[39m",RS="\x1B[31m-\x1B[39m",AS="\x1B[90m \x1B[39m",ES="\x1B[36m",ch="\x1B[0m";function IS(e){let t=e.split(`
175
- `),n=[];for(let r of t)if(!(r.startsWith("---")||r.startsWith("+++"))){if(r.startsWith("@@")){n.push({kind:"hunk-header",raw:r});continue}r.startsWith("+")?n.push({kind:"add",raw:r}):r.startsWith("-")?n.push({kind:"remove",raw:r}):n.push({kind:"context",raw:r})}return n}async function uh(e,t){if(!e)return[];let n=IS(e);if(n.length===0)return[];let r=Ni(t),o=[];for(let u=0;u<n.length;u++)n[u].kind!=="hunk-header"&&o.push(u);if(o.length===0)return n.map(lh);if(!r)return null;let s=o.map(u=>{let d=n[u].raw;return d.length>0?d.slice(1):""}),i=s.join(`
176
- `),a;try{a=await Ho(i,r,_S)}catch{return null}let l=a.split(`
177
- `),c=l.length>0&&l[l.length-1]===""?l.slice(0,-1):l;return c.length!==s.length?null:n.map((u,d)=>{if(u.kind==="hunk-header")return lh(u);let f=o.indexOf(d),h=c[f]??"";return{kind:u.kind,ansi:`${PS(u.kind)}${h}${ch}`}})}function PS(e){switch(e){case"add":return vS;case"remove":return RS;case"context":return AS;case"hunk-header":return""}}function lh(e){return{kind:e.kind,ansi:`${ES}${e.raw}${ch}`}}function dh(e){let t=[];for(let n of e.split(`
178
- `))n.startsWith("---")||n.startsWith("+++")||(n.startsWith("@@")?t.push({kind:"hunk-header",ansi:"",raw:n}):n.startsWith("+")?t.push({kind:"add",ansi:"",raw:n}):n.startsWith("-")?t.push({kind:"remove",ansi:"",raw:n}):t.push({kind:"context",ansi:"",raw:n}));return t}import{jsx as zo,jsxs as Bi}from"react/jsx-runtime";function MS(e){let[t,n]=$S(()=>e.patch?dh(e.patch):[]);return LS(()=>{if(!e.patch){n([]);return}let r={cancelled:!1};return uh(e.patch,e.filePath).then(o=>{r.cancelled||o&&n(o)}).catch(()=>{}),()=>{r.cancelled=!0}},[e.patch,e.filePath]),t}function Fc({diff:e}){let{patch:t,additions:n,deletions:r,existedBefore:o,filePath:s}=e,i=MS(e);if(!t||t.length===0)return null;let a=s.replace(/\\/g,"/").split("/").pop()??s;return Bi(Bc,{flexDirection:"column",marginTop:1,children:[Bi(Bc,{flexDirection:"row",gap:1,children:[Bi(Vo,{bold:!0,color:"#00ffff",children:["\u{1F4DD} ",o?"\u4FEE\u6539":"\u65B0\u5EFA",":"]}),zo(Vo,{bold:!0,children:a}),Bi(Vo,{color:"#555555",children:["(+",n," -",r,")"]})]}),zo(Bc,{flexDirection:"column",marginLeft:2,children:i.map((l,c)=>zo(OS,{line:l},c))})]})}function OS({line:e}){if(e.ansi.length>0)return zo(Vo,{children:e.ansi});let t=DS[e.kind];return zo(Vo,{color:t,children:e.raw??""})}var DS={add:"#22c55e",remove:"#ef4444",context:"#6b7280","hunk-header":"#00cccc"};p();import{Box as Gc,Text as jc}from"ink";import{jsx as Fi,jsxs as ph}from"react/jsx-runtime";var NS="#00bfff";function Uc({skills:e,input:t,selectedIndex:n,triggerMode:r="slash"}){let o=r==="at"?t.match(/(?:^|\s)@([^@]*)$/):t.match(/(?:^|\s)\/([^/]*)$/);if(!o)return null;let s=o[1].toLowerCase().trim();if(e.length===0)return null;let i=r==="at"?"@":"/",a=!s&&t.startsWith(i)?e.slice(0,3):e.filter(l=>l.name.toLowerCase().includes(s)).slice(0,3);return s&&a.some(l=>l.name.toLowerCase()===s)||a.length===0?null:ph(Gc,{flexDirection:"column",marginLeft:4,marginTop:1,children:[Fi(jc,{color:"#808080",dimColor:!0,children:"\u652F\u6301\u7684 Skill\uFF1A"}),a.map((l,c)=>Fi(Gc,{children:ph(jc,{color:c===n?NS:"#808080",children:[c===n?" \u203A ":" ",l.name]})},l.name)),Fi(Gc,{marginTop:1,children:Fi(jc,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as qo,Text as Fr}from"ink";import{jsx as Gi,jsxs as nr}from"react/jsx-runtime";var BS="#ff79c6",FS="#50fa7b",Ko="#808080",fh=5;function GS(e){switch(e){case"ready":return"\u2705";case"starting":return"\u23F3";case"failed":return"\u274C";case"stopped":return"\u23F9";default:return"\u2022"}}function mh({servers:e,input:t,selectedIndex:n}){let r=t.match(/(?:^|\s)@([^@]*)$/);if(!r||e.length===0)return null;let o=r[1].toLowerCase().trim(),s=!o&&t.trim()==="@"?e.slice(0,fh):e.filter(i=>i.id.toLowerCase().includes(o)).slice(0,fh);return o&&s.some(i=>i.id.toLowerCase()===o)||s.length===0?null:nr(qo,{flexDirection:"column",marginLeft:4,marginTop:1,children:[nr(Fr,{color:Ko,dimColor:!0,children:["MCP server\uFF08\u8F93\u5165\u540D\u5B57\u8FFD\u52A0 @","<server>","\uFF0C\u56DE\u8F66\u5F15\u7528\uFF09\uFF1A"]}),s.map((i,a)=>{let l=a===n;return nr(qo,{flexDirection:"column",children:[Gi(qo,{children:nr(Fr,{color:l?BS:Ko,bold:l,children:[l?" \u203A ":" ",GS(i.state)," ",i.id,i.state==="ready"?nr(Fr,{color:FS,children:[" \xB7 ",i.tools.length," tools"]}):nr(Fr,{color:Ko,children:[" \xB7 ",i.state]})]})}),l&&i.state==="ready"&&i.tools.length>0&&Gi(qo,{marginLeft:6,children:nr(Fr,{color:Ko,dimColor:!0,children:[i.tools.slice(0,6).join(", "),i.tools.length>6?` \u2026 +${i.tools.length-6}`:""]})})]},i.id)}),Gi(qo,{marginTop:1,children:Gi(Fr,{color:Ko,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as Wc,Text as Hc}from"ink";import{jsx as ji,jsxs as hh}from"react/jsx-runtime";var jS="#00bfff",Vc="#808080",Ui=6;function gh(e){let t=e.match(/(?:^|\s)\/([^/]*)$/);if(!t||t[1]===""&&t[0].length>1)return null;let n=(t[1]??"").split(/\s+/)[0]??"";return{query:n?`/${n.toLowerCase()}`:""}}function yh({commands:e,input:t,selectedIndex:n}){let r=gh(t);if(!r||e.length===0)return null;let{query:o}=r;if(o&&e.some(i=>i.name.toLowerCase()===o))return null;let s=!o&&t.trimEnd().endsWith("/")?e.slice(0,Ui):e.filter(i=>i.name.toLowerCase().startsWith(o)).slice(0,Ui);return s.length===0?null:hh(Wc,{flexDirection:"column",marginLeft:4,marginTop:1,children:[ji(Hc,{color:Vc,dimColor:!0,children:"\u652F\u6301\u7684\u547D\u4EE4\uFF08\u8F93\u5165 / \u540E\u63A5\u540D\u5B57\u5339\u914D\uFF0CEnter \u9009\u4E2D\uFF09\uFF1A"}),s.map((i,a)=>{let l=a===n;return ji(Wc,{children:hh(Hc,{color:l?jS:Vc,bold:l,children:[l?" \u203A ":" ",i.name.padEnd(16),i.desc]})},i.name)}),ji(Wc,{marginTop:1,children:ji(Hc,{color:Vc,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168 \xB7 Esc \u5173\u95ED"})})]})}function Wi(e,t){let n=gh(e);if(!n)return[];let{query:r}=n;return r?t.filter(o=>o.name.toLowerCase().startsWith(r)).slice(0,Ui):e.trimEnd().endsWith("/")?t.slice(0,Ui):[]}p();var US=/(?:^|\s)@([a-z0-9_-]+)/g;function xh(e,t){if(!t)return null;let n=new Set;for(let a of e.matchAll(US))n.add(a[1]);if(n.size===0)return null;let r=t.listServers(),o=new Map(r.map(a=>[a.id,a])),s=[...n].filter(a=>o.has(a));if(s.length===0)return null;let i=["\u672C\u8F6E\u7528\u6237\u6D88\u606F\u5F15\u7528\u4E86\u4EE5\u4E0B MCP server\u3002\u4E0B\u8868\u5217\u51FA\u6BCF\u4E2A server \u5F53\u524D\u5DF2\u6CE8\u5165\u5230 ToolRegistry \u7684\u5DE5\u5177","\uFF08name \u5F62\u5982 `mcp_<server-id>_<tool>`\uFF0Cdescription \u5F62\u5982 `[mcp:<server-id>] <\u539F\u59CB>`\uFF09\u3002","\u5982\u9700\u8C03\u7528\uFF0C\u76F4\u63A5\u7528\u5DE5\u5177\u540D\uFF1B\u4E0D\u8981\u8BA9\u7528\u6237\u91CD\u590D @ \u5F15\u7528\u3002",""];for(let a of s){let l=o.get(a);if(l.state!=="ready"){i.push(`- @${a}\uFF08${l.state}\uFF0C\u6682\u4E0D\u53EF\u7528\uFF09`);continue}let c=t.tools(),u=`mcp_${a}_`,d=c.filter(f=>f.name.startsWith(u)).map(f=>` - \`${f.name}\`: ${f.description}`);d.length===0?i.push(`- @${a}\uFF08ready\uFF0C\u4F46\u672A\u62C9\u53D6\u5230\u5DE5\u5177\u5217\u8868\uFF09`):(i.push(`- @${a}\uFF08ready\uFF0C${d.length} \u4E2A\u5DE5\u5177\uFF09\uFF1A`),i.push(...d))}return i.join(`
179
- `)}p();import{Box as An,Text as jr}from"ink";import{useEffect as XS,useState as JS}from"react";p();import{Box as Gr,Text as rr}from"ink";import{useEffect as HS,useState as VS}from"react";p();function wh(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 kh(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 zc(e,t){let n=[];for(let r of t){if(!kh(e,r))continue;let o=wh(e,r);o!==null&&n.push({path:r,score:o})}return n.sort((r,o)=>r.score-o.score),n}var Hi=10;function Rn(e){let t=e.match(/(?:^|\s)@([^@]*)$/);if(!t)return null;let n=e.lastIndexOf("@"),r=t[1]??"";return{atIndex:n,query:r}}function Sh(e,t){let n=Rn(e);if(!n)return[];let r=n.query.toLowerCase().trim(),o=/^[12]$/.test(r)?"":r;if(!o)return t.slice(0,3);let s=t.filter(i=>i.name.toLowerCase().includes(o)).slice(0,3);return s.some(i=>i.name.toLowerCase()===o)?[]:s}function Xo(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=zc(o,t);return s.length===0?[]:s[0]?.path.toLowerCase()===o?[]:s.map(i=>i.path)}var bh="\x1B[0m";function Th(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 WS(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+=Th(s)?2:1,n+=s>65535?2:1}return t}function Ch(e,t){if(t<=0)return"";if(WS(e)<=t)return e;let r=t-1;if(r<=0)return"\u2026"+bh;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 f=e.charCodeAt(i);if(i++,f>=64&&f<=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 f=e.charCodeAt(i);if(f===7){i++;break}if(f===27&&i+1<e.length&&e[i+1]==="\\"){i+=2;break}i++}o+=e.slice(d,i);continue}let c=e.codePointAt(i),u=Th(c)?2:1;if(s+u>r)break;o+=String.fromCodePoint(c),s+=u,i+=c>65535?2:1}return o+"\u2026"+bh}import{jsx as rn,jsxs as Vi}from"react/jsx-runtime";var zS="github-dark",qS=512*1024,vh=4e3;var qc="#808080",Kc="#ff4444",_h=512;async function KS(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 m=await(await import("fs/promises")).open(i,"r");try{let g=Buffer.alloc(_h),{bytesRead:w}=await m.read(g,0,_h,0);for(let b=0;b<w;b++)if(g[b]===0)return{kind:"binary"}}finally{await m.close()}}catch{}let l=a.size>qS,c=l?vh: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=Ni(e),f;if(d)try{f=await Ho(u,d,zS)}catch(h){return{kind:"error",message:`\u9AD8\u4EAE\u5931\u8D25: ${h instanceof Error?h.message:String(h)}`}}else f=u;return n.cancelled?{kind:"idle"}:{kind:"ready",ansi:f,truncated:l}}function zi({relativePath:e,cwd:t,width:n,maxLines:r}){let[o,s]=VS({kind:"idle"});if(HS(()=>{if(!e){s({kind:"idle"});return}let m={cancelled:!1};return s({kind:"loading"}),KS(e,t,m).then(g=>{m.cancelled||s(g)}),()=>{m.cancelled=!0}},[e,t]),!e)return rn(Gr,{flexDirection:"column",paddingX:1,children:rn(rr,{color:qc,dimColor:!0,children:"\u2190 \u9009\u62E9\u5DE6\u4FA7\u6587\u4EF6\u67E5\u770B\u9AD8\u4EAE\u4EE3\u7801"})});if(o.kind==="loading"||o.kind==="idle")return rn(Gr,{flexDirection:"column",paddingX:1,children:rn(rr,{color:qc,children:"\u2699 \u52A0\u8F7D\u4E2D\u2026"})});if(o.kind==="binary")return rn(Gr,{flexDirection:"column",paddingX:1,children:rn(rr,{color:Kc,children:"\u26A0 \u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"})});if(o.kind==="too-large")return rn(Gr,{flexDirection:"column",paddingX:1,children:Vi(rr,{color:Kc,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF08",o.bytes," \u5B57\u8282\uFF09\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"]})});if(o.kind==="error")return rn(Gr,{flexDirection:"column",paddingX:1,children:Vi(rr,{color:Kc,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(`
180
- `),u=c.length>l,d=u?c.slice(0,Math.max(l-1,0)):c,f=d.map(m=>Ch(m,i)).join(`
173
+ \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-${Ie(d.codePointAt(0)-1)}${Ie(d.codePointAt(2)+1)}-\u{10FFFF}`),n(Se(nn(`[${d}]`),t))}else n(Se(jc(nn(gT.get(u)),c),t));else if(l==="property")Hc.has(Gr(u))||(e.key="sc");else if(l==="space")n(Rn(nr("space",{negate:c}),t));else if(l==="word")n(Se(jc(nn(tn),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=lt({flags:l});c.body[0].body=i(),o(Se(c,t),{traverse:!0})}else if(a==="keep"){let c=n.body[0],d=n.body.length===1&&Mi(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(t.parent!==d||d.body.length>1)throw new Error(Y`Uses "\K" in a way that's unsupported`);let f=_n({behind:!0});f.body[0].body=s(),o(Se(f,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(Se(_n({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=lt();t.body[0].body.push(e.body),e.body=Se(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=kh(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(Y`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Fc(n)&&(n=Gc(n,t),e.ref=n)}},kT={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=Rn(ch(e.number),t);l.set(d,a.get(e.number)),n(d);return}a.set(e.number,e),i.set(e.number,[]),e.name&&Jo(i,e.name,[]);let u=i.get(e.name??e.number);for(let d=0;d<u.length;d++){let f=u[d];if(c===f.node||c&&c===f.origin||e===f.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=Jo(s,e.name,new Map),f=!1;if(c)f=!0;else for(let h of d.values())if(!h.hasDuplicateNameToRemove){f=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}},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=ji(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?ch(0):yh(i,r.groupOriginByCopy,null),c=l;if(!a){let u=xh(CT(i,f=>f.type==="Group"&&!!f.flags)),d=u?ji(r.globalFlags,u):r.globalFlags;TT(d,r.currentFlags)||(c=lt({flags:_T(d)}),c.body[0].body.push(l))}n(Se(c,t),{traverse:!a})}},wT={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=>ST(i,e));if(!s.length)n(Se(_n({negate:!0}),t));else if(s.length>1){let i=lt({atomic:!0,body:s.reverse().map(a=>en({body:[Oi(a.number)]}))});n(Se(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=Ec();e.body.at(-1).body.push(o)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function gh(e){rr(e,{"*"({node:t,parent:n}){t.parent=n}})}function TT(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function ST(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=bh(n.parent);for(let o of r){if(o===n)break;if(o===e||wh(o,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function yh(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]=yh(i,t,o,n):(s==="type"&&i==="CapturingGroup"&&t.set(o,t.get(e)??e),o[s]=i);return o}function ch(e){let t=Pc(e);return t.isRecursive=!0,t}function CT(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Gc(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 xh(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 _T({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 bh(e){if(!e)throw new Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function kh(e){let t=e.find(n=>n.kind==="search_start"||AT(n,{negate:!1})||!vT(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=kh(r.body);if(!o)return null;Array.isArray(o)?n.push(...o):n.push(o)}return n}return null}function wh(e,t){let n=bh(e)??[];for(let r of n)if(r===t||wh(r,t))return!0;return!1}function vT({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function RT(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function AT(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Mi(e.body[0],{type:"Assertion",kind:"search_start"})}function Fc(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function nn(e,t){let r=Di(e,{...t,unicodePropertyMap:Hc}).body;return r.length>1||r[0].body.length>1?lt({body:r}):r[0].body[0]}function jc(e,t){return e.negate=t,e}function Rn(e,t){return e.parent=t,e}function Se(e,t){return gh(e),e.parent=t,e}function ET(e,t){let n=fh(t),r=Uc(n.target,"ES2024"),o=Uc(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];rr(e,IT,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(m){h.push(m)},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,cT(PT[h.type],`Unexpected node type "${h.type}"`)(h,u,d)}let f={pattern:e.body.map(d).join("|"),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((h,m)=>{h.hidden&&f._hiddenCaptures.push(m),h.transferTo&&Jo(f._captureTransfers,h.transferTo,[]).push(m)}),f}var IT={"*":{enter({node:e},t){if(dh(e)){let n=t.getCurrentModI();t.pushModI(e.flags?ji({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){dh(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Vc(Ie(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Th(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&hh.has(e.value)&&t.setHasCasedChar()}},PT={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?Y`\B`:Y`\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=Ie(e),r=jr(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Vc(n)){let o=mh(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");_t.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(ph)&&(i=[Br(45),...i.filter(c=>!ph(c))]);let a=()=>`[${o?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||_t.bugNestedClassIgnoresNegation)&&!o){let u=i.filter(d=>d.type==="CharacterClass"&&d.kind==="union"&&d.negate);if(u.length){let d=lt(),f=d.body[0];return d.parent=s,f.parent=d,i=i.filter(h=>!u.includes(h)),e.body=i,i.length?(e.parent=f,f.body.push(e)):d.body.pop(),u.forEach(h=>{let m=en({body:[h]});h.parent=m,m.parent=d,d.body.push(m)}),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"&&!(_t.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=jr(n,o),i=jr(r,o),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=Th(e);DT(l).forEach(u=>{a.add(Array.isArray(u)?`${jr(u[0],o)}-${jr(u[1],o)}`:jr(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?".":"[^]":Y`[^\n]`;if(e==="digit")return t?Y`\D`:Y`\d`;if(e==="property"){if(o.useAppliedIgnoreCase&&o.currentFlags.ignoreCase&&hh.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Y`\P`:Y`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?Y`\W`:Y`\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=ji(i,n));let a=t.map(s).join("|"),l=!o.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!o.useFlagMods||!n)?a:`(?${NT(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)+BT(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})`:Y`\g<${t}&R=${r}>`}},$T=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),LT=new Set(["-","\\","]","^","["]),MT=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),uh=new Map([[9,Y`\t`],[10,Y`\n`],[11,Y`\v`],[12,Y`\f`],[13,Y`\r`],[8232,Y`\u2028`],[8233,Y`\u2029`],[65279,Y`\uFEFF`]]),OT=new RegExp("^\\p{Cased}$","u");function Vc(e){return OT.test(e)}function Th(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=Ie(i);if(!Vc(a))continue;let l=mh(a).filter(c=>{let u=c.codePointAt(0);return u<r||u>o});if(l.length&&(s.push(...l),n))break}return s}function jr(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(uh.has(e))return uh.get(e);if(e<32||e>126&&e<160||e>262143||t&&GT(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let o=n?r?MT:LT:$T,s=Ie(e);return(o.has(s)?"\\":"")+s}function DT(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 NT(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 BT({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 dh({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function GT(e){return e>47&&e<58}function ph({type:e,value:t}){return e==="Character"&&t===45}var FT=class Wc 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 Wc&&(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=UT(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 Wc(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&&(jT(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=WT(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 jT(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 UT(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)Jo(n,s,{}).transferTo=r;return n}function WT(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 Sh(e,t){let n=HT(e,t);return n.options?new FT(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function HT(e,t){let n=fh(t),r=Di(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Hc}),o=xT(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=ET(o,n),i=ah(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),a=Oc(i.pattern),l=Mc(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((m,g)=>m-g),d=Array.from(l.captureTransfers),f=o._strategy,h=c.pattern.length>=n.lazyCompileLength;(u.length||d.length||f||h)&&(c.options={...u.length&&{hiddenCaptures:u},...d.length&&{transfers:d},...f&&{strategy:f},...h&&{lazyCompile:h}})}return c}function Wi(e,t){return Sh(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function zc(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>Wi(n,{target:t.target}),{createScanner(n){return new Pm(n,t)},createString(n){return{content:n}}}}di(Lr({bundledLanguages:()=>$o,bundledLanguagesAlias:()=>Po,bundledLanguagesBase:()=>Io,bundledLanguagesInfo:()=>Mr,bundledThemes:()=>Mo,bundledThemesInfo:()=>Lo,codeToHast:()=>Sc,codeToHtml:()=>Tc,codeToTokens:()=>Cc,codeToTokensBase:()=>Wo,codeToTokensWithThemes:()=>_c,createHighlighter:()=>$i,createJavaScriptRegexEngine:()=>zc,createOnigurumaEngine:()=>Zl,defaultJavaScriptRegexConstructor:()=>Wi,getLastGrammarState:()=>vc,getSingletonHighlighter:()=>Ho,loadWasm:()=>hi}),Im);var VT=/#/;function zT(e){return e=e.replace(VT,""),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 qT(e){return e=zT(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 Ch(e,t,n){return[e,t,n].map(r=>{let o=r.toString(16);return o.length===1?`0${o}`:o}).join("")}function KT(e,t="dark"){let{r:n,g:r,b:o,a:s}=qT(e);return t==="dark"?Ch(n*s,r*s,o*s):Ch(n*s+255*(1-s),r*s+255*(1-s),o*s+255*(1-s))}async function Zo(e,t,n){let r="",o=await Wo(e,{lang:t,theme:n}),s=(await Ho()).getTheme(n);for(let i of o){for(let a of i){let l=a.content,c=a.color||s.fg;c&&(l=$r.hex(KT(c,s.type))(l)),a.fontStyle&&(a.fontStyle&xe.Bold&&(l=$r.bold(l)),a.fontStyle&xe.Italic&&(l=$r.italic(l)),a.fontStyle&xe.Underline&&(l=$r.underline(l)),a.fontStyle&xe.Strikethrough&&(l=$r.strikethrough(l))),r+=l}r+=`
174
+ `}return r}p();var vh={".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"},_h={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",".bashrc":"bash",".zshrc":"bash",".profile":"bash"};function Hi(e){let t=e.split(/[\\/]/).pop()??"";if(_h[t])return _h[t];let n=t.lastIndexOf(".");if(n<0)return;let r=t.slice(n).toLowerCase();return vh[r]}var SM=new Set(Object.keys(vh));var XT="github-dark",JT="\x1B[32m+\x1B[39m",ZT="\x1B[31m-\x1B[39m",YT="\x1B[90m \x1B[39m",QT="\x1B[36m",Ah="\x1B[0m";function eS(e){let t=e.split(`
175
+ `),n=[];for(let r of t)if(!(r.startsWith("---")||r.startsWith("+++"))){if(r.startsWith("@@")){n.push({kind:"hunk-header",raw:r});continue}r.startsWith("+")?n.push({kind:"add",raw:r}):r.startsWith("-")?n.push({kind:"remove",raw:r}):n.push({kind:"context",raw:r})}return n}async function Eh(e,t){if(!e)return[];let n=eS(e);if(n.length===0)return[];let r=Hi(t),o=[];for(let u=0;u<n.length;u++)n[u].kind!=="hunk-header"&&o.push(u);if(o.length===0)return n.map(Rh);if(!r)return null;let s=o.map(u=>{let d=n[u].raw;return d.length>0?d.slice(1):""}),i=s.join(`
176
+ `),a;try{a=await Zo(i,r,XT)}catch{return null}let l=a.split(`
177
+ `),c=l.length>0&&l[l.length-1]===""?l.slice(0,-1):l;return c.length!==s.length?null:n.map((u,d)=>{if(u.kind==="hunk-header")return Rh(u);let f=o.indexOf(d),h=c[f]??"";return{kind:u.kind,ansi:`${tS(u.kind)}${h}${Ah}`}})}function tS(e){switch(e){case"add":return JT;case"remove":return ZT;case"context":return YT;case"hunk-header":return""}}function Rh(e){return{kind:e.kind,ansi:`${QT}${e.raw}${Ah}`}}function Ih(e){let t=[];for(let n of e.split(`
178
+ `))n.startsWith("---")||n.startsWith("+++")||(n.startsWith("@@")?t.push({kind:"hunk-header",ansi:"",raw:n}):n.startsWith("+")?t.push({kind:"add",ansi:"",raw:n}):n.startsWith("-")?t.push({kind:"remove",ansi:"",raw:n}):t.push({kind:"context",ansi:"",raw:n}));return t}import{jsx as Qo,jsxs as Vi}from"react/jsx-runtime";function oS(e){let[t,n]=rS(()=>e.patch?Ih(e.patch):[]);return nS(()=>{if(!e.patch){n([]);return}let r={cancelled:!1};return Eh(e.patch,e.filePath).then(o=>{r.cancelled||o&&n(o)}).catch(()=>{}),()=>{r.cancelled=!0}},[e.patch,e.filePath]),t}function Kc({diff:e}){let{patch:t,additions:n,deletions:r,existedBefore:o,filePath:s}=e,i=oS(e);if(!t||t.length===0)return null;let a=s.replace(/\\/g,"/").split("/").pop()??s;return Vi(qc,{flexDirection:"column",marginTop:1,children:[Vi(qc,{flexDirection:"row",gap:1,children:[Vi(Yo,{bold:!0,color:"#00ffff",children:["\u{1F4DD} ",o?"\u4FEE\u6539":"\u65B0\u5EFA",":"]}),Qo(Yo,{bold:!0,children:a}),Vi(Yo,{color:"#555555",children:["(+",n," -",r,")"]})]}),Qo(qc,{flexDirection:"column",marginLeft:2,children:i.map((l,c)=>Qo(sS,{line:l},c))})]})}function sS({line:e}){if(e.ansi.length>0)return Qo(Yo,{children:e.ansi});let t=iS[e.kind];return Qo(Yo,{color:t,children:e.raw??""})}var iS={add:"#22c55e",remove:"#ef4444",context:"#6b7280","hunk-header":"#00cccc"};p();import{Box as Xc,Text as Jc}from"ink";import{jsx as zi,jsxs as Ph}from"react/jsx-runtime";var aS="#00bfff";function Zc({skills:e,input:t,selectedIndex:n,triggerMode:r="slash"}){let o=r==="at"?t.match(/(?:^|\s)@([^@]*)$/):t.match(/(?:^|\s)\/([^/]*)$/);if(!o)return null;let s=o[1].toLowerCase().trim();if(e.length===0)return null;let i=r==="at"?"@":"/",a=!s&&t.startsWith(i)?e.slice(0,3):e.filter(l=>l.name.toLowerCase().includes(s)).slice(0,3);return s&&a.some(l=>l.name.toLowerCase()===s)||a.length===0?null:Ph(Xc,{flexDirection:"column",marginLeft:4,marginTop:1,children:[zi(Jc,{color:"#808080",dimColor:!0,children:"\u652F\u6301\u7684 Skill\uFF1A"}),a.map((l,c)=>zi(Xc,{children:Ph(Jc,{color:c===n?aS:"#808080",children:[c===n?" \u203A ":" ",l.name]})},l.name)),zi(Xc,{marginTop:1,children:zi(Jc,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as es,Text as Ur}from"ink";import{jsx as qi,jsxs as sr}from"react/jsx-runtime";var lS="#ff79c6",cS="#50fa7b",ts="#808080",$h=5;function uS(e){switch(e){case"ready":return"\u2705";case"starting":return"\u23F3";case"failed":return"\u274C";case"stopped":return"\u23F9";default:return"\u2022"}}function Lh({servers:e,input:t,selectedIndex:n}){let r=t.match(/(?:^|\s)@([^@]*)$/);if(!r||e.length===0)return null;let o=r[1].toLowerCase().trim(),s=!o&&t.trim()==="@"?e.slice(0,$h):e.filter(i=>i.id.toLowerCase().includes(o)).slice(0,$h);return o&&s.some(i=>i.id.toLowerCase()===o)||s.length===0?null:sr(es,{flexDirection:"column",marginLeft:4,marginTop:1,children:[sr(Ur,{color:ts,dimColor:!0,children:["MCP server\uFF08\u8F93\u5165\u540D\u5B57\u8FFD\u52A0 @","<server>","\uFF0C\u56DE\u8F66\u5F15\u7528\uFF09\uFF1A"]}),s.map((i,a)=>{let l=a===n;return sr(es,{flexDirection:"column",children:[qi(es,{children:sr(Ur,{color:l?lS:ts,bold:l,children:[l?" \u203A ":" ",uS(i.state)," ",i.id,i.state==="ready"?sr(Ur,{color:cS,children:[" \xB7 ",i.tools.length," tools"]}):sr(Ur,{color:ts,children:[" \xB7 ",i.state]})]})}),l&&i.state==="ready"&&i.tools.length>0&&qi(es,{marginLeft:6,children:sr(Ur,{color:ts,dimColor:!0,children:[i.tools.slice(0,6).join(", "),i.tools.length>6?` \u2026 +${i.tools.length-6}`:""]})})]},i.id)}),qi(es,{marginTop:1,children:qi(Ur,{color:ts,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168"})})]})}p();import{Box as Yc,Text as Qc}from"ink";import{jsx as Ki,jsxs as Mh}from"react/jsx-runtime";var dS="#00bfff",eu="#808080",Xi=6;function Oh(e){let t=e.match(/(?:^|\s)\/([^/]*)$/);if(!t||t[1]===""&&t[0].length>1)return null;let n=(t[1]??"").split(/\s+/)[0]??"";return{query:n?`/${n.toLowerCase()}`:""}}function Dh({commands:e,input:t,selectedIndex:n}){let r=Oh(t);if(!r||e.length===0)return null;let{query:o}=r;if(o&&e.some(i=>i.name.toLowerCase()===o))return null;let s=!o&&t.trimEnd().endsWith("/")?e.slice(0,Xi):e.filter(i=>i.name.toLowerCase().startsWith(o)).slice(0,Xi);return s.length===0?null:Mh(Yc,{flexDirection:"column",marginLeft:4,marginTop:1,children:[Ki(Qc,{color:eu,dimColor:!0,children:"\u652F\u6301\u7684\u547D\u4EE4\uFF08\u8F93\u5165 / \u540E\u63A5\u540D\u5B57\u5339\u914D\uFF0CEnter \u9009\u4E2D\uFF09\uFF1A"}),s.map((i,a)=>{let l=a===n;return Ki(Yc,{children:Mh(Qc,{color:l?dS:eu,bold:l,children:[l?" \u203A ":" ",i.name.padEnd(16),i.desc]})},i.name)}),Ki(Yc,{marginTop:1,children:Ki(Qc,{color:eu,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168 \xB7 Esc \u5173\u95ED"})})]})}function Ji(e,t){let n=Oh(e);if(!n)return[];let{query:r}=n;return r?t.filter(o=>o.name.toLowerCase().startsWith(r)).slice(0,Xi):e.trimEnd().endsWith("/")?t.slice(0,Xi):[]}p();var pS=/(?:^|\s)@([a-z0-9_-]+)/g;function Nh(e,t){if(!t)return null;let n=new Set;for(let a of e.matchAll(pS))n.add(a[1]);if(n.size===0)return null;let r=t.listServers(),o=new Map(r.map(a=>[a.id,a])),s=[...n].filter(a=>o.has(a));if(s.length===0)return null;let i=["\u672C\u8F6E\u7528\u6237\u6D88\u606F\u5F15\u7528\u4E86\u4EE5\u4E0B MCP server\u3002\u4E0B\u8868\u5217\u51FA\u6BCF\u4E2A server \u5F53\u524D\u5DF2\u6CE8\u5165\u5230 ToolRegistry \u7684\u5DE5\u5177","\uFF08name \u5F62\u5982 `mcp_<server-id>_<tool>`\uFF0Cdescription \u5F62\u5982 `[mcp:<server-id>] <\u539F\u59CB>`\uFF09\u3002","\u5982\u9700\u8C03\u7528\uFF0C\u76F4\u63A5\u7528\u5DE5\u5177\u540D\uFF1B\u4E0D\u8981\u8BA9\u7528\u6237\u91CD\u590D @ \u5F15\u7528\u3002",""];for(let a of s){let l=o.get(a);if(l.state!=="ready"){i.push(`- @${a}\uFF08${l.state}\uFF0C\u6682\u4E0D\u53EF\u7528\uFF09`);continue}let c=t.tools(),u=`mcp_${a}_`,d=c.filter(f=>f.name.startsWith(u)).map(f=>` - \`${f.name}\`: ${f.description}`);d.length===0?i.push(`- @${a}\uFF08ready\uFF0C\u4F46\u672A\u62C9\u53D6\u5230\u5DE5\u5177\u5217\u8868\uFF09`):(i.push(`- @${a}\uFF08ready\uFF0C${d.length} \u4E2A\u5DE5\u5177\uFF09\uFF1A`),i.push(...d))}return i.join(`
179
+ `)}p();import{Box as En,Text as Hr}from"ink";import{useEffect as bS,useState as kS}from"react";p();import{Box as Wr,Text as ir}from"ink";import{useEffect as mS,useState as hS}from"react";p();function Gh(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 Fh(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 tu(e,t){let n=[];for(let r of t){if(!Fh(e,r))continue;let o=Gh(e,r);o!==null&&n.push({path:r,score:o})}return n.sort((r,o)=>r.score-o.score),n}var Zi=10;function An(e){let t=e.match(/(?:^|\s)@([^@]*)$/);if(!t)return null;let n=e.lastIndexOf("@"),r=t[1]??"";return{atIndex:n,query:r}}function jh(e,t){let n=An(e);if(!n)return[];let r=n.query.toLowerCase().trim(),o=/^[12]$/.test(r)?"":r;if(!o)return t.slice(0,3);let s=t.filter(i=>i.name.toLowerCase().includes(o)).slice(0,3);return s.some(i=>i.name.toLowerCase()===o)?[]:s}function ns(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=tu(o,t);return s.length===0?[]:s[0]?.path.toLowerCase()===o?[]:s.map(i=>i.path)}var Bh="\x1B[0m";function Uh(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 fS(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+=Uh(s)?2:1,n+=s>65535?2:1}return t}function Wh(e,t){if(t<=0)return"";if(fS(e)<=t)return e;let r=t-1;if(r<=0)return"\u2026"+Bh;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 f=e.charCodeAt(i);if(i++,f>=64&&f<=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 f=e.charCodeAt(i);if(f===7){i++;break}if(f===27&&i+1<e.length&&e[i+1]==="\\"){i+=2;break}i++}o+=e.slice(d,i);continue}let c=e.codePointAt(i),u=Uh(c)?2:1;if(s+u>r)break;o+=String.fromCodePoint(c),s+=u,i+=c>65535?2:1}return o+"\u2026"+Bh}import{jsx as rn,jsxs as Yi}from"react/jsx-runtime";var gS="github-dark",yS=512*1024,Vh=4e3;var nu="#808080",ru="#ff4444",Hh=512;async function xS(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 m=await(await import("fs/promises")).open(i,"r");try{let g=Buffer.alloc(Hh),{bytesRead:b}=await m.read(g,0,Hh,0);for(let k=0;k<b;k++)if(g[k]===0)return{kind:"binary"}}finally{await m.close()}}catch{}let l=a.size>yS,c=l?Vh: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=Hi(e),f;if(d)try{f=await Zo(u,d,gS)}catch(h){return{kind:"error",message:`\u9AD8\u4EAE\u5931\u8D25: ${h instanceof Error?h.message:String(h)}`}}else f=u;return n.cancelled?{kind:"idle"}:{kind:"ready",ansi:f,truncated:l}}function Qi({relativePath:e,cwd:t,width:n,maxLines:r}){let[o,s]=hS({kind:"idle"});if(mS(()=>{if(!e){s({kind:"idle"});return}let m={cancelled:!1};return s({kind:"loading"}),xS(e,t,m).then(g=>{m.cancelled||s(g)}),()=>{m.cancelled=!0}},[e,t]),!e)return rn(Wr,{flexDirection:"column",paddingX:1,children:rn(ir,{color:nu,dimColor:!0,children:"\u2190 \u9009\u62E9\u5DE6\u4FA7\u6587\u4EF6\u67E5\u770B\u9AD8\u4EAE\u4EE3\u7801"})});if(o.kind==="loading"||o.kind==="idle")return rn(Wr,{flexDirection:"column",paddingX:1,children:rn(ir,{color:nu,children:"\u2699 \u52A0\u8F7D\u4E2D\u2026"})});if(o.kind==="binary")return rn(Wr,{flexDirection:"column",paddingX:1,children:rn(ir,{color:ru,children:"\u26A0 \u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"})});if(o.kind==="too-large")return rn(Wr,{flexDirection:"column",paddingX:1,children:Yi(ir,{color:ru,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF08",o.bytes," \u5B57\u8282\uFF09\uFF0C\u4E0D\u652F\u6301\u9884\u89C8"]})});if(o.kind==="error")return rn(Wr,{flexDirection:"column",paddingX:1,children:Yi(ir,{color:ru,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(`
180
+ `),u=c.length>l,d=u?c.slice(0,Math.max(l-1,0)):c,f=d.map(m=>Wh(m,i)).join(`
181
181
  `),h=u&&l>0?`${f}
182
- \u2026 \u4EE5\u4E0B ${c.length-d.length} \u884C\u672A\u663E\u793A`:f;return Vi(Gr,{flexDirection:"column",paddingX:1,children:[o.truncated&&Vi(rr,{color:qc,dimColor:!0,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF0C\u4EC5\u663E\u793A\u524D ",vh," \u5B57\u8282"]}),rn(rr,{children:h})]})}import{jsx as or,jsxs as En}from"react/jsx-runtime";var Rh="#00ff41",Ur="#808080",Xc=4,ZS=60,YS=20;function QS(e,t){return t<=0?"":e.length<=t?e:t<=1?"\u2026":e.slice(0,t-1)+"\u2026"}function Jc({files:e,input:t,selectedIndex:n,cwd:r,width:o}){let s=Xo(t,e);if(!s||s.length===0)return null;let i=Hi,a=Math.max(1,Math.ceil(s.length/i)),[l,c]=JS(0);XS(()=>{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>=ZS))return En(An,{flexDirection:"column",marginLeft:Xc,marginTop:1,children:[En(jr,{color:Ur,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),d.map((v,I)=>{let D=u+I===n;return or(An,{children:En(jr,{color:D?Rh:Ur,children:[D?" \u203A ":" ",v]})},v)})]});let h=o-Xc,m=Math.max(Math.floor(h/3),YS),g=Math.max(h-m-1,20),w=10,b=n>=0&&n<s.length?s[n]??null:null,k=Math.max(m-2,4);return En(An,{flexDirection:"row",paddingLeft:Xc,marginTop:1,children:[En(An,{flexDirection:"column",width:m,flexShrink:0,children:[En(jr,{color:Ur,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),or(An,{flexDirection:"column",marginTop:1,children:d.map((v,I)=>{let D=u+I===n;return En(jr,{color:D?Rh:Ur,bold:D,children:[D?"\u25B8 ":" ",QS(v,k)]},v)})})]}),or(An,{width:1,flexShrink:0,children:or(jr,{color:Ur,children:"\u2502"})}),En(An,{flexDirection:"column",width:g,flexShrink:0,children:[or(jr,{color:Ur,dimColor:!0,children:b?`\u{1F4C4} ${b}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),or(An,{flexDirection:"column",marginTop:1,children:or(zi,{relativePath:b,cwd:r,width:g,maxLines:w})})]})]})}p();import{Box as Gt,Text as sr,useInput as eT}from"ink";import tT from"ink-text-input";import{useEffect as Ah,useMemo as nT,useState as Zc}from"react";import{jsx as yt,jsxs as ir}from"react/jsx-runtime";var rT="#00ff41",Jo="#808080",qi="#00ffff",jt=Hi;function Eh({files:e,cwd:t,width:n,height:r,onPick:o,onClose:s}){let[i,a]=Zc(""),[l,c]=Zc(0),u=nT(()=>i.trim()?zc(i,e):[],[i,e]),d=Math.max(1,Math.ceil(u.length/jt)),[f,h]=Zc(0);Ah(()=>{h(0),c(0)},[i]),Ah(()=>{h(R=>u.length===0?0:R<0||R>=u.length?Math.floor(l/jt)*jt:l<R?Math.max(0,Math.floor(l/jt)*jt):l>=R+jt?Math.floor(l/jt)*jt:R)},[l,u.length]);let m=f,g=u.slice(m,m+jt),w=l>=m&&l<m+g.length?l-m:0;eT((R,D)=>{if(D.ctrl&&R==="p"){s();return}if(D.escape){s();return}if(D.upArrow){if(u.length===0)return;c(F=>(F-1+u.length)%u.length);return}if(D.downArrow){if(u.length===0)return;c(F=>(F+1)%u.length);return}if(D.return){let F=u[l];F&&o(F.path);return}},{isActive:!0});let b=Math.max(Math.floor(n/3),24),k=Math.max(n-b-1,20),v=Math.max(r-11,4),I=u[l]?.path??null;return ir(Gt,{flexDirection:"column",height:r,children:[ir(Gt,{flexDirection:"row",borderStyle:"round",borderColor:qi,paddingX:1,children:[yt(sr,{bold:!0,color:qi,children:"\u{1F50D} "}),yt(Gt,{flexGrow:1,children:yt(tT,{value:i,onChange:a,placeholder:"\u8F93\u5165\u6587\u4EF6\u540D"})})]}),ir(Gt,{flexDirection:"row",flexGrow:1,marginTop:1,children:[ir(Gt,{flexDirection:"column",width:b,borderStyle:"single",borderColor:qi,paddingX:1,flexShrink:0,children:[ir(sr,{color:Jo,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6 (",u.length," \u6761)",d>1?` \xB7 ${Math.floor(f/jt)+1}/${d}`:""]}),yt(Gt,{flexDirection:"column",marginTop:1,children:g.length===0?yt(sr,{color:Jo,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((R,D)=>{let F=D===w;return ir(sr,{color:F?rT:void 0,bold:F,children:[F?"\u25B8 ":" ",R.path]},R.path)})})]}),yt(Gt,{width:1,flexShrink:0,children:yt(sr,{color:Jo,children:"\u2502"})}),ir(Gt,{flexDirection:"column",width:k,borderStyle:"single",borderColor:qi,flexShrink:0,children:[yt(sr,{color:Jo,dimColor:!0,children:I?`\u{1F4C4} ${I}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),yt(Gt,{flexDirection:"column",marginTop:1,children:yt(zi,{relativePath:I,cwd:t,width:k,maxLines:v})})]})]}),yt(Gt,{marginTop:1,children:yt(sr,{color:Jo,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{Box as Ki,Text as Yc}from"ink";import{jsx as Zo,jsxs as Ih}from"react/jsx-runtime";var oT="#00ff41",Qc="#808080",In=[{index:1,label:"Files & Directories",enabled:!0},{index:2,label:"Skills",enabled:!0},{index:3,label:"MCPs",enabled:!0},{index:4,label:"Fetch",enabled:!1}];function Ph(){return In.filter(e=>e.enabled)}function sT(e){return e?Ph().length>0:!1}var iT=4;function Lh({open:e,selectedIndex:t}){if(!sT(e))return null;let n=Ph(),r=Math.min(Math.max(t,0),In.length-1),o=In[r]?.index??n[0].index;return Ih(Ki,{flexDirection:"column",marginLeft:iT,marginTop:1,children:[Zo(Yc,{color:Qc,dimColor:!0,children:"\u9009\u62E9 @ \u5F15\u7528\u7C7B\u578B\uFF08\u8F93\u5165\u6570\u5B57\u6216\u5B57\u6BCD\u76F4\u63A5\u5F00\u59CB\u6587\u4EF6\u641C\u7D22\uFF09\uFF1A"}),Zo(Ki,{flexDirection:"column",marginTop:1,children:n.map(s=>{let i=s.index===o;return Zo(Ki,{children:Ih(Yc,{color:i?oT:Qc,bold:i,children:[i?" \u203A ":" ",s.index,". ",s.label]})},s.index)})}),Zo(Ki,{marginTop:1,children:Zo(Yc,{color:Qc,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 \u6570\u5B57\u952E\u76F4\u8FBE \xB7 Esc \u53D6\u6D88 \xB7 \u76F4\u63A5\u8F93\u5165\u5B57\u6BCD\u8FDB\u5165 Files"})})]})}p();import{Text as ar,useInput as aT}from"ink";import{jsx as Yo,jsxs as $h}from"react/jsx-runtime";function Mh({value:e,onChange:t,onSubmit:n,placeholder:r="",focus:o=!0}){if(aT((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?Yo(ar,{dimColor:!0,children:r}):Yo(ar,{children:e});if(!e&&r){let s=r[0],i=r.slice(1);return $h(ar,{children:[Yo(ar,{inverse:!0,children:s}),Yo(ar,{dimColor:!0,children:i})]})}return $h(ar,{children:[e,Yo(ar,{inverse:!0,children:" "})]})}p();p();function eu(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function lT(e){return e.replace(/<skill_content/g,"&lt;skill_content").replace(/<\/skill_content/g,"&lt;/skill_content")}function Xi(e,t){let n=eu(e.name),r=eu(e.source),o=eu(e.directoryPath),s=lT(t.trim());return`<skill_content name="${n}">
182
+ \u2026 \u4EE5\u4E0B ${c.length-d.length} \u884C\u672A\u663E\u793A`:f;return Yi(Wr,{flexDirection:"column",paddingX:1,children:[o.truncated&&Yi(ir,{color:nu,dimColor:!0,children:["\u26A0 \u6587\u4EF6\u8FC7\u5927\uFF0C\u4EC5\u663E\u793A\u524D ",Vh," \u5B57\u8282"]}),rn(ir,{children:h})]})}import{jsx as ar,jsxs as In}from"react/jsx-runtime";var zh="#00ff41",Vr="#808080",ou=4,wS=60,TS=20;function SS(e,t){return t<=0?"":e.length<=t?e:t<=1?"\u2026":e.slice(0,t-1)+"\u2026"}function su({files:e,input:t,selectedIndex:n,cwd:r,width:o}){let s=ns(t,e);if(!s||s.length===0)return null;let i=Zi,a=Math.max(1,Math.ceil(s.length/i)),[l,c]=kS(0);bS(()=>{c(A=>A<0||A>=s.length?Math.floor(n/i)*i:n<A?Math.max(0,Math.floor(n/i)*i):n>=A+i?Math.floor(n/i)*i:A)},[n,s.length,i]);let u=l,d=s.slice(u,u+i);if(!(o>=wS))return In(En,{flexDirection:"column",marginLeft:ou,marginTop:1,children:[In(Hr,{color:Vr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),d.map((A,E)=>{let F=u+E===n;return ar(En,{children:In(Hr,{color:F?zh:Vr,children:[F?" \u203A ":" ",A]})},A)})]});let h=o-ou,m=Math.max(Math.floor(h/3),TS),g=Math.max(h-m-1,20),b=10,k=n>=0&&n<s.length?s[n]??null:null,T=Math.max(m-2,4);return In(En,{flexDirection:"row",paddingLeft:ou,marginTop:1,children:[In(En,{flexDirection:"column",width:m,flexShrink:0,children:[In(Hr,{color:Vr,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6\uFF08",s.length,"\uFF09",a>1?` \xB7 ${Math.floor(l/i)+1}/${a}`:""]}),ar(En,{flexDirection:"column",marginTop:1,children:d.map((A,E)=>{let F=u+E===n;return In(Hr,{color:F?zh:Vr,bold:F,children:[F?"\u25B8 ":" ",SS(A,T)]},A)})})]}),ar(En,{width:1,flexShrink:0,children:ar(Hr,{color:Vr,children:"\u2502"})}),In(En,{flexDirection:"column",width:g,flexShrink:0,children:[ar(Hr,{color:Vr,dimColor:!0,children:k?`\u{1F4C4} ${k}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),ar(En,{flexDirection:"column",marginTop:1,children:ar(Qi,{relativePath:k,cwd:r,width:g,maxLines:b})})]})]})}p();import{Box as Ft,Text as lr,useInput as CS}from"ink";import _S from"ink-text-input";import{useEffect as qh,useMemo as vS,useState as iu}from"react";import{jsx as bt,jsxs as cr}from"react/jsx-runtime";var RS="#00ff41",rs="#808080",ea="#00ffff",jt=Zi;function Kh({files:e,cwd:t,width:n,height:r,onPick:o,onClose:s}){let[i,a]=iu(""),[l,c]=iu(0),u=vS(()=>i.trim()?tu(i,e):[],[i,e]),d=Math.max(1,Math.ceil(u.length/jt)),[f,h]=iu(0);qh(()=>{h(0),c(0)},[i]),qh(()=>{h(I=>u.length===0?0:I<0||I>=u.length?Math.floor(l/jt)*jt:l<I?Math.max(0,Math.floor(l/jt)*jt):l>=I+jt?Math.floor(l/jt)*jt:I)},[l,u.length]);let m=f,g=u.slice(m,m+jt),b=l>=m&&l<m+g.length?l-m:0;CS((I,F)=>{if(F.ctrl&&I==="p"){s();return}if(F.escape){s();return}if(F.upArrow){if(u.length===0)return;c(M=>(M-1+u.length)%u.length);return}if(F.downArrow){if(u.length===0)return;c(M=>(M+1)%u.length);return}if(F.return){let M=u[l];M&&o(M.path);return}},{isActive:!0});let k=Math.max(Math.floor(n/3),24),T=Math.max(n-k-1,20),A=Math.max(r-11,4),E=u[l]?.path??null;return cr(Ft,{flexDirection:"column",height:r,children:[cr(Ft,{flexDirection:"row",borderStyle:"round",borderColor:ea,paddingX:1,children:[bt(lr,{bold:!0,color:ea,children:"\u{1F50D} "}),bt(Ft,{flexGrow:1,children:bt(_S,{value:i,onChange:a,placeholder:"\u8F93\u5165\u6587\u4EF6\u540D"})})]}),cr(Ft,{flexDirection:"row",flexGrow:1,marginTop:1,children:[cr(Ft,{flexDirection:"column",width:k,borderStyle:"single",borderColor:ea,paddingX:1,flexShrink:0,children:[cr(lr,{color:rs,dimColor:!0,children:["\u5339\u914D\u6587\u4EF6 (",u.length," \u6761)",d>1?` \xB7 ${Math.floor(f/jt)+1}/${d}`:""]}),bt(Ft,{flexDirection:"column",marginTop:1,children:g.length===0?bt(lr,{color:rs,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((I,F)=>{let M=F===b;return cr(lr,{color:M?RS:void 0,bold:M,children:[M?"\u25B8 ":" ",I.path]},I.path)})})]}),bt(Ft,{width:1,flexShrink:0,children:bt(lr,{color:rs,children:"\u2502"})}),cr(Ft,{flexDirection:"column",width:T,borderStyle:"single",borderColor:ea,flexShrink:0,children:[bt(lr,{color:rs,dimColor:!0,children:E?`\u{1F4C4} ${E}`:"\u{1F4C4} \uFF08\u672A\u9009\u62E9\u6587\u4EF6\uFF09"}),bt(Ft,{flexDirection:"column",marginTop:1,children:bt(Qi,{relativePath:E,cwd:t,width:T,maxLines:A})})]})]}),bt(Ft,{marginTop:1,children:bt(lr,{color:rs,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{Box as ta,Text as au}from"ink";import{jsx as os,jsxs as Xh}from"react/jsx-runtime";var AS="#00ff41",lu="#808080",Pn=[{index:1,label:"Files & Directories",enabled:!0},{index:2,label:"Skills",enabled:!0},{index:3,label:"MCPs",enabled:!0},{index:4,label:"Fetch",enabled:!1}];function Jh(){return Pn.filter(e=>e.enabled)}function ES(e){return e?Jh().length>0:!1}var IS=4;function Zh({open:e,selectedIndex:t}){if(!ES(e))return null;let n=Jh(),r=Math.min(Math.max(t,0),Pn.length-1),o=Pn[r]?.index??n[0].index;return Xh(ta,{flexDirection:"column",marginLeft:IS,marginTop:1,children:[os(au,{color:lu,dimColor:!0,children:"\u9009\u62E9 @ \u5F15\u7528\u7C7B\u578B\uFF08\u8F93\u5165\u6570\u5B57\u6216\u5B57\u6BCD\u76F4\u63A5\u5F00\u59CB\u6587\u4EF6\u641C\u7D22\uFF09\uFF1A"}),os(ta,{flexDirection:"column",marginTop:1,children:n.map(s=>{let i=s.index===o;return os(ta,{children:Xh(au,{color:i?AS:lu,bold:i,children:[i?" \u203A ":" ",s.index,". ",s.label]})},s.index)})}),os(ta,{marginTop:1,children:os(au,{color:lu,dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 \u6570\u5B57\u952E\u76F4\u8FBE \xB7 Esc \u53D6\u6D88 \xB7 \u76F4\u63A5\u8F93\u5165\u5B57\u6BCD\u8FDB\u5165 Files"})})]})}p();import{Text as ur,useInput as PS}from"ink";import{jsx as ss,jsxs as Yh}from"react/jsx-runtime";function Qh({value:e,onChange:t,onSubmit:n,placeholder:r="",focus:o=!0}){if(PS((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?ss(ur,{dimColor:!0,children:r}):ss(ur,{children:e});if(!e&&r){let s=r[0],i=r.slice(1);return Yh(ur,{children:[ss(ur,{inverse:!0,children:s}),ss(ur,{dimColor:!0,children:i})]})}return Yh(ur,{children:[e,ss(ur,{inverse:!0,children:" "})]})}p();p();function cu(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function $S(e){return e.replace(/<skill_content/g,"&lt;skill_content").replace(/<\/skill_content/g,"&lt;/skill_content")}function na(e,t){let n=cu(e.name),r=cu(e.source),o=cu(e.directoryPath),s=$S(t.trim());return`<skill_content name="${n}">
183
183
  <source>${r}</source>
184
184
  <directory>${o}</directory>
185
185
  Relative paths in this skill resolve against <directory>.
186
186
 
187
187
  ${s}
188
188
  </skill_content>
189
- `}var cT=/^\/(\S+)(?:\s+(.*))?$/;async function Oh(e,t){let n=cT.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 Ws(s.skillFilePath)}catch(l){return{kind:"error",message:l instanceof Error?l.message:String(l)}}let a=Xi(s,i);return{kind:"text",text:o?`${a}
189
+ `}var LS=/^\/(\S+)(?:\s+(.*))?$/;async function eg(e,t){let n=LS.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 Js(s.skillFilePath)}catch(l){return{kind:"error",message:l instanceof Error?l.message:String(l)}}let a=na(s,i);return{kind:"text",text:o?`${a}
190
190
 
191
- ${o}`:a}}p();import{Box as tu,Text as lr}from"ink";import uT from"ink-spinner";import{jsx as Ut,jsxs as Nh}from"react/jsx-runtime";function Dh(e){switch(e){case"pending":return"\u2610";case"done":return"\u2611";case"failed":return"\u2717";case"skipped":return"\u2298";case"running":return"\u25B6"}}function dT({status:e}){return e==="running"?Ut(lr,{color:"cyan",children:Ut(uT,{type:"dots"})}):e==="done"?Ut(lr,{color:"green",children:"\u2705"}):e==="failed"?Ut(lr,{color:"red",children:Dh(e)}):Ut(lr,{dimColor:!0,children:Dh(e)})}function nu({items:e}){return e.length===0?null:Nh(tu,{flexDirection:"column",marginTop:1,children:[Ut(tu,{children:Ut(lr,{dimColor:!0,children:"\u{1F527} \u4EFB\u52A1\u8FDB\u5EA6"})}),e.map(t=>Nh(tu,{children:[Ut(lr,{dimColor:!0,children:" "}),Ut(dT,{status:t.status}),Ut(lr,{dimColor:!0,children:` ${t.content}`})]},t.id))]})}p();import{Box as qe,Text as Ae}from"ink";import pT from"ink-spinner";import{useMemo as Bh}from"react";import{Fragment as bT,jsx as Te,jsxs as Pe}from"react/jsx-runtime";function fT(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 mT(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 hT({percent:e,color:t}){let r=Math.round(e/100*24),o=24-r;return Pe(Ae,{children:[Te(Ae,{color:t,children:"\u2588".repeat(r)}),Te(Ae,{color:"#444444",children:"\u2591".repeat(o)}),Pe(Ae,{color:t,children:[" ",e.toFixed(0),"%"]})]})}function gT({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 Te(qe,{children:n.map((r,o)=>{let s=o===t,i=o<t;return Pe(qe,{marginRight:1,children:[Pe(Ae,{color:i?"#00ff41":s?"#00ffff":"#444444",children:[i?"\u2713":s?"\u25B8":"\xB7"," ",r]}),o<n.length-1&&Te(Ae,{color:"#444444",children:" \u2192 "})]},r)})})}function yT({text:e,contentWidth:t}){let r=Math.max(t-6,20);if(!e)return Te(Ae,{dimColor:!0,children:" (\u7B49\u5F85 LLM \u8F93\u51FA...)"});let s=xT(e,r).slice(-4);return Te(qe,{flexDirection:"column",children:s.map((i,a)=>Pe(Ae,{dimColor:!0,children:[" ",i]},a))})}function xT(e,t){if(e==="")return[];if(t<=0)return[e];let n=[];for(let r of e.split(`
192
- `)){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 Fh(e){return e.toLocaleString()}function ru({state:e,contentWidth:t}){let n=Bh(()=>fT(e),[e]),r=Bh(()=>mT(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 Te(qe,{flexDirection:"column",marginTop:1,children:Pe(qe,{flexDirection:"row",children:[Te(qe,{width:1,backgroundColor:"#9b59b6",flexShrink:0}),Pe(qe,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[Pe(qe,{children:[Te(Ae,{bold:!0,color:i,children:"\u{1F5DC} \u4E0A\u4E0B\u6587\u538B\u7F29"}),Te(qe,{flexGrow:1}),e.phase==="running"&&Pe(Ae,{color:r.color,children:[Te(pT,{type:"dots"})," ",r.text]}),e.phase==="done"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]}),e.phase==="error"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]})]}),Pe(qe,{marginTop:1,children:[Te(Ae,{color:"#808080",children:"\u8FDB\u5EA6: "}),Te(hT,{percent:n,color:e.phase==="error"?"#ff6347":r.color})]}),Te(qe,{marginTop:1,children:Te(gT,{state:e})}),(e.beforeTokens!==void 0||e.droppedTurns!==void 0)&&Pe(qe,{marginTop:1,flexDirection:"column",children:[e.droppedTurns!==void 0&&Pe(Ae,{color:"#00ff41",children:["\u{1F4CA} \u56DE\u5408: ",e.droppedTurns," \u6298\u53E0 \u2192 ",e.keptTurns??0," \u4FDD\u7559"]}),e.beforeTokens!==void 0&&Pe(Ae,{color:"#ff9800",children:["\u{1F4E6} token: ",Fh(e.beforeTokens),e.afterTokens!==void 0&&Pe(bT,{children:[" \u2192 ",Te(Ae,{color:"#00ff41",bold:!0,children:Fh(e.afterTokens)}),Pe(Ae,{color:"#808080",children:[" (\u8282\u7701 ",((e.beforeTokens-e.afterTokens)/Math.max(e.beforeTokens,1)*100).toFixed(1),"%)"]})]})]})]}),(e.phase==="running"||e.phase==="done")&&s&&Pe(qe,{marginTop:1,flexDirection:"column",children:[Te(Ae,{color:"#808080",children:"\u2504\u2504\u2504 LLM \u6458\u8981\u9884\u89C8 \u2504\u2504\u2504"}),Te(yT,{text:s,contentWidth:t})]}),e.phase==="done"&&e.strategy==="fallback"&&Te(qe,{marginTop:1,children:Te(Ae,{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&&Te(qe,{marginTop:1,children:Pe(Ae,{color:"#ff6347",children:["\u26A0 ",e.errorMessage]})})]})]})})}p();var Gh={name:"dskcode",version:"0.1.53",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 Qo=Gh.version;p();p();var Ji=class{#e=new Map;#t=new Map;register(t,n){this.#e.set(t,n)}get(t,n){if(!al(n.model))throw new ll(n.model);let r=`${t}:${n.baseUrl}:${n.model}`,o=this.#t.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.#t.set(r,i),i}list(){return[...this.#e.keys()]}clear(){this.#t.clear()}},ou=new Ji;ou.register("deepseek",e=>new cl({apiKey:e.apiKey,baseUrl:e.baseUrl,model:e.model}));function su(e){return ou.get(e.name,e)}p();p();import Wh from"handlebars";var jh=`\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
191
+ ${o}`:a}}p();import{Box as uu,Text as dr}from"ink";import MS from"ink-spinner";import{jsx as Ut,jsxs as ng}from"react/jsx-runtime";function tg(e){switch(e){case"pending":return"\u2610";case"done":return"\u2611";case"failed":return"\u2717";case"skipped":return"\u2298";case"running":return"\u25B6"}}function OS({status:e}){return e==="running"?Ut(dr,{color:"cyan",children:Ut(MS,{type:"dots"})}):e==="done"?Ut(dr,{color:"green",children:"\u2705"}):e==="failed"?Ut(dr,{color:"red",children:tg(e)}):Ut(dr,{dimColor:!0,children:tg(e)})}function du({items:e}){return e.length===0?null:ng(uu,{flexDirection:"column",marginTop:1,children:[Ut(uu,{children:Ut(dr,{dimColor:!0,children:"\u{1F527} \u4EFB\u52A1\u8FDB\u5EA6"})}),e.map(t=>ng(uu,{children:[Ut(dr,{dimColor:!0,children:" "}),Ut(OS,{status:t.status}),Ut(dr,{dimColor:!0,children:` ${t.content}`})]},t.id))]})}p();import{Box as qe,Text as Ae}from"ink";import DS from"ink-spinner";import{useMemo as rg}from"react";import{Fragment as WS,jsx as Ce,jsxs as Pe}from"react/jsx-runtime";function NS(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 BS(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 GS({percent:e,color:t}){let r=Math.round(e/100*24),o=24-r;return Pe(Ae,{children:[Ce(Ae,{color:t,children:"\u2588".repeat(r)}),Ce(Ae,{color:"#444444",children:"\u2591".repeat(o)}),Pe(Ae,{color:t,children:[" ",e.toFixed(0),"%"]})]})}function FS({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 Ce(qe,{children:n.map((r,o)=>{let s=o===t,i=o<t;return Pe(qe,{marginRight:1,children:[Pe(Ae,{color:i?"#00ff41":s?"#00ffff":"#444444",children:[i?"\u2713":s?"\u25B8":"\xB7"," ",r]}),o<n.length-1&&Ce(Ae,{color:"#444444",children:" \u2192 "})]},r)})})}function jS({text:e,contentWidth:t}){let r=Math.max(t-6,20);if(!e)return Ce(Ae,{dimColor:!0,children:" (\u7B49\u5F85 LLM \u8F93\u51FA...)"});let s=US(e,r).slice(-4);return Ce(qe,{flexDirection:"column",children:s.map((i,a)=>Pe(Ae,{dimColor:!0,children:[" ",i]},a))})}function US(e,t){if(e==="")return[];if(t<=0)return[e];let n=[];for(let r of e.split(`
192
+ `)){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 og(e){return e.toLocaleString()}function pu({state:e,contentWidth:t}){let n=rg(()=>NS(e),[e]),r=rg(()=>BS(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 Ce(qe,{flexDirection:"column",marginTop:1,children:Pe(qe,{flexDirection:"row",children:[Ce(qe,{width:1,backgroundColor:"#9b59b6",flexShrink:0}),Pe(qe,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[Pe(qe,{children:[Ce(Ae,{bold:!0,color:i,children:"\u{1F5DC} \u4E0A\u4E0B\u6587\u538B\u7F29"}),Ce(qe,{flexGrow:1}),e.phase==="running"&&Pe(Ae,{color:r.color,children:[Ce(DS,{type:"dots"})," ",r.text]}),e.phase==="done"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]}),e.phase==="error"&&Pe(Ae,{color:r.color,children:[r.icon," ",r.text]})]}),Pe(qe,{marginTop:1,children:[Ce(Ae,{color:"#808080",children:"\u8FDB\u5EA6: "}),Ce(GS,{percent:n,color:e.phase==="error"?"#ff6347":r.color})]}),Ce(qe,{marginTop:1,children:Ce(FS,{state:e})}),(e.beforeTokens!==void 0||e.droppedTurns!==void 0)&&Pe(qe,{marginTop:1,flexDirection:"column",children:[e.droppedTurns!==void 0&&Pe(Ae,{color:"#00ff41",children:["\u{1F4CA} \u56DE\u5408: ",e.droppedTurns," \u6298\u53E0 \u2192 ",e.keptTurns??0," \u4FDD\u7559"]}),e.beforeTokens!==void 0&&Pe(Ae,{color:"#ff9800",children:["\u{1F4E6} token: ",og(e.beforeTokens),e.afterTokens!==void 0&&Pe(WS,{children:[" \u2192 ",Ce(Ae,{color:"#00ff41",bold:!0,children:og(e.afterTokens)}),Pe(Ae,{color:"#808080",children:[" (\u8282\u7701 ",((e.beforeTokens-e.afterTokens)/Math.max(e.beforeTokens,1)*100).toFixed(1),"%)"]})]})]})]}),(e.phase==="running"||e.phase==="done")&&s&&Pe(qe,{marginTop:1,flexDirection:"column",children:[Ce(Ae,{color:"#808080",children:"\u2504\u2504\u2504 LLM \u6458\u8981\u9884\u89C8 \u2504\u2504\u2504"}),Ce(jS,{text:s,contentWidth:t})]}),e.phase==="done"&&e.strategy==="fallback"&&Ce(qe,{marginTop:1,children:Ce(Ae,{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&&Ce(qe,{marginTop:1,children:Pe(Ae,{color:"#ff6347",children:["\u26A0 ",e.errorMessage]})})]})]})})}p();var sg={name:"dskcode",version:"0.1.54",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 is=sg.version;p();p();var ra=class{#e=new Map;#t=new Map;register(t,n){this.#e.set(t,n)}get(t,n){if(!fl(n.model))throw new ml(n.model);let r=`${t}:${n.baseUrl}:${n.model}`,o=this.#t.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.#t.set(r,i),i}list(){return[...this.#e.keys()]}clear(){this.#t.clear()}},fu=new ra;fu.register("deepseek",e=>new hl({apiKey:e.apiKey,baseUrl:e.baseUrl,model:e.model}));function mu(e){return fu.get(e.name,e)}p();p();import lg from"handlebars";var ig=`\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
193
193
  \r
194
194
  ## \u6838\u5FC3\u539F\u5219\r
195
195
  - \u56DE\u7B54\u4F7F\u7528\u4E2D\u6587\uFF0C\u4EE3\u7801\u6807\u8BC6\u7B26\u4FDD\u6301\u82F1\u6587\r
@@ -364,7 +364,7 @@ ${o}`:a}}p();import{Box as tu,Text as lr}from"ink";import uT from"ink-spinner";i
364
364
  - \u5F53\u524D\u65E5\u671F\uFF1A{{date}}\r
365
365
  - \u5F53\u524D\u65F6\u95F4\uFF1A{{time}}\r
366
366
  - \u5DE5\u4F5C\u76EE\u5F55\uFF1A{{cwd}}\r
367
- `;var Uh=`\u4F60\u662F dskcode\uFF0C\u5F53\u524D\u5DE5\u4F5C\u5728**\u8BA1\u5212\u6A21\u5F0F\uFF08Plan Mode\uFF09**\u3002\r
367
+ `;var ag=`\u4F60\u662F dskcode\uFF0C\u5F53\u524D\u5DE5\u4F5C\u5728**\u8BA1\u5212\u6A21\u5F0F\uFF08Plan Mode\uFF09**\u3002\r
368
368
  \r
369
369
  \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
370
370
  \r
@@ -464,7 +464,7 @@ ${o}`:a}}p();import{Box as tu,Text as lr}from"ink";import uT from"ink-spinner";i
464
464
  - \u5F53\u524D\u65E5\u671F\uFF1A{{date}}\r
465
465
  - \u5F53\u524D\u65F6\u95F4\uFF1A{{time}}\r
466
466
  - \u5DE5\u4F5C\u76EE\u5F55\uFF1A{{cwd}}\r
467
- `;var TT=Wh.compile(jh),CT=Wh.compile(Uh);function _T(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 Hh(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?_T(e.tools):void 0,projectContext:e.projectContext??void 0,skills:e.availableSkills,hasSkills:(e.availableSkills?.length??0)>0}}function Vh(e){return TT(Hh(e))}function zh(e){return CT(Hh(e))}p();function Kh(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Sr(t)+10}function Zi(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 qh(e){let t=0;for(let n of e)t+=Kh(n);return t}function Xh(e,t){let r=kn(t.model).contextWindow-t.reservedForOutput,o=Sr(t.systemPrompt),s=r-o,i=Zi(e),a=[],l=0;for(let m=i.length-1;m>=0&&l<t.preserveRecentRounds;m--)a.unshift(i[m]),l++;let c=a.flat();for(let m of c)s-=Kh(m);if(s<0){for(;a.length>1&&s<0;){let m=a.shift();s+=qh(m)}return[a.flat(),!0]}let u=i.slice(0,i.length-a.length),d=[];for(let m=u.length-1;m>=0;m--){let g=qh(u[m]);if(s-g<0)break;s-=g,d.unshift(u[m])}let f=[...d,...a].flat(),h=f.length<e.length;return[f,h]}function Jh(e,t){return[{role:"system",content:e},...t]}p();var au=.85,lu=6,Yi=8,vT="[history-summary]",RT=`\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
467
+ `;var qS=lg.compile(ig),KS=lg.compile(ag);function XS(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 cg(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?XS(e.tools):void 0,projectContext:e.projectContext??void 0,skills:e.availableSkills,hasSkills:(e.availableSkills?.length??0)>0}}function ug(e){return qS(cg(e))}function dg(e){return KS(cg(e))}p();function fg(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return _r(t)+10}function oa(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 pg(e){let t=0;for(let n of e)t+=fg(n);return t}function mg(e,t){let r=Tn(t.model).contextWindow-t.reservedForOutput,o=_r(t.systemPrompt),s=r-o,i=oa(e),a=[],l=0;for(let m=i.length-1;m>=0&&l<t.preserveRecentRounds;m--)a.unshift(i[m]),l++;let c=a.flat();for(let m of c)s-=fg(m);if(s<0){for(;a.length>1&&s<0;){let m=a.shift();s+=pg(m)}return[a.flat(),!0]}let u=i.slice(0,i.length-a.length),d=[];for(let m=u.length-1;m>=0;m--){let g=pg(u[m]);if(s-g<0)break;s-=g,d.unshift(u[m])}let f=[...d,...a].flat(),h=f.length<e.length;return[f,h]}function hg(e,t){return[{role:"system",content:e},...t]}p();var gu=.85,yu=6,sa=8,JS="[history-summary]",ZS=`\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
468
468
 
469
469
  \u6458\u8981\u5FC5\u987B\u4FDD\u7559\u4EE5\u4E0B\u4FE1\u606F\uFF08\u6309\u91CD\u8981\u6027\u6392\u5E8F\uFF09\uFF1A
470
470
  1. \u7528\u6237\u7684\u6838\u5FC3\u76EE\u6807\u4E0E\u6700\u7EC8\u610F\u56FE
@@ -479,21 +479,21 @@ ${o}`:a}}p();import{Box as tu,Text as lr}from"ink";import uT from"ink-spinner";i
479
479
  - \u6BCF\u6761\u4FE1\u606F\u72EC\u7ACB\u6210\u884C\uFF0C\u65B9\u4FBF\u540E\u7EED\u6309\u884C\u89E3\u6790
480
480
  - \u603B\u957F\u5EA6\u63A7\u5236\u5728 2000 \u5B57\u4EE5\u5185
481
481
  - \u4E0D\u9700\u8981\u5BA2\u5957\u8BDD\u3001\u4E0D\u9700\u8981"\u4EE5\u4E0B\u662F\u6458\u8981"\u7B49\u5F00\u5934
482
- `,Zh=500,AT=60;function ET(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return Sr(t)+10}function iu(e){let t=0;for(let n of e)t+=ET(n);return t}function cu(e,t){let n=iu(e),r=t>0?n/t:0;return{messageCount:e.length,estimatedTokens:n,contextWindow:t,ratio:r,headroom:t-n}}function Qh(e,t){let n=Zi(e),r=t.minTurnsToCompact??Yi;if(n.length<r)return!1;let o=t.autoCompactRatio??au;return cu(e,t.contextWindow).ratio>=o}function IT(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>Zh?o.content.slice(0,Zh)+`\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(`
483
- `)}function Yh(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,AT);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=Ar(a.argsRaw);return l.ok?Hs(a.name,po(l.args)):`${a.name}(\u89E3\u6790\u5931\u8D25)`});t.push(` \u8C03\u7528\u5DE5\u5177: ${i.join("; ")}`)}}return t.join(`
484
- `)}async function PT(e,t){if(e.length===0)return"";let n=IT(e);try{let r=[{role:"system",content:RT},{role:"user",content:`\u8BF7\u628A\u4EE5\u4E0B ${e.length} \u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u6458\u8981\uFF1A
482
+ `,gg=500,YS=60;function QS(e){let t=e.content;if(e.toolCalls)for(let n of e.toolCalls)t+=n.name+n.arguments;return _r(t)+10}function hu(e){let t=0;for(let n of e)t+=QS(n);return t}function xu(e,t){let n=hu(e),r=t>0?n/t:0;return{messageCount:e.length,estimatedTokens:n,contextWindow:t,ratio:r,headroom:t-n}}function xg(e,t){let n=oa(e),r=t.minTurnsToCompact??sa;if(n.length<r)return!1;let o=t.autoCompactRatio??gu;return xu(e,t.contextWindow).ratio>=o}function eC(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>gg?o.content.slice(0,gg)+`\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(`
483
+ `)}function yg(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,YS);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=Pr(a.argsRaw);return l.ok?Zs(a.name,xo(l.args)):`${a.name}(\u89E3\u6790\u5931\u8D25)`});t.push(` \u8C03\u7528\u5DE5\u5177: ${i.join("; ")}`)}}return t.join(`
484
+ `)}async function tC(e,t){if(e.length===0)return"";let n=eC(e);try{let r=[{role:"system",content:ZS},{role:"user",content:`\u8BF7\u628A\u4EE5\u4E0B ${e.length} \u8F6E\u5BF9\u8BDD\u5386\u53F2\u538B\u7F29\u6210\u7ED3\u6784\u5316\u6458\u8981\uFF1A
485
485
 
486
- ${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=Yh(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=Yh(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:o,fallbackSummary:s})}catch{}return s}}function LT(e){return{role:"system",content:`${vT}
487
- ${e}`}}async function uu(e,t){let n=iu(e),r=Zi(e),o=t.minTurnsToCompact??Yi,s=t.preserveRecentRounds??lu;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 PT(a,t),u=[LT(c)];for(let f of l)for(let h of f)u.push(h);let d=iu(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 Pn=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(je(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=>!Vn(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 RD}from"zod";function du(e,t){let n=t.safeParse(e);if(n.success)return{ok:!0,issues:[]};let r=n.error.issues.map(o=>$T(o,e));return{ok:r.length===0,issues:r}}function $T(e,t){let n=MT(e.path),r=OT(e),o=DT(t,e.path),s=NT(n,r,o,e);return{path:n,expected:r,received:o,message:s}}function MT(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 OT(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 DT(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 NT(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 eg(e,t){if(BT(t))return du(e,t);let n=[];return fu(t)?t.type!==void 0&&t.type!=="object"?{ok:!0,issues:n}:(tg(e,t,"$",n),{ok:n.length===0,issues:n}):{ok:!0,issues:n}}function BT(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 tg(e,t,n,r){if(!fu(e)){r.push({path:n,expected:"object",received:Ln(e),message:`${n} \u5E94\u4E3A object\uFF0C\u5B9E\u9645\u4E3A ${Ln(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:Ln(a),message:`${n}.${i} \u4E0D\u5728\u5141\u8BB8\u5B57\u6BB5\u4E2D`}):fu(s)&&pu(a,s,`${n}.${i}`,r);continue}pu(a,l,`${n}.${i}`,r)}}function pu(e,t,n,r){if(t.type!==void 0){let o=GT(e);if(!jT(o,t.type)){r.push({path:n,expected:t.type,received:Ln(e),message:`${n} \u5E94\u4E3A ${t.type}\uFF0C\u5B9E\u9645\u4E3A ${o}`});return}}if(t.enum&&t.enum.length>0){let o=`enum[${t.enum.map(s=>JSON.stringify(s)).join(",")}]`;FT(e)?t.enum.includes(e)||r.push({path:n,expected:o,received:Ln(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${JSON.stringify(e)}`}):r.push({path:n,expected:o,received:Ln(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${Ln(e)}`})}if(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:Ln(e),message:`${n} \u4E0D\u5339\u914D pattern ${t.pattern}`})}catch{}if(t.properties!==void 0&&tg(e,t,n,r),t.items!==void 0&&Array.isArray(e))for(let o=0;o<e.length;o++)pu(e[o],t.items,`${n}[${o}]`,r)}function fu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function FT(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function GT(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e}function jT(e,t){return e===t||t==="integer"&&e==="number"||t==="number"&&e==="integer"}function Ln(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 Qi=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.#c(t)}#n(t){return t.every(n=>{let r=this.#e.get(n.name);return r?Vn(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#c(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 c=`\u5DE5\u5177 "${n}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`;return{item:{name:n,callId:t.id,result:{success:!1,data:c,error:"TOOL_NOT_FOUND"}},record:{name:n,success:!1,error:"TOOL_NOT_FOUND",timestamp:r}}}let s=Ar(t.arguments??"");if(!s.ok){if(s.reason==="PARTIAL"){let u=`\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:u,error:"PARTIAL_JSON"}},record:{name:n,success:!1,error:"PARTIAL_JSON",timestamp:r}}}let c=`\u5DE5\u5177 "${n}" \u53C2\u6570\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${s.error}
488
- \u539F\u6587: ${s.raw.slice(0,200)}`;return{item:{name:n,callId:t.id,result:{success:!1,data:c,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 c=eg(i,l);c.ok||(a=c.issues)}if(!Vn(o.kind)&&!await this.#t.check(n,i)){let u=this.#t.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(!Vn(o.kind)){let c=o.preview;if(typeof c=="function")try{await c(i,this.#r)}catch{}}try{let c=await this.#p(o,i);if(a&&a.length>0){let d=a.map(h=>` - ${h.message}`).join(`
486
+ ${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=yg(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=yg(e);if(t.onProgress)try{t.onProgress({type:"fallback",reason:o,fallbackSummary:s})}catch{}return s}}function nC(e){return{role:"system",content:`${JS}
487
+ ${e}`}}async function bu(e,t){let n=hu(e),r=oa(e),o=t.minTurnsToCompact??sa,s=t.preserveRecentRounds??yu;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 tC(a,t),u=[nC(c)];for(let f of l)for(let h of f)u.push(h);let d=hu(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 $n=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(je(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=>!qn(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 QD}from"zod";function ku(e,t){let n=t.safeParse(e);if(n.success)return{ok:!0,issues:[]};let r=n.error.issues.map(o=>rC(o,e));return{ok:r.length===0,issues:r}}function rC(e,t){let n=oC(e.path),r=sC(e),o=iC(t,e.path),s=aC(n,r,o,e);return{path:n,expected:r,received:o,message:s}}function oC(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 sC(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 iC(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 aC(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 bg(e,t){if(lC(t))return ku(e,t);let n=[];return Tu(t)?t.type!==void 0&&t.type!=="object"?{ok:!0,issues:n}:(kg(e,t,"$",n),{ok:n.length===0,issues:n}):{ok:!0,issues:n}}function lC(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 kg(e,t,n,r){if(!Tu(e)){r.push({path:n,expected:"object",received:Ln(e),message:`${n} \u5E94\u4E3A object\uFF0C\u5B9E\u9645\u4E3A ${Ln(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:Ln(a),message:`${n}.${i} \u4E0D\u5728\u5141\u8BB8\u5B57\u6BB5\u4E2D`}):Tu(s)&&wu(a,s,`${n}.${i}`,r);continue}wu(a,l,`${n}.${i}`,r)}}function wu(e,t,n,r){if(t.type!==void 0){let o=uC(e);if(!dC(o,t.type)){r.push({path:n,expected:t.type,received:Ln(e),message:`${n} \u5E94\u4E3A ${t.type}\uFF0C\u5B9E\u9645\u4E3A ${o}`});return}}if(t.enum&&t.enum.length>0){let o=`enum[${t.enum.map(s=>JSON.stringify(s)).join(",")}]`;cC(e)?t.enum.includes(e)||r.push({path:n,expected:o,received:Ln(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${JSON.stringify(e)}`}):r.push({path:n,expected:o,received:Ln(e),message:`${n} \u5E94\u4E3A enum \u503C\u4E4B\u4E00\uFF0C\u5B9E\u9645\u4E3A ${Ln(e)}`})}if(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:Ln(e),message:`${n} \u4E0D\u5339\u914D pattern ${t.pattern}`})}catch{}if(t.properties!==void 0&&kg(e,t,n,r),t.items!==void 0&&Array.isArray(e))for(let o=0;o<e.length;o++)wu(e[o],t.items,`${n}[${o}]`,r)}function Tu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cC(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function uC(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e}function dC(e,t){return e===t||t==="integer"&&e==="number"||t==="number"&&e==="integer"}function Ln(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 ia=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?qn(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 c=`\u5DE5\u5177 "${n}" \u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u7981\u7528`;return{item:{name:n,callId:t.id,result:{success:!1,data:c,error:"TOOL_NOT_FOUND"}},record:{name:n,success:!1,error:"TOOL_NOT_FOUND",timestamp:r}}}let s=Pr(t.arguments??"");if(!s.ok){if(s.reason==="PARTIAL"){let u=`\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:u,error:"PARTIAL_JSON"}},record:{name:n,success:!1,error:"PARTIAL_JSON",timestamp:r}}}let c=`\u5DE5\u5177 "${n}" \u53C2\u6570\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${s.error}
488
+ \u539F\u6587: ${s.raw.slice(0,200)}`;return{item:{name:n,callId:t.id,result:{success:!1,data:c,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 c=bg(i,l);c.ok||(a=c.issues)}if(!qn(o.kind)&&!await this.#t.check(n,i)){let u=this.#t.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 c=o.preview;if(typeof c=="function")try{await c(i,this.#r)}catch{}}try{let c=await this.#p(o,i);if(a&&a.length>0){let d=a.map(h=>` - ${h.message}`).join(`
489
489
  `),f=c.success?"[schema \u8B66\u544A]":"[schema \u95EE\u9898]";c={...c,data:`${c.data}
490
490
 
491
491
  ${f} \u53C2\u6570\u4E0D\u7B26\u5408 schema\uFF1A
492
- ${d}`,issues:a}}let u={name:n,success:c.success,error:c.error,timestamp:r,...a?{issues:a}:{}};return{item:{name:n,callId:t.id,result:c},record:u}}catch(c){let u=c instanceof Error?c.message:String(c),d={success:!1,data:`\u5DE5\u5177 "${n}" \u6267\u884C\u5F02\u5E38\uFF1A${u}`,error:"EXECUTION_ERROR"};return{item:{name:n,callId:t.id,result:d},record:{name:n,success:!1,error:"EXECUTION_ERROR",timestamp:r}}}}async#p(t,n){return t.execute(n,this.#r)}};p();var ea=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 ta=class{#e;#t;#r;constructor(t={}){this.#e=t.repeatThreshold??2,this.#t=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.#o(o)??this.#n(o)??this.#a(o)??this.#c(o)??this.#i(o,n.writeRoots)??this.#s(o);if(s&&r.push(s),r.length>=this.#t)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.#p(s.hint);return`- \u5DE5\u5177 \`${s.toolName}\` \u5931\u8D25\uFF1A${i}`})].join(`
492
+ ${d}`,issues:a}}let u={name:n,success:c.success,error:c.error,timestamp:r,...a?{issues:a}:{}};return{item:{name:n,callId:t.id,result:c},record:u}}catch(c){let u=c instanceof Error?c.message:String(c),d={success:!1,data:`\u5DE5\u5177 "${n}" \u6267\u884C\u5F02\u5E38\uFF1A${u}`,error:"EXECUTION_ERROR"};return{item:{name:n,callId:t.id,result:d},record:{name:n,success:!1,error:"EXECUTION_ERROR",timestamp:r}}}}async#p(t,n){return t.execute(n,this.#r)}};p();var aa=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 la=class{#e;#t;#r;constructor(t={}){this.#e=t.repeatThreshold??2,this.#t=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.#o(o)??this.#n(o)??this.#a(o)??this.#u(o)??this.#i(o,n.writeRoots)??this.#s(o);if(s&&r.push(s),r.length>=this.#t)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.#p(s.hint);return`- \u5DE5\u5177 \`${s.toolName}\` \u5931\u8D25\uFF1A${i}`})].join(`
493
493
  `);return t+`
494
494
 
495
- `+o}#o(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`}}#n(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`}}#a(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}}#c(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`}}#p(t){return t.length<=this.#r?t:t.slice(0,this.#r-3)+"..."}#s(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 ng(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 na=class{#e=[];#t=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.#t++;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.#o(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.#o(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.#n(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(`
496
- `)}#r(t){return this.#e.find(n=>n.id===t)}#o(t){return t.every(n=>{let r=this.#e.find(o=>o.id===n);return r?.status==="done"||r?.status==="skipped"})}#n(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 rg(e){return[UT(e),WT(e),HT(e),VT(e),zT(e)]}function UT(e){return{name:"todo_add",kind:"read",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
495
+ `+o}#o(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`}}#n(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`}}#a(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}}#u(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`}}#p(t){return t.length<=this.#r?t:t.slice(0,this.#r-3)+"..."}#s(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 wg(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 ca=class{#e=[];#t=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.#t++;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.#o(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.#o(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.#n(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(`
496
+ `)}#r(t){return this.#e.find(n=>n.id===t)}#o(t){return t.every(n=>{let r=this.#e.find(o=>o.id===n);return r?.status==="done"||r?.status==="skipped"})}#n(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 Tg(e){return[pC(e),fC(e),mC(e),hC(e),gC(e)]}function pC(e){return{name:"todo_add",kind:"read",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
497
497
 
498
498
  \u4EC0\u4E48\u60C5\u51B5\u4E0B\u8C03\u6211\uFF1A
499
499
  - \u9700\u8981\u591A\u6B65\u624D\u80FD\u5B8C\u6210\uFF08\u6539\u591A\u4E2A\u6587\u4EF6 / \u8DE8\u591A\u8F6E\uFF09
@@ -505,111 +505,120 @@ ${d}`,issues:a}}let u={name:n,success:c.success,error:c.error,timestamp:r,...a?{
505
505
 
506
506
  \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
507
507
 
508
- \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 WT(e){return{name:"todo_mark_running",kind:"read",description:`\u628A todo \u4ECE pending \u63A8\u8FDB\u5230 running\uFF0C\u8868\u793A\u4F60\u300C\u6B63\u5728\u505A\u300D\u8FD9\u4E00\u6B65\u3002
508
+ \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 fC(e){return{name:"todo_mark_running",kind:"read",description:`\u628A todo \u4ECE pending \u63A8\u8FDB\u5230 running\uFF0C\u8868\u793A\u4F60\u300C\u6B63\u5728\u505A\u300D\u8FD9\u4E00\u6B65\u3002
509
509
  \u524D\u63D0\uFF1A\u8BE5 todo \u5B58\u5728\u3001\u5F53\u524D\u662F pending\u3001\u4E14\u6240\u6709 deps \u5DF2 done \u6216 skipped\u3002
510
510
  \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
511
- **\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 HT(e){return{name:"todo_mark_done",kind:"read",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
512
- \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 VT(e){return{name:"todo_mark_failed",kind:"read",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
511
+ **\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 mC(e){return{name:"todo_mark_done",kind:"read",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
512
+ \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 hC(e){return{name:"todo_mark_failed",kind:"read",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
513
513
  \u524D\u63D0\uFF1A\u5F53\u524D\u72B6\u6001\u5FC5\u987B\u662F running\u3002\u82E5\u8FD8\u662F pending\uFF0C\u5148\u8C03 todo_mark_running\u3002
514
- \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 zT(e){return{name:"todo_retry",kind:"read",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
515
- \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 qT}from"child_process";import{promisify as KT}from"util";var oa=KT(qT),sa={windowsHide:!0};async function mu(e){try{return await oa("git",["rev-parse","--is-inside-work-tree"],{cwd:e,...sa}),!0}catch{return!1}}async function og(e){try{return await oa("git",["rev-parse","--verify","HEAD"],{cwd:e,...sa}),!0}catch{return!1}}async function XT(e){return(await oa("git",["status","--porcelain"],{cwd:e,...sa})).stdout.trim().length>0}async function Wt(e,t){try{let{stdout:n}=await oa("git",e,{cwd:t,...sa});return n}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`git ${e.join(" ")} \u5931\u8D25: ${r}`)}}async function ra(e){return(await Wt(["stash","list","--format=%H"],e)).split(`
516
- `).map(n=>n.trim()).filter(Boolean)}async function hu(e){let t=Date.now();if(!await mu(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!1};if(!await og(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};if(!await XT(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};let r=await ra(e);await Wt(["stash","push","-m",`dskcode-cp-${t}`,"-u"],e);let o=await ra(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 Wt(["stash","apply",s],e),{stashSha:s,timestamp:t,cwd:e,isGitRepo:!0}}async function gu(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 ra(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 Wt(["checkout","--","."],t),await Wt(["clean","-fd"],t),await Wt(["stash","apply",n],t);let o=r.indexOf(n);o>=0&&await Wt(["stash","drop",`stash@{${o}}`],t)}async function yu(e){if(!await mu(e))throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!await og(e))throw new Error("\u4ED3\u5E93\u65E0 commit\uFF0C\u65E0\u6CD5\u6062\u590D");await Wt(["checkout","--","."],e),await Wt(["clean","-fd"],e)}async function ia(e){if(!e.isGitRepo||!e.stashSha)return;let{cwd:t,stashSha:n}=e,r;try{r=await ra(t)}catch{return}let o=r.indexOf(n);if(!(o<0))try{await Wt(["stash","drop",`stash@{${o}}`],t)}catch{}}p();p();import{mkdir as JT,readFile as sg,writeFile as ZT,readdir as YT,unlink as QT,rename as eC}from"fs/promises";import{join as Wr}from"path";import{randomUUID as tC}from"crypto";function ig(){let e=process.env.HOME??process.env.USERPROFILE??"~";return Wr(e,".dskcode","sessions")}var cr=class{#e;constructor(t){this.#e=t??ig()}get dir(){return this.#e}async save(t){await JT(this.#e,{recursive:!0});let n=Wr(this.#e,`${t.id}.json`),r=Wr(this.#e,`.${t.id}.json.tmp`);await ZT(r,JSON.stringify(t,null,2),"utf-8"),await eC(r,n)}async load(t){let n=Wr(this.#e,`${t}.json`);try{let r=await sg(n,"utf-8");return JSON.parse(r)}catch(r){if(xu(r))return null;throw r}}async list(){let t;try{t=await YT(this.#e)}catch(r){if(xu(r))return[];throw r}let n=[];for(let r of t)if(!(!r.endsWith(".json")||r.startsWith(".")))try{let o=await sg(Wr(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=Wr(this.#e,`${t}.json`);try{await QT(n)}catch(r){if(!xu(r))throw r}}async exists(t){return await this.load(t)!==null}static newId(){return tC()}};function xu(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}p();p();import{readFile as sC,stat as iC,open as aC}from"fs/promises";import{relative as lC}from"path";p();import{resolve as es,relative as cg,isAbsolute as nC}from"path";import{realpath as ag}from"fs/promises";import{spawn as rC}from"child_process";import ug from"process";var dg=3e4,pg=5e4,hN=10*1024*1024,aa=ug.platform==="win32";function Hr(e){return e.startsWith("@")?e.slice(1):e}function lt(e,t){let n=Hr(e),r=nC(n)?n:es(t,n);return es(r)}async function lg(e){try{return await ag(e)}catch{let t=es(e,"..");try{let n=await ag(t);return es(n,cg(t,e))}catch{return es(e)}}}async function on(e,t){if(e.length===0)return{ok:!0};let n=await lg(t);for(let r of e){let o=await lg(r);if(n===o)return{ok:!0};let s=cg(o,n);if(!s.startsWith("..")&&s!==""&&!s.startsWith("/")&&!s.startsWith("\\"))return{ok:!0}}return{ok:!1,error:`\u8DEF\u5F84 "${t}" \u4E0D\u5728\u5141\u8BB8\u7684\u5199\u5165\u8303\u56F4\u5185 ${e.join(", ")}`}}function Ze(e,t=pg){return e.length<=t?e:`${e.slice(0,t)}
514
+ \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 gC(e){return{name:"todo_retry",kind:"read",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
515
+ \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 yC}from"child_process";import{promisify as xC}from"util";var da=xC(yC),pa={windowsHide:!0};async function Su(e){try{return await da("git",["rev-parse","--is-inside-work-tree"],{cwd:e,...pa}),!0}catch{return!1}}async function Sg(e){try{return await da("git",["rev-parse","--verify","HEAD"],{cwd:e,...pa}),!0}catch{return!1}}async function bC(e){return(await da("git",["status","--porcelain"],{cwd:e,...pa})).stdout.trim().length>0}async function Wt(e,t){try{let{stdout:n}=await da("git",e,{cwd:t,...pa});return n}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`git ${e.join(" ")} \u5931\u8D25: ${r}`)}}async function ua(e){return(await Wt(["stash","list","--format=%H"],e)).split(`
516
+ `).map(n=>n.trim()).filter(Boolean)}async function Cu(e){let t=Date.now();if(!await Su(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!1};if(!await Sg(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};if(!await bC(e))return{stashSha:"",timestamp:t,cwd:e,isGitRepo:!0};let r=await ua(e);await Wt(["stash","push","-m",`dskcode-cp-${t}`,"-u"],e);let o=await ua(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 Wt(["stash","apply",s],e),{stashSha:s,timestamp:t,cwd:e,isGitRepo:!0}}async function _u(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 ua(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 Wt(["checkout","--","."],t),await Wt(["clean","-fd"],t),await Wt(["stash","apply",n],t);let o=r.indexOf(n);o>=0&&await Wt(["stash","drop",`stash@{${o}}`],t)}async function vu(e){if(!await Su(e))throw new Error("\u975E git \u4ED3\u5E93\uFF0C\u65E0\u6CD5\u6062\u590D\u6587\u4EF6\u72B6\u6001");if(!await Sg(e))throw new Error("\u4ED3\u5E93\u65E0 commit\uFF0C\u65E0\u6CD5\u6062\u590D");await Wt(["checkout","--","."],e),await Wt(["clean","-fd"],e)}async function fa(e){if(!e.isGitRepo||!e.stashSha)return;let{cwd:t,stashSha:n}=e,r;try{r=await ua(t)}catch{return}let o=r.indexOf(n);if(!(o<0))try{await Wt(["stash","drop",`stash@{${o}}`],t)}catch{}}p();p();import{mkdir as kC,readFile as Cg,writeFile as wC,readdir as TC,unlink as SC,rename as CC}from"fs/promises";import{join as zr}from"path";import{randomUUID as _C}from"crypto";function _g(){let e=process.env.HOME??process.env.USERPROFILE??"~";return zr(e,".dskcode","sessions")}var pr=class{#e;constructor(t){this.#e=t??_g()}get dir(){return this.#e}async save(t){await kC(this.#e,{recursive:!0});let n=zr(this.#e,`${t.id}.json`),r=zr(this.#e,`.${t.id}.json.tmp`);await wC(r,JSON.stringify(t,null,2),"utf-8"),await CC(r,n)}async load(t){let n=zr(this.#e,`${t}.json`);try{let r=await Cg(n,"utf-8");return JSON.parse(r)}catch(r){if(Ru(r))return null;throw r}}async list(){let t;try{t=await TC(this.#e)}catch(r){if(Ru(r))return[];throw r}let n=[];for(let r of t)if(!(!r.endsWith(".json")||r.startsWith(".")))try{let o=await Cg(zr(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=zr(this.#e,`${t}.json`);try{await SC(n)}catch(r){if(!Ru(r))throw r}}async exists(t){return await this.load(t)!==null}static newId(){return _C()}};function Ru(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}p();p();import{readFile as EC,stat as IC,open as PC}from"fs/promises";import{relative as $C}from"path";p();import{resolve as as,relative as Ag,isAbsolute as vC}from"path";import{realpath as vg}from"fs/promises";import{spawn as RC}from"child_process";import Eg from"process";var Ig=3e4,Pg=5e4,jN=10*1024*1024,ma=Eg.platform==="win32";function qr(e){return e.startsWith("@")?e.slice(1):e}function ct(e,t){let n=qr(e),r=vC(n)?n:as(t,n);return as(r)}async function Rg(e){try{return await vg(e)}catch{let t=as(e,"..");try{let n=await vg(t);return as(n,Ag(t,e))}catch{return as(e)}}}async function on(e,t){if(e.length===0)return{ok:!0};let n=await Rg(t);for(let r of e){let o=await Rg(r);if(n===o)return{ok:!0};let s=Ag(o,n);if(!s.startsWith("..")&&s!==""&&!s.startsWith("/")&&!s.startsWith("\\"))return{ok:!0}}return{ok:!1,error:`\u8DEF\u5F84 "${t}" \u4E0D\u5728\u5141\u8BB8\u7684\u5199\u5165\u8303\u56F4\u5185 ${e.join(", ")}`}}function Ze(e,t=Pg){return e.length<=t?e:`${e.slice(0,t)}
517
517
 
518
- ... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u5171 ${String(e.length)} \u5B57\u7B26]`}function bu(){return dg}async function wu(e,t,n,r=dg,o,s){return new Promise(i=>{let a,l,c;s?(a=e,l=t,c=!1,aa&&a==="cmd"&&l[0]==="/c"&&(l=["/c",`chcp 65001 >nul && ${l[1]??""}`])):(c=!aa,a=aa?"cmd":e,l=aa?["/c",e,...t]:t);let u=rC(a,l,{cwd:n,shell:c,env:{...ug.env},stdio:["pipe","pipe","pipe"]}),d=5*pg,f=`
519
- ... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u4E22\u5F03\u540E\u7EED\u5185\u5BB9]`,h="",m="",g=!1,w=!1,b=(R,D)=>{let F=R==="stdout";if(F?g:w)return;let P=(F?h:m)+D;if(P.length<=d){F?h=P:m=P;return}let z=P.slice(0,d)+f;F?(h=z,g=!0,u.stdout?.removeAllListeners("data")):(m=z,w=!0,u.stderr?.removeAllListeners("data"))};u.stdout.on("data",R=>{b("stdout",R.toString("utf8"))}),u.stderr.on("data",R=>{b("stderr",R.toString("utf8"))});let k=null,v=null,I=()=>{k!==null&&(clearTimeout(k),k=null),v!==null&&(clearTimeout(v),v=null)};k=setTimeout(()=>{u.kill("SIGTERM"),k=null,v=setTimeout(()=>{u.kill("SIGKILL"),v=null},5e3)},r),o&&(o.aborted&&u.kill("SIGTERM"),o.addEventListener("abort",()=>{u.kill("SIGTERM")},{once:!0})),u.on("close",R=>{I(),i({stdout:h,stderr:m,exitCode:R})}),u.on("error",R=>{I(),m+=`
520
- \u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF1A${R.message}`,i({stdout:h,stderr:m,exitCode:null})})})}p();import{writeFile as oC}from"fs/promises";function fg(e){if(e.length===0)return`
518
+ ... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u5171 ${String(e.length)} \u5B57\u7B26]`}function Au(){return Ig}async function Eu(e,t,n,r=Ig,o,s){return new Promise(i=>{let a,l,c;s?(a=e,l=t,c=!1,ma&&a==="cmd"&&l[0]==="/c"&&(l=["/c",`chcp 65001 >nul && ${l[1]??""}`])):(c=!ma,a=ma?"cmd":e,l=ma?["/c",e,...t]:t);let u=RC(a,l,{cwd:n,shell:c,env:{...Eg.env},stdio:["pipe","pipe","pipe"]}),d=5*Pg,f=`
519
+ ... [\u8F93\u51FA\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF0C\u4E22\u5F03\u540E\u7EED\u5185\u5BB9]`,h="",m="",g=!1,b=!1,k=(I,F)=>{let M=I==="stdout";if(M?g:b)return;let C=(M?h:m)+F;if(C.length<=d){M?h=C:m=C;return}let N=C.slice(0,d)+f;M?(h=N,g=!0,u.stdout?.removeAllListeners("data")):(m=N,b=!0,u.stderr?.removeAllListeners("data"))};u.stdout.on("data",I=>{k("stdout",I.toString("utf8"))}),u.stderr.on("data",I=>{k("stderr",I.toString("utf8"))});let T=null,A=null,E=()=>{T!==null&&(clearTimeout(T),T=null),A!==null&&(clearTimeout(A),A=null)};T=setTimeout(()=>{u.kill("SIGTERM"),T=null,A=setTimeout(()=>{u.kill("SIGKILL"),A=null},5e3)},r),o&&(o.aborted&&u.kill("SIGTERM"),o.addEventListener("abort",()=>{u.kill("SIGTERM")},{once:!0})),u.on("close",I=>{E(),i({stdout:h,stderr:m,exitCode:I})}),u.on("error",I=>{E(),m+=`
520
+ \u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF1A${I.message}`,i({stdout:h,stderr:m,exitCode:null})})})}p();import{writeFile as AC}from"fs/promises";function $g(e){if(e.length===0)return`
521
521
  `;let t=e.indexOf(`\r
522
522
  `),n=e.indexOf(`
523
523
  `);return t!==-1&&(n===-1||t<=n)?`\r
524
524
  `:`
525
- `}function mg(e){return e.endsWith(`
525
+ `}function Lg(e){return e.endsWith(`
526
526
  `)||e.endsWith(`\r
527
527
  `)}function Ye(e){return e.includes("\r")?e.replace(/\r\n/g,`
528
528
  `).replace(/\r/g,`
529
- `):e}function $n(e,t){let n=fg(e),r=t.replace(/\r\n/g,`
529
+ `):e}function Mn(e,t){let n=$g(e),r=t.replace(/\r\n/g,`
530
530
  `).split(`
531
- `),o=mg(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 ku(e,t,n){let r=t.length>0?$n(t,n):n;await oC(e,r,"utf-8")}async function cC(e){let t=await aC(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 Su={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=lt(e.path,t.cwd),r=lC(t.cwd,n).replace(/\\/g,"/");try{let o=await iC(n),s=10*1024*1024;if(o.size>s)return{success:!1,data:`\u6587\u4EF6\u8FC7\u5927\uFF08${(o.size/1024/1024).toFixed(1)}MB\uFF09\uFF0C\u8D85\u8FC7 10MB \u9650\u5236`,error:"FILE_TOO_LARGE"};if(o.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(o.size>0&&await cC(n))return{success:!1,data:`"${n}" \u770B\u8D77\u6765\u662F\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u8BFB\u53D6`,error:"BINARY_FILE"};if(o.size===0)return{success:!0,data:"(\u7A7A\u6587\u4EF6)",summary:`\u{1F4D6} ${r}\uFF080 \u884C\uFF09`};let i=await sC(n,"utf-8"),a=Ye(i).split(`
531
+ `),o=Lg(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 Iu(e,t,n){let r=t.length>0?Mn(t,n):n;await AC(e,r,"utf-8")}async function LC(e){let t=await PC(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 Pu={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=ct(e.path,t.cwd),r=$C(t.cwd,n).replace(/\\/g,"/");try{let o=await IC(n),s=10*1024*1024;if(o.size>s)return{success:!1,data:`\u6587\u4EF6\u8FC7\u5927\uFF08${(o.size/1024/1024).toFixed(1)}MB\uFF09\uFF0C\u8D85\u8FC7 10MB \u9650\u5236`,error:"FILE_TOO_LARGE"};if(o.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(o.size>0&&await LC(n))return{success:!1,data:`"${n}" \u770B\u8D77\u6765\u662F\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u4E0D\u652F\u6301\u8BFB\u53D6`,error:"BINARY_FILE"};if(o.size===0)return{success:!0,data:"(\u7A7A\u6587\u4EF6)",summary:`\u{1F4D6} ${r}\uFF080 \u884C\uFF09`};let i=await EC(n,"utf-8"),a=Ye(i).split(`
532
532
  `),l=a.length>0&&a[a.length-1]===""&&i.endsWith(`
533
- `)?a.slice(0,-1):a,c=Math.max(1,e.startLine??1)-1,u=e.endLine?Math.min(e.endLine,l.length):l.length,d=l.slice(c,u),f=String(u).length,h=d.map((b,k)=>`${String(c+k+1).padStart(f," ")}\u2192${b}`).join(`
533
+ `)?a.slice(0,-1):a,c=Math.max(1,e.startLine??1)-1,u=e.endLine?Math.min(e.endLine,l.length):l.length,d=l.slice(c,u),f=String(u).length,h=d.map((k,T)=>`${String(c+T+1).padStart(f," ")}\u2192${k}`).join(`
534
534
  `),m=l.length-u,g=m>0?`
535
535
 
536
- [\u8FD8\u6709 ${m} \u884C\uFF1B\u4F7F\u7528 startLine=${u+1} \u7EE7\u7EED\u67E5\u770B]`:"",w=c>0||u<l.length?`\u7B2C ${c+1}-${u} \u884C`:`${l.length} \u884C`;return{success:!0,data:Ze(h)+g,summary:`\u{1F4D6} ${r}\uFF08${w}\uFF09`}}catch(o){return{success:!1,data:`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"READ_ERROR"}}}};p();import{mkdir as gC,readFile as yC}from"fs/promises";import{dirname as xC,relative as bC,basename as wC}from"path";p();function la(e){if(e.length===0)return{lines:[],eol:`
536
+ [\u8FD8\u6709 ${m} \u884C\uFF1B\u4F7F\u7528 startLine=${u+1} \u7EE7\u7EED\u67E5\u770B]`:"",b=c>0||u<l.length?`\u7B2C ${c+1}-${u} \u884C`:`${l.length} \u884C`;return{success:!0,data:Ze(h)+g,summary:`\u{1F4D6} ${r}\uFF08${b}\uFF09`}}catch(o){return{success:!1,data:`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A${o instanceof Error?o.message:String(o)}`,error:"READ_ERROR"}}}};p();import{mkdir as FC,readFile as jC}from"fs/promises";import{dirname as UC,relative as WC,basename as HC}from"path";p();function ha(e){if(e.length===0)return{lines:[],eol:`
537
537
  `,eofStyle:"no-eol"};let t=e.indexOf(`\r
538
538
  `),n=e.indexOf(`
539
539
  `),r=t!==-1&&(n===-1||t<=n)?`\r
540
540
  `:`
541
- `,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 uC(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 f=u;f<=d;f+=2){let h=f+a,m;f===-l||f!==l&&i[h-1]<i[h+1]?m=i[h+1]:m=i[h-1]+1;let g=m-f;for(;m<n&&g<r&&e[m]===t[g];)m++,g++;if(i[h]=m,c.set(f,m),m>=n&&g>=r)return o.push(c),dC(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 dC(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],f=d.get(u-1),h=d.get(u+1),m;u===-c?m=u+1:u===c?m=u-1:(f??-1)<(h??-1)?m=u+1:m=u-1;let g=d.get(m)??0,w=g-m;if(m===u-1){for(;a>g+1&&l>w;)a--,l--,i.unshift({op:"equal",line:r[a]});a>g&&(a--,i.unshift({op:"remove",line:r[a]}))}else{for(;a>g&&l>w+1;)a--,l--,i.unshift({op:"equal",line:r[a]});l>w&&(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 Tu=3;function pC(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*Tu?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-Tu),l=Math.min(e.length-1,i+Tu),c=e.slice(a,l+1),u=0,d=0;for(let m=0;m<a;m++){let g=e[m];(g.op==="equal"||g.op==="remove")&&u++,(g.op==="equal"||g.op==="add")&&d++}let f=0,h=0;for(let m of c)(m.op==="equal"||m.op==="remove")&&f++,(m.op==="equal"||m.op==="add")&&h++;r.push({oldStart:u+1,oldCount:f,newStart:d+1,newCount:h,lines:c})}return r}function fC(e,t){if(e.length===0)return"";let n=[],r=Cu(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(`
542
- `)}function mC(e,t){let n=Cu(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(`
543
- `)}function hC(e,t){let n=Cu(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(`
544
- `)}function Cu(e){return e.replace(/\\/g,"/").split("/").pop()??e}function sn(e,t,n){if(e===t)return{filePath:n,patch:"",existedBefore:e.length>0,additions:0,deletions:0};if(e.length===0){let u=la(t),d=mC(u.lines,n);return{filePath:n,patch:d,existedBefore:!1,additions:u.lines.length,deletions:0}}if(t.length===0){let u=la(e),d=hC(u.lines,n);return{filePath:n,patch:d,existedBefore:!0,additions:0,deletions:u.lines.length}}let r=la(e),o=la(t),s=uC(r.lines,o.lines),i=0,a=0;for(let u of s)u.op==="add"&&i++,u.op==="remove"&&a++;let l=pC(s),c=fC(l,n);return{filePath:n,patch:c,existedBefore:!0,additions:i,deletions:a}}var _u={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=lt(e.path,t.cwd);try{if(t.writeRoots&&t.writeRoots.length>0){let h=await on(t.writeRoots,n);if(!h.ok)return{success:!1,data:h.error,error:"OUTSIDE_WRITE_ROOTS"}}let r="",o=!1;try{r=await yC(n,"utf-8"),o=!0}catch{}await gC(xC(n),{recursive:!0});let s=e.content;await ku(n,r,s);let i=sn(r,s,n);i.existedBefore=o;let a=s.split(`
545
- `).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=wC(n),f=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${bC(t.cwd,n).replace(/\\/g,"/")}\uFF08${a} \u884C\uFF0C${l} \u5B57\u8282${u}\uFF09`,summary:f,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 kC,writeFile as SC}from"fs/promises";import{basename as TC}from"path";var vu={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=lt(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await on(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await kC(n,"utf-8"),o=Ye(r),s=Ye(e.old_text),i=Ye(e.new_text),a=o.indexOf(s);if(a===-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,a+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 c=o.slice(0,a)+i+o.slice(a+s.length),u=$n(r,c);await SC(n,u,"utf-8");let d=sn(r,u,n);d.existedBefore=!0;let h=o.slice(0,a).split(`
541
+ `,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 MC(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 f=u;f<=d;f+=2){let h=f+a,m;f===-l||f!==l&&i[h-1]<i[h+1]?m=i[h+1]:m=i[h-1]+1;let g=m-f;for(;m<n&&g<r&&e[m]===t[g];)m++,g++;if(i[h]=m,c.set(f,m),m>=n&&g>=r)return o.push(c),OC(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 OC(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],f=d.get(u-1),h=d.get(u+1),m;u===-c?m=u+1:u===c?m=u-1:(f??-1)<(h??-1)?m=u+1:m=u-1;let g=d.get(m)??0,b=g-m;if(m===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 $u=3;function DC(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*$u?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-$u),l=Math.min(e.length-1,i+$u),c=e.slice(a,l+1),u=0,d=0;for(let m=0;m<a;m++){let g=e[m];(g.op==="equal"||g.op==="remove")&&u++,(g.op==="equal"||g.op==="add")&&d++}let f=0,h=0;for(let m of c)(m.op==="equal"||m.op==="remove")&&f++,(m.op==="equal"||m.op==="add")&&h++;r.push({oldStart:u+1,oldCount:f,newStart:d+1,newCount:h,lines:c})}return r}function NC(e,t){if(e.length===0)return"";let n=[],r=Lu(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(`
542
+ `)}function BC(e,t){let n=Lu(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(`
543
+ `)}function GC(e,t){let n=Lu(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(`
544
+ `)}function Lu(e){return e.replace(/\\/g,"/").split("/").pop()??e}function sn(e,t,n){if(e===t)return{filePath:n,patch:"",existedBefore:e.length>0,additions:0,deletions:0};if(e.length===0){let u=ha(t),d=BC(u.lines,n);return{filePath:n,patch:d,existedBefore:!1,additions:u.lines.length,deletions:0}}if(t.length===0){let u=ha(e),d=GC(u.lines,n);return{filePath:n,patch:d,existedBefore:!0,additions:0,deletions:u.lines.length}}let r=ha(e),o=ha(t),s=MC(r.lines,o.lines),i=0,a=0;for(let u of s)u.op==="add"&&i++,u.op==="remove"&&a++;let l=DC(s),c=NC(l,n);return{filePath:n,patch:c,existedBefore:!0,additions:i,deletions:a}}var Mu={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=ct(e.path,t.cwd);try{if(t.writeRoots&&t.writeRoots.length>0){let h=await on(t.writeRoots,n);if(!h.ok)return{success:!1,data:h.error,error:"OUTSIDE_WRITE_ROOTS"}}let r="",o=!1;try{r=await jC(n,"utf-8"),o=!0}catch{}await FC(UC(n),{recursive:!0});let s=e.content;await Iu(n,r,s);let i=sn(r,s,n);i.existedBefore=o;let a=s.split(`
545
+ `).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=HC(n),f=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${WC(t.cwd,n).replace(/\\/g,"/")}\uFF08${a} \u884C\uFF0C${l} \u5B57\u8282${u}\uFF09`,summary:f,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 VC,writeFile as zC}from"fs/promises";import{basename as qC}from"path";var Ou={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=ct(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await on(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await VC(n,"utf-8"),o=Ye(r),s=Ye(e.old_text),i=Ye(e.new_text),a=o.indexOf(s);if(a===-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,a+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 c=o.slice(0,a)+i+o.slice(a+s.length),u=Mn(r,c);await zC(n,u,"utf-8");let d=sn(r,u,n);d.existedBefore=!0;let h=o.slice(0,a).split(`
546
546
  `).length,m=s.split(`
547
547
  `).length,g=i.split(`
548
- `).length,w=`+${d.additions} -${d.deletions}`,b=`\u{1F4DD} \u4FEE\u6539: ${TC(n)} (+${d.additions} -${d.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
548
+ `).length,b=`+${d.additions} -${d.deletions}`,k=`\u{1F4DD} \u4FEE\u6539: ${qC(n)} (+${d.additions} -${d.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
549
549
  \u66FF\u6362\u4F4D\u7F6E\uFF1A\u7B2C ${h} \u884C
550
550
  ${m} \u884C \u2192 ${g} \u884C
551
- \u53D8\u66F4\uFF1A${w}`,summary:b,diff:d}}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 CC,writeFile as _C}from"fs/promises";import{basename as vC}from"path";var Ru={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=lt(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await on(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await CC(n,"utf-8"),o=Ye(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=Ye(l.oldText),u=Ye(l.newText);if(l.replaceAll){if(!o.includes(c))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=$n(r,o);await _C(n,s,"utf-8");let i=sn(r,s,n);return i.existedBefore=!0,{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
551
+ \u53D8\u66F4\uFF1A${b}`,summary:k,diff:d}}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 KC,writeFile as XC}from"fs/promises";import{basename as JC}from"path";var Du={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=ct(e.path,t.cwd);if(t.writeRoots&&t.writeRoots.length>0){let r=await on(t.writeRoots,n);if(!r.ok)return{success:!1,data:r.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let r=await KC(n,"utf-8"),o=Ye(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=Ye(l.oldText),u=Ye(l.newText);if(l.replaceAll){if(!o.includes(c))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=Mn(r,o);await XC(n,s,"utf-8");let i=sn(r,s,n);return i.existedBefore=!0,{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
552
552
  \u5171\u6267\u884C ${e.edits.length} \u6B65\u66FF\u6362
553
- \u53D8\u66F4\uFF1A+${i.additions} -${i.deletions}`,summary:`\u{1F4DD} \u4FEE\u6539: ${vC(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 RC}from"fs/promises";import{writeFile as AC}from"fs/promises";import{basename as EC}from"path";function hg(e,t,n){let r=Ye(t),o=[];for(let s=0;s<e.length;s++)Ye(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 Au={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=lt(e.path,t.cwd),r=e.inclusive??!1;if(t.writeRoots&&t.writeRoots.length>0){let o=await on(t.writeRoots,n);if(!o.ok)return{success:!1,data:o.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let o=await RC(n,"utf-8"),s=Ye(o).split(`
554
- `),i=hg(s,e.startAnchor,"start_anchor");if("error"in i)return{success:!1,data:i.error,error:"ANCHOR_NOT_FOUND"};let a=hg(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(`
555
- `),m=$n(o,h);await AC(n,m,"utf-8");let g=sn(o,m,n);g.existedBefore=!0;let w=d-u+1,b=`\u{1F4DD} \u4FEE\u6539: ${EC(n)} (\u5220 ${w} \u884C, +${g.additions} -${g.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
556
- \u5220\u9664\u884C\u8303\u56F4\uFF1A\u7B2C ${u+1} \u884C ~ \u7B2C ${d+1} \u884C\uFF08\u5171 ${w} \u884C\uFF09
557
- \u53D8\u66F4\uFF1A+${g.additions} -${g.deletions}`,summary:b,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 Vr from"process";import{existsSync as gg}from"fs";import{join as yg}from"path";var IC=Vr.platform==="win32";function PC(){if(!IC)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=Vr.env.DSKCODE_BASH;if(e&&gg(e))return{bin:e,args:["-c"],label:"Git Bash",hint:xg};let t=[Vr.env.ProgramFiles,Vr.env["ProgramFiles(x86)"],Vr.env.LOCALAPPDATA?yg(Vr.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=yg(n,r);if(gg(o))return{bin:o,args:["-c"],label:"Git Bash",hint:xg}}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 xg="\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002",ts=PC();var Eu={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${ts.label}\u3002${ts.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${ts.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??bu();try{let r=ts.bin??"cmd",o=[...ts.args,e.command],s=await wu(r,o,t.cwd,n,t.signal,!0),i=[];s.stdout&&i.push(Ze(s.stdout)),s.stderr&&i.push(`[stderr]
553
+ \u53D8\u66F4\uFF1A+${i.additions} -${i.deletions}`,summary:`\u{1F4DD} \u4FEE\u6539: ${JC(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 ZC}from"fs/promises";import{writeFile as YC}from"fs/promises";import{basename as QC}from"path";function Mg(e,t,n){let r=Ye(t),o=[];for(let s=0;s<e.length;s++)Ye(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 Nu={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=ct(e.path,t.cwd),r=e.inclusive??!1;if(t.writeRoots&&t.writeRoots.length>0){let o=await on(t.writeRoots,n);if(!o.ok)return{success:!1,data:o.error,error:"OUTSIDE_WRITE_ROOTS"}}try{let o=await ZC(n,"utf-8"),s=Ye(o).split(`
554
+ `),i=Mg(s,e.startAnchor,"start_anchor");if("error"in i)return{success:!1,data:i.error,error:"ANCHOR_NOT_FOUND"};let a=Mg(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(`
555
+ `),m=Mn(o,h);await YC(n,m,"utf-8");let g=sn(o,m,n);g.existedBefore=!0;let b=d-u+1,k=`\u{1F4DD} \u4FEE\u6539: ${QC(n)} (\u5220 ${b} \u884C, +${g.additions} -${g.deletions})`;return{success:!0,data:`\u6587\u4EF6\u5DF2\u7F16\u8F91\uFF1A${n}
556
+ \u5220\u9664\u884C\u8303\u56F4\uFF1A\u7B2C ${u+1} \u884C ~ \u7B2C ${d+1} \u884C\uFF08\u5171 ${b} \u884C\uFF09
557
+ \u53D8\u66F4\uFF1A+${g.additions} -${g.deletions}`,summary:k,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 Kr from"process";import{existsSync as Og}from"fs";import{join as Dg}from"path";var e_=Kr.platform==="win32";function t_(){if(!e_)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=Kr.env.DSKCODE_BASH;if(e&&Og(e))return{bin:e,args:["-c"],label:"Git Bash",hint:Ng};let t=[Kr.env.ProgramFiles,Kr.env["ProgramFiles(x86)"],Kr.env.LOCALAPPDATA?Dg(Kr.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=Dg(n,r);if(Og(o))return{bin:o,args:["-c"],label:"Git Bash",hint:Ng}}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 Ng="\u5F53\u524D shell \u662F bash \u517C\u5BB9\u8BED\u6CD5\uFF0C\u652F\u6301 pwd/ls/&&/\u7BA1\u9053\u7B49\u6807\u51C6 Unix \u5DE5\u5177\u3002",ls=t_();var Bu={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${ls.label}\u3002${ls.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${ls.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??Au();try{let r=ls.bin??"cmd",o=[...ls.args,e.command],s=await Eu(r,o,t.cwd,n,t.signal,!0),i=[];s.stdout&&i.push(Ze(s.stdout)),s.stderr&&i.push(`[stderr]
558
558
  ${Ze(s.stderr)}`);let a=s.exitCode===0,l=i.length>0?i.join(`
559
559
  `):"(\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}
560
- [\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 LC,stat as $C}from"fs/promises";import{join as bg,relative as MC,isAbsolute as OC}from"path";function DC(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 wg(e,t){let n=[],r;try{r=await LC(e,{withFileTypes:!0})}catch{return n}for(let o of r){if(o.isDirectory()&&(o.name==="node_modules"||o.name===".git"))continue;let s=bg(e,o.name),i=MC(t,s);o.isDirectory()?n.push(...await wg(s,t)):n.push(i)}return n}var Iu={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?Hr(e.directory):void 0,r=n?OC(n)?n:bg(t.cwd,n):t.cwd,o=DC(e.pattern);try{if(!(await $C(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let a=(await wg(r,r)).filter(f=>o.test(f));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(`
560
+ [\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 n_,stat as r_}from"fs/promises";import{join as Bg,relative as o_,isAbsolute as s_}from"path";function i_(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 Gg(e,t){let n=[],r;try{r=await n_(e,{withFileTypes:!0})}catch{return n}for(let o of r){if(o.isDirectory()&&(o.name==="node_modules"||o.name===".git"))continue;let s=Bg(e,o.name),i=o_(t,s);o.isDirectory()?n.push(...await Gg(s,t)):n.push(i)}return n}var Gu={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?qr(e.directory):void 0,r=n?s_(n)?n:Bg(t.cwd,n):t.cwd,o=i_(e.pattern);try{if(!(await r_(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let a=(await Gg(r,r)).filter(f=>o.test(f));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(`
561
561
  `),d=a.length>l?`
562
562
 
563
- ... \u5171 ${a.length} \u4E2A\u6587\u4EF6\uFF0C\u53EA\u663E\u793A\u524D ${l} \u4E2A`:"";return{success:!0,data:Ze(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 NC,readFile as BC,stat as FC}from"fs/promises";import{join as kg,relative as GC,isAbsolute as jC}from"path";async function Sg(e,t,n=200){let r=[],o;try{o=await NC(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=kg(e,s.name);if(s.isDirectory())r.push(...await Sg(i,t,n-r.length));else{if(t&&!s.name.endsWith(`.${t}`))continue;r.push(i)}}return r}var Pu={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?Hr(e.directory):void 0,r=n?jC(n)?n:kg(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 FC(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let l=await Sg(r,e.include,o),c=[];for(let h of l)try{let g=(await BC(h,"utf-8")).split(`
564
- `),w=GC(r,h);for(let b=0;b<g.length&&!(i.test(g[b]??"")&&(i.lastIndex=0,c.push({file:w,line:b+1,content:g[b]}),c.length>=500));b++);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(`
565
- `),d=new Set(c.map(h=>h.file)),f=`\u{1F50D} "${e.pattern}" \u2192 ${c.length} \u6761\u547D\u4E2D / ${d.size} \u4E2A\u6587\u4EF6`;return{success:!0,data:Ze(u),summary:f}}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 UC,stat as WC}from"fs/promises";import{join as HC,relative as Tg}from"path";var Lu={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?lt(e.path,t.cwd):t.cwd,r=e.all??!1;try{let o=await UC(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 f=await WC(HC(n,l.name));f.size<1024?u=`${f.size}B`:f.size<1024*1024?u=`${(f.size/1024).toFixed(1)}KB`:u=`${(f.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} ${Tg(t.cwd,n).replace(/\\/g,"/")}\uFF08\u7A7A\uFF09`};let a=Tg(t.cwd,n).replace(/\\/g,"/");return{success:!0,data:Ze(`\u76EE\u5F55\uFF1A${n}
563
+ ... \u5171 ${a.length} \u4E2A\u6587\u4EF6\uFF0C\u53EA\u663E\u793A\u524D ${l} \u4E2A`:"";return{success:!0,data:Ze(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 a_,readFile as l_,stat as c_}from"fs/promises";import{join as Fg,relative as u_,isAbsolute as d_}from"path";async function jg(e,t,n=200){let r=[],o;try{o=await a_(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=Fg(e,s.name);if(s.isDirectory())r.push(...await jg(i,t,n-r.length));else{if(t&&!s.name.endsWith(`.${t}`))continue;r.push(i)}}return r}var Fu={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?qr(e.directory):void 0,r=n?d_(n)?n:Fg(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 c_(r)).isDirectory())return{success:!1,data:`\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${r}`,error:"NOT_DIRECTORY"};let l=await jg(r,e.include,o),c=[];for(let h of l)try{let g=(await l_(h,"utf-8")).split(`
564
+ `),b=u_(r,h);for(let k=0;k<g.length&&!(i.test(g[k]??"")&&(i.lastIndex=0,c.push({file:b,line:k+1,content:g[k]}),c.length>=500));k++);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(`
565
+ `),d=new Set(c.map(h=>h.file)),f=`\u{1F50D} "${e.pattern}" \u2192 ${c.length} \u6761\u547D\u4E2D / ${d.size} \u4E2A\u6587\u4EF6`;return{success:!0,data:Ze(u),summary:f}}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 p_,stat as f_}from"fs/promises";import{join as m_,relative as Ug}from"path";var ju={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?ct(e.path,t.cwd):t.cwd,r=e.all??!1;try{let o=await p_(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 f=await f_(m_(n,l.name));f.size<1024?u=`${f.size}B`:f.size<1024*1024?u=`${(f.size/1024).toFixed(1)}KB`:u=`${(f.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} ${Ug(t.cwd,n).replace(/\\/g,"/")}\uFF08\u7A7A\uFF09`};let a=Ug(t.cwd,n).replace(/\\/g,"/");return{success:!0,data:Ze(`\u76EE\u5F55\uFF1A${n}
566
566
  ${s.join(`
567
- `)}`),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 $u={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=Ze(c,o),d=`\u72B6\u6001: ${l}
567
+ `)}`),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 Uu={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=Ze(c,o),d=`\u72B6\u6001: ${l}
568
568
  \u5185\u5BB9\u7C7B\u578B: ${a}`,f=c.length>0?`
569
569
  ---
570
- `:"",h=e.url.length>60?e.url.slice(0,57)+"...":e.url,m=`\u{1F310} ${n} ${h} \u2192 ${i.status}`;return{success:i.ok,data:`${d}${f}${u}`,summary:m,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 Cg}from"zod";var _g=Cg.object({name:Cg.string().min(1,"skill \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A").describe("Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>")});function Mu(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:_g,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:Xi(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 Ou=[je(Su),je(_u),je(vu),je(Ru),je(Au),je(Eu),je(Iu),je(Pu),je(Lu),je($u)];p();function vg(e,t={}){let n=t.maxBytes??Us,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 zr=String.raw`(?:--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?\s+|-[a-zA-Z]+\s+)*`,ns=String.raw`(?:--\s+)?`,rs=String.raw`(?:\s+--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?|\s+-[a-zA-Z]+)*`,os=String.raw`(?:[\s;&|]|$)`,VC=[new RegExp(String.raw`\brm\s+${zr}${ns}/\*?${rs}${os}`),new RegExp(String.raw`\brm\s+${zr}${ns}~/?\*?${rs}${os}`),new RegExp(String.raw`\brm\s+${zr}${ns}\$\{?HOME\}?(?:/|\*)?(?:[^\s/]*\*)?${rs}${os}`),new RegExp(String.raw`\brm\s+${zr}${ns}\.(?:/\*?|/\.\.?/?\*?|\*)?${rs}${os}`),new RegExp(String.raw`\brm\s+${zr}${ns}\.\.(?:/\*?|/\.\.?/?\*?|\*)?${rs}${os}`),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+${zr}-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 Ag(e){if(typeof e!="string"||e.length===0)return!1;if(Rg(e))return!0;let t=zC(e);for(let n of t)if(Rg(n))return!0;return!1}function Rg(e){for(let t of VC)if(t.test(e))return!0;return!1}function zC(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 ur=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):Ag(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}};function qC(e){let t=-1;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.role==="assistant"&&i.toolCalls&&i.toolCalls.length>0){t=s;break}if(i.role==="system")break}if(t<0)return 0;let n=e[t].toolCalls??[],r=new Set;for(let s=t+1;s<e.length;s++){let i=e[s];i.role==="tool"&&i.toolCallId&&r.add(i.toolCallId)}let o=0;for(let s of n)!s.id||r.has(s.id)||(e.splice(t+1+o,0,{role:"tool",content:"[\u4E0A\u8F6E\u88AB\u6253\u65AD\uFF0C\u672A\u6267\u884C\u3002\u8BF7\u6839\u636E\u4E0A\u4E0B\u6587\u81EA\u884C\u5224\u65AD\u662F\u5426\u9700\u8981\u91CD\u8BD5\u6216\u8C03\u6574\u8C03\u7528\u3002]",toolCallId:s.id,name:s.name}),o++);return o}var ss=class e{#e=[];#t;#r;#o;#n;#a=new AbortController;#c;#i;#p;#s=null;#l=new Map;#m=[];#f="code";#u;#x;#h;#g=null;#d;#w=!1;#y;#k;#S;constructor(t,n=[],r,o){this.#t=t,n instanceof Pn?this.#r=n:(this.#r=new Pn,this.#r.registerAll(n)),this.#o=r??new ze;let s;if(o?.permissions){let i=o.permissions,a=i.engine??new Qd([]);s=new Mn([new ur,new ep({engine:a,grants:i.grants,prompt:i.prompt,defaultDecision:i.defaultDecision})])}else s=o?.gate??new ul;if(this.#n={cwd:o?.cwd??process.cwd(),maxToolRounds:o?.maxToolRounds??20,reservedForOutput:o?.reservedForOutput??4096,preserveRecentRounds:o?.preserveRecentRounds??10,autoCompactRatio:o?.autoCompactRatio??au,preserveRecentRoundsOnCompact:o?.preserveRecentRoundsOnCompact??lu,minTurnsToCompact:o?.minTurnsToCompact??Yi,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.#c=o?.sessionId??cr.newId(),this.#i=o?.store===!1?null:o?.store??new cr,this.#p=Date.now(),this.#u=new bn(this.#c,this.#n.cwd,{enabled:this.#n.enableLog}),this.#u.logSessionStart(this.#c,this.#n.cwd,this.#t.model(),this.#f),this.#x=new ea({threshold:3}),this.#h=this.#n.enableReflection?new ta:null,this.#n.enableHarness){let i=new na;this.#d=i;for(let a of rg(i))this.#r.registerErased(je(a))}else this.#d=null;this.#y=o?.skills??[],this.#k=()=>this.#y,this.#S=o?.skillCatalogBudgetBytes??Us,this.#y.length>0&&this.#r.register(Mu({getSkills:this.#k,readBody:async i=>Ws(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.#c}get store(){return this.#i}get createdAt(){return this.#p}setMode(t){return this.#f=t,this.#f}async*chat(t,n,r){let o=qC(this.#e);o>0&&this.#u.logError(`\u515C\u5E95\u4FEE\u590D\u4E86 ${o} \u6761 orphan tool_calls\uFF08\u4E0A\u8F6E\u88AB\u4E2D\u65AD\uFF09`,void 0),this.#e.push({role:"user",content:t}),this.#u.logUserMessage(t);let s=this.#e.length-1;if(this.#n.enableCheckpoint)try{let u=await hu(this.#n.cwd);this.#l.set(s,u)}catch{}if(this.#n.enableAutoCompact){let u=await this.#C();u&&(yield{type:"compaction",droppedTurns:u.droppedTurns,keptTurns:u.keptTurns,beforeTokens:u.beforeTokens,afterTokens:u.afterTokens,strategy:u.strategy})}let i=Date.now(),a=0,l=this.#R();this.#w=!1;try{for(;a<this.#n.maxToolRounds;){let u=this.#A();if(r&&r.length>0&&(u=`${u}
570
+ `:"",h=e.url.length>60?e.url.slice(0,57)+"...":e.url,m=`\u{1F310} ${n} ${h} \u2192 ${i.status}`;return{success:i.ok,data:`${d}${f}${u}`,summary:m,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 Wg}from"zod";var Hg=Wg.object({name:Wg.string().min(1,"skill \u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A").describe("Skill \u540D\u79F0\uFF0C\u5BF9\u5E94 <available_skills> \u4E2D\u7684 <name>")});function Wu(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:Hg,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:na(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 Hu=[je(Pu),je(Mu),je(Ou),je(Du),je(Nu),je(Bu),je(Gu),je(Fu),je(ju),je(Uu)];p();function Vg(e,t={}){let n=t.maxBytes??Xs,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 cs={maxTurns:30,maxTokens:5e5,maxWallMs:18e5},Vu=5;p();var us=class{#e=null;current(){return this.#e?{...this.#e}:null}isActive(){return this.#e?.status==="active"}hasGoal(){return this.#e!==null}setGoal(t,n,r=Date.now()){let o={condition:t,status:"active",createdAt:r,turnCount:0,tokenBaseline:0,wallBaseline:r,maxTurns:n?.maxTurns??cs.maxTurns,maxTokens:n?.maxTokens??cs.maxTokens,maxWallMs:n?.maxWallMs??cs.maxWallMs};return this.#e=o,this.#e}restore(t,n,r=Date.now()){return t.status==="achieved"||t.status==="cleared"?(this.#e=null,null):(this.#e={...t,status:"active",turnCount:0,tokenBaseline:n,wallBaseline:r,lastEval:void 0,history:void 0},this.#e)}pause(t){return!this.#e||this.#e.status!=="active"?this.#e:(this.#e.status="paused",t!==void 0&&(this.#e.pausedSnapshot=t),this.#e)}resume(){return!this.#e||this.#e.status!=="paused"?this.#e:(this.#e.status="active",this.#e)}markAchieved(){return this.#e?(this.#e.status="achieved",this.#e):null}clear(){this.#e=null}recordEval(t){if(!this.#e)return;this.#e.lastEval=t,this.#e.turnCount+=1;let n=this.#e.history??[],r=[t,...n].slice(0,Vu);this.#e.history=r}checkBreaker(t,n=Date.now()){if(!this.#e)return{tripped:!1};let r=this.#e;return r.turnCount>r.maxTurns?{tripped:!0,reason:{kind:"max_turns",maxTurns:r.maxTurns}}:t-r.tokenBaseline>r.maxTokens?{tripped:!0,reason:{kind:"max_tokens",maxTokens:r.maxTokens}}:n-r.wallBaseline>r.maxWallMs?{tripped:!0,reason:{kind:"max_wall",maxWallMs:r.maxWallMs}}:r.status!=="active"?{tripped:!0}:{tripped:!1}}pausedSnapshot(){return this.#e?.pausedSnapshot}status(){return this.#e?.status??null}};p();function Ku(e,t){let n=["\u4F60\u662F\u4E00\u4E2A\u76EE\u6807\u9A8C\u6536\u88C1\u5224\u3002","\u4F60\u7684\u552F\u4E00\u804C\u8D23\uFF1A\u5224\u65AD\u7528\u6237\u8BBE\u5B9A\u7684\u5B8C\u6210\u6761\u4EF6\u662F\u5426\u80FD\u88AB\u5F53\u524D\u5BF9\u8BDD\u8BB0\u5F55\u91CC\u7684\u8BC1\u636E\u6240\u8BC1\u5B9E\u3002","","\u4E25\u683C\u7EA6\u675F\uFF1A","1. \u53EA\u80FD\u770B\u5BF9\u8BDD\u4E2D\u5DF2\u51FA\u73B0\u7684\u8F93\u51FA\uFF08assistant \u6587\u672C\u3001\u5DE5\u5177\u8C03\u7528\u7ED3\u679C\uFF09\uFF0C\u4E0D\u8981\u731C\u6D4B\u3001\u4E0D\u8981\u8DD1\u547D\u4EE4\u3001\u4E0D\u8981\u5047\u8BBE\u672A\u53D1\u751F\u7684\u64CD\u4F5C",'2. \u5982\u679C\u6761\u4EF6\u6D89\u53CA"\u6D4B\u8BD5\u901A\u8FC7""\u7F16\u8BD1\u6210\u529F""\u68C0\u67E5\u65E0\u8BEF"\u7B49\uFF0C\u770B\u5BF9\u8BDD\u91CC\u5BF9\u5E94\u5DE5\u5177\u7684\u8FD4\u56DE\u6570\u636E\u6765\u5224\u5B9A',"3. \u5982\u679C\u6761\u4EF6\u542B\u7CCA\u6216\u65E0\u6CD5\u4ECE\u8BC1\u636E\u5224\u5B9A\uFF0C\u503E\u5411\u4E8E ok=false \u5E76\u5728 reason \u91CC\u8BF4\u6E05\u695A\u8FD8\u5DEE\u4EC0\u4E48","4. reason \u5B57\u6BB5\u7528\u4E2D\u6587\uFF0C\u7B80\u6D01\u660E\u786E\uFF0C\u4FBF\u4E8E\u8BA9\u4E3B\u6A21\u578B\u7EE7\u7EED\u5DE5\u4F5C","","\u4E25\u683C\u6309 JSON \u8F93\u51FA\uFF0C\u683C\u5F0F\uFF1A",'{"ok": true | false, "reason": "..."}',"\u4E0D\u8981\u8F93\u51FA\u4EFB\u4F55\u989D\u5916\u5B57\u7B26\u3001markdown fence\u3001\u89E3\u91CA\u3002"].join(`
571
+ `),r=["# \u7528\u6237\u8BBE\u5B9A\u7684\u5B8C\u6210\u6761\u4EF6",e,"","# \u5F53\u524D\u5BF9\u8BDD\u8BB0\u5F55\uFF08\u4EC5\u542B\u6700\u8FD1\u82E5\u5E72\u8F6E\uFF09","<transcript>",t,"</transcript>","","\u8BF7\u6309 system \u7EA6\u675F\u8F93\u51FA JSON\u3002"].join(`
572
+ `);return{systemPrompt:n,userPrompt:r}}function Xu(e){let t=e.trim();if(!t)return null;let n=zu(t);if(n)return qu(n);let r=/^```(?:json)?\s*([\s\S]*?)\s*```$/i.exec(t);if(r){let i=r[1]?.trim();if(i){let a=zu(i);if(a)return qu(a)}}let o=t.indexOf("{"),s=t.lastIndexOf("}");if(o>=0&&s>o){let i=t.slice(o,s+1),a=zu(i);if(a)return qu(a)}return null}function zu(e){try{let t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function qu(e){let t=e.ok,n=e.reason;return typeof t!="boolean"||typeof n!="string"?null:{ok:t,reason:n}}function Ju(e){if(!e)return"condition \u4E0D\u80FD\u4E3A\u7A7A";if(e.length>500)return`condition \u592A\u957F\uFF08${e.length} > 500\uFF09\uFF0C\u8BF7\u7CBE\u7B80`;let t=["\u5DEE\u4E0D\u591A","\u5C3D\u91CF","\u597D\u4E00\u70B9","\u8FD8\u884C","good enough","as good as","nice","decent"],n=e.toLowerCase();for(let r of t)if(n.includes(r))return`condition \u542B\u6A21\u7CCA\u8BCD"${r}"\uFF0Cevaluator \u53EA\u80FD\u57FA\u4E8E\u5BF9\u8BDD\u91CC\u7684\u8BC1\u636E\u5224\u5B9A\uFF0C\u8BF7\u6539\u5199\u4E3A\u53EF\u9A8C\u8BC1\u63CF\u8FF0\uFF08\u5982 "npm test \u5168\u7EFF" / "tsc --noEmit \u901A\u8FC7"\uFF09`;return null}function Zu(e,t=50){let n=e.slice(-t),r=[];for(let o of n)if(o.role!=="system"){if(o.role==="assistant"){let s=(o.content??"").slice(0,500);r.push(`[assistant] ${s}`)}else if(o.role==="user"){let s=(o.content??"").slice(0,500);r.push(`[user] ${s}`)}else if(o.role==="tool"){let s=(o.content??"").slice(0,500);r.push(`[tool:${o.name??"?"}] ${s}`)}}return r.join(`
573
+ `)}p();async function Yu(e,t){let n=Zu(t.messages,50),{systemPrompt:r,userPrompt:o}=Ku(t.condition,n),s=[{role:"system",content:r},{role:"user",content:o}],i="",a=0,l=0;try{for await(let u of e.provider.chat(s,{responseFormat:"json_object"}))u.content&&(i+=u.content),u.usage&&(a=u.usage.promptTokens,l=u.usage.completionTokens)}catch(u){return{ok:!1,reason:`evaluator \u5F02\u5E38\uFF1A${u instanceof Error?u.message:String(u)}`,promptTokens:0,completionTokens:0,evaluatedAt:Date.now()}}let c=Xu(i);return c?{ok:c.ok,reason:c.reason,promptTokens:a,completionTokens:l,evaluatedAt:Date.now()}:{ok:!1,reason:`evaluator \u8F93\u51FA\u65E0\u6CD5\u89E3\u6790\uFF1A${i.slice(0,200)||"\uFF08\u7A7A\u8F93\u51FA\uFF09"}`,promptTokens:a,completionTokens:l,evaluatedAt:Date.now()}}p();p();var Xr=String.raw`(?:--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?\s+|-[a-zA-Z]+\s+)*`,ds=String.raw`(?:--\s+)?`,ps=String.raw`(?:\s+--[a-zA-Z0-9][-a-zA-Z0-9_]*(?:=[^\s]*)?|\s+-[a-zA-Z]+)*`,fs=String.raw`(?:[\s;&|]|$)`,h_=[new RegExp(String.raw`\brm\s+${Xr}${ds}/\*?${ps}${fs}`),new RegExp(String.raw`\brm\s+${Xr}${ds}~/?\*?${ps}${fs}`),new RegExp(String.raw`\brm\s+${Xr}${ds}\$\{?HOME\}?(?:/|\*)?(?:[^\s/]*\*)?${ps}${fs}`),new RegExp(String.raw`\brm\s+${Xr}${ds}\.(?:/\*?|/\.\.?/?\*?|\*)?${ps}${fs}`),new RegExp(String.raw`\brm\s+${Xr}${ds}\.\.(?:/\*?|/\.\.?/?\*?|\*)?${ps}${fs}`),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+${Xr}-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 qg(e){if(typeof e!="string"||e.length===0)return!1;if(zg(e))return!0;let t=g_(e);for(let n of t)if(zg(n))return!0;return!1}function zg(e){for(let t of h_)if(t.test(e))return!0;return!1}function g_(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 fr=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):qg(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 On=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}};function y_(e){let t=-1;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.role==="assistant"&&i.toolCalls&&i.toolCalls.length>0){t=s;break}if(i.role==="system")break}if(t<0)return 0;let n=e[t].toolCalls??[],r=new Set;for(let s=t+1;s<e.length;s++){let i=e[s];i.role==="tool"&&i.toolCallId&&r.add(i.toolCallId)}let o=0;for(let s of n)!s.id||r.has(s.id)||(e.splice(t+1+o,0,{role:"tool",content:"[\u4E0A\u8F6E\u88AB\u6253\u65AD\uFF0C\u672A\u6267\u884C\u3002\u8BF7\u6839\u636E\u4E0A\u4E0B\u6587\u81EA\u884C\u5224\u65AD\u662F\u5426\u9700\u8981\u91CD\u8BD5\u6216\u8C03\u6574\u8C03\u7528\u3002]",toolCallId:s.id,name:s.name}),o++);return o}var ms=class e{#e=[];#t;#r;#o;#n;#a=new AbortController;#u;#i;#p;#s=null;#l=new Map;#g=[];#h="code";#c;#k;#y;#x=null;#d;#w=!1;#b;#T;#S;#f=new us;constructor(t,n=[],r,o){this.#t=t,n instanceof $n?this.#r=n:(this.#r=new $n,this.#r.registerAll(n)),this.#o=r??new ze;let s;if(o?.permissions){let i=o.permissions,a=i.engine??new yp([]);s=new On([new fr,new xp({engine:a,grants:i.grants,prompt:i.prompt,defaultDecision:i.defaultDecision})])}else s=o?.gate??new gl;if(this.#n={cwd:o?.cwd??process.cwd(),maxToolRounds:o?.maxToolRounds??20,reservedForOutput:o?.reservedForOutput??4096,preserveRecentRounds:o?.preserveRecentRounds??10,autoCompactRatio:o?.autoCompactRatio??gu,preserveRecentRoundsOnCompact:o?.preserveRecentRoundsOnCompact??yu,minTurnsToCompact:o?.minTurnsToCompact??sa,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??pr.newId(),this.#i=o?.store===!1?null:o?.store??new pr,this.#p=Date.now(),this.#c=new kn(this.#u,this.#n.cwd,{enabled:this.#n.enableLog}),this.#c.logSessionStart(this.#u,this.#n.cwd,this.#t.model(),this.#h),this.#k=new aa({threshold:3}),this.#y=this.#n.enableReflection?new la:null,this.#n.enableHarness){let i=new ca;this.#d=i;for(let a of Tg(i))this.#r.registerErased(je(a))}else this.#d=null;this.#b=o?.skills??[],this.#T=()=>this.#b,this.#S=o?.skillCatalogBudgetBytes??Xs,this.#b.length>0&&this.#r.register(Wu({getSkills:this.#T,readBody:async i=>Js(i.skillFilePath)}))}setGoal(t,n){let r=t.trim(),o=Ju(r);if(o)throw new Error(o);let s=this.#f.setGoal(r,n);return this.#m(),s}pauseGoal(t){let n=this.#f.pause(t);return this.#m(),n}resumeGoal(){let t=this.#f.resume();return this.#m(),t}clearGoal(){this.#f.clear(),this.#m()}getGoal(){return this.#f.current()}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.#h}get id(){return this.#u}get store(){return this.#i}get createdAt(){return this.#p}get goal(){return this.#f.current()}setMode(t){return this.#h=t,this.#h}async*chat(t,n,r){let o=y_(this.#e);o>0&&this.#c.logError(`\u515C\u5E95\u4FEE\u590D\u4E86 ${o} \u6761 orphan tool_calls\uFF08\u4E0A\u8F6E\u88AB\u4E2D\u65AD\uFF09`,void 0),this.#e.push({role:"user",content:t}),this.#c.logUserMessage(t);let s=this.#e.length-1;if(this.#n.enableCheckpoint)try{let i=await Cu(this.#n.cwd);this.#l.set(s,i)}catch{}if(this.#n.enableAutoCompact){let i=await this.#v();i&&(yield{type:"compaction",droppedTurns:i.droppedTurns,keptTurns:i.keptTurns,beforeTokens:i.beforeTokens,afterTokens:i.afterTokens,strategy:i.strategy})}for(;;){if(yield*this.#_(n,r),!this.#f.isActive())return;let i=await Yu({provider:this.#t},{condition:this.#f.current().condition,messages:this.#e});this.#f.recordEval(i);let a=this.#f.checkBreaker(this.#o.sessionTotalCost);if(a.tripped&&a.reason){this.#f.clear(),this.#m(),yield{type:"goal_aborted",reason:a.reason};return}if(i.ok){this.#f.markAchieved(),this.#m(),yield{type:"goal_achieved",eval:i};return}this.#e.push({role:"user",content:`[Goal evaluator] \u6761\u4EF6\u5C1A\u672A\u6EE1\u8DB3\uFF1A${i.reason}
574
+ \u8BF7\u7EE7\u7EED\u3002`}),this.#c.logUserMessage(`[Goal evaluator] ${i.reason}`),this.#m(),yield{type:"goal_continue",eval:i}}}async*#_(t,n){let r=Date.now(),o=0,s=this.#E();this.#w=!1;try{for(;o<this.#n.maxToolRounds;){let a=this.#I();if(n&&n.length>0&&(a=`${a}
571
575
 
572
- ${r}`),this.#h&&this.#g){let j=this.#h.analyze(this.#g,{writeRoots:this.#n.writeRoots,cwd:this.#n.cwd});j.length>0&&(u=this.#h.injectIntoPrompt(u,j),this.#u.logReflections(j.map(N=>({category:N.category,toolName:N.toolName,hint:N.hint})))),this.#g=null}let[d]=Xh([...this.#e],{model:this.#t.model(),reservedForOutput:this.#n.reservedForOutput,systemPrompt:u,preserveRecentRounds:this.#n.preserveRecentRounds}),f=Jh(u,d),h=ng(this.#r,this.#f),m=this.#t.chat(f,{signal:this.#a.signal,tools:h.length>0?h:void 0,thinkingAllowed:n?.thinkingAllowed,thinkingEffort:n?.thinkingEffort,responseFormat:n?.responseFormat,toolChoice:n?.toolChoice}),g=this.#t.model(),w="",b="",k,v,I=null,R=0;for(let j of f)R+=this.#t.countTokens(j.content)+10;let D=0,F=300;for await(let j of m){if(j.reasoningContent&&(b+=j.reasoningContent,yield{type:"reasoning_delta",content:j.reasoningContent}),j.content){w+=j.content,yield{type:"text_delta",content:j.content};let N=Date.now();if(N-D>=F){D=N;let A=this.#t.countTokens(w),ie={promptTokens:R,completionTokens:A},ne=Mt(ie,g);yield{type:"usage",usage:ie,model:g,cost:ne.totalCost,estimated:!0}}}if(j.toolCalls&&j.toolCalls.length>0&&(v=j.toolCalls),j.usage){k=j.usage;let N=Mt(j.usage,g);yield{type:"usage",usage:j.usage,model:g,cost:N.totalCost,estimated:!1}}j.finishReason&&(I=j.finishReason)}if(w&&!k){let j=this.#t.countTokens(w),N={promptTokens:R,completionTokens:j},A=Mt(N,g);yield{type:"usage",usage:N,model:g,cost:A.totalCost,estimated:!0}}if(k){this.#o.record(k,g);let j=Mt(k,g);this.#u.logUsage(g,k.promptTokens,k.completionTokens,k.cachedPromptTokens,j.totalCost,a),yield{type:"usage",usage:k,model:g}}let P={role:"assistant",content:w};if(v&&v.length>0&&(P.toolCalls=v),this.#e.push(P),this.#u.logAssistantText(w,a),b&&this.#u.logReasoning(b,a),v&&v.length>0){yield{type:"tool_calls",calls:v};for(let A of v)this.#u.logToolCall(A.name,A.id,A.arguments,a);if(this.#x.shouldBreak(this.#m,v)){let A=`
576
+ ${n}`),this.#y&&this.#x){let M=this.#y.analyze(this.#x,{writeRoots:this.#n.writeRoots,cwd:this.#n.cwd});M.length>0&&(a=this.#y.injectIntoPrompt(a,M),this.#c.logReflections(M.map(C=>({category:C.category,toolName:C.toolName,hint:C.hint})))),this.#x=null}let[l]=mg([...this.#e],{model:this.#t.model(),reservedForOutput:this.#n.reservedForOutput,systemPrompt:a,preserveRecentRounds:this.#n.preserveRecentRounds}),c=hg(a,l),u=wg(this.#r,this.#h),d=this.#t.chat(c,{signal:this.#a.signal,tools:u.length>0?u:void 0,thinkingAllowed:t?.thinkingAllowed,thinkingEffort:t?.thinkingEffort,responseFormat:t?.responseFormat,toolChoice:t?.toolChoice}),f=this.#t.model(),h="",m="",g,b,k=null,T=0;for(let M of c)T+=this.#t.countTokens(M.content)+10;let A=0,E=300;for await(let M of d){if(M.reasoningContent&&(m+=M.reasoningContent,yield{type:"reasoning_delta",content:M.reasoningContent}),M.content){h+=M.content,yield{type:"text_delta",content:M.content};let C=Date.now();if(C-A>=E){A=C;let N=this.#t.countTokens(h),oe={promptTokens:T,completionTokens:N},j=Mt(oe,f);yield{type:"usage",usage:oe,model:f,cost:j.totalCost,estimated:!0}}}if(M.toolCalls&&M.toolCalls.length>0&&(b=M.toolCalls),M.usage){g=M.usage;let C=Mt(M.usage,f);yield{type:"usage",usage:M.usage,model:f,cost:C.totalCost,estimated:!1}}M.finishReason&&(k=M.finishReason)}if(h&&!g){let M=this.#t.countTokens(h),C={promptTokens:T,completionTokens:M},N=Mt(C,f);yield{type:"usage",usage:C,model:f,cost:N.totalCost,estimated:!0}}if(g){this.#o.record(g,f);let M=Mt(g,f);this.#c.logUsage(f,g.promptTokens,g.completionTokens,g.cachedPromptTokens,M.totalCost,o),yield{type:"usage",usage:g,model:f}}let I={role:"assistant",content:h};if(b&&b.length>0&&(I.toolCalls=b),this.#e.push(I),this.#c.logAssistantText(h,o),m&&this.#c.logReasoning(m,o),b&&b.length>0){yield{type:"tool_calls",calls:b};for(let N of b)this.#c.logToolCall(N.name,N.id,N.arguments,o);if(this.#k.shouldBreak(this.#g,b)){let N=`
573
577
  \u26A0\uFE0F \u540C\u4E00\u5DE5\u5177\u91CD\u590D\u51FA\u9519\uFF0C\u5DF2\u5F3A\u5236\u5207\u6362\u7B56\u7565
574
- `;yield{type:"text_delta",content:A},P.toolCalls=void 0,P.content+=A,this.#m=[],a++;continue}let N=await l.executeBatch(v);this.#m=N.records,this.#g=N.items.map(A=>{let ie=this.#r.get(A.name);return{name:A.name,result:A.result,kind:ie?.kind??"other",recentSameTool:N.records.filter(ne=>ne.name===A.name).map(ne=>({success:ne.success,error:ne.error}))}});for(let A of N.items){let ie=A.name.startsWith("todo_")&&this.#d?this.#d.items.map(Q=>({...Q})):void 0;yield{type:"tool_result",name:A.name,result:A.result,todoSnapshot:ie,callId:A.callId},this.#u.logToolResult(A.name,A.callId,A.result.success,A.result.data,A.result.error,void 0,a);let ne=A.result.data;A.result.diff&&A.result.diff.patch&&(ne+=`
578
+ `;yield{type:"text_delta",content:N},I.toolCalls=void 0,I.content+=N,this.#g=[],o++;continue}let C=await s.executeBatch(b);this.#g=C.records,this.#x=C.items.map(N=>{let oe=this.#r.get(N.name);return{name:N.name,result:N.result,kind:oe?.kind??"other",recentSameTool:C.records.filter(j=>j.name===N.name).map(j=>({success:j.success,error:j.error}))}});for(let N of C.items){let oe=N.name.startsWith("todo_")&&this.#d?this.#d.items.map(O=>({...O})):void 0;yield{type:"tool_result",name:N.name,result:N.result,todoSnapshot:oe,callId:N.callId},this.#c.logToolResult(N.name,N.callId,N.result.success,N.result.data,N.result.error,void 0,o);let j=N.result.data;N.result.diff&&N.result.diff.patch&&(j+=`
575
579
 
576
- ${A.result.diff.patch}`),this.#e.push({role:"tool",content:ne,toolCallId:A.callId,name:A.name})}this.#E(N.items),a++;continue}let z=!1;if(this.#d){for(let j of this.#d.items)j.status==="running"&&(this.#d.markDone(j.id,"LLM \u5DF2\u8F93\u51FA\u6700\u7EC8\u7ED3\u679C\uFF0C\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"),z=!0);if(z){let j=this.#d.items.map(N=>({...N}));yield{type:"tool_result",name:"todo_mark_done",result:{success:!0,data:"\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"},todoSnapshot:j}}}this.#d&&this.#d.items.length>0&&this.#d.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(u){if(u instanceof DOMException&&u.name==="AbortError"||u instanceof Error&&u.name==="AbortError")return;this.#u.logError(u instanceof Error?u.message:String(u),u instanceof Error?u.stack:void 0),yield{type:"error",error:u instanceof Error?u:new Error(String(u))};return}let c=Date.now()-i;this.#u.logTurnDone(c,a),this.#b(),await this.#o.flush().catch(()=>{}),yield{type:"done",elapsed:c}}abort(){this.#a.abort(),this.#s&&(clearTimeout(this.#s),this.#s=null)}async flushLog(){await this.#u.flush()}async drainLog(){await this.#u.drain()}reset(){this.#e.length=0,this.#o.resetSession(),this.#m=[],this.#l.clear(),this.#g=null}getContextStats(){let t=kn(this.#t.model());return cu(this.#e,t.contextWindow)}async compact(t){let n=kn(this.#t.model()),r=await uu(this.#e,{contextWindow:n.contextWindow,autoCompactRatio:this.#n.autoCompactRatio,preserveRecentRounds:this.#n.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#n.minTurnsToCompact,provider:this.#t,signal:this.#a.signal,...t?{onProgress:t}:{}});if(r.droppedTurns>0){this.#e.length=0;for(let o of r.messages)this.#e.push(o);this.#l.clear(),this.#b()}return r}async#C(){let n={contextWindow:kn(this.#t.model()).contextWindow,autoCompactRatio:this.#n.autoCompactRatio,preserveRecentRounds:this.#n.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#n.minTurnsToCompact,provider:this.#t,signal:this.#a.signal};if(!Qh(this.#e,n))return null;let r=await uu(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.#l.clear(),this.#b(),{...r,strategy:o}}async persistNow(){this.#s&&(clearTimeout(this.#s),this.#s=null),await this.#T()}#b(){if(this.#i){if(this.#s){this.#s.refresh();return}this.#s=setTimeout(()=>{this.#s=null,this.#T()},500),this.#s.unref()}}async#T(){if(!this.#i)return;let t={id:this.#c,title:this.#_(),createdAt:this.#p,updatedAt:Date.now(),cwd:this.#n.cwd,model:this.#t.model(),messages:this.#v(),totalCost:this.#o.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.#l.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 cr;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.#l.set(c,u)}return l.#p=a.createdAt,l}listCheckpoints(){let t=[];for(let[n,r]of this.#l){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.#l.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.#l)i>t&&(o.push(a),this.#l.delete(i));let s=!1;if(r.isGitRepo)try{r.stashSha?await gu(r):await yu(this.#n.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.#l.delete(t);for(let i of o)ia(i);return this.#b(),{ok:!0,fileRestored:s}}hasCheckpoints(){return this.listCheckpoints().length>0}get gate(){return this.#n.gate}async delete(){this.#i&&await this.#i.delete(this.#c);for(let t of this.#l.values())ia(t);this.#l.clear(),this.#u.logSessionEnd(Date.now()-this.#p),await this.#u.flush()}#R(){return new Qi({registry:this.#r,gate:this.#n.gate,baseCtx:{cwd:this.#n.cwd,signal:this.#a.signal,writeRoots:this.#n.writeRoots}})}#A(){let n=this.#r.list().map(a=>({name:a.name,description:a.description,parameters:a.parameters})),{catalog:r}=this.#y.length>0?vg(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.#t.model(),maxToolRounds:this.#n.maxToolRounds,tools:n.length>0?n:void 0,projectContext:this.#n.projectContext??void 0,cwd:this.#n.cwd,availableSkills:o},i;return this.#f==="plan"?i=zh(s):i=Vh(s),this.#d&&this.#d.items.length>0&&(i=i+`
580
+ ${N.result.diff.patch}`),this.#e.push({role:"tool",content:j,toolCallId:N.callId,name:N.name})}this.#P(C.items),o++;continue}let F=!1;if(this.#d){for(let M of this.#d.items)M.status==="running"&&(this.#d.markDone(M.id,"LLM \u5DF2\u8F93\u51FA\u6700\u7EC8\u7ED3\u679C\uFF0C\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"),F=!0);if(F){let M=this.#d.items.map(C=>({...C}));yield{type:"tool_result",name:"todo_mark_done",result:{success:!0,data:"\u81EA\u52A8\u6807\u8BB0\u5B8C\u6210"},todoSnapshot:M}}}this.#d&&this.#d.items.length>0&&this.#d.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(a){if(a instanceof DOMException&&a.name==="AbortError"||a instanceof Error&&a.name==="AbortError")return;this.#c.logError(a instanceof Error?a.message:String(a),a instanceof Error?a.stack:void 0),yield{type:"error",error:a instanceof Error?a:new Error(String(a))};return}let i=Date.now()-r;this.#c.logTurnDone(i,o),this.#m(),await this.#o.flush().catch(()=>{}),yield{type:"done",elapsed:i}}abort(){this.#a.abort(),this.#s&&(clearTimeout(this.#s),this.#s=null),this.#f.isActive()&&(this.#f.clear(),this.#m())}async flushLog(){await this.#c.flush()}async drainLog(){await this.#c.drain()}reset(){this.#e.length=0,this.#o.resetSession(),this.#g=[],this.#l.clear(),this.#x=null,this.#f.clear()}getContextStats(){let t=Tn(this.#t.model());return xu(this.#e,t.contextWindow)}async compact(t){let n=Tn(this.#t.model()),r=await bu(this.#e,{contextWindow:n.contextWindow,autoCompactRatio:this.#n.autoCompactRatio,preserveRecentRounds:this.#n.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#n.minTurnsToCompact,provider:this.#t,signal:this.#a.signal,...t?{onProgress:t}:{}});if(r.droppedTurns>0){this.#e.length=0;for(let o of r.messages)this.#e.push(o);this.#l.clear(),this.#m()}return r}async#v(){let n={contextWindow:Tn(this.#t.model()).contextWindow,autoCompactRatio:this.#n.autoCompactRatio,preserveRecentRounds:this.#n.preserveRecentRoundsOnCompact,minTurnsToCompact:this.#n.minTurnsToCompact,provider:this.#t,signal:this.#a.signal};if(!xg(this.#e,n))return null;let r=await bu(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.#l.clear(),this.#m(),{...r,strategy:o}}async persistNow(){this.#s&&(clearTimeout(this.#s),this.#s=null),await this.#C()}#m(){if(this.#i){if(this.#s){this.#s.refresh();return}this.#s=setTimeout(()=>{this.#s=null,this.#C()},500),this.#s.unref()}}async#C(){if(!this.#i)return;let t=this.#f.current(),n={id:this.#u,title:this.#R(),createdAt:this.#p,updatedAt:Date.now(),cwd:this.#n.cwd,model:this.#t.model(),messages:this.#A(),totalCost:this.#o.sessionTotalCost,...t&&(t.status==="active"||t.status==="paused")?{goal:t}:{}};try{await this.#i.save(n)}catch(r){console.error("[Session] \u6301\u4E45\u5316\u5931\u8D25:",r)}}#R(){for(let t of this.#e)if(t.role==="user"&&t.content.trim())return t.content.trim().slice(0,40);return"\u65B0\u4F1A\u8BDD"}#A(){return this.#e.map((t,n)=>{let r=this.#l.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 pr;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.#l.set(c,u)}if(l.#p=a.createdAt,a.goal){let c=l.#f.restore(a.goal,l.#o.sessionTotalCost);c&&(c.pausedSnapshot?l.#e.push({role:"user",content:`[Goal resumed] ${c.pausedSnapshot}`}):l.#e.push({role:"user",content:`[Goal resumed] \u6761\u4EF6\uFF1A${c.condition}`}))}return l}listCheckpoints(){let t=[];for(let[n,r]of this.#l){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.#l.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.#l)i>t&&(o.push(a),this.#l.delete(i));let s=!1;if(r.isGitRepo)try{r.stashSha?await _u(r):await vu(this.#n.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.#l.delete(t);for(let i of o)fa(i);return this.#m(),{ok:!0,fileRestored:s}}hasCheckpoints(){return this.listCheckpoints().length>0}get gate(){return this.#n.gate}async delete(){this.#i&&await this.#i.delete(this.#u);for(let t of this.#l.values())fa(t);this.#l.clear(),this.#c.logSessionEnd(Date.now()-this.#p),await this.#c.flush()}#E(){return new ia({registry:this.#r,gate:this.#n.gate,baseCtx:{cwd:this.#n.cwd,signal:this.#a.signal,writeRoots:this.#n.writeRoots}})}#I(){let n=this.#r.list().map(a=>({name:a.name,description:a.description,parameters:a.parameters})),{catalog:r}=this.#b.length>0?Vg(this.#b,{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.#t.model(),maxToolRounds:this.#n.maxToolRounds,tools:n.length>0?n:void 0,projectContext:this.#n.projectContext??void 0,cwd:this.#n.cwd,availableSkills:o},i;return this.#h==="plan"?i=dg(s):i=ug(s),this.#d&&this.#d.items.length>0&&(i=i+`
577
581
 
578
- `+this.#d.toMarkdown()),i}#E(t){!this.#d||this.#d.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
582
+ `+this.#d.toMarkdown()),i}#P(t){!this.#d||this.#d.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
579
583
  \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
580
584
  \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
581
585
  \u5982\u679C\u662F\u7B80\u5355\uFF0C\u5FFD\u7565\u672C\u63D0\u793A\u3002
582
- \uFF08\u672C\u63D0\u793A\u672C\u4F1A\u8BDD\u4EC5\u53D1\u4E00\u6B21\uFF0C\u540E\u7EED\u4E0D\u518D\u63D0\u9192\u3002\uFF09`}))}};p();p();var ca=class{#e;#t=new Map;#r=new Map;#o=[];#n=new Set;#a=null;#c=!1;constructor(t={}){this.#e=t.store??co.sharedInstance(),t.onToolsChanged&&this.#n.add(t.onToolsChanged)}start(){this.#a||(this.#a=this.#e.onEvent(t=>this.#i(t)))}async dispose(){this.#a?.close(),this.#a=null,this.#t.clear(),this.#r.clear(),this.#o=[],this.#n.clear()}async reconcile(t){return this.#e.reconcile(t)}tools(){return this.#o}prompts(){let t=[];for(let[,n]of this.#r)t.push(...n);return t}status(){return this.#e.status()}listServers(){let t=this.#e.status(),n=this.#o,r=[];for(let[o,s]of Object.entries(t)){if(s.settings.enabled===!1)continue;let i=`mcp_${o}_`,a=[];for(let l of n)l.name.startsWith(i)&&a.push(l.name.slice(i.length));r.push({id:o,state:s.state,tools:a})}return r.sort((o,s)=>o.id.localeCompare(s.id)),r}getServer(t){return this.#e.getServer(t)}onToolsChanged(t){return this.#n.add(t),{close:()=>{this.#n.delete(t)}}}#i(t){switch(t.type){case"started":case"toolsChanged":case"promptsChanged":this.#p();break;case"failed":case"stopped":if(!this.#t.has(t.serverId)&&!this.#r.has(t.serverId))return;this.#t.delete(t.serverId),this.#r.delete(t.serverId),this.#l();break;case"statusChanged":break}}async#p(){if(!this.#c){this.#c=!0;try{let t=this.#e.status(),n=[];for(let[r,o]of Object.entries(t)){if(o.state!=="ready"){this.#t.delete(r),this.#r.delete(r);continue}n.push(this.#s(r))}await Promise.allSettled(n),this.#l()}finally{this.#c=!1}}}async#s(t){let n=this.#m(t);if(!(!n||n.state!=="ready")){try{let r=await n.tools.list();this.#t.set(t,r)}catch(r){process.env.DSKCODE_MCP_DEBUG&&console.error(`[mcp:${t}] tools/list \u5931\u8D25\uFF1A${r.message}`)}if(n.capabilities?.prompts)try{let r=await n.prompts.list();this.#r.set(t,r.map(o=>({serverId:t,name:o.name,description:o.description,slashHint:`${t}.${o.name}`})))}catch(r){process.env.DSKCODE_MCP_DEBUG&&console.error(`[mcp:${t}] prompts/list \u5931\u8D25\uFF1A${r.message}`)}else this.#r.delete(t)}}#l(){let t=[];for(let[n,r]of this.#t)for(let o of r)t.push(KC(n,o,this.#e));this.#o=t;for(let n of this.#n)try{n(t)}catch{}}#m(t){return this.#e.getServer(t)}};function KC(e,t,n){let r=Eg(e),o=Eg(t.name),s=`mcp_${r}_${o}`,i=t.description?`[mcp:${e}] ${t.description}`:`[mcp:${e}] ${t.name}`,a=t.annotations?.readOnlyHint?"read":t.annotations?.destructiveHint?"delete":"other",l={type:"object",properties:t.inputSchema.properties??{},...t.inputSchema.required&&t.inputSchema.required.length>0?{required:t.inputSchema.required}:{},...t.inputSchema.additionalProperties!==void 0?{additionalProperties:t.inputSchema.additionalProperties}:{}};return{name:s,description:i,kind:a,parameters:l,supportsInputStreaming:!1,supportedProviders:[],async execute(c,u){let d=n.getServer(e);if(!d)return{success:!1,data:`MCP server "${e}" \u672A\u8FD0\u884C\u6216\u5DF2\u505C\u6B62`,error:"MCP_SERVER_UNAVAILABLE"};if(d.state!=="ready")return{success:!1,data:`MCP server "${e}" \u5F53\u524D\u72B6\u6001\u4E3A ${d.state}\uFF0C\u6682\u4E0D\u53EF\u7528`,error:"MCP_SERVER_UNAVAILABLE"};let f=u.timeout??d.getEffectiveTimeoutMs(),h;try{h=await d.tools.call(t.name,c??{},{timeoutMs:f,signal:u.signal})}catch(m){return{success:!1,data:`MCP \u5DE5\u5177\u8C03\u7528\u5931\u8D25\uFF1A${m instanceof Error?m.message:String(m)}`,error:"MCP_TOOL_ERROR"}}return h.isError?{success:!1,data:Ig(h.content),error:"MCP_TOOL_ERROR"}:{success:!0,data:Ig(h.content)}},initialTitle(){return s}}}function Eg(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function Ig(e){let t=[];for(let n of e)switch(n.type){case"text":t.push(n.text);break;case"image":t.push(`[image: ${n.mimeType}, ${n.data.length} \u5B57\u7B26 base64]`);break;case"audio":t.push(`[audio: ${n.mimeType}, ${n.data.length} \u5B57\u7B26 base64]`);break;case"resource":t.push(`[resource: ${n.resource.uri}${n.resource.text?`]
586
+ \uFF08\u672C\u63D0\u793A\u672C\u4F1A\u8BDD\u4EC5\u53D1\u4E00\u6B21\uFF0C\u540E\u7EED\u4E0D\u518D\u63D0\u9192\u3002\uFF09`}))}};p();p();var ga=class{#e;#t=new Map;#r=new Map;#o=[];#n=new Set;#a=null;#u=!1;constructor(t={}){this.#e=t.store??go.sharedInstance(),t.onToolsChanged&&this.#n.add(t.onToolsChanged)}start(){this.#a||(this.#a=this.#e.onEvent(t=>this.#i(t)))}async dispose(){this.#a?.close(),this.#a=null,this.#t.clear(),this.#r.clear(),this.#o=[],this.#n.clear()}async reconcile(t){return this.#e.reconcile(t)}tools(){return this.#o}prompts(){let t=[];for(let[,n]of this.#r)t.push(...n);return t}status(){return this.#e.status()}listServers(){let t=this.#e.status(),n=this.#o,r=[];for(let[o,s]of Object.entries(t)){if(s.settings.enabled===!1)continue;let i=`mcp_${o}_`,a=[];for(let l of n)l.name.startsWith(i)&&a.push(l.name.slice(i.length));r.push({id:o,state:s.state,tools:a})}return r.sort((o,s)=>o.id.localeCompare(s.id)),r}getServer(t){return this.#e.getServer(t)}onToolsChanged(t){return this.#n.add(t),{close:()=>{this.#n.delete(t)}}}#i(t){switch(t.type){case"started":case"toolsChanged":case"promptsChanged":this.#p();break;case"failed":case"stopped":if(!this.#t.has(t.serverId)&&!this.#r.has(t.serverId))return;this.#t.delete(t.serverId),this.#r.delete(t.serverId),this.#l();break;case"statusChanged":break}}async#p(){if(!this.#u){this.#u=!0;try{let t=this.#e.status(),n=[];for(let[r,o]of Object.entries(t)){if(o.state!=="ready"){this.#t.delete(r),this.#r.delete(r);continue}n.push(this.#s(r))}await Promise.allSettled(n),this.#l()}finally{this.#u=!1}}}async#s(t){let n=this.#g(t);if(!(!n||n.state!=="ready")){try{let r=await n.tools.list();this.#t.set(t,r)}catch(r){process.env.DSKCODE_MCP_DEBUG&&console.error(`[mcp:${t}] tools/list \u5931\u8D25\uFF1A${r.message}`)}if(n.capabilities?.prompts)try{let r=await n.prompts.list();this.#r.set(t,r.map(o=>({serverId:t,name:o.name,description:o.description,slashHint:`${t}.${o.name}`})))}catch(r){process.env.DSKCODE_MCP_DEBUG&&console.error(`[mcp:${t}] prompts/list \u5931\u8D25\uFF1A${r.message}`)}else this.#r.delete(t)}}#l(){let t=[];for(let[n,r]of this.#t)for(let o of r)t.push(x_(n,o,this.#e));this.#o=t;for(let n of this.#n)try{n(t)}catch{}}#g(t){return this.#e.getServer(t)}};function x_(e,t,n){let r=Kg(e),o=Kg(t.name),s=`mcp_${r}_${o}`,i=t.description?`[mcp:${e}] ${t.description}`:`[mcp:${e}] ${t.name}`,a=t.annotations?.readOnlyHint?"read":t.annotations?.destructiveHint?"delete":"other",l={type:"object",properties:t.inputSchema.properties??{},...t.inputSchema.required&&t.inputSchema.required.length>0?{required:t.inputSchema.required}:{},...t.inputSchema.additionalProperties!==void 0?{additionalProperties:t.inputSchema.additionalProperties}:{}};return{name:s,description:i,kind:a,parameters:l,supportsInputStreaming:!1,supportedProviders:[],async execute(c,u){let d=n.getServer(e);if(!d)return{success:!1,data:`MCP server "${e}" \u672A\u8FD0\u884C\u6216\u5DF2\u505C\u6B62`,error:"MCP_SERVER_UNAVAILABLE"};if(d.state!=="ready")return{success:!1,data:`MCP server "${e}" \u5F53\u524D\u72B6\u6001\u4E3A ${d.state}\uFF0C\u6682\u4E0D\u53EF\u7528`,error:"MCP_SERVER_UNAVAILABLE"};let f=u.timeout??d.getEffectiveTimeoutMs(),h;try{h=await d.tools.call(t.name,c??{},{timeoutMs:f,signal:u.signal})}catch(m){return{success:!1,data:`MCP \u5DE5\u5177\u8C03\u7528\u5931\u8D25\uFF1A${m instanceof Error?m.message:String(m)}`,error:"MCP_TOOL_ERROR"}}return h.isError?{success:!1,data:Xg(h.content),error:"MCP_TOOL_ERROR"}:{success:!0,data:Xg(h.content)}},initialTitle(){return s}}}function Kg(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function Xg(e){let t=[];for(let n of e)switch(n.type){case"text":t.push(n.text);break;case"image":t.push(`[image: ${n.mimeType}, ${n.data.length} \u5B57\u7B26 base64]`);break;case"audio":t.push(`[audio: ${n.mimeType}, ${n.data.length} \u5B57\u7B26 base64]`);break;case"resource":t.push(`[resource: ${n.resource.uri}${n.resource.text?`]
583
587
  ${n.resource.text}`:"]"}`);break}return t.join(`
584
- `)}p();var XC=/^\/mcp(?:\s+(.*))?$/;async function Pg(e,t,n){let r=XC.exec(e);if(!r)return{kind:"no-match"};let o=(r[1]??"").trim();if(o==="")return{kind:"text",text:JC(t)};let s=o.split(/\s+/),i=s[0],a=s[1];if(i==="restart"){if(!a)return{kind:"error",message:"\u7528\u6CD5\uFF1A/mcp restart <server-id>"};let l=t.status();return l[a]?{kind:"restart",serverId:a}:{kind:"error",message:`\u672A\u627E\u5230 MCP server "${a}"\u3002\u53EF\u7528\uFF1A${Object.keys(l).join(", ")||"(\u65E0)"}`}}if(i==="reload")return{kind:"reload"};if(i==="resources"){if(!a)return{kind:"error",message:"\u7528\u6CD5\uFF1A/mcp resources <server-id>"};let l=t.getServer(a);if(!l)return{kind:"error",message:`\u672A\u627E\u5230 MCP server "${a}"`};if(l.state!=="ready")return{kind:"error",message:`MCP server "${a}" \u72B6\u6001\u4E3A ${l.state}\uFF0C\u6682\u4E0D\u53EF\u7528`};if(!l.capabilities?.resources)return{kind:"text",text:`MCP server "${a}" \u672A\u58F0\u660E resources capability\u3002`};try{let c=await l.resources.list();if(c.length===0)return{kind:"text",text:`MCP server "${a}" \u672A\u66B4\u9732\u4EFB\u4F55 resource\u3002`};let u=[`\u{1F4E6} MCP server "${a}" \u66B4\u9732 ${c.length} \u4E2A resource\uFF1A`];for(let d of c){let f=d.mimeType?` (${d.mimeType})`:"";u.push(` - ${d.uri} \u2014 ${d.name}${f}`),d.description&&u.push(` ${d.description}`)}return u.push(""),u.push("\u63D0\u793A\uFF1Aresources \u6BB5 v0.8+ \u6682\u672A\u4F5C\u4E3A tool \u66B4\u9732\uFF0C\u4EC5\u4F9B\u8C03\u8BD5\u3002"),{kind:"text",text:u.join(`
585
- `)}}catch(c){return{kind:"error",message:`resources/list \u5931\u8D25\uFF1A${c instanceof Error?c.message:String(c)}`}}}return{kind:"error",message:`\u672A\u77E5\u5B50\u547D\u4EE4 "/mcp ${i}"\u3002\u53EF\u7528\uFF1A/mcp | /mcp restart <name> | /mcp reload`}}function JC(e){let t=e.status(),n=Object.keys(t);if(n.length===0)return`\u{1F4CB} \u5F53\u524D\u672A\u914D\u7F6E\u4EFB\u4F55 MCP server\u3002
586
- \u5728 ~/.dskcode/settings.json \u7684 mcpServers \u6BB5\u6DFB\u52A0\u5373\u53EF\u3002`;let r=[`\u{1F4CB} MCP server \u72B6\u6001\uFF08\u5171 ${n.length} \u4E2A\uFF09\uFF1A`];for(let o of n){let s=t[o],i=ZC(s.state),a=s.retryPending?` \u27F2 \u91CD\u8BD5 #${s.retryAttempts}`:"",l=s.lastError?`
588
+ `)}p();var b_=/^\/mcp(?:\s+(.*))?$/;async function Jg(e,t,n){let r=b_.exec(e);if(!r)return{kind:"no-match"};let o=(r[1]??"").trim();if(o==="")return{kind:"text",text:k_(t)};let s=o.split(/\s+/),i=s[0],a=s[1];if(i==="restart"){if(!a)return{kind:"error",message:"\u7528\u6CD5\uFF1A/mcp restart <server-id>"};let l=t.status();return l[a]?{kind:"restart",serverId:a}:{kind:"error",message:`\u672A\u627E\u5230 MCP server "${a}"\u3002\u53EF\u7528\uFF1A${Object.keys(l).join(", ")||"(\u65E0)"}`}}if(i==="reload")return{kind:"reload"};if(i==="resources"){if(!a)return{kind:"error",message:"\u7528\u6CD5\uFF1A/mcp resources <server-id>"};let l=t.getServer(a);if(!l)return{kind:"error",message:`\u672A\u627E\u5230 MCP server "${a}"`};if(l.state!=="ready")return{kind:"error",message:`MCP server "${a}" \u72B6\u6001\u4E3A ${l.state}\uFF0C\u6682\u4E0D\u53EF\u7528`};if(!l.capabilities?.resources)return{kind:"text",text:`MCP server "${a}" \u672A\u58F0\u660E resources capability\u3002`};try{let c=await l.resources.list();if(c.length===0)return{kind:"text",text:`MCP server "${a}" \u672A\u66B4\u9732\u4EFB\u4F55 resource\u3002`};let u=[`\u{1F4E6} MCP server "${a}" \u66B4\u9732 ${c.length} \u4E2A resource\uFF1A`];for(let d of c){let f=d.mimeType?` (${d.mimeType})`:"";u.push(` - ${d.uri} \u2014 ${d.name}${f}`),d.description&&u.push(` ${d.description}`)}return u.push(""),u.push("\u63D0\u793A\uFF1Aresources \u6BB5 v0.8+ \u6682\u672A\u4F5C\u4E3A tool \u66B4\u9732\uFF0C\u4EC5\u4F9B\u8C03\u8BD5\u3002"),{kind:"text",text:u.join(`
589
+ `)}}catch(c){return{kind:"error",message:`resources/list \u5931\u8D25\uFF1A${c instanceof Error?c.message:String(c)}`}}}return{kind:"error",message:`\u672A\u77E5\u5B50\u547D\u4EE4 "/mcp ${i}"\u3002\u53EF\u7528\uFF1A/mcp | /mcp restart <name> | /mcp reload`}}function k_(e){let t=e.status(),n=Object.keys(t);if(n.length===0)return`\u{1F4CB} \u5F53\u524D\u672A\u914D\u7F6E\u4EFB\u4F55 MCP server\u3002
590
+ \u5728 ~/.dskcode/settings.json \u7684 mcpServers \u6BB5\u6DFB\u52A0\u5373\u53EF\u3002`;let r=[`\u{1F4CB} MCP server \u72B6\u6001\uFF08\u5171 ${n.length} \u4E2A\uFF09\uFF1A`];for(let o of n){let s=t[o],i=w_(s.state),a=s.retryPending?` \u27F2 \u91CD\u8BD5 #${s.retryAttempts}`:"",l=s.lastError?`
587
591
  \u6700\u8FD1\u9519\u8BEF\uFF1A${s.lastError}`:"";r.push(` ${i} ${o} \u2014 ${s.state}${a}${l}`)}return r.push(""),r.push("\u5B50\u547D\u4EE4\uFF1A/mcp restart <name> | /mcp reload"),r.join(`
588
- `)}function ZC(e){switch(e){case"ready":return"\u2705";case"starting":return"\u23F3";case"failed":return"\u274C";case"stopped":return"\u23F9";default:return"\u2022"}}p();var is=[[0,255,65],[0,255,255],[189,147,249]],Du=[[255,245,180],[255,210,80],[255,150,50]],Nu=[[255,191,0],[210,140,60],[175,70,40]],dr={idlePhaseStep:.06,idleInterval:200,streamingPhaseStep:.2,streamingInterval:200,cmdTipPhaseStep:.2,cmdTipInterval:200},YC=new Set([" ","~",".","\u3002","\uFF01","\u{1F447}"]);function QC(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 an(e,t,n){let r=e.length;return r===0?[]:e.split("").map((o,s)=>{if(YC.has(o))return"";let i=(s/(r-1)+t)%1;return QC(i,n)})}p();import{Box as ua,Text as ct,useInput as e_}from"ink";import{useState as t_}from"react";import{jsx as vt,jsxs as qr}from"react/jsx-runtime";var as=[{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 Lg({pending:e,onResponse:t}){let[n,r]=t_(0);if(e_((s,i)=>{if(e){if(i.escape){t("no");return}if(i.return){let a=as[n];a&&t(a.value);return}if(i.leftArrow){r(a=>(a-1+as.length)%as.length);return}if(i.rightArrow){r(a=>(a+1)%as.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 qr(ua,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,marginTop:1,children:[vt(ct,{bold:!0,color:"yellow",children:"\u{1F510} \u6743\u9650\u5BA1\u6279"}),qr(ua,{flexDirection:"column",marginLeft:2,marginTop:1,children:[qr(ct,{children:[vt(ct,{dimColor:!0,children:"\u5DE5\u5177\uFF1A"}),vt(ct,{bold:!0,children:o.toolName}),vt(ct,{dimColor:!0,children:" \uFF08\u5199\u64CD\u4F5C\u786E\u8BA4\uFF09"})]}),qr(ct,{children:[vt(ct,{dimColor:!0,children:"\u539F\u56E0\uFF1A"}),vt(ct,{children:o.reason})]}),o.toolName==="bash"&&qr(ct,{children:[vt(ct,{dimColor:!0,children:"\u547D\u4EE4\uFF1A"}),vt(ct,{color:"cyan",children:n_(o)})]})]}),vt(ua,{flexDirection:"row",marginTop:1,gap:2,children:as.map((s,i)=>qr(ct,{color:i===n?s.color:"gray",bold:i===n,inverse:i===n,children:[" ","[",s.number,"] ",s.label," "]},s.value))}),vt(ua,{marginTop:1,children:vt(ct,{dimColor:!0,children:"\u2190/\u2192 \u5207\u6362 \xB7 1/2/3 \u76F4\u63A5\u9009 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u62D2\u7EDD"})})]})}function n_(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 a_}from"events";import{randomUUID as Mg}from"crypto";import l_ from"ws";p();import{gunzipSync as r_,gzipSync as Bu}from"zlib";var o_=1,s_=1,On={FULL_REQUEST:1,AUDIO_ONLY:2,SERVER_RESPONSE:9,ERROR:15},pr={NO_SEQUENCE:0,POSITIVE_SEQUENCE:1,LAST_PACKET_NO_SEQ:2,NEGATIVE_SEQUENCE:3,HAS_EVENT:4},Fu={JSON:1},Gu={GZIP:1};function da(e,t,n,r){let o=Buffer.alloc(4);o[0]=o_<<4|s_,o[1]=e<<4|t&15,o[2]=Fu.JSON<<4|Gu.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 ju(e,t){let n=Buffer.from(JSON.stringify(e),"utf8"),r=Bu(n);return da(On.FULL_REQUEST,pr.POSITIVE_SEQUENCE,t,r)}function Uu(e,t){return da(On.AUDIO_ONLY,pr.POSITIVE_SEQUENCE,t,Bu(e))}function Wu(e){return da(On.AUDIO_ONLY,pr.NEGATIVE_SEQUENCE,-Math.abs(e),Bu(Buffer.alloc(0)))}function Hu(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===On.SERVER_RESPONSE?"full_response":i===On.AUDIO_ONLY?"audio_only":i===On.ERROR?"error":"unknown",d=e.subarray(s*4),f=0;a&pr.POSITIVE_SEQUENCE&&(f=d.readInt32BE(0),d=d.subarray(4));let h=(a&pr.LAST_PACKET_NO_SEQ)!==0,m=0;a&pr.HAS_EVENT&&(m=d.readInt32BE(0),d=d.subarray(4));let g=0;i===On.ERROR&&(g=d.readInt32BE(0),d=d.subarray(4)),d.length>=4&&(d=d.subarray(4));let w=i_(d,c,l);return{messageType:u,seq:f,isLast:h,event:m,code:g,body:w,raw:e}}function i_(e,t,n){if(e.length===0)return null;let r=e;if(t===Gu.GZIP)try{r=r_(e)}catch{return null}return n===Fu.JSON||r.length>0&&r[0]===123?$g(r):null}function $g(e){try{return JSON.parse(e.toString("utf8"))}catch{return null}}function Vu(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 c_="wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async",u_="volc.bigasr.sauc.duration",d_=(e,t)=>Reflect.construct(l_,[e,t]),pa=class extends a_{config;url;resourceId;ws=null;seq=1;started=!1;ended=!1;opened=!1;constructor(t){super(),this.config=t,this.url=t.url??c_,this.resourceId=t.resourceId??u_}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":Mg(),"X-Api-Access-Key":this.config.accessKey,"X-Api-App-Key":this.config.appId,"X-Api-Sequence":"-1"},o=this.config.wsFactory??d_,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=Uu(t,this.seq++);this.ws.send(n)}end(){if(!this.ws||this.ended)return;this.ended=!0;let t=Wu(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=Vu({user:{uid:`dskcode-cli-${Mg().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=ju(t,this.seq++);this.ws.send(n),this.started=!0}onMessage(t){let n=typeof t=="string"?Buffer.from(t):t,r=Hu(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 zu(e){return new pa(e)}p();import{EventEmitter as g_}from"events";p();import{spawn as p_}from"child_process";import{platform as qu}from"os";var Ku=(e,t)=>p_(e,t,{stdio:["ignore","pipe","pipe"]}),f_={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 m_(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 Og={name:"ffmpeg",binary:"ffmpeg",buildArgs:e=>{let t=qu();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)})},Dg={name:"sox",binary:"sox",buildArgs:e=>qu()==="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","-"]},Ng={name:"arecord",binary:"arecord",buildArgs:e=>["-q","-f","S16_LE","-r","16000","-c","1",e?["-D",e]:[],"-t","raw"].flat()};async function Xu(e,t){let n=e==="auto"?[Og,Dg,Ng]:[Og,Dg,Ng].filter(r=>r.name===e);for(let r of n){let o=await h_(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 h_(e,t){let n=f_[e]??[];for(let r of[e,...n])if(await m_(r,t,1500))return r;return null}async function Bg(e,t){return qu()!=="win32"||!e.listWindowsAudioDevices?null:e.listWindowsAudioDevices(t,e.binary)}var y_=200,x_=60,b_=16e3,w_=16,k_=1,S_=b_*(w_/8)*k_,fa=class extends g_{options;proc=null;driver=null;buf=[];bufSize=0;chunkBytes;started=!1;stopped=!1;maxDurationTimer=null;constructor(t={}){super(),this.options={chunkMs:t.chunkMs??y_,maxDurationSec:t.maxDurationSec??x_,driver:t.driver??"auto",deviceName:t.deviceName,spawner:t.spawner},this.chunkBytes=Math.floor(S_*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??Ku;this.driver=await Xu(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 Bg(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 Ju(e={}){return new fa(e)}p();import{EventEmitter as T_}from"events";var ma=class extends T_{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??(()=>C_(this.config.asr)))();this.asr=n,this.bindAsrEvents(n);try{await n.connect()}catch(s){this.lastError=`\u8FDE\u63A5 ASR \u5931\u8D25: ${Fg(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}let o=(this.config.recorderOptions?.captureFactory??__)();this.cap=o,this.bindCapEvents(o);try{await o.start()}catch(s){this.lastError=`\u542F\u52A8\u5F55\u97F3\u5931\u8D25: ${Fg(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 C_(e){return zu({appId:e.appId,accessKey:e.accessKey,resourceId:e.resourceId})}function __(){return Ju()}function Fg(e){return e instanceof Error?e.message:String(e)}function Zu(e){return new ma(e)}import{Fragment as Ug,jsx as O,jsxs as re}from"react/jsx-runtime";function A_(e){return e==="edit_file"||e==="write_file"||e==="multi_edit"||e==="delete_range"}function Gg(e){if(!e)return;let t=e.filter(n=>!n.name.startsWith("todo_"));return t.length>0?t:void 0}var ed=new Map;function Fe(e,t){ed.set(e,t)}function Qu(){return ed}Fe("/exit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});Fe("/quit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});Fe("/help",{desc:"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F",handler:()=>{let e=Qu(),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(`
589
- `)}}});Fe("/clear",{desc:"\u6E05\u7A7A\u5BF9\u8BDD\u5386\u53F2",handler:()=>({kind:"clear"})});Fe("/version",{desc:"\u663E\u793A\u7248\u672C\u4FE1\u606F",handler:()=>({kind:"text",content:`dskcode v${Qo}`})});Fe("/model",{desc:"\u5207\u6362\u6A21\u578B",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /model \u8FDB\u5165\u9009\u62E9\u754C\u9762"})});Fe("/thinking",{desc:"\u5207\u6362\u6DF1\u5EA6\u601D\u8003\u6A21\u5F0F",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /thinking \u5207\u6362"})});Fe("/effort",{desc:"\u5207\u6362\u63A8\u7406\u7B49\u7EA7 High/Max",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /effort \u5207\u6362"})});Fe("/game",{desc:"\u542F\u52A8\u6E38\u620F",handler:()=>({kind:"navigate",target:"game"})});Fe("/stock",{desc:"\u67E5\u770B\u80A1\u7968\u884C\u60C5",handler:()=>({kind:"navigate",target:"stock"})});Fe("/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"})});Fe("/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"})});Fe("/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"})});Fe("/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"})});Fe("/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"})});Fe("/permissions",{desc:"\u67E5\u770B\u5F53\u524D\u6743\u9650\u89C4\u5219\u4E0E\u4F1A\u8BDD grants\uFF08v0.6\uFF09",handler:()=>({kind:"permissions"})});var E_=["\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..."],jg=["\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 Yu(e){return e[Math.floor(Math.random()*e.length)]}function td({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:f,thinkingEffortFromConfig:h,verboseFromConfig:m,onLaunchGame:g,onLaunchStock:w,permissionBroker:b,mcpServers:k,mcpServerTimeout:v}){let R=(typeof process.stdout.columns=="number"?process.stdout.columns:80)-2,D=R,[F,P]=H([]),[z,j]=H(0),[N,A]=H(""),[ie,ne]=H(null),Q=de(null),[V,fe]=H(null),[me,hr]=H(!1),[un,gd]=H(null),[Ne,Iy]=H("idle"),[Ta,Ca]=H(""),ps=de(null),[Py,_a]=H(null),[pe,fs]=H(!1),[yd,Ht]=H(null),[Dn,va]=H(""),[Nn,Ly]=H(()=>Yu(jg)),[Ra,Aa]=H([]),ms=de(0),[Ea,Ia]=H([]),hs=de(0),[Pa,La]=H(""),[$y,$a]=H([]),[Qr,Ma]=H([]),[xd,bd]=H(()=>new Map),[Oa,wd]=H(void 0),[My,kd]=H(void 0),[Da,Sd]=H(void 0),[St,Na]=H(l),[Td,Cd]=H(void 0),[Ba,gs]=H(void 0),[Bn,ys]=H([]),[Lv,$v]=H(""),[_d,xs]=H(!0),dn=de(null),eo=de(-1),[Fn,bs]=H("code"),[Gn,vd]=H(!0),[gr,Rd]=H("high"),[Fa]=H("text"),[to,ws]=H(void 0),Oy=ha(()=>F.reduce((_,T)=>T.assistantDetail?.cost?_+T.assistantDetail.cost:_,0),[F]),no=F.length>0,Dy=ha(()=>{if(pe)return null;for(let _=F.length-1;_>=0;_--){let T=F[_];if(T?.role==="assistant"&&T.assistantDetail){let C=T.assistantDetail,W=C.usage?C.usage.promptTokens+C.usage.completionTokens:0;if((C.cost??0)>0||(C.elapsed??0)>0||W>0)return{cost:C.cost??0,elapsed:C.elapsed??0,tokens:W}}}return null},[F,pe]),Et=Array.from(Qu()).filter(([_])=>_!=="/exit"&&_!=="/quit").map(([_,T])=>({name:_,desc:T.desc})),ks=[...Array.from(Qu()).map(([_,T])=>({name:_,desc:T.desc})),{name:"/mcp",desc:"MCP server \u72B6\u6001/\u91CD\u542F/\u91CD\u8F7D"}],[yr,Ga]=H(0),Ss=ha(()=>Wi(N,ks),[N,ks]);ge(()=>{Ss.length===0?Ga(0):yr>=Ss.length&&Ga(Ss.length-1)},[Ss.length,yr]);let[Ts,Ny]=H(0),[ja,Ua]=H([]),Cs=de(0),[By,Ad]=H([]),_s=de(0),[xr,Wa]=H(0),[br,vs]=H(0),[Ed,jn]=H(0),[Un,It]=H(!1),[pn,Id]=H(0),[fn,Tt]=H(null),[Wn,Rs]=H(!1),[ro,As]=H(0),[Hn,Fy]=H([]),[Ha,Pd]=H(!1),[oo,Es]=H(!1),[Ld,Va]=H("idle"),za=de(!1),Pt=de(null),[mn,qa]=H(!1),[Is,Ps]=H(0),hn=["deepseek-v4-flash","deepseek-v4-pro"],[$d,gn]=H({phase:"idle",progress:null}),He=de(null),wr=de(void 0),he=de(null),Ka=de(null),Md=de([]),Lt=de(null),[so,Vt]=H([]),[io,yn]=H(0),Ls=de(""),$s=de([]),Ms=de([]),Os=de(new Map),[Xa,Ds]=H(null),ao=de(null),Ja=xt(_=>{if(b){let{requestId:T,promise:C}=b.register(_);return ao.current=null,Ds({requestId:T,ctx:_,resolve:()=>{}}),C}return new Promise(T=>{ao.current=T,Ds({ctx:_,resolve:T})})},[b]),Gy=xt(_=>{let T=Xa?.requestId,C=ao.current;Ds(null),ao.current=null,b&&T?b.respond(T,_,"terminal"):C?.(_)},[b,Xa]);ge(()=>b?b.onResolved(T=>{Ds(C=>C&&C.requestId===T.requestId?null:C),ao.current=null}):void 0,[b]);let Za=de(void 0),Ya=de(void 0),Qa=de(void 0),el=de(void 0),Ns=de(void 0);ge(()=>{Wa(0),vs(0)},[N]),ge(()=>{let _=Rn(N);if(!_){It(!1),Tt(null),Vt([]),yn(0);return}let T=_.query.trim();if(T.length===0){It(!0);return}if(It(!1),/^[123]$/.test(T)){let C=T==="2"?"skills":T==="3"?"mcps":"files";if(Tt(W=>W===C?W:C),C==="mcps"){let W=Lt.current;W?(Vt(W.listServers()),yn(0)):Vt([])}}else Tt(C=>C==="files"?C:"files")},[N]),ge(()=>()=>{Pt.current&&(clearTimeout(Pt.current),Pt.current=null),He.current&&(clearTimeout(He.current),He.current=null),Q.current&&(clearTimeout(Q.current),Q.current=null)},[]),ge(()=>{if(ie==null)return;let _=setTimeout(()=>ne(null),5e3);return Q.current=_,()=>clearTimeout(_)},[ie]),ge(()=>{d===void 0||d===0||ne(Date.now())},[d]),ge(()=>{l&&Na(l)},[l]),ge(()=>{f!==void 0&&vd(f)},[f]),ge(()=>{h!==void 0&&Rd(h)},[h]);let Od=de(0);ge(()=>{d===void 0||d===0||d!==Od.current&&(Od.current=d,Lt.current&&k&&Lt.current.reconcile(k))},[d,k]),ge(()=>{let _=()=>{let C=he.current;if(!C){_a(null);return}try{let W=C.getContextStats();_a({tokens:W.estimatedTokens,ratio:W.ratio,contextWindow:W.contextWindow})}catch{_a(null)}};_();let T=setInterval(_,3e3);return()=>clearInterval(T)},[]),ge(()=>{if(dn.current&&(clearTimeout(dn.current),dn.current=null),Bn.length===0){xs(!1);return}Bn.some(T=>T.status==="pending"||T.status==="running"||T.status==="failed")?xs(!0):(eo.current=Math.max(...Bn.map(T=>T.id)),dn.current=setTimeout(()=>{xs(!1),dn.current=null},2e3))},[Bn]);let tl=xt(_=>Sh(_,t),[t]),Dd=xt(_=>Xo(_,n)??[],[n]),Bs=xt((_,T)=>{let C=Xo(_,n);if(!C||C.length===0)return!1;let W=C[T];if(!W)return!1;let J=_.lastIndexOf("@");return J<0?!1:(A(_.slice(0,J)+"@"+W+" "),jn(oe=>oe+1),vs(0),!0)},[n]);function jy(_){let T=[];for(let C of _.messages)C.role==="user"?T.push({role:"user",content:C.content}):C.role==="assistant"?T.push({role:"assistant",content:C.content,assistantDetail:{content:C.content,toolCalls:Gg(C.toolCalls)}}):C.role==="tool"&&T.push({role:"tool",content:C.content});P(T),j(C=>C+1)}let nl=xt(async(_,T)=>{let C=he.current;if(C){Pd(!0),fs(!0),Ht("thinking"),va("\u23EA \u6B63\u5728\u56DE\u9000\u5230\u68C0\u67E5\u70B9\u2026"),A("");try{let W=await C.rewind(_.index);if(W.ok){jy(C);let J=W.fileRestored?"\uFF0C\u5DE5\u4F5C\u533A\u6587\u4EF6\u5DF2\u6062\u590D":"\uFF08\u4EC5\u5BF9\u8BDD\u56DE\u9000\uFF0C\u672A\u6062\u590D\u6587\u4EF6\uFF09";P(oe=>[...oe,{role:"assistant",content:`\u23EA \u5DF2\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #${T}${J}\u3002`}])}else P(J=>[...J,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5931\u8D25\uFF1A${W.error}`}])}catch(W){let J=W instanceof Error?W.message:String(W);P(oe=>[...oe,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5F02\u5E38\uFF1A${J}`}])}finally{Pd(!1),fs(!1),Ht(null),va("")}}},[]),rl=xt(async()=>{if(!u||!u.resolved){let T=u?.missing?.join(", ")??"appId, accessKey";P(C=>[...C,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u672A\u914D\u7F6E\uFF08\u7F3A ${T}\uFF09\u3002
592
+ `)}function w_(e){switch(e){case"ready":return"\u2705";case"starting":return"\u23F3";case"failed":return"\u274C";case"stopped":return"\u23F9";default:return"\u2022"}}p();var hs=[[0,255,65],[0,255,255],[189,147,249]],Qu=[[255,245,180],[255,210,80],[255,150,50]],ed=[[255,191,0],[210,140,60],[175,70,40]],mr={idlePhaseStep:.06,idleInterval:200,streamingPhaseStep:.2,streamingInterval:200,cmdTipPhaseStep:.2,cmdTipInterval:200},T_=new Set([" ","~",".","\u3002","\uFF01","\u{1F447}"]);function S_(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 an(e,t,n){let r=e.length;return r===0?[]:e.split("").map((o,s)=>{if(T_.has(o))return"";let i=(s/(r-1)+t)%1;return S_(i,n)})}p();import{Box as ya,Text as ut,useInput as C_}from"ink";import{useState as __}from"react";import{jsx as vt,jsxs as Jr}from"react/jsx-runtime";var gs=[{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 Zg({pending:e,onResponse:t}){let[n,r]=__(0);if(C_((s,i)=>{if(e){if(i.escape){t("no");return}if(i.return){let a=gs[n];a&&t(a.value);return}if(i.leftArrow){r(a=>(a-1+gs.length)%gs.length);return}if(i.rightArrow){r(a=>(a+1)%gs.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 Jr(ya,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,marginTop:1,children:[vt(ut,{bold:!0,color:"yellow",children:"\u{1F510} \u6743\u9650\u5BA1\u6279"}),Jr(ya,{flexDirection:"column",marginLeft:2,marginTop:1,children:[Jr(ut,{children:[vt(ut,{dimColor:!0,children:"\u5DE5\u5177\uFF1A"}),vt(ut,{bold:!0,children:o.toolName}),vt(ut,{dimColor:!0,children:" \uFF08\u5199\u64CD\u4F5C\u786E\u8BA4\uFF09"})]}),Jr(ut,{children:[vt(ut,{dimColor:!0,children:"\u539F\u56E0\uFF1A"}),vt(ut,{children:o.reason})]}),o.toolName==="bash"&&Jr(ut,{children:[vt(ut,{dimColor:!0,children:"\u547D\u4EE4\uFF1A"}),vt(ut,{color:"cyan",children:v_(o)})]})]}),vt(ya,{flexDirection:"row",marginTop:1,gap:2,children:gs.map((s,i)=>Jr(ut,{color:i===n?s.color:"gray",bold:i===n,inverse:i===n,children:[" ","[",s.number,"] ",s.label," "]},s.value))}),vt(ya,{marginTop:1,children:vt(ut,{dimColor:!0,children:"\u2190/\u2192 \u5207\u6362 \xB7 1/2/3 \u76F4\u63A5\u9009 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u62D2\u7EDD"})})]})}function v_(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 P_}from"events";import{randomUUID as Qg}from"crypto";import $_ from"ws";p();import{gunzipSync as R_,gzipSync as td}from"zlib";var A_=1,E_=1,Dn={FULL_REQUEST:1,AUDIO_ONLY:2,SERVER_RESPONSE:9,ERROR:15},hr={NO_SEQUENCE:0,POSITIVE_SEQUENCE:1,LAST_PACKET_NO_SEQ:2,NEGATIVE_SEQUENCE:3,HAS_EVENT:4},nd={JSON:1},rd={GZIP:1};function xa(e,t,n,r){let o=Buffer.alloc(4);o[0]=A_<<4|E_,o[1]=e<<4|t&15,o[2]=nd.JSON<<4|rd.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 od(e,t){let n=Buffer.from(JSON.stringify(e),"utf8"),r=td(n);return xa(Dn.FULL_REQUEST,hr.POSITIVE_SEQUENCE,t,r)}function sd(e,t){return xa(Dn.AUDIO_ONLY,hr.POSITIVE_SEQUENCE,t,td(e))}function id(e){return xa(Dn.AUDIO_ONLY,hr.NEGATIVE_SEQUENCE,-Math.abs(e),td(Buffer.alloc(0)))}function ad(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===Dn.SERVER_RESPONSE?"full_response":i===Dn.AUDIO_ONLY?"audio_only":i===Dn.ERROR?"error":"unknown",d=e.subarray(s*4),f=0;a&hr.POSITIVE_SEQUENCE&&(f=d.readInt32BE(0),d=d.subarray(4));let h=(a&hr.LAST_PACKET_NO_SEQ)!==0,m=0;a&hr.HAS_EVENT&&(m=d.readInt32BE(0),d=d.subarray(4));let g=0;i===Dn.ERROR&&(g=d.readInt32BE(0),d=d.subarray(4)),d.length>=4&&(d=d.subarray(4));let b=I_(d,c,l);return{messageType:u,seq:f,isLast:h,event:m,code:g,body:b,raw:e}}function I_(e,t,n){if(e.length===0)return null;let r=e;if(t===rd.GZIP)try{r=R_(e)}catch{return null}return n===nd.JSON||r.length>0&&r[0]===123?Yg(r):null}function Yg(e){try{return JSON.parse(e.toString("utf8"))}catch{return null}}function ld(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 L_="wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async",M_="volc.bigasr.sauc.duration",O_=(e,t)=>Reflect.construct($_,[e,t]),ba=class extends P_{config;url;resourceId;ws=null;seq=1;started=!1;ended=!1;opened=!1;constructor(t){super(),this.config=t,this.url=t.url??L_,this.resourceId=t.resourceId??M_}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":Qg(),"X-Api-Access-Key":this.config.accessKey,"X-Api-App-Key":this.config.appId,"X-Api-Sequence":"-1"},o=this.config.wsFactory??O_,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=sd(t,this.seq++);this.ws.send(n)}end(){if(!this.ws||this.ended)return;this.ended=!0;let t=id(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=ld({user:{uid:`dskcode-cli-${Qg().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=od(t,this.seq++);this.ws.send(n),this.started=!0}onMessage(t){let n=typeof t=="string"?Buffer.from(t):t,r=ad(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 cd(e){return new ba(e)}p();import{EventEmitter as F_}from"events";p();import{spawn as D_}from"child_process";import{platform as ud}from"os";var dd=(e,t)=>D_(e,t,{stdio:["ignore","pipe","pipe"]}),N_={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 B_(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 ey={name:"ffmpeg",binary:"ffmpeg",buildArgs:e=>{let t=ud();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)})},ty={name:"sox",binary:"sox",buildArgs:e=>ud()==="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","-"]},ny={name:"arecord",binary:"arecord",buildArgs:e=>["-q","-f","S16_LE","-r","16000","-c","1",e?["-D",e]:[],"-t","raw"].flat()};async function pd(e,t){let n=e==="auto"?[ey,ty,ny]:[ey,ty,ny].filter(r=>r.name===e);for(let r of n){let o=await G_(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 G_(e,t){let n=N_[e]??[];for(let r of[e,...n])if(await B_(r,t,1500))return r;return null}async function ry(e,t){return ud()!=="win32"||!e.listWindowsAudioDevices?null:e.listWindowsAudioDevices(t,e.binary)}var j_=200,U_=60,W_=16e3,H_=16,V_=1,z_=W_*(H_/8)*V_,ka=class extends F_{options;proc=null;driver=null;buf=[];bufSize=0;chunkBytes;started=!1;stopped=!1;maxDurationTimer=null;constructor(t={}){super(),this.options={chunkMs:t.chunkMs??j_,maxDurationSec:t.maxDurationSec??U_,driver:t.driver??"auto",deviceName:t.deviceName,spawner:t.spawner},this.chunkBytes=Math.floor(z_*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??dd;this.driver=await pd(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 ry(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 fd(e={}){return new ka(e)}p();import{EventEmitter as q_}from"events";var wa=class extends q_{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??(()=>K_(this.config.asr)))();this.asr=n,this.bindAsrEvents(n);try{await n.connect()}catch(s){this.lastError=`\u8FDE\u63A5 ASR \u5931\u8D25: ${oy(s)}`,this.emit("error",this.lastError),this.setPhase("error"),this.cleanup();return}let o=(this.config.recorderOptions?.captureFactory??X_)();this.cap=o,this.bindCapEvents(o);try{await o.start()}catch(s){this.lastError=`\u542F\u52A8\u5F55\u97F3\u5931\u8D25: ${oy(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 K_(e){return cd({appId:e.appId,accessKey:e.accessKey,resourceId:e.resourceId})}function X_(){return fd()}function oy(e){return e instanceof Error?e.message:String(e)}function md(e){return new wa(e)}import{Fragment as ay,jsx as G,jsxs as ie}from"react/jsx-runtime";function Y_(e){return e==="edit_file"||e==="write_file"||e==="multi_edit"||e==="delete_range"}function sy(e){if(!e)return;let t=e.filter(n=>!n.name.startsWith("todo_"));return t.length>0?t:void 0}var yd=new Map;function Oe(e,t){yd.set(e,t)}function gd(){return yd}Oe("/exit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});Oe("/quit",{desc:"\u9000\u51FA\u5BF9\u8BDD",handler:()=>({kind:"exit"})});Oe("/help",{desc:"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F",handler:()=>{let e=gd(),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(`
593
+ `)}}});Oe("/clear",{desc:"\u6E05\u7A7A\u5BF9\u8BDD\u5386\u53F2",handler:()=>({kind:"clear"})});Oe("/version",{desc:"\u663E\u793A\u7248\u672C\u4FE1\u606F",handler:()=>({kind:"text",content:`dskcode v${is}`})});Oe("/model",{desc:"\u5207\u6362\u6A21\u578B",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /model \u8FDB\u5165\u9009\u62E9\u754C\u9762"})});Oe("/thinking",{desc:"\u5207\u6362\u6DF1\u5EA6\u601D\u8003\u6A21\u5F0F",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /thinking \u5207\u6362"})});Oe("/effort",{desc:"\u5207\u6362\u63A8\u7406\u7B49\u7EA7 High/Max",handler:()=>({kind:"text",content:"\u8BF7\u76F4\u63A5\u8F93\u5165 /effort \u5207\u6362"})});Oe("/game",{desc:"\u542F\u52A8\u6E38\u620F",handler:()=>({kind:"navigate",target:"game"})});Oe("/stock",{desc:"\u67E5\u770B\u80A1\u7968\u884C\u60C5",handler:()=>({kind:"navigate",target:"stock"})});Oe("/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"})});Oe("/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"})});Oe("/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"})});Oe("/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"})});Oe("/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"})});Oe("/permissions",{desc:"\u67E5\u770B\u5F53\u524D\u6743\u9650\u89C4\u5219\u4E0E\u4F1A\u8BDD grants\uFF08v0.6\uFF09",handler:()=>({kind:"permissions"})});Oe("/goal",{desc:"\u76EE\u6807\u5FAA\u73AF\uFF1A/goal <condition> \u8BBE\u7F6E\uFF1B/goal [pause|resume|clear|status] \u5B50\u547D\u4EE4",handler:()=>({kind:"goal"})});var Q_=["\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..."],iy=["\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 hd(e){return e[Math.floor(Math.random()*e.length)]}function yr(e,t){return e.length>t?`${e.slice(0,t)}\u2026`:e}function ev(e){let n=[`${e.status==="active"?"\u25CE":e.status==="paused"?"\u25CC":e.status==="achieved"?"\u2713":"\xB7"} /goal ${e.status}`,` condition: ${e.condition}`,` turns=${e.turnCount} limits: maxTurns=${e.maxTurns}, maxTokens=${e.maxTokens}, maxWallMs=${Math.round(e.maxWallMs/1e3)}s`];return e.lastEval&&n.push(` lastEval: ok=${e.lastEval.ok} reason=${yr(e.lastEval.reason,80)}`),n.join(`
594
+ `)}function tv(e,t){let n=[`${e.status.toUpperCase()} condition=${yr(e.condition,60)}`,` turns: ${e.turnCount} / ${e.maxTurns}`,` sessionCost: \xA5${t.toFixed(4)}`];if(e.lastEval&&(n.push(` lastEval @${new Date(e.lastEval.evaluatedAt).toISOString()}: ok=${e.lastEval.ok}`),n.push(` reason: ${yr(e.lastEval.reason,200)}`)),e.history&&e.history.length>0){n.push(` history (${e.history.length} \u6761):`);for(let r of e.history)n.push(` - ok=${r.ok} ${yr(r.reason,100)}`)}return n.join(`
595
+ `)}function xd({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:f,thinkingEffortFromConfig:h,verboseFromConfig:m,onLaunchGame:g,onLaunchStock:b,permissionBroker:k,mcpServers:T,mcpServerTimeout:A}){let I=(typeof process.stdout.columns=="number"?process.stdout.columns:80)-2,F=I,[M,C]=W([]),[N,oe]=W(0),[j,O]=W(""),[ce,fe]=W(null),ne=pe(null),[K,he]=W(null),[ge,br]=W(!1),[un,Ld]=W(null),[Be,Xy]=W("idle"),[Ia,Pa]=W(""),ws=pe(null),[Jy,$a]=W(null),[de,Ts]=W(!1),[Md,Ht]=W(null),[Nn,La]=W(""),[Bn,Zy]=W(()=>hd(iy)),[Ma,Oa]=W([]),Ss=pe(0),[Da,Na]=W([]),Cs=pe(0),[Ba,Ga]=W(""),[Yy,Fa]=W([]),[no,ja]=W([]),[Od,Dd]=W(()=>new Map),[Ua,Nd]=W(void 0),[Qy,Bd]=W(void 0),[Wa,Gd]=W(void 0),[St,Ha]=W(l),[Fd,jd]=W(void 0),[Va,_s]=W(void 0),[Gn,vs]=W([]),[oR,sR]=W(""),[Ud,Rs]=W(!0),dn=pe(null),ro=pe(-1),[Fn,As]=W("code"),[Wd,ex]=W(null),pn=dt(()=>{ex(me.current?.getGoal()??null)},[]);ye(()=>{pn()},[pn]);let[jn,Hd]=W(!0),[kr,Vd]=W("high"),[za]=W("text"),[oo,Es]=W(void 0),tx=Ta(()=>M.reduce((_,S)=>S.assistantDetail?.cost?_+S.assistantDetail.cost:_,0),[M]),so=M.length>0,nx=Ta(()=>{if(de)return null;for(let _=M.length-1;_>=0;_--){let S=M[_];if(S?.role==="assistant"&&S.assistantDetail){let w=S.assistantDetail,H=w.usage?w.usage.promptTokens+w.usage.completionTokens:0;if((w.cost??0)>0||(w.elapsed??0)>0||H>0)return{cost:w.cost??0,elapsed:w.elapsed??0,tokens:H}}}return null},[M,de]),Et=Array.from(gd()).filter(([_])=>_!=="/exit"&&_!=="/quit").map(([_,S])=>({name:_,desc:S.desc})),io=[...Array.from(gd()).map(([_,S])=>({name:_,desc:S.desc})),{name:"/mcp",desc:"MCP server \u72B6\u6001/\u91CD\u542F/\u91CD\u8F7D"}],[Un,ao]=W(0),Is=Ta(()=>Ji(j,io),[j,io]);ye(()=>{Is.length===0?ao(0):Un>=Is.length&&ao(Is.length-1)},[Is.length,Un]);let[Ps,rx]=W(0),[qa,Ka]=W([]),$s=pe(0),[ox,zd]=W([]),Ls=pe(0),[wr,Xa]=W(0),[Tr,Ms]=W(0),[qd,Wn]=W(0),[Hn,It]=W(!1),[fn,Kd]=W(0),[mn,Ct]=W(null),[Vn,Os]=W(!1),[lo,Ds]=W(0),[zn,sx]=W([]),[Ja,Xd]=W(!1),[co,Ns]=W(!1),[Jd,Za]=W("idle"),Ya=pe(!1),Pt=pe(null),[hn,Qa]=W(!1),[Bs,Gs]=W(0),gn=["deepseek-v4-flash","deepseek-v4-pro"],[Zd,yn]=W({phase:"idle",progress:null}),He=pe(null),Sr=pe(void 0),me=pe(null),el=pe(null),Yd=pe([]),$t=pe(null),[uo,Vt]=W([]),[po,xn]=W(0),Fs=pe(""),js=pe([]),Us=pe([]),Ws=pe(new Map),[tl,Hs]=W(null),fo=pe(null),nl=dt(_=>{if(k){let{requestId:S,promise:w}=k.register(_);return fo.current=null,Hs({requestId:S,ctx:_,resolve:()=>{}}),w}return new Promise(S=>{fo.current=S,Hs({ctx:_,resolve:S})})},[k]),ix=dt(_=>{let S=tl?.requestId,w=fo.current;Hs(null),fo.current=null,k&&S?k.respond(S,_,"terminal"):w?.(_)},[k,tl]);ye(()=>k?k.onResolved(S=>{Hs(w=>w&&w.requestId===S.requestId?null:w),fo.current=null}):void 0,[k]);let rl=pe(void 0),ol=pe(void 0),sl=pe(void 0),il=pe(void 0),Vs=pe(void 0);ye(()=>{Xa(0),Ms(0)},[j]),ye(()=>{let _=An(j);if(!_){It(!1),Ct(null),Vt([]),xn(0);return}let S=_.query.trim();if(S.length===0){It(!0);return}if(It(!1),/^[123]$/.test(S)){let w=S==="2"?"skills":S==="3"?"mcps":"files";if(Ct(H=>H===w?H:w),w==="mcps"){let H=$t.current;H?(Vt(H.listServers()),xn(0)):Vt([])}}else Ct(w=>w==="files"?w:"files")},[j]),ye(()=>()=>{Pt.current&&(clearTimeout(Pt.current),Pt.current=null),He.current&&(clearTimeout(He.current),He.current=null),ne.current&&(clearTimeout(ne.current),ne.current=null)},[]),ye(()=>{if(ce==null)return;let _=setTimeout(()=>fe(null),5e3);return ne.current=_,()=>clearTimeout(_)},[ce]),ye(()=>{d===void 0||d===0||fe(Date.now())},[d]),ye(()=>{l&&Ha(l)},[l]),ye(()=>{f!==void 0&&Hd(f)},[f]),ye(()=>{h!==void 0&&Vd(h)},[h]);let Qd=pe(0);ye(()=>{d===void 0||d===0||d!==Qd.current&&(Qd.current=d,$t.current&&T&&$t.current.reconcile(T))},[d,T]),ye(()=>{let _=()=>{let w=me.current;if(!w){$a(null);return}try{let H=w.getContextStats();$a({tokens:H.estimatedTokens,ratio:H.ratio,contextWindow:H.contextWindow})}catch{$a(null)}};_();let S=setInterval(_,3e3);return()=>clearInterval(S)},[]),ye(()=>{if(dn.current&&(clearTimeout(dn.current),dn.current=null),Gn.length===0){Rs(!1);return}Gn.some(S=>S.status==="pending"||S.status==="running"||S.status==="failed")?Rs(!0):(ro.current=Math.max(...Gn.map(S=>S.id)),dn.current=setTimeout(()=>{Rs(!1),dn.current=null},2e3))},[Gn]);let al=dt(_=>jh(_,t),[t]),ep=dt(_=>ns(_,n)??[],[n]),zs=dt((_,S)=>{let w=ns(_,n);if(!w||w.length===0)return!1;let H=w[S];if(!H)return!1;let Q=_.lastIndexOf("@");return Q<0?!1:(O(_.slice(0,Q)+"@"+H+" "),Wn(ae=>ae+1),Ms(0),!0)},[n]);function ax(_){let S=[];for(let w of _.messages)w.role==="user"?S.push({role:"user",content:w.content}):w.role==="assistant"?S.push({role:"assistant",content:w.content,assistantDetail:{content:w.content,toolCalls:sy(w.toolCalls)}}):w.role==="tool"&&S.push({role:"tool",content:w.content});C(S),oe(w=>w+1)}let ll=dt(async(_,S)=>{let w=me.current;if(w){Xd(!0),Ts(!0),Ht("thinking"),La("\u23EA \u6B63\u5728\u56DE\u9000\u5230\u68C0\u67E5\u70B9\u2026"),O("");try{let H=await w.rewind(_.index);if(H.ok){ax(w);let Q=H.fileRestored?"\uFF0C\u5DE5\u4F5C\u533A\u6587\u4EF6\u5DF2\u6062\u590D":"\uFF08\u4EC5\u5BF9\u8BDD\u56DE\u9000\uFF0C\u672A\u6062\u590D\u6587\u4EF6\uFF09";C(ae=>[...ae,{role:"assistant",content:`\u23EA \u5DF2\u56DE\u9000\u5230\u68C0\u67E5\u70B9 #${S}${Q}\u3002`}])}else C(Q=>[...Q,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5931\u8D25\uFF1A${H.error}`}])}catch(H){let Q=H instanceof Error?H.message:String(H);C(ae=>[...ae,{role:"assistant",content:`\u26A0 \u56DE\u9000\u5F02\u5E38\uFF1A${Q}`}])}finally{Xd(!1),Ts(!1),Ht(null),La("")}}},[]),cl=dt(async()=>{if(!u||!u.resolved){let S=u?.missing?.join(", ")??"appId, accessKey";C(w=>[...w,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u672A\u914D\u7F6E\uFF08\u7F3A ${S}\uFF09\u3002
590
596
  \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
591
597
  \u7136\u540E\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF VOLC_ASR_APP_ID \u548C VOLC_ASR_ACCESS_KEY\uFF0C
592
- \u6216\u5728 ~/.dskcode/settings.json \u6DFB\u52A0 voice \u6BB5\u3002`}]);return}if(Ne!=="idle"&&Ne!=="error")return;Ca("");let _=Zu({asr:{appId:u.config.appId,accessKey:u.config.accessKey,resourceId:u.config.resourceId}});_.on("phase",T=>Iy(T)),_.on("partial",T=>Ca(T)),_.on("final",T=>{A(C=>C?C+T:T),Ca("")}),_.on("error",T=>{P(C=>[...C,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u51FA\u9519: ${T}`}])}),_.on("log",T=>{o&&console.error(`[voice] ${T}`)}),ps.current=_,await _.start()},[u,Ne,o]),ol=xt(()=>{ps.current?.stop()},[]),sl=xt(()=>{Ne==="recording"||Ne==="connecting"?ol():(Ne==="idle"||Ne==="error")&&rl()},[Ne,rl,ol]),{doubleCtrlC:Uy,handleCtrlC:Nd}=zn(()=>{if(ps.current)try{ps.current.abort()}catch{}let _=he.current;_?_.flushLog().finally(()=>process.exit(0)):process.exit(0)});v_(xt((_,T)=>{if(oo){T.ctrl&&_==="p"&&Es(!1);return}if(Wn){if(T.upArrow)As(S=>(S-1+Hn.length)%Hn.length);else if(T.downArrow)As(S=>(S+1)%Hn.length);else if(T.return){let S=Hn[ro];Rs(!1),S&&nl(S,ro+1)}else T.escape&&(Rs(!1),P(S=>[...S,{role:"assistant",content:"\u5DF2\u53D6\u6D88\u56DE\u9000\u3002"}]));return}if(mn){if(T.upArrow)Ps(S=>(S-1+hn.length)%hn.length);else if(T.downArrow)Ps(S=>(S+1)%hn.length);else if(T.return){let S=hn[Is];S===St?P(M=>[...M,{role:"assistant",content:`\u5DF2\u7ECF\u5728\u4F7F\u7528 ${wn[S].displayName}`}]):(Na(S),he.current?.reset(),qd(S).catch(()=>{}),P(M=>[...M,{role:"assistant",content:`\u6A21\u578B\u5DF2\u5207\u6362\u4E3A ${wn[S].displayName}\uFF08${S}\uFF09`}])),qa(!1)}else T.escape&&qa(!1);return}if(Un){if(T.upArrow){let S=In.map((M,B)=>({o:M,i:B})).filter(({o:M})=>M.enabled);if(S.length>0){let B=(S.findIndex(({i:$})=>$===pn)-1+S.length)%S.length,E=S[B];E&&Id(E.i)}return}if(T.downArrow){let S=In.map((M,B)=>({o:M,i:B})).filter(({o:M})=>M.enabled);if(S.length>0){let B=(S.findIndex(({i:$})=>$===pn)+1)%S.length,E=S[B];E&&Id(E.i)}return}if(T.return){let S=In[pn];if(S&&S.enabled){let M=S.index===2?"skills":S.index===3?"mcps":"files";if(Tt(M),M==="mcps"){let B=Lt.current;B?(Vt(B.listServers()),yn(0)):Vt([])}}else Tt("files");It(!1);return}if(T.escape){It(!1);return}}let C=fn??"files",W=C==="files"?Dd(N):[],J=C==="skills"?tl(N):[],oe=C==="mcps"?(()=>{let M=(Rn(N)?.query??"").toLowerCase().trim();return M?so.filter(B=>B.id.toLowerCase().startsWith(M)).slice(0,5):so.slice(0,5)})():[];if(W.length>0){if(T.upArrow){vs(S=>(S-1+W.length)%W.length);return}if(T.downArrow){vs(S=>(S+1)%W.length);return}if(T.tab){Bs(N,br);return}}if(J.length>0){if(T.upArrow){Wa(S=>(S-1+J.length)%J.length);return}if(T.downArrow){Wa(S=>(S+1)%J.length);return}if(T.tab){let S=J[xr];if(S&&C==="skills"){let M=Rn(N);if(M){let B=N.slice(0,M.atIndex);A(`${B}/${S.name} `),jn(E=>E+1),It(!1),Tt(null)}return}}}if(oe.length>0){if(T.upArrow){yn(S=>(S-1+oe.length)%oe.length);return}if(T.downArrow){yn(S=>(S+1)%oe.length);return}if(T.tab){let S=io>=0&&io<oe.length?io:0,M=oe[S];if(M){let B=Rn(N);if(B){let E=N.slice(0,B.atIndex);A(`${E}@${M.id} `),jn($=>$+1),It(!1),Tt(null),Vt([]),yn(0);return}}}}if(T.tab||T.return){let S=Wi(N,ks);if(S.length>0){let M=yr>=0&&yr<S.length?yr:0,B=S[M];if(/(?:^|\s)\/[^/]*$/.test(N)&&B&&T.tab){let $=N.lastIndexOf("/");$>=0&&(A(N.slice(0,$)+B.name+" "),jn(U=>U+1),Ga(0));return}}}if(mn){T.upArrow||T.downArrow;return}if(T.ctrl&&_==="c"){pe?Ka.current?.abort():Nd();return}if(T.ctrl&&_==="p"&&!pe&&!Wn&&!mn){Es(!0);return}if(T.escape&&(Ne==="recording"||Ne==="connecting"||Ne==="finalizing")){ol();return}if(T.shift&&T.tab){if(!pe){let S=Fn==="plan"?"code":"plan";bs(S),he.current?.setMode(S),ws(void 0),he.current?.reset(),P(M=>[...M,{role:"assistant",content:S==="plan"?`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**\uFF08Shift+Tab\uFF09
598
+ \u6216\u5728 ~/.dskcode/settings.json \u6DFB\u52A0 voice \u6BB5\u3002`}]);return}if(Be!=="idle"&&Be!=="error")return;Pa("");let _=md({asr:{appId:u.config.appId,accessKey:u.config.accessKey,resourceId:u.config.resourceId}});_.on("phase",S=>Xy(S)),_.on("partial",S=>Pa(S)),_.on("final",S=>{O(w=>w?w+S:S),Pa("")}),_.on("error",S=>{C(w=>[...w,{role:"assistant",content:`\u26A0 \u8BED\u97F3\u8BC6\u522B\u51FA\u9519: ${S}`}])}),_.on("log",S=>{o&&console.error(`[voice] ${S}`)}),ws.current=_,await _.start()},[u,Be,o]),ul=dt(()=>{ws.current?.stop()},[]),dl=dt(()=>{Be==="recording"||Be==="connecting"?ul():(Be==="idle"||Be==="error")&&cl()},[Be,cl,ul]),{doubleCtrlC:lx,handleCtrlC:tp}=Kn(()=>{if(ws.current)try{ws.current.abort()}catch{}let _=me.current;_?_.flushLog().finally(()=>process.exit(0)):process.exit(0)});J_(dt((_,S)=>{if(co){S.ctrl&&_==="p"&&Ns(!1);return}if(Vn){if(S.upArrow)Ds(R=>(R-1+zn.length)%zn.length);else if(S.downArrow)Ds(R=>(R+1)%zn.length);else if(S.return){let R=zn[lo];Os(!1),R&&ll(R,lo+1)}else S.escape&&(Os(!1),C(R=>[...R,{role:"assistant",content:"\u5DF2\u53D6\u6D88\u56DE\u9000\u3002"}]));return}if(hn){if(S.upArrow)Gs(R=>(R-1+gn.length)%gn.length);else if(S.downArrow)Gs(R=>(R+1)%gn.length);else if(S.return){let R=gn[Bs];R===St?C(B=>[...B,{role:"assistant",content:`\u5DF2\u7ECF\u5728\u4F7F\u7528 ${wn[R].displayName}`}]):(Ha(R),me.current?.reset(),dp(R).catch(()=>{}),C(B=>[...B,{role:"assistant",content:`\u6A21\u578B\u5DF2\u5207\u6362\u4E3A ${wn[R].displayName}\uFF08${R}\uFF09`}])),Qa(!1)}else S.escape&&Qa(!1);return}if(Hn){if(S.upArrow){let R=Pn.map((B,v)=>({o:B,i:v})).filter(({o:B})=>B.enabled);if(R.length>0){let v=(R.findIndex(({i:D})=>D===fn)-1+R.length)%R.length,P=R[v];P&&Kd(P.i)}return}if(S.downArrow){let R=Pn.map((B,v)=>({o:B,i:v})).filter(({o:B})=>B.enabled);if(R.length>0){let v=(R.findIndex(({i:D})=>D===fn)+1)%R.length,P=R[v];P&&Kd(P.i)}return}if(S.return){let R=Pn[fn];if(R&&R.enabled){let B=R.index===2?"skills":R.index===3?"mcps":"files";if(Ct(B),B==="mcps"){let v=$t.current;v?(Vt(v.listServers()),xn(0)):Vt([])}}else Ct("files");It(!1);return}if(S.escape){It(!1);return}}let w=mn??"files",H=w==="files"?ep(j):[],Q=w==="skills"?al(j):[],ae=w==="mcps"?(()=>{let B=(An(j)?.query??"").toLowerCase().trim();return B?uo.filter(v=>v.id.toLowerCase().startsWith(B)).slice(0,5):uo.slice(0,5)})():[];if(H.length>0){if(S.upArrow){Ms(R=>(R-1+H.length)%H.length);return}if(S.downArrow){Ms(R=>(R+1)%H.length);return}if(S.tab){zs(j,Tr);return}}if(Q.length>0){if(S.upArrow){Xa(R=>(R-1+Q.length)%Q.length);return}if(S.downArrow){Xa(R=>(R+1)%Q.length);return}if(S.tab){let R=Q[wr];if(R&&w==="skills"){let B=An(j);if(B){let v=j.slice(0,B.atIndex);O(`${v}/${R.name} `),Wn(P=>P+1),It(!1),Ct(null)}return}}}if(ae.length>0){if(S.upArrow){xn(R=>(R-1+ae.length)%ae.length);return}if(S.downArrow){xn(R=>(R+1)%ae.length);return}if(S.tab){let R=po>=0&&po<ae.length?po:0,B=ae[R];if(B){let v=An(j);if(v){let P=j.slice(0,v.atIndex);O(`${P}@${B.id} `),Wn(D=>D+1),It(!1),Ct(null),Vt([]),xn(0);return}}}}let $=Ji(j,io);if($.length>0){if(S.upArrow){ao(R=>(R-1+$.length)%$.length);return}if(S.downArrow){ao(R=>(R+1)%$.length);return}}if((S.tab||S.return)&&$.length>0){let R=Un>=0&&Un<$.length?Un:0,B=$[R];if(/(?:^|\s)\/[^/]*$/.test(j)&&B&&S.tab){let P=j.lastIndexOf("/");P>=0&&(O(j.slice(0,P)+B.name+" "),Wn(D=>D+1),ao(0));return}}if(hn){S.upArrow||S.downArrow;return}if(S.ctrl&&_==="c"){de?el.current?.abort():tp();return}if(S.ctrl&&_==="p"&&!de&&!Vn&&!hn){Ns(!0);return}if(S.escape&&(Be==="recording"||Be==="connecting"||Be==="finalizing")){ul();return}if(S.shift&&S.tab){if(!de){let R=Fn==="plan"?"code":"plan";As(R),me.current?.setMode(R),Es(void 0),me.current?.reset(),C(B=>[...B,{role:"assistant",content:R==="plan"?`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**\uFF08Shift+Tab\uFF09
593
599
 
594
600
  \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
595
601
 
596
- \u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002`}])}return}!N&&!pe&&_&&A(_)},[mn,Is,hn,St,pe,Nd,N,t,xr,br,Dd,tl,Bs,Fn,bs,Wn,ro,Hn,nl,sl,Un,pn,fn])),ge(()=>{if(!process.stdin.isTTY)return;let _=Buffer.alloc(0),T=[Buffer.from([27,79,81]),Buffer.from([27,91,49,50,126]),Buffer.from([27,91,91,66])],C=W=>{let J=Buffer.isBuffer(W)?W:Buffer.from(W,"binary");_=Buffer.concat([_,J]),_.length>16&&(_=_.subarray(_.length-16));for(let oe of T)if(_.includes(oe)){_=Buffer.alloc(0),!pe&&!Wn&&!mn&&sl();return}};return process.stdin.on("data",C),()=>{process.stdin.off("data",C)}},[pe,Wn,mn,sl]),ge(()=>{if(Et.length<=1)return;let _=setInterval(()=>{Ny(T=>(T+1)%Et.length)},2e3);return()=>clearInterval(_)},[Et.length]),ge(()=>{let _=Et[Ts%Et.length];if(!_){Ua([]);return}let T=`${_.name} ${_.desc}`;Cs.current=0,Ua(an(T,1,Du));let C=setInterval(()=>{Cs.current=(Cs.current+dr.cmdTipPhaseStep)%1,Ua(an(T,1-Cs.current,Du))},dr.cmdTipInterval);return()=>clearInterval(C)},[Ts,Et.length]),ge(()=>{let _="\u2500".repeat(200);if(_s.current=0,Ad(an(_,1,is)),no)return;let T=setInterval(()=>{_s.current=(_s.current+1/12)%1,Ad(an(_,1-_s.current,is))},200);return()=>clearInterval(T)},[no]),ge(()=>{let _=!1;if(!s||!i)return;let T=su({name:"deepseek",apiKey:s,baseUrl:i,model:St}),C=a??new ze,W=new Pn;W.registerAll(Ou);let J=null,oe=null;if(k&&Object.keys(k).length>0){let S=co.sharedInstance({globalTimeoutSeconds:v});J=new ca({store:S}),Lt.current=J,J.start();let M=J.onToolsChanged(E=>{for(let $ of W.names())$.startsWith("mcp_")&&W.unregister($);for(let $ of E)try{W.registerErased($)}catch(U){o&&console.warn(` \u26A0 \u6CE8\u518C MCP \u5DE5\u5177 "${$.name}" \u5931\u8D25\uFF1A${U.message}`)}});oe=()=>M.close();let B=J;B.reconcile(k).then(()=>{if(o){let E=B.status(),$=Object.values(E).filter(ee=>ee.state==="ready").length,U=Object.values(E).filter(ee=>ee.state==="failed").length;console.log(` \u2139 MCP servers: ${$} ready, ${U} failed (of ${Object.keys(E).length})`)}})}return(async()=>{let S=new ur,M=[];try{let{loadAllSkills:B}=await import("./loader-GPVLJCXF.js"),E=await B(process.cwd());if(M=E.skills,Md.current=E.skills,o&&E.errors.length>0)for(let $ of E.errors)console.warn(` \u26A0 ${$.message} (${$.skillFilePath})`)}catch(B){o&&console.warn(` \u26A0 \u52A0\u8F7D skill \u5931\u8D25\uFF1A${B instanceof Error?B.message:String(B)}`)}if(c){let{permissionsFromConfig:B}=await import("./permissions-loader-KFO6PIVU.js"),{InteractiveGate:E}=await import("./interactive-gate-UBPGIMF2.js"),$=B(c);if(!_){let U=new E({engine:$.engine,grants:void 0,prompt:Ja,defaultDecision:"confirm"}),ee=new ss(T,W,C,{cwd:process.cwd(),gate:new Mn([new ur,U]),skills:M});he.current=ee,js.register({id:ee.id,cwd:process.cwd(),chat:(Ct,kr)=>ee.chat(Ct,kr)},()=>ee.drainLog(),{onRemoteUserInput:async(Ct,kr)=>{if(!lo.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await lo.current(Ct,kr,{displayText:Ct})}})}if(o&&$.warnings.length>0)for(let U of $.warnings)console.warn(` \u26A0 ${U}`)}else{let{WriteConfirmGate:B}=await import("./write-gate-HEFJJQX6.js");if(!_){let E=new B(W,Ja),$=new ss(T,W,C,{cwd:process.cwd(),gate:new Mn([S,E]),skills:M});he.current=$,js.register({id:$.id,cwd:process.cwd(),chat:(U,ee)=>$.chat(U,ee)},()=>$.drainLog(),{onRemoteUserInput:async(U,ee)=>{if(!lo.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await lo.current(U,ee,{displayText:U})}})}}})(),()=>{_=!0,he.current&&js.unregister(he.current.id),he.current=null,oe?.(),J&&(Lt.current=null,J.dispose())}},[s,i,St,a,Ja,o,k]),ge(()=>{if(!s||!i)return;let _=!1;return hr(!0),import("./deepseek-X6USE3PW.js").then(({DeepSeekProvider:T})=>new T({apiKey:s,baseUrl:i,model:"deepseek-v4-flash"}).getBalance()).then(T=>{if(_)return;let C=T.balances.find(W=>W.currency==="CNY");C&&fe(C.totalBalance)}).catch(()=>{}).finally(()=>{_||hr(!1)}),()=>{_=!0}},[s,i]),ge(()=>{if(!a)return;let _=!1,T,C=()=>{gd(a.todayTotalCost)};return a.load().then(()=>{_||(C(),T=setInterval(C,5e3))}).catch(()=>{}),()=>{_=!0,T&&clearInterval(T)}},[a]),ge(()=>{if(pe||!Nn){Aa([]);return}ms.current=0,Aa(an(Nn,1,is));let _=setInterval(()=>{ms.current=(ms.current+dr.idlePhaseStep)%1,Aa(an(Nn,1-ms.current,is))},dr.idleInterval);return()=>clearInterval(_)},[pe,Nn]),ge(()=>{if(!pe||!Dn){Ia([]);return}hs.current=0,Ia(an(Dn,1,Nu));let _=setInterval(()=>{hs.current=(hs.current+dr.streamingPhaseStep)%1,Ia(an(Dn,1-hs.current,Nu))},dr.streamingInterval);return()=>clearInterval(_)},[pe,Dn]);let Fs=xt(async(_,T,C)=>{let W=he.current;if(!W){P(S=>[...S,{role:"user",content:C.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 J=T==="chrome"?`\u{1F310} [chrome] ${C.displayText}`:T==="api"?`\u{1F50C} [api] ${C.displayText}`:T==="test"?`\u{1F9EA} [test] ${C.displayText}`:C.displayText;P(S=>[...S,{role:"user",content:J}]),fs(!0),Ht("thinking"),va(Yu(E_)),La(""),$a([]),Ma([]),wd(void 0),kd(void 0),Sd(void 0),Cd(void 0),gs(void 0),bd(new Map),Os.current=new Map,Ls.current="",$s.current=[],Ms.current=[],Za.current=void 0,Ya.current=void 0,Qa.current=void 0,el.current=void 0,Ns.current=void 0,za.current=!1,Va("idle"),Pt.current&&(clearTimeout(Pt.current),Pt.current=null),ys([]),dn.current&&(clearTimeout(dn.current),dn.current=null),xs(!1),gn({phase:"idle",progress:null}),wr.current=void 0,He.current&&(clearTimeout(He.current),He.current=null);let oe=new AbortController;Ka.current=oe;try{for await(let S of W.chat(_,{thinkingAllowed:C.thinkingAllowed,thinkingEffort:C.thinkingEffort,...C.responseFormat?{responseFormat:C.responseFormat}:{},...C.toolChoice?{toolChoice:C.toolChoice}:{}},C.extraSystemContext)){if(oe.signal.aborted)break;switch(S.type){case"text_delta":Ht("generating"),La(M=>{let B=M+S.content;return Ls.current=B,B});break;case"reasoning_delta":Ht("thinking"),$a(M=>{let B=M[M.length-1],E=B!==void 0?[...M.slice(0,-1),B+S.content]:[...M,S.content];return $s.current=E,E});break;case"tool_calls":Ht("calling_tools"),Ma(M=>{let B=[...M,...S.calls];return Ms.current=B,B});for(let M of S.calls)if(A_(M.name)){za.current=!0;break}break;case"tool_result":Ht("executing_tools"),setTimeout(()=>Ht("thinking"),300),La(""),Ls.current="",$a(M=>{let B=[...M,""];return $s.current=B,B}),Ma([]),Ms.current=[];{let M=S.callId??`${S.name}#${S.result.data.length}`;bd(B=>{let E=new Map(B);return E.set(M,{success:S.result.success,...S.result.error?{error:S.result.error}:{},...S.result.denial?{denial:S.result.denial}:{}}),Os.current=E,E})}{let M=S.result;if(S.name.startsWith("todo_")&&S.todoSnapshot){let B=[...S.todoSnapshot];B.length>0&&B.every($=>$.status==="done"||$.status==="failed"||$.status==="skipped")?(eo.current=Math.max(...B.map($=>$.id)),ys(B)):eo.current>=0?ys(B.filter($=>$.id>eo.current)):ys(B)}else{let B=M.success?M.summary??`\u2705 ${S.name}: ${M.data.slice(0,500)}${M.data.length>500?"...":""}`:`\u274C ${S.name}: ${M.error??"\u6267\u884C\u5931\u8D25"}`;P(E=>[...E,{role:"tool",content:B,diff:M.diff}])}}break;case"usage":wd(S.usage),Cd(S.model),Za.current=S.usage,el.current=S.model;{let M=Mt(S.usage,S.model);Sd(M.totalCost),Qa.current=M.totalCost}break;case"done":kd(S.elapsed),Ya.current=S.elapsed;break;case"error":gs(S.error.message),Ns.current=S.error.message;break}}}catch(S){let M=S instanceof Error?S.message:String(S);gs(M),Ns.current=M}finally{fs(!1),Ht(null),Ly(Yu(jg)),Ka.current=null;let S=Ls.current,M=$s.current.map($=>$.trim()).filter($=>$.length>0),B=Gg(Ms.current),E=Ns.current;if(S||B||E){let $={content:E?`\u26A0 \u8BF7\u6C42\u51FA\u9519\uFF1A${E}`:S||"",...M.length>0?{reasoning:M}:{},toolCalls:B,toolResults:Os.current.size>0?new Map(Os.current):void 0,usage:Za.current,elapsed:Ya.current,cost:Qa.current,model:el.current};P(U=>[...U,{role:"assistant",content:$.content,assistantDetail:$}])}za.current&&!E&&(Va("pending"),Pt.current&&clearTimeout(Pt.current),Pt.current=setTimeout(()=>{Va($=>$==="pending"?"visible":$),Pt.current=null},2e3))}},[]),lo=de(null);ge(()=>{lo.current=Fs},[Fs]);let Bd=xt(async _=>{if(Un){let S=In[pn];if(S&&S.enabled){let M=S.index===2?"skills":S.index===3?"mcps":"files";if(Tt(M),M==="mcps"){let B=Lt.current;B?(Vt(B.listServers()),yn(0)):Vt([])}}else Tt("files");It(!1);return}let T=fn??"files";if(T==="files"&&Bs(_,br))return;if(T==="skills"){let S=tl(_);if(S.length>0){let M=S[xr]??S[0];if(M){let B=Rn(_);if(B){let E=_.slice(0,B.atIndex);A(`${E}/${M.name} `),jn($=>$+1),It(!1),Tt(null)}return}}}if(T==="mcps"){let S=so[io]??so[0];if(S){let M=Rn(_);if(M){let B=_.slice(0,M.atIndex);A(`${B}@${S.id} `),jn(E=>E+1),It(!1),Tt(null),Vt([]),yn(0);return}}}let C=_.trim();if(!C)return;let W=C;if(C.startsWith("/")&&C.length>1){let S=C.toLowerCase();if(S==="/rewind"||S.startsWith("/rewind ")){if(pe||Ha){let U=Ha?"\u56DE\u9000\u4E2D":"\u751F\u6210\u4E2D";P(ee=>[...ee,{role:"user",content:C},{role:"assistant",content:`\u26A0 \u6B63\u5728${U}\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /rewind\u3002`}]),A("");return}if(!he.current){P(U=>[...U,{role:"user",content:C},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u56DE\u9000\u3002"}]),A("");return}let E=he.current.listCheckpoints();if(E.length===0){P(U=>[...U,{role:"user",content:C},{role:"assistant",content:`\u26A0 \u6CA1\u6709\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u3002
597
- \u53EA\u6709\u5728 git \u4ED3\u5E93\u5185\u4E14\u53D1\u751F\u8FC7\u5BF9\u8BDD\u540E\u624D\u4F1A\u751F\u6210\u68C0\u67E5\u70B9\u3002`}]),A("");return}let $=C.split(/\s+/);if($.length>=2){let U=Number($[1]);if(!Number.isInteger(U)||U<1||U>E.length){P(Ct=>[...Ct,{role:"user",content:C},{role:"assistant",content:`\u26A0 \u65E0\u6548\u7684\u5E8F\u53F7\u300C${$[1]}\u300D\u3002\u53EF\u7528\u8303\u56F4 1~${E.length}\uFF081 \u8868\u793A\u6700\u65B0\uFF09\u3002`}]),A("");return}let ee=E[E.length-U];A(""),await nl(ee,U);return}Fy([...E].reverse()),As(0),Rs(!0),P(U=>[...U,{role:"user",content:C},{role:"assistant",content:`\u23F7\u2191\u2193 \u9009\u62E9\u68C0\u67E5\u70B9\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88\uFF08\u5171 ${E.length} \u4E2A\u53EF\u56DE\u9000\u4F4D\u7F6E\uFF09`}]),A("");return}if(S==="/compact"){if(pe){P(E=>[...E,{role:"user",content:C},{role:"assistant",content:"\u26A0 \u6B63\u5728\u751F\u6210\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /compact\u3002"}]),A("");return}if(!he.current){P(E=>[...E,{role:"user",content:C},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u538B\u7F29\u3002"}]),A("");return}A(""),P(E=>[...E,{role:"user",content:C}]),gn({phase:"running",progress:null,beforeTokens:void 0,afterTokens:void 0,droppedTurns:void 0,keptTurns:void 0,strategy:void 0,errorMessage:void 0});try{let E=await he.current.compact($=>{gn(U=>{if($.type==="start")return{...U,phase:"running",progress:$,beforeTokens:$.beforeTokens,droppedTurns:$.droppedTurns};if($.type==="summary_delta")return{...U,phase:"running",progress:$};if($.type==="fallback")return wr.current="fallback",{...U,phase:"running",progress:$,strategy:"fallback"};if($.type==="done"){let ee=wr.current==="fallback"?"fallback":"summary";return wr.current=ee,{...U,phase:"done",progress:$,droppedTurns:$.droppedTurns,keptTurns:$.keptTurns,beforeTokens:$.beforeTokens,afterTokens:$.afterTokens,strategy:ee}}return U})});E.droppedTurns===0?(gn($=>({...$,phase:"done",progress:$.progress,droppedTurns:0,keptTurns:E.keptTurns,beforeTokens:E.beforeTokens,afterTokens:E.afterTokens,strategy:void 0})),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{gn({phase:"idle",progress:null}),P($=>[...$,{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)):(He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{let $=((E.beforeTokens-E.afterTokens)/Math.max(E.beforeTokens,1)*100).toFixed(1),U=wr.current==="fallback"?`
598
- \u26A0 \u6458\u8981\u4E3A\u672C\u5730\u5151\u5E95\uFF08LLM \u4E0D\u53EF\u7528\uFF09`:"";gn({phase:"idle",progress:null}),wr.current=void 0,P(ee=>[...ee,{role:"assistant",content:`\u2714 \u538B\u7F29\u5B8C\u6210\uFF1A${E.droppedTurns} \u56DE\u5408 \u2192 ${E.keptTurns} \u56DE\u5408\uFF08\u8282\u7701 ${$}% token\uFF09${U}`}])},4e3))}catch(E){let $=E instanceof Error?E.message:String(E);gn(U=>({...U,phase:"error",errorMessage:$})),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{gn({phase:"idle",progress:null}),P(U=>[...U,{role:"assistant",content:`\u26A0 \u538B\u7F29\u5931\u8D25\uFF1A${$}`}])},3e3)}return}if(S==="/model"){let E=hn.indexOf(St);Ps(E>=0?E:0),qa(!0),A("");return}if(S==="/voice"){A(""),rl();return}if(S==="/thinking"){vd(E=>!E),P(E=>[...E,{role:"user",content:C},{role:"assistant",content:`\u6DF1\u5EA6\u601D\u8003\u5DF2${Gn?"\u5173\u95ED":"\u5F00\u542F"}`}]),A("");return}if(S==="/effort"){let E=gr==="high"?"max":"high";Rd(E),P($=>[...$,{role:"user",content:C},{role:"assistant",content:`\u63A8\u7406\u7B49\u7EA7\u5DF2\u5207\u6362\u4E3A ${E==="high"?"High":"Max"}`}]),A("");return}if(S==="/plan"){Fn==="plan"?P(E=>[...E,{role:"user",content:C},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u8BA1\u5212\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002"}]):(bs("plan"),he.current?.setMode("plan"),ws(void 0),P(E=>[...E,{role:"user",content:C},{role:"assistant",content:`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**
602
+ \u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002`}])}return}!j&&!de&&_&&O(_)},[hn,Bs,gn,St,de,tp,j,t,wr,Tr,ep,al,zs,Fn,As,Vn,lo,zn,ll,dl,Hn,fn,mn,io,Un])),ye(()=>{if(!process.stdin.isTTY)return;let _=Buffer.alloc(0),S=[Buffer.from([27,79,81]),Buffer.from([27,91,49,50,126]),Buffer.from([27,91,91,66])],w=H=>{let Q=Buffer.isBuffer(H)?H:Buffer.from(H,"binary");_=Buffer.concat([_,Q]),_.length>16&&(_=_.subarray(_.length-16));for(let ae of S)if(_.includes(ae)){_=Buffer.alloc(0),!de&&!Vn&&!hn&&dl();return}};return process.stdin.on("data",w),()=>{process.stdin.off("data",w)}},[de,Vn,hn,dl]),ye(()=>{if(Et.length<=1)return;let _=setInterval(()=>{rx(S=>(S+1)%Et.length)},2e3);return()=>clearInterval(_)},[Et.length]),ye(()=>{let _=Et[Ps%Et.length];if(!_){Ka([]);return}let S=`${_.name} ${_.desc}`;$s.current=0,Ka(an(S,1,Qu));let w=setInterval(()=>{$s.current=($s.current+mr.cmdTipPhaseStep)%1,Ka(an(S,1-$s.current,Qu))},mr.cmdTipInterval);return()=>clearInterval(w)},[Ps,Et.length]),ye(()=>{let _="\u2500".repeat(200);if(Ls.current=0,zd(an(_,1,hs)),so)return;let S=setInterval(()=>{Ls.current=(Ls.current+1/12)%1,zd(an(_,1-Ls.current,hs))},200);return()=>clearInterval(S)},[so]),ye(()=>{let _=!1;if(!s||!i)return;let S=mu({name:"deepseek",apiKey:s,baseUrl:i,model:St}),w=a??new ze,H=new $n;H.registerAll(Hu);let Q=null,ae=null;if(T&&Object.keys(T).length>0){let $=go.sharedInstance({globalTimeoutSeconds:A});Q=new ga({store:$}),$t.current=Q,Q.start();let R=Q.onToolsChanged(v=>{for(let P of H.names())P.startsWith("mcp_")&&H.unregister(P);for(let P of v)try{H.registerErased(P)}catch(D){o&&console.warn(` \u26A0 \u6CE8\u518C MCP \u5DE5\u5177 "${P.name}" \u5931\u8D25\uFF1A${D.message}`)}});ae=()=>R.close();let B=Q;B.reconcile(T).then(()=>{if(o){let v=B.status(),P=Object.values(v).filter(z=>z.state==="ready").length,D=Object.values(v).filter(z=>z.state==="failed").length;console.log(` \u2139 MCP servers: ${P} ready, ${D} failed (of ${Object.keys(v).length})`)}})}return(async()=>{let $=new fr,R=[];try{let{loadAllSkills:B}=await import("./loader-GPVLJCXF.js"),v=await B(process.cwd());if(R=v.skills,Yd.current=v.skills,o&&v.errors.length>0)for(let P of v.errors)console.warn(` \u26A0 ${P.message} (${P.skillFilePath})`)}catch(B){o&&console.warn(` \u26A0 \u52A0\u8F7D skill \u5931\u8D25\uFF1A${B instanceof Error?B.message:String(B)}`)}if(c){let{permissionsFromConfig:B}=await import("./permissions-loader-KFO6PIVU.js"),{InteractiveGate:v}=await import("./interactive-gate-UBPGIMF2.js"),P=B(c);if(!_){let D=new v({engine:P.engine,grants:void 0,prompt:nl,defaultDecision:"confirm"}),z=new ms(S,H,w,{cwd:process.cwd(),gate:new On([new fr,D]),skills:R});me.current=z,Ks.register({id:z.id,cwd:process.cwd(),chat:(nt,Cr)=>z.chat(nt,Cr)},()=>z.drainLog(),{onRemoteUserInput:async(nt,Cr)=>{if(!ho.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await ho.current(nt,Cr,{displayText:nt})}})}if(o&&P.warnings.length>0)for(let D of P.warnings)console.warn(` \u26A0 ${D}`)}else{let{WriteConfirmGate:B}=await import("./write-gate-HEFJJQX6.js");if(!_){let v=new B(H,nl),P=new ms(S,H,w,{cwd:process.cwd(),gate:new On([$,v]),skills:R});me.current=P,Ks.register({id:P.id,cwd:process.cwd(),chat:(D,z)=>P.chat(D,z)},()=>P.drainLog(),{onRemoteUserInput:async(D,z)=>{if(!ho.current)throw new Error("ChatSession \u672A\u5C31\u7EEA");await ho.current(D,z,{displayText:D})}})}}})(),()=>{_=!0,me.current&&Ks.unregister(me.current.id),me.current=null,ae?.(),Q&&($t.current=null,Q.dispose())}},[s,i,St,a,nl,o,T]),ye(()=>{if(!s||!i)return;let _=!1;return br(!0),import("./deepseek-X6USE3PW.js").then(({DeepSeekProvider:S})=>new S({apiKey:s,baseUrl:i,model:"deepseek-v4-flash"}).getBalance()).then(S=>{if(_)return;let w=S.balances.find(H=>H.currency==="CNY");w&&he(w.totalBalance)}).catch(()=>{}).finally(()=>{_||br(!1)}),()=>{_=!0}},[s,i]),ye(()=>{if(!a)return;let _=!1,S,w=()=>{Ld(a.todayTotalCost)};return a.load().then(()=>{_||(w(),S=setInterval(w,5e3))}).catch(()=>{}),()=>{_=!0,S&&clearInterval(S)}},[a]),ye(()=>{if(de||!Bn){Oa([]);return}Ss.current=0,Oa(an(Bn,1,hs));let _=setInterval(()=>{Ss.current=(Ss.current+mr.idlePhaseStep)%1,Oa(an(Bn,1-Ss.current,hs))},mr.idleInterval);return()=>clearInterval(_)},[de,Bn]),ye(()=>{if(!de||!Nn){Na([]);return}Cs.current=0,Na(an(Nn,1,ed));let _=setInterval(()=>{Cs.current=(Cs.current+mr.streamingPhaseStep)%1,Na(an(Nn,1-Cs.current,ed))},mr.streamingInterval);return()=>clearInterval(_)},[de,Nn]);let mo=dt(async(_,S,w)=>{let H=me.current;if(!H){C($=>[...$,{role:"user",content:w.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 Q=S==="chrome"?`\u{1F310} [chrome] ${w.displayText}`:S==="api"?`\u{1F50C} [api] ${w.displayText}`:S==="test"?`\u{1F9EA} [test] ${w.displayText}`:w.displayText;C($=>[...$,{role:"user",content:Q}]),Ts(!0),Ht("thinking"),La(hd(Q_)),Ga(""),Fa([]),ja([]),Nd(void 0),Bd(void 0),Gd(void 0),jd(void 0),_s(void 0),Dd(new Map),Ws.current=new Map,Fs.current="",js.current=[],Us.current=[],rl.current=void 0,ol.current=void 0,sl.current=void 0,il.current=void 0,Vs.current=void 0,Ya.current=!1,Za("idle"),Pt.current&&(clearTimeout(Pt.current),Pt.current=null),vs([]),dn.current&&(clearTimeout(dn.current),dn.current=null),Rs(!1),yn({phase:"idle",progress:null}),Sr.current=void 0,He.current&&(clearTimeout(He.current),He.current=null);let ae=new AbortController;el.current=ae;try{for await(let $ of H.chat(_,{thinkingAllowed:w.thinkingAllowed,thinkingEffort:w.thinkingEffort,...w.responseFormat?{responseFormat:w.responseFormat}:{},...w.toolChoice?{toolChoice:w.toolChoice}:{}},w.extraSystemContext)){if(ae.signal.aborted)break;switch($.type){case"text_delta":Ht("generating"),Ga(R=>{let B=R+$.content;return Fs.current=B,B});break;case"reasoning_delta":Ht("thinking"),Fa(R=>{let B=R[R.length-1],v=B!==void 0?[...R.slice(0,-1),B+$.content]:[...R,$.content];return js.current=v,v});break;case"tool_calls":Ht("calling_tools"),ja(R=>{let B=[...R,...$.calls];return Us.current=B,B});for(let R of $.calls)if(Y_(R.name)){Ya.current=!0;break}break;case"tool_result":Ht("executing_tools"),setTimeout(()=>Ht("thinking"),300),Ga(""),Fs.current="",Fa(R=>{let B=[...R,""];return js.current=B,B}),ja([]),Us.current=[];{let R=$.callId??`${$.name}#${$.result.data.length}`;Dd(B=>{let v=new Map(B);return v.set(R,{success:$.result.success,...$.result.error?{error:$.result.error}:{},...$.result.denial?{denial:$.result.denial}:{}}),Ws.current=v,v})}{let R=$.result;if($.name.startsWith("todo_")&&$.todoSnapshot){let B=[...$.todoSnapshot];B.length>0&&B.every(P=>P.status==="done"||P.status==="failed"||P.status==="skipped")?(ro.current=Math.max(...B.map(P=>P.id)),vs(B)):ro.current>=0?vs(B.filter(P=>P.id>ro.current)):vs(B)}else{let B=R.success?R.summary??`\u2705 ${$.name}: ${R.data.slice(0,500)}${R.data.length>500?"...":""}`:`\u274C ${$.name}: ${R.error??"\u6267\u884C\u5931\u8D25"}`;C(v=>[...v,{role:"tool",content:B,diff:R.diff}])}}break;case"usage":Nd($.usage),jd($.model),rl.current=$.usage,il.current=$.model;{let R=Mt($.usage,$.model);Gd(R.totalCost),sl.current=R.totalCost}break;case"done":Bd($.elapsed),ol.current=$.elapsed;break;case"goal_continue":pn(),C(R=>[...R,{role:"assistant",content:`\u25CE /goal \u8BC4\u4F30\u672A\u901A\u8FC7\uFF1A${yr($.eval.reason,200)}`}]);break;case"goal_achieved":pn(),C(R=>[...R,{role:"assistant",content:`\u2713 /goal achieved\uFF1A${yr($.eval.reason,200)}`}]);break;case"goal_aborted":pn(),C(R=>[...R,{role:"assistant",content:`\u2715 /goal aborted\uFF1A${JSON.stringify($.reason)}`}]);break;case"goal_paused":pn();break;case"error":_s($.error.message),Vs.current=$.error.message;break}}}catch($){let R=$ instanceof Error?$.message:String($);_s(R),Vs.current=R}finally{Ts(!1),Ht(null),Zy(hd(iy)),el.current=null;let $=Fs.current,R=js.current.map(P=>P.trim()).filter(P=>P.length>0),B=sy(Us.current),v=Vs.current;if($||B||v){let P={content:v?`\u26A0 \u8BF7\u6C42\u51FA\u9519\uFF1A${v}`:$||"",...R.length>0?{reasoning:R}:{},toolCalls:B,toolResults:Ws.current.size>0?new Map(Ws.current):void 0,usage:rl.current,elapsed:ol.current,cost:sl.current,model:il.current};C(D=>[...D,{role:"assistant",content:P.content,assistantDetail:P}])}Ya.current&&!v&&(Za("pending"),Pt.current&&clearTimeout(Pt.current),Pt.current=setTimeout(()=>{Za(P=>P==="pending"?"visible":P),Pt.current=null},2e3))}},[]),ho=pe(null);ye(()=>{ho.current=mo},[mo]);let np=dt(async _=>{if(Hn){let $=Pn[fn];if($&&$.enabled){let R=$.index===2?"skills":$.index===3?"mcps":"files";if(Ct(R),R==="mcps"){let B=$t.current;B?(Vt(B.listServers()),xn(0)):Vt([])}}else Ct("files");It(!1);return}let S=mn??"files";if(S==="files"&&zs(_,Tr))return;if(S==="skills"){let $=al(_);if($.length>0){let R=$[wr]??$[0];if(R){let B=An(_);if(B){let v=_.slice(0,B.atIndex);O(`${v}/${R.name} `),Wn(P=>P+1),It(!1),Ct(null)}return}}}if(S==="mcps"){let $=uo[po]??uo[0];if($){let R=An(_);if(R){let B=_.slice(0,R.atIndex);O(`${B}@${$.id} `),Wn(v=>v+1),It(!1),Ct(null),Vt([]),xn(0);return}}}let w=_.trim();if(!w)return;let H=w;if(w.startsWith("/")&&w.length>1){let $=w.toLowerCase();if($==="/rewind"||$.startsWith("/rewind ")){if(de||Ja){let D=Ja?"\u56DE\u9000\u4E2D":"\u751F\u6210\u4E2D";C(z=>[...z,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u6B63\u5728${D}\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /rewind\u3002`}]),O("");return}if(!me.current){C(D=>[...D,{role:"user",content:w},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u56DE\u9000\u3002"}]),O("");return}let v=me.current.listCheckpoints();if(v.length===0){C(D=>[...D,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u6CA1\u6709\u53EF\u56DE\u9000\u7684\u68C0\u67E5\u70B9\u3002
603
+ \u53EA\u6709\u5728 git \u4ED3\u5E93\u5185\u4E14\u53D1\u751F\u8FC7\u5BF9\u8BDD\u540E\u624D\u4F1A\u751F\u6210\u68C0\u67E5\u70B9\u3002`}]),O("");return}let P=w.split(/\s+/);if(P.length>=2){let D=Number(P[1]);if(!Number.isInteger(D)||D<1||D>v.length){C(nt=>[...nt,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u65E0\u6548\u7684\u5E8F\u53F7\u300C${P[1]}\u300D\u3002\u53EF\u7528\u8303\u56F4 1~${v.length}\uFF081 \u8868\u793A\u6700\u65B0\uFF09\u3002`}]),O("");return}let z=v[v.length-D];O(""),await ll(z,D);return}sx([...v].reverse()),Ds(0),Os(!0),C(D=>[...D,{role:"user",content:w},{role:"assistant",content:`\u23F7\u2191\u2193 \u9009\u62E9\u68C0\u67E5\u70B9\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88\uFF08\u5171 ${v.length} \u4E2A\u53EF\u56DE\u9000\u4F4D\u7F6E\uFF09`}]),O("");return}if($==="/compact"){if(de){C(v=>[...v,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u6B63\u5728\u751F\u6210\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5 /compact\u3002"}]),O("");return}if(!me.current){C(v=>[...v,{role:"user",content:w},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u538B\u7F29\u3002"}]),O("");return}O(""),C(v=>[...v,{role:"user",content:w}]),yn({phase:"running",progress:null,beforeTokens:void 0,afterTokens:void 0,droppedTurns:void 0,keptTurns:void 0,strategy:void 0,errorMessage:void 0});try{let v=await me.current.compact(P=>{yn(D=>{if(P.type==="start")return{...D,phase:"running",progress:P,beforeTokens:P.beforeTokens,droppedTurns:P.droppedTurns};if(P.type==="summary_delta")return{...D,phase:"running",progress:P};if(P.type==="fallback")return Sr.current="fallback",{...D,phase:"running",progress:P,strategy:"fallback"};if(P.type==="done"){let z=Sr.current==="fallback"?"fallback":"summary";return Sr.current=z,{...D,phase:"done",progress:P,droppedTurns:P.droppedTurns,keptTurns:P.keptTurns,beforeTokens:P.beforeTokens,afterTokens:P.afterTokens,strategy:z}}return D})});v.droppedTurns===0?(yn(P=>({...P,phase:"done",progress:P.progress,droppedTurns:0,keptTurns:v.keptTurns,beforeTokens:v.beforeTokens,afterTokens:v.afterTokens,strategy:void 0})),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{yn({phase:"idle",progress:null}),C(P=>[...P,{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)):(He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{let P=((v.beforeTokens-v.afterTokens)/Math.max(v.beforeTokens,1)*100).toFixed(1),D=Sr.current==="fallback"?`
604
+ \u26A0 \u6458\u8981\u4E3A\u672C\u5730\u5151\u5E95\uFF08LLM \u4E0D\u53EF\u7528\uFF09`:"";yn({phase:"idle",progress:null}),Sr.current=void 0,C(z=>[...z,{role:"assistant",content:`\u2714 \u538B\u7F29\u5B8C\u6210\uFF1A${v.droppedTurns} \u56DE\u5408 \u2192 ${v.keptTurns} \u56DE\u5408\uFF08\u8282\u7701 ${P}% token\uFF09${D}`}])},4e3))}catch(v){let P=v instanceof Error?v.message:String(v);yn(D=>({...D,phase:"error",errorMessage:P})),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{yn({phase:"idle",progress:null}),C(D=>[...D,{role:"assistant",content:`\u26A0 \u538B\u7F29\u5931\u8D25\uFF1A${P}`}])},3e3)}return}if($==="/model"){let v=gn.indexOf(St);Gs(v>=0?v:0),Qa(!0),O("");return}if($==="/voice"){O(""),cl();return}if($==="/thinking"){Hd(v=>!v),C(v=>[...v,{role:"user",content:w},{role:"assistant",content:`\u6DF1\u5EA6\u601D\u8003\u5DF2${jn?"\u5173\u95ED":"\u5F00\u542F"}`}]),O("");return}if($==="/effort"){let v=kr==="high"?"max":"high";Vd(v),C(P=>[...P,{role:"user",content:w},{role:"assistant",content:`\u63A8\u7406\u7B49\u7EA7\u5DF2\u5207\u6362\u4E3A ${v==="high"?"High":"Max"}`}]),O("");return}if($==="/plan"){Fn==="plan"?C(v=>[...v,{role:"user",content:w},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u8BA1\u5212\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002"}]):(As("plan"),me.current?.setMode("plan"),Es(void 0),C(v=>[...v,{role:"user",content:w},{role:"assistant",content:`\u{1F4CB} \u5DF2\u5207\u6362\u4E3A **\u8BA1\u5212\u6A21\u5F0F**
599
605
 
600
606
  \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
601
- \u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002`}]),he.current?.reset()),A("");return}if(S==="/code"){Fn==="code"?P(E=>[...E,{role:"user",content:C},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u4EE3\u7801\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /plan \u5207\u56DE\u8BA1\u5212\u6A21\u5F0F\u3002"}]):(bs("code"),he.current?.setMode("code"),ws(void 0),P(E=>[...E,{role:"user",content:C},{role:"assistant",content:`\u{1F6E0} \u5DF2\u5207\u6362\u4E3A **\u4EE3\u7801\u6A21\u5F0F**
607
+ \u8F93\u5165 /code \u5207\u56DE\u4EE3\u7801\u6A21\u5F0F\u3002`}]),me.current?.reset()),O("");return}if($==="/code"){Fn==="code"?C(v=>[...v,{role:"user",content:w},{role:"assistant",content:"\u5DF2\u7ECF\u5728\u4EE3\u7801\u6A21\u5F0F\u4E2D\u3002\u8F93\u5165 /plan \u5207\u56DE\u8BA1\u5212\u6A21\u5F0F\u3002"}]):(As("code"),me.current?.setMode("code"),Es(void 0),C(v=>[...v,{role:"user",content:w},{role:"assistant",content:`\u{1F6E0} \u5DF2\u5207\u6362\u4E3A **\u4EE3\u7801\u6A21\u5F0F**
602
608
 
603
609
  \u73B0\u5728\u53EF\u4EE5\u6B63\u5E38\u8BFB\u53D6\u548C\u4FEE\u6539\u4EE3\u7801\u4E86\u3002
604
- \u8F93\u5165 /plan \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08\u53EA\u8BFB\u5206\u6790\uFF09\u3002`}]),he.current?.reset()),A("");return}if(S==="/tools"){let E=to===void 0?"none":to==="none"?"required":to==="required"?"auto":void 0;ws(E);let $=E===void 0?"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09":E==="none"?"\u7981\u6B62\u8C03\u7528":E==="required"?"\u5F3A\u5236\u8C03\u7528":"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09";P(U=>[...U,{role:"user",content:C},{role:"assistant",content:`\u5DE5\u5177\u8C03\u7528\u7B56\u7565\u5DF2\u5207\u6362\u4E3A ${$}`}]),A("");return}if(S==="/mcp"||S.startsWith("/mcp ")){let E=Lt.current;if(!E){P(ee=>[...ee,{role:"user",content:C},{role:"assistant",content:"\u26A0 \u5F53\u524D\u672A\u542F\u52A8 MCP registry\uFF08mcpServers \u4E3A\u7A7A\u6216 Session \u672A\u5C31\u7EEA\uFF09\u3002"}]),A("");return}let $=async()=>{k&&await E.reconcile(k)},U=await Pg(C,E,$);if(U.kind==="no-match")return;if(U.kind==="error"){P(ee=>[...ee,{role:"user",content:C},{role:"assistant",content:`\u26A0 /mcp: ${U.message}`}]),A("");return}if(U.kind==="text"){P(ee=>[...ee,{role:"user",content:C},{role:"assistant",content:U.text}]),A("");return}if(U.kind==="restart"){co.sharedInstance().restart(U.serverId),P(Ct=>[...Ct,{role:"user",content:C},{role:"assistant",content:`\u27F2 \u6B63\u5728\u91CD\u542F MCP server "${U.serverId}"...`}]),A("");return}if(U.kind==="reload"){await $(),P(ee=>[...ee,{role:"user",content:C},{role:"assistant",content:"\u27F2 MCP \u914D\u7F6E\u5DF2\u91CD\u8F7D\u3002"}]),A("");return}}let M=ed.get(S);if(M){let E=M.handler();switch(E.kind){case"exit":await he.current?.flushLog(),process.exit(0);return;case"clear":P([]),j($=>$+1),A(""),gs(void 0),process.stdout.write("\x1B[2J\x1B[H\x1B[3J"),he.current?.reset(),eo.current=-1;return;case"navigate":A(""),E.target==="game"?g?.():E.target==="stock"&&w?.();return;case"text":P($=>[...$,{role:"user",content:C},{role:"assistant",content:E.content}]),A("");return;case"permissions":{let $=he.current;if(!$){P(Ge=>[...Ge,{role:"user",content:C},{role:"assistant",content:"Session \u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}]),A("");return}let U=$.gate,ee=[],Ct=0,kr="",Gs="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09";if(U instanceof Mn){let Ge=U.gates;kr=Ge.length===0?"(\u7A7A)":`\u5171 ${Ge.length} \u4E2A`;try{let $t=(await import("./interactive-gate-UBPGIMF2.js")).InteractiveGate;for(let nt of Ge)nt instanceof $t&&(ee=nt.engine.rules,Ct=nt.grants.size,Gs="\u89C4\u5219\u5F15\u64CE")}catch{}ee.length===0&&(Gs="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09")}else Gs="\u672A\u77E5";let Ve=[];if(Ve.push("\u{1F4CB} \u5F53\u524D\u6743\u9650\u7CFB\u7EDF\u72B6\u6001\uFF1A"),Ve.push(` Gate \u94FE\uFF1A${kr}`),Ve.push(` \u6A21\u5F0F\uFF1A${Gs??"\u672A\u77E5"}`),ee.length===0)Ve.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{Ve.push(` \u89C4\u5219\u6570\uFF1A${ee.length}`);for(let Ge=0;Ge<ee.length;Ge++){let dt=ee[Ge],$t=dt.match?JSON.stringify(dt.match):"(\u5168\u90E8\u5339\u914D)",nt=dt.reason?` \u2014 ${dt.reason}`:"";Ve.push(` ${Ge+1}. ${dt.tool} \u2192 ${dt.action}\uFF08${$t}\uFF09${nt}`)}}Ve.push(` \u4F1A\u8BDD grants\uFF1A${Ct} \u4E2A\uFF08"always" \u6279\u51C6\u7684\u5DE5\u5177\u8C03\u7528\uFF09`);let Fd=Lt.current;if(Fd){let Ge=Fd.tools();if(Ge.length>0){let dt=new Map;for(let $t of Ge){let nt=/^mcp_([^_]+(?:_[^_]+)*)_/.exec($t.name),Gd=nt&&nt[1]?nt[1]:"?",jd=nt?$t.name.slice(nt[0].length):$t.name,Ud=dt.get(Gd);Ud?Ud.push(jd):dt.set(Gd,[jd])}Ve.push(""),Ve.push(`MCP \u5DE5\u5177\uFF08\u5171 ${Ge.length} \u4E2A\uFF0C${dt.size} \u4E2A server\uFF09\uFF1A`);for(let[$t,nt]of dt)Ve.push(` [${$t}] ${nt.length} \u4E2A\uFF1Amcp_${$t}_*`);Ve.push(" \u5728 permissions \u6BB5\u52A0 mcp_<server>_ \u524D\u7F00\u89C4\u5219\u53EF\u7EDF\u4E00\u653E\u884C/\u62D2\u7EDD\u4E00\u7C7B\u5DE5\u5177\u3002")}}Ve.push(""),Ve.push("\u914D\u7F6E\u6587\u4EF6\uFF1A~/.dskcode/permissions.json\uFF08\u5168\u5C40\uFF09"),Ve.push(" .dskcode/permissions.json\uFF08\u9879\u76EE\u7EA7\uFF0C\u9879\u76EE\u7EA7\u4F18\u5148\uFF09"),P(Ge=>[...Ge,{role:"user",content:C},{role:"assistant",content:Ve.join(`
605
- `)}]),A("");return}}}let B=await Oh(C,Md.current);if(B.kind==="no-match"){P(E=>[...E,{role:"user",content:C},{role:"assistant",content:`\u672A\u77E5\u547D\u4EE4\uFF1A${C}\u3002\u8F93\u5165 /help \u67E5\u770B\u3002`}]),A("");return}if(B.kind==="error"){P(E=>[...E,{role:"user",content:C},{role:"assistant",content:`\u26A0 \u6FC0\u6D3B skill \u5931\u8D25\uFF1A${B.message}`}]),A("");return}W=B.text}if(!he.current){P(S=>[...S,{role:"user",content:C},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]),A("");return}if(pe){P(S=>[...S,{role:"user",content:C},{role:"assistant",content:"\u26A0 \u751F\u6210\u4E2D\uFF0C\u8BF7\u7B49\u5F85\u672C\u8F6E\u7ED3\u675F\u518D\u53D1\u65B0\u6D88\u606F\u3002\u5982\u9700\u4E2D\u6B62\u672C\u8F6E\uFF0C\u6309 Ctrl+C\u3002"}]),A("");return}let J=W!==C?(()=>{let S=/^\/(\S+)(?:\s+(.*))?$/.exec(C),M=S?.[1]??"",B=(S?.[2]??"").trim();return B?`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${M} \u2014 ${B}`:`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${M}`})():C;A("");let oe=xh(W,Lt.current);await Fs(W,"local",{displayText:J,thinkingAllowed:Gn||void 0,thinkingEffort:Gn?gr:void 0,responseFormat:Fa!=="text"?Fa:void 0,toolChoice:to,...oe?{extraSystemContext:oe}:{}})},[g,w,Pa,$y,Qr,t,xr,Gn,gr,Fa,to,St,Fn,pe,Ha,Bs,br,Fs,Un,pn,fn]);ge(()=>{!pe&&a&&gd(a.todayTotalCost)},[pe,a]);let Wy=ha(()=>re(q,{flexDirection:"column",flexGrow:1,children:[re(q,{flexDirection:"column",flexGrow:1,children:[!no&&(()=>{let T=Math.max(Math.floor((D-2)*.4),24),C=T,W=D-2-T;return re(q,{flexDirection:"row",marginTop:2,flexGrow:1,children:[re(q,{width:C,flexShrink:0,flexDirection:"column",alignItems:"center",borderStyle:"single",borderColor:"#6a6a6a",paddingX:1,children:[O(q,{children:O(Z,{color:"#5fbedb",bold:!0,children:"DSK Agent"})}),O(q,{children:"\u2500".repeat(Math.max(C-4,8)).split("").map((J,oe)=>O(Z,{color:By[oe],children:J},oe))}),re(q,{flexDirection:"column",alignItems:"flex-start",children:[O(fr,{k:"version",v:`v${Qo}`}),O(fr,{k:"model",v:wn[St]?.displayName??St}),O(fr,{k:"thinking",v:Gn?gr==="max"?"Max":"High":"off"}),O(fr,{k:"skills",v:String(e)}),O(fr,{k:"tools",v:String(r)}),Fn==="plan"&&O(fr,{k:"mode",v:"plan"}),o&&O(fr,{k:"verbose",v:"on"})]})]}),O(q,{width:2,flexShrink:0}),re(q,{width:D-2-T,flexDirection:"column",alignItems:"center",children:[re(q,{flexDirection:"column",alignItems:"center",children:[V!==null?re(Z,{color:"yellow",children:["\u{1F4B0} \u4F59\u989D \xA5",V.toFixed(2)]}):me?O(Z,{color:"yellow",children:"\u23F3 \u67E5\u8BE2\u4F59\u989D..."}):null,un!==null&&re(Z,{color:"cyan",children:["\u{1F4CA} \u4ECA\u65E5 \xA5",un.toFixed(2)]})]}),O(q,{marginTop:1}),Et.length>0&&(()=>{let J=Et[Ts%Et.length];if(!J)return null;let oe=`${J.name} ${J.desc}`;return re(q,{flexDirection:"row",children:[O(Z,{color:"#808080",children:"\u{1F4A1} "}),ja.length>0?oe.split("").map((S,M)=>O(Z,{color:ja[M]||void 0,children:S},M)):O(Z,{color:"#808080",children:oe})]})})(),O(q,{flexGrow:1}),O(Ip,{panelWidth:W})]})]})})(),re(q,{flexDirection:"column",marginTop:1,children:[O(R_,{items:F,children:(_,T)=>{if(_.role==="user")return re(q,{marginTop:1,flexDirection:"row",children:[O(q,{width:1,backgroundColor:"#FF8C00",flexShrink:0}),O(q,{flexGrow:1,paddingLeft:1,children:re(q,{flexDirection:"row",children:[O(q,{width:4,flexShrink:0,children:O(Z,{bold:!0,color:"#FF8C00",children:"\u{1F4AC}"})}),O(q,{flexGrow:1,children:O(Z,{wrap:"wrap",children:_.content})})]})})]},T);if(_.role==="tool")return re(q,{marginTop:1,flexDirection:"row",children:[O(q,{width:1,backgroundColor:"#666666",flexShrink:0}),re(q,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[re(q,{flexDirection:"row",children:[O(q,{width:4,flexShrink:0,children:O(Z,{dimColor:!0,children:"\u{1F527}"})}),O(q,{flexGrow:1,children:O(Z,{dimColor:!0,wrap:"wrap",children:_.content})})]}),_.diff&&O(Fc,{diff:_.diff})]})]},T);let C=_.assistantDetail;return O(qs,{content:_.content,toolCalls:C?.toolCalls,isStreaming:!1,usage:C?.usage,elapsed:C?.elapsed,cost:C?.cost,model:C?.model,toolResults:C?.toolResults},T)}},z),pe&&O(qs,{content:Pa,toolCalls:Qr.length>0?Qr:void 0,isStreaming:!0,usage:Oa,cost:Da,model:Td,toolResults:xd}),$d.phase!=="idle"&&O(ru,{state:$d,contentWidth:D}),ie!==null&&O(q,{borderStyle:"single",borderColor:"cyan",paddingX:1,marginBottom:1,children:O(Z,{color:"cyan",children:"\u27F3 \u914D\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D\uFF08\u8FD0\u884C\u65F6\u751F\u6548\uFF09"})}),O(Lg,{pending:Xa,onResponse:Gy}),!pe&&Ba&&O(q,{marginTop:1,marginLeft:3,children:re(Z,{color:"red",children:["\u26A0 ",Ba]})})]}),_d&&Bn.length>0&&O(nu,{items:Bn})]}),mn?re(q,{marginTop:1,flexDirection:"column",children:[O(Z,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(D)}),re(q,{flexDirection:"column",marginTop:1,children:[O(Z,{bold:!0,color:"#00ffff",children:"\u9009\u62E9\u6A21\u578B\uFF1A"}),hn.map((_,T)=>{let C=wn[_],W=_===St,J=T===Is,oe=J?" > ":" ",S=W?" (\u5F53\u524D)":"";return re(q,{children:[re(Z,{color:J?"#00ff41":void 0,bold:J,children:[oe,C.displayName,S]}),J&&re(Z,{color:"#808080",children:[" \u2014 ",_]})]},_)}),O(q,{marginTop:1,children:O(Z,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),O(Z,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(D)})]}):Wn?re(q,{marginTop:1,flexDirection:"column",children:[O(Z,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(D)}),re(q,{flexDirection:"column",marginTop:1,children:[O(Z,{bold:!0,color:"#ff9800",children:"\u9009\u62E9\u8981\u56DE\u9000\u7684\u68C0\u67E5\u70B9\uFF1A"}),Hn.map((_,T)=>{let C=T===ro,W=C?" > ":" ",J=new Date(_.timestamp).toLocaleTimeString(),oe=_.preview||"(\u7A7A)",S=_.isGitRepo?"":" [\u975E git\uFF0C\u4EC5\u5BF9\u8BDD]";return O(q,{children:re(Z,{color:C?"#ff9800":void 0,bold:C,children:[W,"#",T+1," ",J," `",oe,S,"`"]})},_.index)}),O(q,{marginTop:1,children:O(Z,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),O(Z,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(D)})]}):re(Ug,{children:[Ld==="visible"&&O(q,{marginTop:1,justifyContent:"center",children:O(Z,{color:"#808080",children:"\u21A9 /rewind 1 \u53EF\u64A4\u56DE\u672C\u6B21\u4FEE\u6539"})}),re(q,{flexDirection:"column",children:[O(q,{children:O(Z,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(D-4)})}),re(q,{children:[O(q,{width:4,flexShrink:0,children:O(Z,{bold:!0,color:"#00ff41",children:"\u26A1"})}),re(q,{flexGrow:1,children:[oo?O(Z,{color:"#808080",children:"Ctrl+P \u6587\u4EF6\u641C\u7D22\u4E2D\u2026\uFF08Esc \u53D6\u6D88\uFF09"}):!N&&!pe&&Nn&&Ra.length>0?O(Z,{children:Nn.split("").map((_,T)=>O(Z,{color:Ra[T]??void 0,children:_},T))}):!N&&pe&&Dn&&Ea.length>0?O(Z,{children:Dn.split("").map((_,T)=>O(Z,{color:Ea[T]??void 0,children:_},T))}):O(Mh,{value:N,onChange:A,onSubmit:Bd,placeholder:"",focus:!oo},Ed),Ne!=="idle"&&re(q,{children:[re(Z,{color:Ne==="error"?"red":"cyan",children:[Ne==="connecting"&&"\u25CC \u6B63\u5728\u8FDE\u63A5 ASR \u670D\u52A1...",Ne==="recording"&&`\u25CF \u5F55\u97F3\u4E2D ${Ta}`,Ne==="finalizing"&&`\u25CC \u7B49\u5F85\u670D\u52A1\u7AEF\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C ${Ta}`,Ne==="error"&&`\u2717 \u9519\u8BEF ${Ta}`]}),O(Z,{dimColor:!0,children:" (\u518D\u6309 F2 \u7ED3\u675F\uFF0CESC \u53D6\u6D88)"})]})]})]}),O(q,{children:O(Z,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(D-4)})})]}),fn==="skills"?O(Uc,{skills:t,input:N,selectedIndex:xr,triggerMode:"at"}):O(yh,{commands:Wi(N,ks),input:N,selectedIndex:yr}),O(mh,{servers:so,input:N,selectedIndex:io}),O(Lh,{open:Un,selectedIndex:pn}),!Un&&fn!=="skills"&&fn!=="mcps"&&O(Jc,{files:n,input:N,selectedIndex:br,cwd:process.cwd(),width:D}),O(q,{children:O(Ap,{activeModel:St,thinkingEnabled:Gn,thinkingEffort:gr,balance:V,todayCost:un,sessionCost:Oy,hasConversationStarted:no,isStreaming:pe,streamingPhase:yd,currentUsage:Oa,currentCost:Da,currentElapsed:My,currentToolCalls:Qr,currentToolResults:xd,contextStats:Py,lastRound:Dy})})]})]}),[F,z,pe,Pa,Qr,Oa,Da,Td,Ba,Bn,_d,mn,hn,St,Is,Na,Ps,Wn,Hn,ro,Rs,As,Ld,no,Fn,yd,Nn,Ra,Dn,Ea,N,A,D,Bd,t,xr,n,br,Un,pn,fn,Ed,Et,Ts,ja,e,r,o,V,me,un,Gn,gr]),Hy=typeof process.stdout.rows=="number"?Math.max(process.stdout.rows-4,10):24,Vy=_=>{A(T=>`${T.endsWith(" ")||T.length===0?T:T+" "}@${_} `),jn(T=>T+1),Es(!1)};return re(q,{flexDirection:"column",paddingLeft:1,paddingRight:1,children:[oo&&O(Eh,{files:n,cwd:process.cwd(),width:R,height:Hy,onPick:Vy,onClose:()=>Es(!1)}),!oo&&re(Ug,{children:[Wy,Uy&&!pe&&O(q,{marginTop:1,children:O(Z,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})}),pe&&O(q,{marginTop:1,children:O(Z,{color:"yellow",dimColor:!0,children:" \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42"})})]})]})}function fr({k:e,v:t}){return re(q,{children:[O(Z,{color:"#808080",children:e.padEnd(10," ")}),O(Z,{color:"#d4d4d4",children:t})]})}p();import{Box as ln,Text as mr,useInput as I_}from"ink";import{useState as P_,useCallback as L_}from"react";import{jsx as Qe,jsxs as Wg}from"react/jsx-runtime";function ga({games:e,onSelect:t,onExit:n,onBackToChat:r}){let[o,s]=P_(0),i=r??n??(()=>process.exit(0)),{doubleCtrlC:a,handleCtrlC:l}=zn(i);return I_(L_((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])),Wg(ln,{flexDirection:"column",children:[Qe(ln,{marginBottom:1,children:Qe(mr,{bold:!0,color:"#00ffff",children:"\u{1F3AE} \u6E38\u620F\u5217\u8868"})}),Qe(ln,{flexDirection:"column",children:e.map((c,u)=>{let d=u===o;return Wg(ln,{flexDirection:"row",children:[Qe(ln,{width:3,flexShrink:0,children:d?Qe(mr,{bold:!0,color:"#00ff41",children:"\u25B8 "}):Qe(mr,{children:" "})}),Qe(ln,{width:20,flexShrink:0,children:Qe(mr,{bold:!0,color:d?"#00ff41":"#ffffff",children:c.name})}),Qe(ln,{children:Qe(mr,{color:"#888888",children:c.description})})]},c.id)})}),Qe(ln,{marginTop:1,children:Qe(mr,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE"})}),a&&Qe(ln,{marginTop:1,children:Qe(mr,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}p();p();var nd=new Map;function ya(e){nd.set(e.id,e)}function Hg(e){return nd.get(e)}function ls(){return Array.from(nd.values())}p();import{Box as et,Text as Ce,useInput as $_,render as M_}from"ink";import{useState as rd,useEffect as O_,useRef as Vg,useCallback as od}from"react";import{jsx as be,jsxs as tt}from"react/jsx-runtime";var bt=40,Kr=18,Xr=9,zg=[166,214,76,69],sd=[{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 id(e){return sd[(e-1)%sd.length]}function D_(e){let t=id(e),n=[],r=2,o=t.cols*t.bw+(t.cols-1)*r,s=Math.floor((bt-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 qg(e){let t=id(e),n=t.cols*t.bw+(t.cols-1)*2,r=Math.floor((bt-n)/2);return{level:e,bricks:D_(e),paddleX:Math.floor(bt/2)-Math.floor(Xr/2),ball:{x:bt/2,y:Kr-3},ballDir:{x:1,y:-1},score:0,lives:3,gameOver:!1,win:!1,paused:!1}}function N_(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>=bt-1&&(e.ball.x=bt-1,e.ballDir.x=-1),e.ball.y<=0&&(e.ball.y=0,e.ballDir.y=1),e.ball.y===Kr-1&&e.ball.x>=e.paddleX&&e.ball.x<=e.paddleX+Xr){e.ballDir.y=-1;let n=(e.ball.x-e.paddleX)/Xr;e.ballDir.x=n<.5?-1:1}e.ball.y>Kr&&(e.lives--,e.lives<=0?e.gameOver=!0:(e.ball={x:bt/2,y:Kr-3},e.ballDir={x:1,y:-1},e.paddleX=Math.floor(bt/2)-Math.floor(Xr/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 B_(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%zg.length}for(let r=0;r<Kr;r++){let o="";for(let s=0;s<bt;s++){let i=e.ball.x===s&&e.ball.y===r,a=r===Kr-1&&s>=e.paddleX&&s<e.paddleX+Xr,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;${zg[l]}m\u2580\x1B[0m`:o+=" "}t.push(o)}return t.map(r=>`\u2502${r}\u2502`).join(`
606
- `)}function F_({onExit:e}){let[t,n]=rd(1),[r,o]=rd(!0),s=Vg(qg(t)),[i,a]=rd(0),l=Vg(e);l.current=e,O_(()=>{if(r)return;let g=setInterval(()=>{N_(s.current),a(w=>w+1)},80);return()=>clearInterval(g)},[r]);let c=od(g=>{let w=g??s.current.level;s.current=qg(w),n(w),o(!1),a(0)},[]),u=od(()=>{o(!0)},[]);$_(od((g,w)=>{let b=s.current;if(r){g>="1"&&g<="9"?c(Number(g)):g==="0"?c(10):(w.escape||g==="q")&&l.current();return}w.leftArrow?(b.paddleX=Math.max(0,b.paddleX-1),a(k=>k+1)):w.rightArrow?(b.paddleX=Math.min(bt-Xr,b.paddleX+1),a(k=>k+1)):g==="p"||g===" "?b.paused=!b.paused:g==="r"?(b.gameOver||b.win)&&c():g==="l"?(b.gameOver||b.win)&&u():(g==="q"||w.escape)&&l.current()},[r,c,u]));let d=s.current,f=d.bricks.filter(g=>g.alive).length,h=B_(d),m=id(d.level);return tt(et,{flexDirection:"column",children:[tt(et,{flexDirection:"row",children:[be(et,{width:20,children:tt(Ce,{children:["\u5173\u5361 ",d.level,": ",be(Ce,{color:"cyan",children:m.desc})]})}),be(et,{width:12,children:tt(Ce,{children:["\u5206\u6570: ",be(Ce,{color:"yellow",children:String(d.score).padStart(3,"0")})]})}),be(et,{width:12,children:tt(Ce,{children:["\u751F\u547D: ",be(Ce,{color:"red",children:"\u2665".repeat(Math.max(0,d.lives))})]})}),be(et,{width:10,children:tt(Ce,{children:["\u7816\u5757: ",be(Ce,{color:"cyan",children:f})]})}),be(et,{children:tt(Ce,{color:d.paused?"gray":"green",children:["[",d.paused?"\u6682\u505C":"\u8FD0\u884C\u4E2D","]"]})})]}),tt(et,{flexDirection:"column",children:[tt(Ce,{children:["\u250C","\u2500".repeat(bt),"\u2510"]}),be(Ce,{children:r?" \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m":h}),tt(Ce,{children:["\u2514","\u2500".repeat(bt),"\u2518"]})]}),r&&tt(et,{marginTop:1,flexDirection:"column",children:[be(Ce,{bold:!0,color:"yellow",children:"\u9009\u62E9\u5173\u5361"}),be(et,{flexDirection:"row",flexWrap:"wrap",children:sd.map((g,w)=>be(et,{width:22,children:tt(Ce,{children:[be(Ce,{color:t===w+1?"green":"white",children:w+1===10?"0":String(w+1)}),". ",g.desc," (",g.rows,"\xD7",g.cols,")"]})},w))}),be(et,{marginTop:1,children:be(Ce,{dimColor:!0,children:"\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA"})})]}),!r&&(d.gameOver||d.win)&&tt(et,{marginTop:1,children:[be(Ce,{bold:!0,color:d.gameOver?"red":"green",children:d.gameOver?"\u6E38\u620F\u7ED3\u675F\uFF01":"\u606D\u559C\u901A\u5173\uFF01"}),tt(Ce,{children:[" \u5206\u6570: ",be(Ce,{color:"yellow",children:d.score})]})]}),!r&&be(et,{marginTop:1,children:d.gameOver||d.win?be(Ce,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA"}):be(Ce,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA"})})]})}var Kg={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}=M_(be(F_,{onExit:()=>{t(),e()}}))})}};p();import{Box as Jr,Text as ut,useInput as G_,render as j_}from"ink";import{useState as Xg,useEffect as Jg,useRef as Zg,useCallback as U_}from"react";import{jsx as Rt,jsxs as cn}from"react/jsx-runtime";var wt=66,ty=20,ld=6,W_=10,Zr=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],Yg={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 H_(e){let t=["","","","",""];for(let r of e){let o=Yg[r]??Yg[0];for(let s=0;s<5;s++)t[s]+=" "+(o[s]??"")}let n=6;return t.map(r=>" ".repeat(n)+r)}function ad(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 Qg=["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 V_(e){let t;do t=Qg[Math.floor(Math.random()*Qg.length)];while(e.has(t));return t}function ey(){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 xa(e){let t=null;for(let n of e.words)(!t||n.col<t.col)&&(t=n);return t?.text??null}function z_(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<W_)){let r=new Set(e.usedWords);for(let a of e.words)r.add(a.text);let o=V_(r),s=new Set(e.words.map(a=>a.row)),i=-1;for(let a=ld;a<ty;a++)if(!s.has(a)){i=a;break}i>=0&&(e.words.push({text:o,row:i,col:wt-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=xa(e),e.lives<=0&&(e.gameOver=!0,e.words=[])),e.target=xa(e),e.messageTimer>0&&(e.messageTimer--,e.messageTimer<=0&&(e.message=""))}function q_(e,t,n,r){let o=[];for(let s=0;s<ty;s++){let i="";if(s<ld){if(s<5){let a=(t[s]??"").padEnd(wt);i=`\x1B[38;2;${ad(n)}m${a}\x1B[0m`}else if(s===5){if(e.combo>=3){let a=`${e.combo}\u8FDE\u51FB!`,l=Math.floor((wt-a.length)/2),c=Zr[e.combo%Zr.length],u=" ".repeat(l)+a+" ".repeat(wt-l-a.length);i=`\x1B[38;2;${ad(c)}m${u}\x1B[0m`}else if(e.paused){let l=Math.floor((wt-2)/2);i=" ".repeat(l)+"\u6682\u505C",i=i.padEnd(wt)}}i=i.padEnd(wt)}else if(s===ld&&r){let a=Math.floor((wt-r.length)/2),l=" ".repeat(a)+r+" ".repeat(wt-a-r.length),c=Zr[Math.floor(Math.random()*Zr.length)];i=`\x1B[38;2;${ad(c)}m${l}\x1B[0m`}else for(let a=0;a<wt;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,f=e.target===l.text?e.typed.length:0,h=d&&c<f;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 K_({onExit:e}){let t=Zg(ey()),[n,r]=Xg(0),[o,s]=Xg(0),i=Zg(e);i.current=e,Jg(()=>{let f=setInterval(()=>{s(h=>(h+1)%Zr.length)},400);return()=>clearInterval(f)},[]),Jg(()=>{let f=setInterval(()=>{z_(t.current),r(h=>h+1)},60);return()=>clearInterval(f)},[]),G_(U_((f,h)=>{let m=t.current;if(m.gameOver){f==="r"?(t.current=ey(),r(0)):(f==="q"||h.escape)&&i.current();return}if(f==="p"&&h.ctrl||f===" "){m.paused=!m.paused;return}if(f==="q"&&h.ctrl||h.escape){i.current();return}if(!m.paused&&f.length===1&&f>="a"&&f<="z"&&(m.target||(m.target=xa(m)),m.target))if(m.target[m.typed.length]===f){if(m.typed+=f,m.typed===m.target){m.words=m.words.filter(R=>R.text!==m.target),m.combo++;let w=m.score,b=m.target.length,k=m.combo>=3?m.score:0;m.score+=b+k,m.speed=m.speed+.02;let v=Math.floor(w/500);Math.floor(m.score/500)>v&&(m.speed+=.15),m.score>=1e5&&w<1e5&&(m.message="\u606D\u559C\u901A\u5173! \u96BE\u5EA6\u6700\u5927\u5316!",m.messageTimer=100),m.typed="",m.target=xa(m)}}else m.combo=0},[]));let a=t.current,l=Zr[o],c=String(a.score).padStart(5,"0"),u=H_(c),d=q_(a,u,l,a.message);return cn(Jr,{flexDirection:"column",paddingX:1,children:[Rt(Jr,{flexDirection:"row",children:cn(ut,{children:["\u751F\u547D ",Rt(ut,{color:"red",children:"\u2665".repeat(Math.max(0,a.lives))})," ","\u901F\u5EA6 ",cn(ut,{color:"cyan",children:["Lv.",Math.floor(a.speed*10)]})]})}),!a.gameOver&&a.target&&Rt(Jr,{marginTop:1,children:cn(ut,{children:["\u6253\u5B57: ",Rt(ut,{color:"green",children:a.typed}),Rt(ut,{color:"white",children:a.target.slice(a.typed.length)})]})}),cn(Jr,{flexDirection:"column",marginTop:1,children:[cn(ut,{children:["\u250C","\u2500".repeat(wt),"\u2510"]}),d.map((f,h)=>Rt(ut,{children:`\u2502${f}\u2502`},h)),cn(ut,{children:["\u2514","\u2500".repeat(wt),"\u2518"]})]}),a.gameOver&&cn(Jr,{marginTop:1,children:[Rt(ut,{bold:!0,color:"red",children:"\u6E38\u620F\u7ED3\u675F\uFF01"}),cn(ut,{children:[" \u5F97\u5206: ",Rt(ut,{color:"yellow",children:a.score})," r \u91CD\u5F00 q \u9000\u51FA"]})]}),Rt(Jr,{marginTop:1,children:Rt(ut,{dimColor:!0,children:"\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA"})})]})}var ny={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}=j_(Rt(K_,{onExit:()=>{t(),e()}}))})}};p();p();function X_(e,t){return e==="UP"&&t==="DOWN"||e==="DOWN"&&t==="UP"||e==="LEFT"&&t==="RIGHT"||e==="RIGHT"&&t==="LEFT"}function cd(e,t){return e.x===t.x&&e.y===t.y}function J_(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 Z_(e,t){return{x:(e.x%t.width+t.width)%t.width,y:(e.y%t.height+t.height)%t.height}}function ud(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 dd(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=ud(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 oy(e,t){e.direction=e.nextDirection;let n=e.snake[0],r=J_(n,e.direction);if(r.x<0||r.x>=t.width||r.y<0||r.y>=t.height)if(e.wallWrap)r=Z_(r,t);else{e.isGameOver=!0;return}let s=cd(r,e.food.position),i=e.specialFood!==null&&cd(r,e.specialFood.position),l=s||i?e.snake:e.snake.slice(0,-1);for(let c of l)if(cd(r,c)){e.isGameOver=!0;return}if(e.snake.unshift(r),s){e.score+=1,ry(e,t);let c=e.specialFood?[e.specialFood.position]:[],u=ud(e.snake,t,"normal",c);if(u)e.food=u;else{e.isGameOver=!0;return}e.specialFood===null&&Math.random()<.25&&(e.specialFood=ud(e.snake,t,"special",[e.food.position]))}else i?(e.score+=3,ry(e,t),e.specialFood=null):e.snake.pop();e.specialFood?.spawnedAt!==void 0&&Date.now()-e.specialFood.spawnedAt>5e3&&(e.specialFood=null)}function ry(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 sy(e,t){X_(t,e.direction)||(e.nextDirection=t)}p();import Oe from"chalk";var iy=2,Y_=" ",Q_="\u2593",ev="\u2593",tv="\u25C6",nv="\u2605",cs="\x1B[",rv=`${cs}?25l`,ov=`${cs}?25h`,ay=`${cs}H`;function ly(){process.stdout.write(rv)}function cy(){process.stdout.write(ov)}function uy(){process.stdout.write(`${cs}2J${ay}`)}function sv(e,t){switch(t){case"snake-head":return Oe.greenBright(e);case"snake-body":return Oe.green(e);case"normal-food":return Oe.red(e);case"special-food":return Oe.yellow(e);case"empty":return e}}function dy(e,t){let n=iv(e,t);process.stdout.write(`${cs}2J${ay}`+n.join(`
607
- `))}function iv(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(" "+Oe.gray("\u2554"+"\u2550\u2550".repeat(n)+"\u2557"));for(let l=0;l<r;l++){let c=" "+Oe.gray("\u2551");for(let u=0;u<n;u++){let d=s[l][u],f;switch(d){case"snake-head":f=ev.repeat(iy);break;case"snake-body":f=Q_.repeat(iy);break;case"normal-food":f=tv+" ";break;case"special-food":f=nv+" ";break;default:f=Y_}c+=sv(f,d)}c+=Oe.gray("\u2551"),o.push(c)}if(o.push(" "+Oe.gray("\u255A"+"\u2550\u2550".repeat(n)+"\u255D")),o.push(""),o.push(` ${Oe.cyan("\u5206\u6570")}: ${e.score} ${Oe.cyan("\u957F\u5EA6")}: ${e.snake.length} ${Oe.cyan("\u901F\u5EA6")}: Lv.${e.speedLevel} ${Oe.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(` ${Oe.yellow(`\u2B50 \u7279\u6B8A\u98DF\u7269 ${l} \u79D2\u540E\u6D88\u5931`)}`)}return o.push(` ${Oe.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(` ${Oe.yellow("\u23F8 \u5DF2\u6682\u505C \u2014 \u6309 P \u7EE7\u7EED")}`)),e.isGameOver&&(o.push(""),o.push(` ${Oe.red.bold("\u{1F480} \u6E38\u620F\u7ED3\u675F!")} ${Oe.cyan("\u6700\u7EC8\u5206\u6570: "+e.score)}`),o.push(` ${Oe.gray("\u6309 R \u91CD\u65B0\u5F00\u59CB | \u6309 Q \u9000\u51FA")}`)),o}p();import*as py from"readline";var av={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 fy(e,t,n){py.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=av[i];c&&sy(l,c)};return process.stdin.on("keypress",r),()=>{process.stdin.removeListener("keypress",r),process.stdin.isTTY&&process.stdin.setRawMode(!1)}}var ba={width:20,height:16,initialSpeed:180,minSpeed:60,speedDecrement:10,scorePerLevel:5},lv=200,cv={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:dd(ba)};return new Promise(t=>{let n=fy(e,()=>{r=!0,clearTimeout(o),cy(),n(),t()},()=>dd(ba));uy(),ly();let r=!1,o;function s(){if(r)return;let i=e.state;!i.isGameOver&&!i.isPaused&&oy(i,ba),dy(i,ba);let a=i.isGameOver||i.isPaused?lv:i.tickInterval;o=setTimeout(s,a)}o=setTimeout(s,0)})}},my=cv;function pd(){return ya(Kg),ya(ny),ya(my),ls()}import{render as Ry}from"ink";import At from"chalk";p();p();import{Box as Y,Text as te,useInput as uv}from"ink";import{useState as kt,useCallback as hy,useEffect as us,useMemo as dv}from"react";import fd from"asciichart";import pv from"os";import{join as fv}from"path";import{jsx as G,jsxs as De}from"react/jsx-runtime";var gy=fv(pv.homedir(),".dskcode","settings.json");function mv(e){let t=e.replace(/\\/g,"/");return process.platform==="win32"?"file://"+t.replace(/^([a-zA-Z]:)/,"/$1"):"file://"+t}function hv(e,t){return`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`}var gv="https://web.ifzq.gtimg.cn/appstock/app/minute/query?code={code}&r=0.1";function yy(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 xy(e){let t=gv.replace("{code}",yy(e));try{let r=await(await fetch(t)).json();if(r.code!==0)return null;let o=yy(e),s=r.data?.[o];if(!s)return null;let i=s.data?.data??[],a=[];for(let d of i){let f=d.split(" ");if(f.length>=2){let h=parseFloat(f[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 by=new Map;function wy(e,t){by.set(e,t)}var yv=[{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 xv(e){let n=(await Promise.all(e.map(async r=>{let o=await xy(r);return o?.quote?(o.prices.length>0&&wy(r,o.prices),o.quote):null}))).filter(r=>r!==null);return n.length>0?n:yv}function wa(e){return e>=100?e.toFixed(2):e.toFixed(3)}function bv(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 wv(e,t=60){return e.length<=t?e:e.slice(e.length-t)}function ka({codes:e,onExit:t,onBackToChat:n}){let[r,o]=kt([]),[s,i]=kt(0),[a,l]=kt(!0),[c,u]=kt(""),[d,f]=kt(null),[h,m]=kt(null),[g,w]=kt(!1),[b,k]=kt(10),[v,I]=kt(5),[R,D]=kt(()=>new Date().toLocaleTimeString("zh-CN",{hour12:!1})),[F,P]=kt(!1),[z,j]=kt("default"),N=dv(()=>z==="default"?r:[...r].toSorted((V,fe)=>z==="desc"?fe.changePercent-V.changePercent:V.changePercent-fe.changePercent),[r,z]),{doubleCtrlC:A,handleCtrlC:ie}=zn(t);us(()=>{let V=setInterval(()=>{D(new Date().toLocaleTimeString("zh-CN",{hour12:!1}))},1e3);return()=>clearInterval(V)},[]);let ne=hy(async()=>{l(!0);try{let V=await xv(e??[]);o(V),u(new Date().toLocaleTimeString())}catch{}l(!1)},[e]);if(us(()=>{ne()},[ne]),us(()=>{let V=setInterval(()=>{I(fe=>fe<=1?(ne(),5):fe-1)},1e3);return()=>clearInterval(V)},[ne]),us(()=>{if(d){let V=()=>{by.delete(d.code),xy(d.code).then(me=>{me&&me.prices.length>0&&(wy(d.code,me.prices),m(me.prices))})};V(),k(10);let fe=setInterval(V,1e4);return()=>clearInterval(fe)}m(null),w(!1)},[d]),us(()=>{if(!d)return;let V=setInterval(()=>{k(fe=>fe>0?fe-1:10)},1e3);return()=>clearInterval(V)},[d]),uv(hy((V,fe)=>{if(V==="c"&&fe.ctrl){ie();return}if(d){(fe.escape||V==="q"||V===" ")&&f(null);return}if(r.length!==0)if(fe.upArrow||V==="k")i(me=>me>0?me-1:r.length-1);else if(fe.downArrow||V==="j")i(me=>me<r.length-1?me+1:0);else if(fe.return){let me=r[s];me&&f(me)}else fe.escape||V==="q"?n?n():t():V==="r"?(I(5),ne()):V==="o"?j(me=>me==="default"?"desc":me==="desc"?"asc":"default"):V==="h"&&P(me=>!me)},[r,s,d,t,n,ne,ie,P])),d)return g?G(Y,{paddingLeft:1,children:G(te,{dimColor:!0,children:" \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..."})}):kv(d,()=>f(null),h??void 0,b,R);let Q=V=>F?{dimColor:!0}:{color:V};return De(Y,{flexDirection:"column",children:[De(Y,{marginBottom:1,justifyContent:"space-between",children:[G(te,{bold:!0,...Q("#00ffff"),children:" \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7"}),De(te,{dimColor:!0,children:[" \u{1F550} ",R]}),G(te,{dimColor:!0,children:a?" \u27F3 \u5237\u65B0\u4E2D...":` ${v}s \u540E\u81EA\u52A8\u5237\u65B0`})]}),De(Y,{children:[G(Y,{width:3}),G(Y,{width:9,children:G(te,{dimColor:!0,children:"\u4EE3\u7801"})}),G(Y,{width:16,children:G(te,{dimColor:!0,children:"\u540D\u79F0"})}),G(Y,{width:12,children:G(te,{dimColor:!0,children:"\u6700\u65B0\u4EF7"})}),G(Y,{width:12,children:De(te,{dimColor:!0,children:["\u6DA8\u8DCC\u5E45",z==="desc"?" \u25BC":z==="asc"?" \u25B2":""]})}),G(Y,{width:12,children:G(te,{dimColor:!0,children:"\u6DA8\u8DCC\u989D"})}),G(Y,{width:12,children:G(te,{dimColor:!0,children:"\u6700\u9AD8"})}),G(Y,{width:12,children:G(te,{dimColor:!0,children:"\u6700\u4F4E"})}),G(Y,{children:G(te,{dimColor:!0,children:"\u6210\u4EA4\u989D"})})]}),G(Y,{children:G(te,{dimColor:!0,children:" "+"\u2500".repeat(100)})}),G(Y,{flexDirection:"column",children:N.map((V,fe)=>{let me=fe===s,hr=V.changePercent>=0,un=hr?"#ff1493":"#00ff41";return De(Y,{children:[G(Y,{width:3,flexShrink:0,children:me?G(te,{bold:!0,...Q("#00ffff"),children:"\u25B8 "}):G(te,{children:" "})}),G(Y,{width:9,children:G(te,{bold:!0,...Q(me?"#00ffff":"#ffffff"),children:V.code})}),G(Y,{width:16,children:G(te,{...Q(me?"#ffffff":"#cccccc"),children:V.name})}),G(Y,{width:12,children:G(te,{bold:!0,...Q(un),children:wa(V.price)})}),G(Y,{width:12,children:De(te,{...Q(un),children:[hr?"+":"",V.changePercent.toFixed(2),"%"]})}),G(Y,{width:12,children:De(te,{...Q(un),children:[hr?"+":"",V.changeAmount.toFixed(3)]})}),G(Y,{width:12,children:G(te,{...Q("#cccccc"),children:wa(V.high)})}),G(Y,{width:12,children:G(te,{...Q("#888888"),children:wa(V.low)})}),G(Y,{children:G(te,{...Q("#888888"),children:bv(V.amount)})})]},V.code)})}),G(Y,{marginTop:1,children:G(te,{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"})}),De(Y,{children:[G(te,{dimColor:!0,children:` \u6700\u540E\u66F4\u65B0: ${c} \u7F16\u8F91\u81EA\u9009\u80A1: `}),G(te,{...Q("#c792ea"),children:hv(mv(gy),gy)})]}),A&&G(Y,{marginTop:1,children:G(te,{bold:!0,...Q("#ff1493"),children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}function kv(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?fd.red:fd.green,u=wv(n,60),d=fd.plot(u,{height:10,colors:[c]});d=d.replaceAll("\u256D","\u250C").replaceAll("\u256E","\u2510").replaceAll("\u2570","\u2514").replaceAll("\u256F","\u2518"),l=d.split(`
608
- `)}return De(Y,{flexDirection:"column",paddingLeft:1,children:[De(Y,{marginBottom:1,justifyContent:"space-between",children:[De(Y,{children:[De(te,{bold:!0,color:"#00ffff",children:[" \u{1F4CA} ",e.name," "]}),G(te,{dimColor:!0,children:e.code}),o&&De(te,{dimColor:!0,children:[" \u{1F550} ",o]})]}),G(te,{dimColor:!0,children:`${r}s \u540E\u5237\u65B0`})]}),De(Y,{children:[G(Y,{width:16,children:G(te,{bold:!0,color:"#888888",children:"\u5F53\u524D\u4EF7"})}),G(Y,{children:De(te,{bold:!0,color:i,children:[a," ",wa(e.price)]})})]}),De(Y,{children:[G(Y,{width:16,children:G(te,{color:"#888888",children:"\u6DA8\u8DCC\u5E45"})}),G(Y,{children:De(te,{color:i,children:[s?"+":"",e.changePercent.toFixed(2),"%"," ",s?"+":"",e.changeAmount.toFixed(3)]})})]}),l.length>0&&G(Y,{marginTop:1,flexDirection:"column",children:l.map((c,u)=>G(Y,{children:G(te,{color:i,children:c||" "})},u))}),G(Y,{marginTop:1,children:G(te,{dimColor:!0,children:" Space/q \u8FD4\u56DE\u5217\u8868"})})]})}p();import{readdir as Sv,realpath as Tv}from"fs/promises";import{join as ky,relative as Cv}from"path";var _v=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 Sy(e,t,n=1/0,r){let o=t??e,s=r??new Set;try{let d=await Tv(o);if(s.has(d))return[];s.add(d)}catch{}let i;try{i=await Sv(o,{withFileTypes:!0})}catch{return[]}let a=[],l=[];for(let d of i){let f=d.name;_v.has(f)||f.startsWith(".")||(d.isDirectory()?l.push(f):d.isFile()&&a.push(Cv(e,ky(o,f))))}let c=t===void 0?n:Math.max(0,n-1),u=c<=1?[]:await Promise.all(l.map(d=>Sy(e,ky(o,d),c,s)));for(let d of u)a.push(...d);return a}var vv=8;async function Ty(e){return Sy(e,void 0,vv)}import{jsx as Yr}from"react/jsx-runtime";var Iv=["chat","run","setup","init","completion","game","stock","config-ui"];function Ay(){let e=new Rv;return e.exitOverride(),e.name("dskcode").description("\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\u7EC8\u7AEF\u5DE5\u5177").version(Qo,"-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=()=>np(e),e.hook("preAction",async(t,n)=>{let r=await tp.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 _y(this)}),e.action(async function(){let t=this;if(t.opts().ws){let{startConfigUi:r}=await import("./config-ui-W3XDQASQ.js");await r({});return}await _y(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
610
+ \u8F93\u5165 /plan \u5207\u6362\u4E3A\u8BA1\u5212\u6A21\u5F0F\uFF08\u53EA\u8BFB\u5206\u6790\uFF09\u3002`}]),me.current?.reset()),O("");return}if($==="/tools"){let v=oo===void 0?"none":oo==="none"?"required":oo==="required"?"auto":void 0;Es(v);let P=v===void 0?"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09":v==="none"?"\u7981\u6B62\u8C03\u7528":v==="required"?"\u5F3A\u5236\u8C03\u7528":"\u81EA\u52A8\uFF08\u9ED8\u8BA4\uFF09";C(D=>[...D,{role:"user",content:w},{role:"assistant",content:`\u5DE5\u5177\u8C03\u7528\u7B56\u7565\u5DF2\u5207\u6362\u4E3A ${P}`}]),O("");return}if($==="/mcp"||$.startsWith("/mcp ")){let v=$t.current;if(!v){C(z=>[...z,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u5F53\u524D\u672A\u542F\u52A8 MCP registry\uFF08mcpServers \u4E3A\u7A7A\u6216 Session \u672A\u5C31\u7EEA\uFF09\u3002"}]),O("");return}let P=async()=>{T&&await v.reconcile(T)},D=await Jg(w,v,P);if(D.kind==="no-match")return;if(D.kind==="error"){C(z=>[...z,{role:"user",content:w},{role:"assistant",content:`\u26A0 /mcp: ${D.message}`}]),O("");return}if(D.kind==="text"){C(z=>[...z,{role:"user",content:w},{role:"assistant",content:D.text}]),O("");return}if(D.kind==="restart"){go.sharedInstance().restart(D.serverId),C(nt=>[...nt,{role:"user",content:w},{role:"assistant",content:`\u27F2 \u6B63\u5728\u91CD\u542F MCP server "${D.serverId}"...`}]),O("");return}if(D.kind==="reload"){await P(),C(z=>[...z,{role:"user",content:w},{role:"assistant",content:"\u27F2 MCP \u914D\u7F6E\u5DF2\u91CD\u8F7D\u3002"}]),O("");return}}if($==="/goal"||$.startsWith("/goal ")){let v=w.slice(5).trim(),P=me.current;if(!P){C(D=>[...D,{role:"user",content:w},{role:"assistant",content:"\u26A0 Session \u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}]),O("");return}if(v===""){let D=P.getGoal(),z=D?ev(D):"\uFF08\u65E0 /goal\uFF09\u8F93\u5165 `/goal <condition>` \u542F\u52A8\u4E00\u4E2A\u76EE\u6807\u5FAA\u73AF\u3002";C(nt=>[...nt,{role:"user",content:w},{role:"assistant",content:z}]),O("");return}if(v==="pause"||v==="resume"||v==="clear"){let D;if(v==="pause"){let z=P.pauseGoal();D=z?`\u25CC /goal paused\uFF08turns=${z.turnCount}\uFF09\u3002\u6062\u590D\uFF1A/goal resume`:"\u26A0 \u65E0 active /goal \u53EF\u6682\u505C\u3002"}else if(v==="resume"){let z=P.resumeGoal();D=z&&z.status==="active"?`\u25CE /goal resumed\uFF1A${yr(z.condition,60)}`:"\u26A0 \u65E0 paused /goal \u53EF\u6062\u590D\u3002"}else P.clearGoal(),D="\u2713 /goal cleared\u3002";pn(),C(z=>[...z,{role:"user",content:w},{role:"assistant",content:D}]),O("");return}if(v==="status"){let D=P.getGoal();C(z=>[...z,{role:"user",content:w},{role:"assistant",content:D?tv(D,P.accumulatedCost):"\uFF08\u65E0 /goal\uFF09"}]),O("");return}if(de){C(D=>[...D,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u751F\u6210\u4E2D\uFF0C\u8BF7\u7B49\u5F85\u672C\u8F6E\u7ED3\u675F\u518D\u8BBE\u7F6E /goal\u3002"}]),O("");return}try{let D=P.setGoal(v);pn(),C(z=>[...z,{role:"user",content:w},{role:"assistant",content:`\u25CE /goal started
611
+ condition: ${D.condition}
612
+ limits: maxTurns=${D.maxTurns}, maxTokens=${D.maxTokens}, maxWallMs=${D.maxWallMs}
613
+ \u6B63\u5728\u4EE5\u8BE5 condition \u4F5C\u4E3A\u672C\u8F6E\u4EFB\u52A1\u542F\u52A8\uFF1B\u6BCF\u8F6E\u7ED3\u675F\u540E\u4F1A\u81EA\u52A8\u8BC4\u4F30\uFF0C\u8FBE\u6210\u5219\u505C\u3002`}]),O(""),await mo(v,"local",{displayText:`[goal] ${v}`})}catch(D){C(z=>[...z,{role:"user",content:w},{role:"assistant",content:`\u26A0 /goal \u5931\u8D25\uFF1A${D instanceof Error?D.message:String(D)}`}]),O("")}return}let R=yd.get($);if(R){let v=R.handler();switch(v.kind){case"exit":await me.current?.flushLog(),process.exit(0);return;case"clear":C([]),oe(P=>P+1),O(""),_s(void 0),process.stdout.write("\x1B[2J\x1B[H\x1B[3J"),me.current?.reset(),ro.current=-1;return;case"navigate":O(""),v.target==="game"?g?.():v.target==="stock"&&b?.();return;case"text":C(P=>[...P,{role:"user",content:w},{role:"assistant",content:v.content}]),O("");return;case"permissions":{let P=me.current;if(!P){C(Fe=>[...Fe,{role:"user",content:w},{role:"assistant",content:"Session \u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}]),O("");return}let D=P.gate,z=[],nt=0,Cr="",qs="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09";if(D instanceof On){let Fe=D.gates;Cr=Fe.length===0?"(\u7A7A)":`\u5171 ${Fe.length} \u4E2A`;try{let Lt=(await import("./interactive-gate-UBPGIMF2.js")).InteractiveGate;for(let rt of Fe)rt instanceof Lt&&(z=rt.engine.rules,nt=rt.grants.size,qs="\u89C4\u5219\u5F15\u64CE")}catch{}z.length===0&&(qs="\u5199\u786E\u8BA4\uFF08\u9ED8\u8BA4\uFF09")}else qs="\u672A\u77E5";let Ve=[];if(Ve.push("\u{1F4CB} \u5F53\u524D\u6743\u9650\u7CFB\u7EDF\u72B6\u6001\uFF1A"),Ve.push(` Gate \u94FE\uFF1A${Cr}`),Ve.push(` \u6A21\u5F0F\uFF1A${qs??"\u672A\u77E5"}`),z.length===0)Ve.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{Ve.push(` \u89C4\u5219\u6570\uFF1A${z.length}`);for(let Fe=0;Fe<z.length;Fe++){let ft=z[Fe],Lt=ft.match?JSON.stringify(ft.match):"(\u5168\u90E8\u5339\u914D)",rt=ft.reason?` \u2014 ${ft.reason}`:"";Ve.push(` ${Fe+1}. ${ft.tool} \u2192 ${ft.action}\uFF08${Lt}\uFF09${rt}`)}}Ve.push(` \u4F1A\u8BDD grants\uFF1A${nt} \u4E2A\uFF08"always" \u6279\u51C6\u7684\u5DE5\u5177\u8C03\u7528\uFF09`);let rp=$t.current;if(rp){let Fe=rp.tools();if(Fe.length>0){let ft=new Map;for(let Lt of Fe){let rt=/^mcp_([^_]+(?:_[^_]+)*)_/.exec(Lt.name),op=rt&&rt[1]?rt[1]:"?",sp=rt?Lt.name.slice(rt[0].length):Lt.name,ip=ft.get(op);ip?ip.push(sp):ft.set(op,[sp])}Ve.push(""),Ve.push(`MCP \u5DE5\u5177\uFF08\u5171 ${Fe.length} \u4E2A\uFF0C${ft.size} \u4E2A server\uFF09\uFF1A`);for(let[Lt,rt]of ft)Ve.push(` [${Lt}] ${rt.length} \u4E2A\uFF1Amcp_${Lt}_*`);Ve.push(" \u5728 permissions \u6BB5\u52A0 mcp_<server>_ \u524D\u7F00\u89C4\u5219\u53EF\u7EDF\u4E00\u653E\u884C/\u62D2\u7EDD\u4E00\u7C7B\u5DE5\u5177\u3002")}}Ve.push(""),Ve.push("\u914D\u7F6E\u6587\u4EF6\uFF1A~/.dskcode/permissions.json\uFF08\u5168\u5C40\uFF09"),Ve.push(" .dskcode/permissions.json\uFF08\u9879\u76EE\u7EA7\uFF0C\u9879\u76EE\u7EA7\u4F18\u5148\uFF09"),C(Fe=>[...Fe,{role:"user",content:w},{role:"assistant",content:Ve.join(`
614
+ `)}]),O("");return}}}let B=await eg(w,Yd.current);if(B.kind==="no-match"){C(v=>[...v,{role:"user",content:w},{role:"assistant",content:`\u672A\u77E5\u547D\u4EE4\uFF1A${w}\u3002\u8F93\u5165 /help \u67E5\u770B\u3002`}]),O("");return}if(B.kind==="error"){C(v=>[...v,{role:"user",content:w},{role:"assistant",content:`\u26A0 \u6FC0\u6D3B skill \u5931\u8D25\uFF1A${B.message}`}]),O("");return}H=B.text}if(!me.current){C($=>[...$,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u65E0\u6CD5\u8FDE\u63A5\u5230 Provider\u3002\u8BF7\u68C0\u67E5 API Key \u548C\u7F51\u7EDC\u914D\u7F6E\u3002"}]),O("");return}if(de){C($=>[...$,{role:"user",content:w},{role:"assistant",content:"\u26A0 \u751F\u6210\u4E2D\uFF0C\u8BF7\u7B49\u5F85\u672C\u8F6E\u7ED3\u675F\u518D\u53D1\u65B0\u6D88\u606F\u3002\u5982\u9700\u4E2D\u6B62\u672C\u8F6E\uFF0C\u6309 Ctrl+C\u3002"}]),O("");return}let Q=H!==w?(()=>{let $=/^\/(\S+)(?:\s+(.*))?$/.exec(w),R=$?.[1]??"",B=($?.[2]??"").trim();return B?`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${R} \u2014 ${B}`:`\u{1F4E6} \u5DF2\u52A0\u8F7D Skill: ${R}`})():w;O("");let ae=Nh(H,$t.current);await mo(H,"local",{displayText:Q,thinkingAllowed:jn||void 0,thinkingEffort:jn?kr:void 0,responseFormat:za!=="text"?za:void 0,toolChoice:oo,...ae?{extraSystemContext:ae}:{}})},[g,b,Ba,Yy,no,t,wr,jn,kr,za,oo,St,Fn,de,Ja,zs,Tr,mo,Hn,fn,mn]);ye(()=>{!de&&a&&Ld(a.todayTotalCost)},[de,a]);let cx=Ta(()=>ie(X,{flexDirection:"column",flexGrow:1,children:[ie(X,{flexDirection:"column",flexGrow:1,children:[!so&&(()=>{let S=Math.max(Math.floor((F-2)*.4),24),w=S,H=F-2-S;return ie(X,{flexDirection:"row",marginTop:2,flexGrow:1,children:[ie(X,{width:w,flexShrink:0,flexDirection:"column",alignItems:"center",borderStyle:"single",borderColor:"#6a6a6a",paddingX:1,children:[G(X,{children:G(ee,{color:"#5fbedb",bold:!0,children:"DSK Agent"})}),G(X,{children:"\u2500".repeat(Math.max(w-4,8)).split("").map((Q,ae)=>G(ee,{color:ox[ae],children:Q},ae))}),ie(X,{flexDirection:"column",alignItems:"flex-start",children:[G(gr,{k:"version",v:`v${is}`}),G(gr,{k:"model",v:wn[St]?.displayName??St}),G(gr,{k:"thinking",v:jn?kr==="max"?"Max":"High":"off"}),G(gr,{k:"skills",v:String(e)}),G(gr,{k:"tools",v:String(r)}),Fn==="plan"&&G(gr,{k:"mode",v:"plan"}),o&&G(gr,{k:"verbose",v:"on"})]})]}),G(X,{width:2,flexShrink:0}),ie(X,{width:F-2-S,flexDirection:"column",alignItems:"center",children:[ie(X,{flexDirection:"column",alignItems:"center",children:[K!==null?ie(ee,{color:"yellow",children:["\u{1F4B0} \u4F59\u989D \xA5",K.toFixed(2)]}):ge?G(ee,{color:"yellow",children:"\u23F3 \u67E5\u8BE2\u4F59\u989D..."}):null,un!==null&&ie(ee,{color:"cyan",children:["\u{1F4CA} \u4ECA\u65E5 \xA5",un.toFixed(2)]})]}),G(X,{marginTop:1}),Et.length>0&&(()=>{let Q=Et[Ps%Et.length];if(!Q)return null;let ae=`${Q.name} ${Q.desc}`;return ie(X,{flexDirection:"row",children:[G(ee,{color:"#808080",children:"\u{1F4A1} "}),qa.length>0?ae.split("").map(($,R)=>G(ee,{color:qa[R]||void 0,children:$},R)):G(ee,{color:"#808080",children:ae})]})})(),G(X,{flexGrow:1}),G(Xp,{panelWidth:H})]})]})})(),ie(X,{flexDirection:"column",marginTop:1,children:[G(Z_,{items:M,children:(_,S)=>{if(_.role==="user")return ie(X,{marginTop:1,flexDirection:"row",children:[G(X,{width:1,backgroundColor:"#FF8C00",flexShrink:0}),G(X,{flexGrow:1,paddingLeft:1,children:ie(X,{flexDirection:"row",children:[G(X,{width:4,flexShrink:0,children:G(ee,{bold:!0,color:"#FF8C00",children:"\u{1F4AC}"})}),G(X,{flexGrow:1,children:G(ee,{wrap:"wrap",children:_.content})})]})})]},S);if(_.role==="tool")return ie(X,{marginTop:1,flexDirection:"row",children:[G(X,{width:1,backgroundColor:"#666666",flexShrink:0}),ie(X,{flexGrow:1,paddingLeft:1,flexDirection:"column",children:[ie(X,{flexDirection:"row",children:[G(X,{width:4,flexShrink:0,children:G(ee,{dimColor:!0,children:"\u{1F527}"})}),G(X,{flexGrow:1,children:G(ee,{dimColor:!0,wrap:"wrap",children:_.content})})]}),_.diff&&G(Kc,{diff:_.diff})]})]},S);let w=_.assistantDetail;return G(ei,{content:_.content,toolCalls:w?.toolCalls,isStreaming:!1,usage:w?.usage,elapsed:w?.elapsed,cost:w?.cost,model:w?.model,toolResults:w?.toolResults},S)}},N),de&&G(ei,{content:Ba,toolCalls:no.length>0?no:void 0,isStreaming:!0,usage:Ua,cost:Wa,model:Fd,toolResults:Od}),Zd.phase!=="idle"&&G(pu,{state:Zd,contentWidth:F}),ce!==null&&G(X,{borderStyle:"single",borderColor:"cyan",paddingX:1,marginBottom:1,children:G(ee,{color:"cyan",children:"\u27F3 \u914D\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D\uFF08\u8FD0\u884C\u65F6\u751F\u6548\uFF09"})}),G(Zg,{pending:tl,onResponse:ix}),!de&&Va&&G(X,{marginTop:1,marginLeft:3,children:ie(ee,{color:"red",children:["\u26A0 ",Va]})})]}),Ud&&Gn.length>0&&G(du,{items:Gn})]}),hn?ie(X,{marginTop:1,flexDirection:"column",children:[G(ee,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(F)}),ie(X,{flexDirection:"column",marginTop:1,children:[G(ee,{bold:!0,color:"#00ffff",children:"\u9009\u62E9\u6A21\u578B\uFF1A"}),gn.map((_,S)=>{let w=wn[_],H=_===St,Q=S===Bs,ae=Q?" > ":" ",$=H?" (\u5F53\u524D)":"";return ie(X,{children:[ie(ee,{color:Q?"#00ff41":void 0,bold:Q,children:[ae,w.displayName,$]}),Q&&ie(ee,{color:"#808080",children:[" \u2014 ",_]})]},_)}),G(X,{marginTop:1,children:G(ee,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),G(ee,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(F)})]}):Vn?ie(X,{marginTop:1,flexDirection:"column",children:[G(ee,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(F)}),ie(X,{flexDirection:"column",marginTop:1,children:[G(ee,{bold:!0,color:"#ff9800",children:"\u9009\u62E9\u8981\u56DE\u9000\u7684\u68C0\u67E5\u70B9\uFF1A"}),zn.map((_,S)=>{let w=S===lo,H=w?" > ":" ",Q=new Date(_.timestamp).toLocaleTimeString(),ae=_.preview||"(\u7A7A)",$=_.isGitRepo?"":" [\u975E git\uFF0C\u4EC5\u5BF9\u8BDD]";return G(X,{children:ie(ee,{color:w?"#ff9800":void 0,bold:w,children:[H,"#",S+1," ",Q," `",ae,$,"`"]})},_.index)}),G(X,{marginTop:1,children:G(ee,{color:"#808080",dimColor:!0,children:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88"})})]}),G(ee,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(F)})]}):ie(ay,{children:[Jd==="visible"&&G(X,{marginTop:1,justifyContent:"center",children:G(ee,{color:"#808080",children:"\u21A9 /rewind 1 \u53EF\u64A4\u56DE\u672C\u6B21\u4FEE\u6539"})}),ie(X,{flexDirection:"column",children:[G(X,{children:G(ee,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(F-4)})}),ie(X,{children:[G(X,{width:4,flexShrink:0,children:G(ee,{bold:!0,color:"#00ff41",children:"\u26A1"})}),ie(X,{flexGrow:1,children:[co?G(ee,{color:"#808080",children:"Ctrl+P \u6587\u4EF6\u641C\u7D22\u4E2D\u2026\uFF08Esc \u53D6\u6D88\uFF09"}):!j&&!de&&Bn&&Ma.length>0?G(ee,{children:Bn.split("").map((_,S)=>G(ee,{color:Ma[S]??void 0,children:_},S))}):!j&&de&&Nn&&Da.length>0?G(ee,{children:Nn.split("").map((_,S)=>G(ee,{color:Da[S]??void 0,children:_},S))}):G(Qh,{value:j,onChange:O,onSubmit:np,placeholder:"",focus:!co},qd),Be!=="idle"&&ie(X,{children:[ie(ee,{color:Be==="error"?"red":"cyan",children:[Be==="connecting"&&"\u25CC \u6B63\u5728\u8FDE\u63A5 ASR \u670D\u52A1...",Be==="recording"&&`\u25CF \u5F55\u97F3\u4E2D ${Ia}`,Be==="finalizing"&&`\u25CC \u7B49\u5F85\u670D\u52A1\u7AEF\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C ${Ia}`,Be==="error"&&`\u2717 \u9519\u8BEF ${Ia}`]}),G(ee,{dimColor:!0,children:" (\u518D\u6309 F2 \u7ED3\u675F\uFF0CESC \u53D6\u6D88)"})]})]})]}),G(X,{children:G(ee,{color:"#00ffff",dimColor:!0,children:"\u2500".repeat(F-4)})})]}),mn==="skills"?G(Zc,{skills:t,input:j,selectedIndex:wr,triggerMode:"at"}):G(Dh,{commands:Ji(j,io),input:j,selectedIndex:Un}),G(Lh,{servers:uo,input:j,selectedIndex:po}),G(Zh,{open:Hn,selectedIndex:fn}),!Hn&&mn!=="skills"&&mn!=="mcps"&&G(su,{files:n,input:j,selectedIndex:Tr,cwd:process.cwd(),width:F}),G(X,{children:G(qp,{activeModel:St,thinkingEnabled:jn,thinkingEffort:kr,balance:K,todayCost:un,sessionCost:tx,hasConversationStarted:so,isStreaming:de,streamingPhase:Md,currentUsage:Ua,currentCost:Wa,currentElapsed:Qy,currentToolCalls:no,currentToolResults:Od,contextStats:Jy,lastRound:nx,goal:Wd})})]})]}),[M,N,de,Ba,no,Ua,Wa,Fd,Va,Gn,Ud,hn,gn,St,Bs,Ha,Gs,Vn,zn,lo,Os,Ds,Jd,so,Fn,Md,Bn,Ma,Nn,Da,j,O,F,np,t,wr,n,Tr,Hn,fn,mn,qd,Et,Ps,qa,e,r,o,K,ge,un,jn,kr,Wd]),ux=typeof process.stdout.rows=="number"?Math.max(process.stdout.rows-4,10):24,dx=_=>{O(S=>`${S.endsWith(" ")||S.length===0?S:S+" "}@${_} `),Wn(S=>S+1),Ns(!1)};return ie(X,{flexDirection:"column",paddingLeft:1,paddingRight:1,children:[co&&G(Kh,{files:n,cwd:process.cwd(),width:I,height:ux,onPick:dx,onClose:()=>Ns(!1)}),!co&&ie(ay,{children:[cx,lx&&!de&&G(X,{marginTop:1,children:G(ee,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})}),de&&G(X,{marginTop:1,children:G(ee,{color:"yellow",dimColor:!0,children:" \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42"})})]})]})}function gr({k:e,v:t}){return ie(X,{children:[G(ee,{color:"#808080",children:e.padEnd(10," ")}),G(ee,{color:"#d4d4d4",children:t})]})}p();import{Box as ln,Text as xr,useInput as nv}from"ink";import{useState as rv,useCallback as ov}from"react";import{jsx as Qe,jsxs as ly}from"react/jsx-runtime";function Sa({games:e,onSelect:t,onExit:n,onBackToChat:r}){let[o,s]=rv(0),i=r??n??(()=>process.exit(0)),{doubleCtrlC:a,handleCtrlC:l}=Kn(i);return nv(ov((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])),ly(ln,{flexDirection:"column",children:[Qe(ln,{marginBottom:1,children:Qe(xr,{bold:!0,color:"#00ffff",children:"\u{1F3AE} \u6E38\u620F\u5217\u8868"})}),Qe(ln,{flexDirection:"column",children:e.map((c,u)=>{let d=u===o;return ly(ln,{flexDirection:"row",children:[Qe(ln,{width:3,flexShrink:0,children:d?Qe(xr,{bold:!0,color:"#00ff41",children:"\u25B8 "}):Qe(xr,{children:" "})}),Qe(ln,{width:20,flexShrink:0,children:Qe(xr,{bold:!0,color:d?"#00ff41":"#ffffff",children:c.name})}),Qe(ln,{children:Qe(xr,{color:"#888888",children:c.description})})]},c.id)})}),Qe(ln,{marginTop:1,children:Qe(xr,{dimColor:!0,children:" \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE"})}),a&&Qe(ln,{marginTop:1,children:Qe(xr,{color:"#ff1493",bold:!0,children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}p();p();var bd=new Map;function Ca(e){bd.set(e.id,e)}function cy(e){return bd.get(e)}function ys(){return Array.from(bd.values())}p();import{Box as et,Text as _e,useInput as sv,render as iv}from"ink";import{useState as kd,useEffect as av,useRef as uy,useCallback as wd}from"react";import{jsx as ke,jsxs as tt}from"react/jsx-runtime";var kt=40,Zr=18,Yr=9,dy=[166,214,76,69],Td=[{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 Sd(e){return Td[(e-1)%Td.length]}function lv(e){let t=Sd(e),n=[],r=2,o=t.cols*t.bw+(t.cols-1)*r,s=Math.floor((kt-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 py(e){let t=Sd(e),n=t.cols*t.bw+(t.cols-1)*2,r=Math.floor((kt-n)/2);return{level:e,bricks:lv(e),paddleX:Math.floor(kt/2)-Math.floor(Yr/2),ball:{x:kt/2,y:Zr-3},ballDir:{x:1,y:-1},score:0,lives:3,gameOver:!1,win:!1,paused:!1}}function cv(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>=kt-1&&(e.ball.x=kt-1,e.ballDir.x=-1),e.ball.y<=0&&(e.ball.y=0,e.ballDir.y=1),e.ball.y===Zr-1&&e.ball.x>=e.paddleX&&e.ball.x<=e.paddleX+Yr){e.ballDir.y=-1;let n=(e.ball.x-e.paddleX)/Yr;e.ballDir.x=n<.5?-1:1}e.ball.y>Zr&&(e.lives--,e.lives<=0?e.gameOver=!0:(e.ball={x:kt/2,y:Zr-3},e.ballDir={x:1,y:-1},e.paddleX=Math.floor(kt/2)-Math.floor(Yr/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 uv(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%dy.length}for(let r=0;r<Zr;r++){let o="";for(let s=0;s<kt;s++){let i=e.ball.x===s&&e.ball.y===r,a=r===Zr-1&&s>=e.paddleX&&s<e.paddleX+Yr,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;${dy[l]}m\u2580\x1B[0m`:o+=" "}t.push(o)}return t.map(r=>`\u2502${r}\u2502`).join(`
615
+ `)}function dv({onExit:e}){let[t,n]=kd(1),[r,o]=kd(!0),s=uy(py(t)),[i,a]=kd(0),l=uy(e);l.current=e,av(()=>{if(r)return;let g=setInterval(()=>{cv(s.current),a(b=>b+1)},80);return()=>clearInterval(g)},[r]);let c=wd(g=>{let b=g??s.current.level;s.current=py(b),n(b),o(!1),a(0)},[]),u=wd(()=>{o(!0)},[]);sv(wd((g,b)=>{let k=s.current;if(r){g>="1"&&g<="9"?c(Number(g)):g==="0"?c(10):(b.escape||g==="q")&&l.current();return}b.leftArrow?(k.paddleX=Math.max(0,k.paddleX-1),a(T=>T+1)):b.rightArrow?(k.paddleX=Math.min(kt-Yr,k.paddleX+1),a(T=>T+1)):g==="p"||g===" "?k.paused=!k.paused:g==="r"?(k.gameOver||k.win)&&c():g==="l"?(k.gameOver||k.win)&&u():(g==="q"||b.escape)&&l.current()},[r,c,u]));let d=s.current,f=d.bricks.filter(g=>g.alive).length,h=uv(d),m=Sd(d.level);return tt(et,{flexDirection:"column",children:[tt(et,{flexDirection:"row",children:[ke(et,{width:20,children:tt(_e,{children:["\u5173\u5361 ",d.level,": ",ke(_e,{color:"cyan",children:m.desc})]})}),ke(et,{width:12,children:tt(_e,{children:["\u5206\u6570: ",ke(_e,{color:"yellow",children:String(d.score).padStart(3,"0")})]})}),ke(et,{width:12,children:tt(_e,{children:["\u751F\u547D: ",ke(_e,{color:"red",children:"\u2665".repeat(Math.max(0,d.lives))})]})}),ke(et,{width:10,children:tt(_e,{children:["\u7816\u5757: ",ke(_e,{color:"cyan",children:f})]})}),ke(et,{children:tt(_e,{color:d.paused?"gray":"green",children:["[",d.paused?"\u6682\u505C":"\u8FD0\u884C\u4E2D","]"]})})]}),tt(et,{flexDirection:"column",children:[tt(_e,{children:["\u250C","\u2500".repeat(kt),"\u2510"]}),ke(_e,{children:r?" \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m":h}),tt(_e,{children:["\u2514","\u2500".repeat(kt),"\u2518"]})]}),r&&tt(et,{marginTop:1,flexDirection:"column",children:[ke(_e,{bold:!0,color:"yellow",children:"\u9009\u62E9\u5173\u5361"}),ke(et,{flexDirection:"row",flexWrap:"wrap",children:Td.map((g,b)=>ke(et,{width:22,children:tt(_e,{children:[ke(_e,{color:t===b+1?"green":"white",children:b+1===10?"0":String(b+1)}),". ",g.desc," (",g.rows,"\xD7",g.cols,")"]})},b))}),ke(et,{marginTop:1,children:ke(_e,{dimColor:!0,children:"\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA"})})]}),!r&&(d.gameOver||d.win)&&tt(et,{marginTop:1,children:[ke(_e,{bold:!0,color:d.gameOver?"red":"green",children:d.gameOver?"\u6E38\u620F\u7ED3\u675F\uFF01":"\u606D\u559C\u901A\u5173\uFF01"}),tt(_e,{children:[" \u5206\u6570: ",ke(_e,{color:"yellow",children:d.score})]})]}),!r&&ke(et,{marginTop:1,children:d.gameOver||d.win?ke(_e,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA"}):ke(_e,{dimColor:!0,children:"\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA"})})]})}var fy={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}=iv(ke(dv,{onExit:()=>{t(),e()}}))})}};p();import{Box as Qr,Text as pt,useInput as pv,render as fv}from"ink";import{useState as my,useEffect as hy,useRef as gy,useCallback as mv}from"react";import{jsx as Rt,jsxs as cn}from"react/jsx-runtime";var wt=66,ky=20,_d=6,hv=10,eo=["#00ffff","#ff00ff","#00ff41","#ff1493","#8b00ff"],yy={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 gv(e){let t=["","","","",""];for(let r of e){let o=yy[r]??yy[0];for(let s=0;s<5;s++)t[s]+=" "+(o[s]??"")}let n=6;return t.map(r=>" ".repeat(n)+r)}function Cd(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 xy=["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 yv(e){let t;do t=xy[Math.floor(Math.random()*xy.length)];while(e.has(t));return t}function by(){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 _a(e){let t=null;for(let n of e.words)(!t||n.col<t.col)&&(t=n);return t?.text??null}function xv(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<hv)){let r=new Set(e.usedWords);for(let a of e.words)r.add(a.text);let o=yv(r),s=new Set(e.words.map(a=>a.row)),i=-1;for(let a=_d;a<ky;a++)if(!s.has(a)){i=a;break}i>=0&&(e.words.push({text:o,row:i,col:wt-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=_a(e),e.lives<=0&&(e.gameOver=!0,e.words=[])),e.target=_a(e),e.messageTimer>0&&(e.messageTimer--,e.messageTimer<=0&&(e.message=""))}function bv(e,t,n,r){let o=[];for(let s=0;s<ky;s++){let i="";if(s<_d){if(s<5){let a=(t[s]??"").padEnd(wt);i=`\x1B[38;2;${Cd(n)}m${a}\x1B[0m`}else if(s===5){if(e.combo>=3){let a=`${e.combo}\u8FDE\u51FB!`,l=Math.floor((wt-a.length)/2),c=eo[e.combo%eo.length],u=" ".repeat(l)+a+" ".repeat(wt-l-a.length);i=`\x1B[38;2;${Cd(c)}m${u}\x1B[0m`}else if(e.paused){let l=Math.floor((wt-2)/2);i=" ".repeat(l)+"\u6682\u505C",i=i.padEnd(wt)}}i=i.padEnd(wt)}else if(s===_d&&r){let a=Math.floor((wt-r.length)/2),l=" ".repeat(a)+r+" ".repeat(wt-a-r.length),c=eo[Math.floor(Math.random()*eo.length)];i=`\x1B[38;2;${Cd(c)}m${l}\x1B[0m`}else for(let a=0;a<wt;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,f=e.target===l.text?e.typed.length:0,h=d&&c<f;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 kv({onExit:e}){let t=gy(by()),[n,r]=my(0),[o,s]=my(0),i=gy(e);i.current=e,hy(()=>{let f=setInterval(()=>{s(h=>(h+1)%eo.length)},400);return()=>clearInterval(f)},[]),hy(()=>{let f=setInterval(()=>{xv(t.current),r(h=>h+1)},60);return()=>clearInterval(f)},[]),pv(mv((f,h)=>{let m=t.current;if(m.gameOver){f==="r"?(t.current=by(),r(0)):(f==="q"||h.escape)&&i.current();return}if(f==="p"&&h.ctrl||f===" "){m.paused=!m.paused;return}if(f==="q"&&h.ctrl||h.escape){i.current();return}if(!m.paused&&f.length===1&&f>="a"&&f<="z"&&(m.target||(m.target=_a(m)),m.target))if(m.target[m.typed.length]===f){if(m.typed+=f,m.typed===m.target){m.words=m.words.filter(I=>I.text!==m.target),m.combo++;let b=m.score,k=m.target.length,T=m.combo>=3?m.score:0;m.score+=k+T,m.speed=m.speed+.02;let A=Math.floor(b/500);Math.floor(m.score/500)>A&&(m.speed+=.15),m.score>=1e5&&b<1e5&&(m.message="\u606D\u559C\u901A\u5173! \u96BE\u5EA6\u6700\u5927\u5316!",m.messageTimer=100),m.typed="",m.target=_a(m)}}else m.combo=0},[]));let a=t.current,l=eo[o],c=String(a.score).padStart(5,"0"),u=gv(c),d=bv(a,u,l,a.message);return cn(Qr,{flexDirection:"column",paddingX:1,children:[Rt(Qr,{flexDirection:"row",children:cn(pt,{children:["\u751F\u547D ",Rt(pt,{color:"red",children:"\u2665".repeat(Math.max(0,a.lives))})," ","\u901F\u5EA6 ",cn(pt,{color:"cyan",children:["Lv.",Math.floor(a.speed*10)]})]})}),!a.gameOver&&a.target&&Rt(Qr,{marginTop:1,children:cn(pt,{children:["\u6253\u5B57: ",Rt(pt,{color:"green",children:a.typed}),Rt(pt,{color:"white",children:a.target.slice(a.typed.length)})]})}),cn(Qr,{flexDirection:"column",marginTop:1,children:[cn(pt,{children:["\u250C","\u2500".repeat(wt),"\u2510"]}),d.map((f,h)=>Rt(pt,{children:`\u2502${f}\u2502`},h)),cn(pt,{children:["\u2514","\u2500".repeat(wt),"\u2518"]})]}),a.gameOver&&cn(Qr,{marginTop:1,children:[Rt(pt,{bold:!0,color:"red",children:"\u6E38\u620F\u7ED3\u675F\uFF01"}),cn(pt,{children:[" \u5F97\u5206: ",Rt(pt,{color:"yellow",children:a.score})," r \u91CD\u5F00 q \u9000\u51FA"]})]}),Rt(Qr,{marginTop:1,children:Rt(pt,{dimColor:!0,children:"\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA"})})]})}var wy={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}=fv(Rt(kv,{onExit:()=>{t(),e()}}))})}};p();p();function wv(e,t){return e==="UP"&&t==="DOWN"||e==="DOWN"&&t==="UP"||e==="LEFT"&&t==="RIGHT"||e==="RIGHT"&&t==="LEFT"}function vd(e,t){return e.x===t.x&&e.y===t.y}function Tv(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 Sv(e,t){return{x:(e.x%t.width+t.width)%t.width,y:(e.y%t.height+t.height)%t.height}}function Rd(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 Ad(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=Rd(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 Sy(e,t){e.direction=e.nextDirection;let n=e.snake[0],r=Tv(n,e.direction);if(r.x<0||r.x>=t.width||r.y<0||r.y>=t.height)if(e.wallWrap)r=Sv(r,t);else{e.isGameOver=!0;return}let s=vd(r,e.food.position),i=e.specialFood!==null&&vd(r,e.specialFood.position),l=s||i?e.snake:e.snake.slice(0,-1);for(let c of l)if(vd(r,c)){e.isGameOver=!0;return}if(e.snake.unshift(r),s){e.score+=1,Ty(e,t);let c=e.specialFood?[e.specialFood.position]:[],u=Rd(e.snake,t,"normal",c);if(u)e.food=u;else{e.isGameOver=!0;return}e.specialFood===null&&Math.random()<.25&&(e.specialFood=Rd(e.snake,t,"special",[e.food.position]))}else i?(e.score+=3,Ty(e,t),e.specialFood=null):e.snake.pop();e.specialFood?.spawnedAt!==void 0&&Date.now()-e.specialFood.spawnedAt>5e3&&(e.specialFood=null)}function Ty(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 Cy(e,t){wv(t,e.direction)||(e.nextDirection=t)}p();import De from"chalk";var _y=2,Cv=" ",_v="\u2593",vv="\u2593",Rv="\u25C6",Av="\u2605",xs="\x1B[",Ev=`${xs}?25l`,Iv=`${xs}?25h`,vy=`${xs}H`;function Ry(){process.stdout.write(Ev)}function Ay(){process.stdout.write(Iv)}function Ey(){process.stdout.write(`${xs}2J${vy}`)}function Pv(e,t){switch(t){case"snake-head":return De.greenBright(e);case"snake-body":return De.green(e);case"normal-food":return De.red(e);case"special-food":return De.yellow(e);case"empty":return e}}function Iy(e,t){let n=$v(e,t);process.stdout.write(`${xs}2J${vy}`+n.join(`
616
+ `))}function $v(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(" "+De.gray("\u2554"+"\u2550\u2550".repeat(n)+"\u2557"));for(let l=0;l<r;l++){let c=" "+De.gray("\u2551");for(let u=0;u<n;u++){let d=s[l][u],f;switch(d){case"snake-head":f=vv.repeat(_y);break;case"snake-body":f=_v.repeat(_y);break;case"normal-food":f=Rv+" ";break;case"special-food":f=Av+" ";break;default:f=Cv}c+=Pv(f,d)}c+=De.gray("\u2551"),o.push(c)}if(o.push(" "+De.gray("\u255A"+"\u2550\u2550".repeat(n)+"\u255D")),o.push(""),o.push(` ${De.cyan("\u5206\u6570")}: ${e.score} ${De.cyan("\u957F\u5EA6")}: ${e.snake.length} ${De.cyan("\u901F\u5EA6")}: Lv.${e.speedLevel} ${De.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(` ${De.yellow(`\u2B50 \u7279\u6B8A\u98DF\u7269 ${l} \u79D2\u540E\u6D88\u5931`)}`)}return o.push(` ${De.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(` ${De.yellow("\u23F8 \u5DF2\u6682\u505C \u2014 \u6309 P \u7EE7\u7EED")}`)),e.isGameOver&&(o.push(""),o.push(` ${De.red.bold("\u{1F480} \u6E38\u620F\u7ED3\u675F!")} ${De.cyan("\u6700\u7EC8\u5206\u6570: "+e.score)}`),o.push(` ${De.gray("\u6309 R \u91CD\u65B0\u5F00\u59CB | \u6309 Q \u9000\u51FA")}`)),o}p();import*as Py from"readline";var Lv={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 $y(e,t,n){Py.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=Lv[i];c&&Cy(l,c)};return process.stdin.on("keypress",r),()=>{process.stdin.removeListener("keypress",r),process.stdin.isTTY&&process.stdin.setRawMode(!1)}}var va={width:20,height:16,initialSpeed:180,minSpeed:60,speedDecrement:10,scorePerLevel:5},Mv=200,Ov={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:Ad(va)};return new Promise(t=>{let n=$y(e,()=>{r=!0,clearTimeout(o),Ay(),n(),t()},()=>Ad(va));Ey(),Ry();let r=!1,o;function s(){if(r)return;let i=e.state;!i.isGameOver&&!i.isPaused&&Sy(i,va),Iy(i,va);let a=i.isGameOver||i.isPaused?Mv:i.tickInterval;o=setTimeout(s,a)}o=setTimeout(s,0)})}},Ly=Ov;function Ed(){return Ca(fy),Ca(wy),Ca(Ly),ys()}import{render as zy}from"ink";import At from"chalk";p();p();import{Box as te,Text as re,useInput as Dv}from"ink";import{useState as Tt,useCallback as My,useEffect as bs,useMemo as Nv}from"react";import Id from"asciichart";import Bv from"os";import{join as Gv}from"path";import{jsx as U,jsxs as Ne}from"react/jsx-runtime";var Oy=Gv(Bv.homedir(),".dskcode","settings.json");function Fv(e){let t=e.replace(/\\/g,"/");return process.platform==="win32"?"file://"+t.replace(/^([a-zA-Z]:)/,"/$1"):"file://"+t}function jv(e,t){return`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`}var Uv="https://web.ifzq.gtimg.cn/appstock/app/minute/query?code={code}&r=0.1";function Dy(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 Ny(e){let t=Uv.replace("{code}",Dy(e));try{let r=await(await fetch(t)).json();if(r.code!==0)return null;let o=Dy(e),s=r.data?.[o];if(!s)return null;let i=s.data?.data??[],a=[];for(let d of i){let f=d.split(" ");if(f.length>=2){let h=parseFloat(f[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 By=new Map;function Gy(e,t){By.set(e,t)}var Wv=[{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 Hv(e){let n=(await Promise.all(e.map(async r=>{let o=await Ny(r);return o?.quote?(o.prices.length>0&&Gy(r,o.prices),o.quote):null}))).filter(r=>r!==null);return n.length>0?n:Wv}function Ra(e){return e>=100?e.toFixed(2):e.toFixed(3)}function Vv(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 zv(e,t=60){return e.length<=t?e:e.slice(e.length-t)}function Aa({codes:e,onExit:t,onBackToChat:n}){let[r,o]=Tt([]),[s,i]=Tt(0),[a,l]=Tt(!0),[c,u]=Tt(""),[d,f]=Tt(null),[h,m]=Tt(null),[g,b]=Tt(!1),[k,T]=Tt(10),[A,E]=Tt(5),[I,F]=Tt(()=>new Date().toLocaleTimeString("zh-CN",{hour12:!1})),[M,C]=Tt(!1),[N,oe]=Tt("default"),j=Nv(()=>N==="default"?r:[...r].toSorted((K,he)=>N==="desc"?he.changePercent-K.changePercent:K.changePercent-he.changePercent),[r,N]),{doubleCtrlC:O,handleCtrlC:ce}=Kn(t);bs(()=>{let K=setInterval(()=>{F(new Date().toLocaleTimeString("zh-CN",{hour12:!1}))},1e3);return()=>clearInterval(K)},[]);let fe=My(async()=>{l(!0);try{let K=await Hv(e??[]);o(K),u(new Date().toLocaleTimeString())}catch{}l(!1)},[e]);if(bs(()=>{fe()},[fe]),bs(()=>{let K=setInterval(()=>{E(he=>he<=1?(fe(),5):he-1)},1e3);return()=>clearInterval(K)},[fe]),bs(()=>{if(d){let K=()=>{By.delete(d.code),Ny(d.code).then(ge=>{ge&&ge.prices.length>0&&(Gy(d.code,ge.prices),m(ge.prices))})};K(),T(10);let he=setInterval(K,1e4);return()=>clearInterval(he)}m(null),b(!1)},[d]),bs(()=>{if(!d)return;let K=setInterval(()=>{T(he=>he>0?he-1:10)},1e3);return()=>clearInterval(K)},[d]),Dv(My((K,he)=>{if(K==="c"&&he.ctrl){ce();return}if(d){(he.escape||K==="q"||K===" ")&&f(null);return}if(r.length!==0)if(he.upArrow||K==="k")i(ge=>ge>0?ge-1:r.length-1);else if(he.downArrow||K==="j")i(ge=>ge<r.length-1?ge+1:0);else if(he.return){let ge=r[s];ge&&f(ge)}else he.escape||K==="q"?n?n():t():K==="r"?(E(5),fe()):K==="o"?oe(ge=>ge==="default"?"desc":ge==="desc"?"asc":"default"):K==="h"&&C(ge=>!ge)},[r,s,d,t,n,fe,ce,C])),d)return g?U(te,{paddingLeft:1,children:U(re,{dimColor:!0,children:" \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..."})}):qv(d,()=>f(null),h??void 0,k,I);let ne=K=>M?{dimColor:!0}:{color:K};return Ne(te,{flexDirection:"column",children:[Ne(te,{marginBottom:1,justifyContent:"space-between",children:[U(re,{bold:!0,...ne("#00ffff"),children:" \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7"}),Ne(re,{dimColor:!0,children:[" \u{1F550} ",I]}),U(re,{dimColor:!0,children:a?" \u27F3 \u5237\u65B0\u4E2D...":` ${A}s \u540E\u81EA\u52A8\u5237\u65B0`})]}),Ne(te,{children:[U(te,{width:3}),U(te,{width:9,children:U(re,{dimColor:!0,children:"\u4EE3\u7801"})}),U(te,{width:16,children:U(re,{dimColor:!0,children:"\u540D\u79F0"})}),U(te,{width:12,children:U(re,{dimColor:!0,children:"\u6700\u65B0\u4EF7"})}),U(te,{width:12,children:Ne(re,{dimColor:!0,children:["\u6DA8\u8DCC\u5E45",N==="desc"?" \u25BC":N==="asc"?" \u25B2":""]})}),U(te,{width:12,children:U(re,{dimColor:!0,children:"\u6DA8\u8DCC\u989D"})}),U(te,{width:12,children:U(re,{dimColor:!0,children:"\u6700\u9AD8"})}),U(te,{width:12,children:U(re,{dimColor:!0,children:"\u6700\u4F4E"})}),U(te,{children:U(re,{dimColor:!0,children:"\u6210\u4EA4\u989D"})})]}),U(te,{children:U(re,{dimColor:!0,children:" "+"\u2500".repeat(100)})}),U(te,{flexDirection:"column",children:j.map((K,he)=>{let ge=he===s,br=K.changePercent>=0,un=br?"#ff1493":"#00ff41";return Ne(te,{children:[U(te,{width:3,flexShrink:0,children:ge?U(re,{bold:!0,...ne("#00ffff"),children:"\u25B8 "}):U(re,{children:" "})}),U(te,{width:9,children:U(re,{bold:!0,...ne(ge?"#00ffff":"#ffffff"),children:K.code})}),U(te,{width:16,children:U(re,{...ne(ge?"#ffffff":"#cccccc"),children:K.name})}),U(te,{width:12,children:U(re,{bold:!0,...ne(un),children:Ra(K.price)})}),U(te,{width:12,children:Ne(re,{...ne(un),children:[br?"+":"",K.changePercent.toFixed(2),"%"]})}),U(te,{width:12,children:Ne(re,{...ne(un),children:[br?"+":"",K.changeAmount.toFixed(3)]})}),U(te,{width:12,children:U(re,{...ne("#cccccc"),children:Ra(K.high)})}),U(te,{width:12,children:U(re,{...ne("#888888"),children:Ra(K.low)})}),U(te,{children:U(re,{...ne("#888888"),children:Vv(K.amount)})})]},K.code)})}),U(te,{marginTop:1,children:U(re,{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"})}),Ne(te,{children:[U(re,{dimColor:!0,children:` \u6700\u540E\u66F4\u65B0: ${c} \u7F16\u8F91\u81EA\u9009\u80A1: `}),U(re,{...ne("#c792ea"),children:jv(Fv(Oy),Oy)})]}),O&&U(te,{marginTop:1,children:U(re,{bold:!0,...ne("#ff1493"),children:" \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode"})})]})}function qv(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?Id.red:Id.green,u=zv(n,60),d=Id.plot(u,{height:10,colors:[c]});d=d.replaceAll("\u256D","\u250C").replaceAll("\u256E","\u2510").replaceAll("\u2570","\u2514").replaceAll("\u256F","\u2518"),l=d.split(`
617
+ `)}return Ne(te,{flexDirection:"column",paddingLeft:1,children:[Ne(te,{marginBottom:1,justifyContent:"space-between",children:[Ne(te,{children:[Ne(re,{bold:!0,color:"#00ffff",children:[" \u{1F4CA} ",e.name," "]}),U(re,{dimColor:!0,children:e.code}),o&&Ne(re,{dimColor:!0,children:[" \u{1F550} ",o]})]}),U(re,{dimColor:!0,children:`${r}s \u540E\u5237\u65B0`})]}),Ne(te,{children:[U(te,{width:16,children:U(re,{bold:!0,color:"#888888",children:"\u5F53\u524D\u4EF7"})}),U(te,{children:Ne(re,{bold:!0,color:i,children:[a," ",Ra(e.price)]})})]}),Ne(te,{children:[U(te,{width:16,children:U(re,{color:"#888888",children:"\u6DA8\u8DCC\u5E45"})}),U(te,{children:Ne(re,{color:i,children:[s?"+":"",e.changePercent.toFixed(2),"%"," ",s?"+":"",e.changeAmount.toFixed(3)]})})]}),l.length>0&&U(te,{marginTop:1,flexDirection:"column",children:l.map((c,u)=>U(te,{children:U(re,{color:i,children:c||" "})},u))}),U(te,{marginTop:1,children:U(re,{dimColor:!0,children:" Space/q \u8FD4\u56DE\u5217\u8868"})})]})}p();import{readdir as Kv,realpath as Xv}from"fs/promises";import{join as Fy,relative as Jv}from"path";var Zv=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 jy(e,t,n=1/0,r){let o=t??e,s=r??new Set;try{let d=await Xv(o);if(s.has(d))return[];s.add(d)}catch{}let i;try{i=await Kv(o,{withFileTypes:!0})}catch{return[]}let a=[],l=[];for(let d of i){let f=d.name;Zv.has(f)||f.startsWith(".")||(d.isDirectory()?l.push(f):d.isFile()&&a.push(Jv(e,Fy(o,f))))}let c=t===void 0?n:Math.max(0,n-1),u=c<=1?[]:await Promise.all(l.map(d=>jy(e,Fy(o,d),c,s)));for(let d of u)a.push(...d);return a}var Yv=8;async function Uy(e){return jy(e,void 0,Yv)}import{jsx as to}from"react/jsx-runtime";var nR=["chat","run","setup","init","completion","game","stock","config-ui"];function qy(){let e=new Qv;return e.exitOverride(),e.name("dskcode").description("\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\u7EC8\u7AEF\u5DE5\u5177").version(is,"-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=()=>kp(e),e.hook("preAction",async(t,n)=>{let r=await bp.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 Hy(this)}),e.action(async function(){let t=this;if(t.opts().ws){let{startConfigUi:r}=await import("./config-ui-W3XDQASQ.js");await r({});return}await Hy(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
609
618
  _dskcode_completion() {
610
619
  local cur=\${COMP_WORDS[COMP_CWORD]}
611
620
  if [[ \${COMP_CWORD} -eq 1 ]]; then
612
- COMPREPLY=( $(compgen -W "${Iv.join(" ")}" -- "\${cur}") )
621
+ COMPREPLY=( $(compgen -W "${nR.join(" ")}" -- "\${cur}") )
613
622
  return 0
614
623
  fi
615
624
  COMPREPLY=( $(compgen -W "--verbose --config --model" -- "\${cur}") )
@@ -628,15 +637,15 @@ _dskcode_completion() {
628
637
  )
629
638
  _describe 'dskcode commands' commands
630
639
  }
631
- 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=vy(r,".dskcode","settings.json"),s=!1;try{let c=await Ev(o,"utf-8"),d=JSON.parse(c).stock;s=Array.isArray(d?.symbols)&&d.symbols.length>0}catch{}if(!s){let u=await Kd([{code:"sh000001"},{code:"sz399300"},{code:"sh601899"}]);console.log(`${At.green("\u2714")} \u5DF2\u751F\u6210\u81EA\u9009\u80A1\u914D\u7F6E: ${At.dim(u)}`),console.log(`${At.dim(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u81EA\u5B9A\u4E49\u81EA\u9009\u80A1\u5217\u8868")}
632
- `)}let i=await xn(),a=t&&t.length>0?t:i.config.stock?.symbols?.map(c=>c.code)??["sh000001","sz399006","sh601688"];await uo(Yr(ka,{codes:a,onExit:()=>process.exit(0)})).waitUntilExit}),pd(),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=Hg(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}
633
- `),await n.play()}else{let n=ls();if(n.length===0){console.log("\u6682\u65E0\u53EF\u7528\u6E38\u620F\u3002");return}let r=await new Promise(o=>{let{unmount:s}=Ry(Yr(ga,{games:n,onSelect:i=>{s(),o(i)},onExit:()=>{s(),o(null)}}),{exitOnCtrlC:!1})});r&&(console.log(`
640
+ 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=Vy(r,".dskcode","settings.json"),s=!1;try{let c=await tR(o,"utf-8"),d=JSON.parse(c).stock;s=Array.isArray(d?.symbols)&&d.symbols.length>0}catch{}if(!s){let u=await pp([{code:"sh000001"},{code:"sz399300"},{code:"sh601899"}]);console.log(`${At.green("\u2714")} \u5DF2\u751F\u6210\u81EA\u9009\u80A1\u914D\u7F6E: ${At.dim(u)}`),console.log(`${At.dim(" \u63D0\u793A: \u53EF\u7F16\u8F91\u4E0A\u8FF0\u6587\u4EF6\u81EA\u5B9A\u4E49\u81EA\u9009\u80A1\u5217\u8868")}
641
+ `)}let i=await bn(),a=t&&t.length>0?t:i.config.stock?.symbols?.map(c=>c.code)??["sh000001","sz399006","sh601688"];await yo(to(Aa,{codes:a,onExit:()=>process.exit(0)})).waitUntilExit}),Ed(),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=cy(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}
642
+ `),await n.play()}else{let n=ys();if(n.length===0){console.log("\u6682\u65E0\u53EF\u7528\u6E38\u620F\u3002");return}let r=await new Promise(o=>{let{unmount:s}=zy(to(Sa,{games:n,onSelect:i=>{s(),o(i)},onExit:()=>{s(),o(null)}}),{exitOnCtrlC:!1})});r&&(console.log(`
634
643
  \u542F\u52A8\u6E38\u620F: ${At.green(r.name)}
635
- `),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-W3XDQASQ.js");await n({host:t.host??"127.0.0.1",port:t.port??54006})}),e}async function _y(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&&!op(r.config.providers)){let u=await sp();u||process.exit(1);let d=await zd(u);console.log(` ${At.green("\u2714")} API Key \u5DF2\u4FDD\u5B58\u5230 ${At.dim(d)}
636
- `);let f=await xn();r={...r,config:f.config}}await cp(process.cwd());let o=await Xd();if(o){let u=await xn();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=il(r?.config.voice);if(s.resolved)(s.source.appId==="env"||s.source.accessKey==="env")&&console.log(` ${At.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 ip();if(!u)console.log(" "+At.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??"~",f=vy(d,".dskcode","settings.json");await Jd(f,u.appId,u.accessKey),console.log(` ${At.green("\u2714")} \u8BED\u97F3\u51ED\u636E\u5DF2\u4FDD\u5B58\u5230 ${At.dim(f)}
637
- `);let h=await xn();r=r?{...r,config:h.config}:{config:h.config,verbose:!1},s=il(h.config.voice)}}let i=new ze({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-W3XDQASQ.js");c=await u({})}Sa(r,i,n,s,c)}async function Sa(e,t,n=process.cwd(),r,o=null){let[s,i,a,l]=await Promise.all([lp(),ml(process.cwd()),up(process.cwd()),Ty(n)]),c=s+i;function u(f){let[h,m]=Cy(e),[g,w]=Cy(0),b=o;Av(()=>b?b.onConfigChanged(N=>{xn().then(A=>{e&&(e.config=A.config,m({...e,config:A.config})),w(ie=>ie+1),console.error(At.cyan(`
638
- \u27F3 dskcode \u8FD0\u884C\u65F6\u8BBE\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D (source: ${N.source})
639
- `))}).catch(A=>{console.error(` \u26A0 \u91CD\u65B0\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25: ${A.message}`)})}):void 0,[b]);let k=h??e,v=k?.config.providers.find(j=>j.name===(k?.config.defaultProvider??"deepseek")),I=v?.model??"deepseek-v4-flash",R=v?.apiKey,D=v?.baseUrl??"https://api.deepseek.com",F=k?.verbose??!1,P=k?.config.thinking?.enabled??!1,z=k?.config.thinking?.effort??"high";return Yr(td,{...f,model:I,apiKey:R,baseUrl:D,verbose:F,thinkingEnabledFromConfig:P,thinkingEffortFromConfig:z,configReloadEpoch:g,mcpServers:k?.config.mcpServers,mcpServerTimeout:k?.config.mcpServerTimeout})}let d=uo(Yr(u,{skillCount:c,skills:a,files:l,toolCount:e?.config.tools.length??0,costTracker:t,permissionsConfig:e?.config.permissions,voiceConfig:r,permissionBroker:o?.permissionBroker,onLaunchGame:()=>{d.unmount(),setImmediate(()=>{pd();let f=ls(),{unmount:h}=Ry(Yr(ga,{games:f,onSelect:async m=>{h(),await m.play(),Sa(e,t,n,r,o)},onBackToChat:()=>{h(),setImmediate(()=>Sa(e,t,n,r,o))}}),{exitOnCtrlC:!1})})},onLaunchStock:()=>{d.unmount(),setImmediate(()=>{let f=e?.config.stock?.symbols?.map(m=>m.code)??["sh000001","sz399006","sh601688"],h=uo(Yr(ka,{codes:f,onBackToChat:()=>{h.unmount(),setImmediate(()=>Sa(e,t,n,r))},onExit:()=>process.exit(0)}))})}}))}p();var ds={SUCCESS:0,GENERAL_ERROR:1,CONFIG_ERROR:2,SIGINT:130};var md=0,hd=null;async function Ey(e){try{await Promise.all([ze.flushAll(),bn.endAllAndFlush()])}catch{}try{let{McpServerStore:t}=await import("./store-T6ITXKA5.js");await t.sharedInstance().shutdown()}catch{}process.exit(e)}process.on("SIGINT",()=>{if(md++,md>=2){Ey(ds.SIGINT);return}process.stdout.write(`
644
+ `),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-W3XDQASQ.js");await n({host:t.host??"127.0.0.1",port:t.port??54006})}),e}async function Hy(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&&!Tp(r.config.providers)){let u=await Sp();u||process.exit(1);let d=await up(u);console.log(` ${At.green("\u2714")} API Key \u5DF2\u4FDD\u5B58\u5230 ${At.dim(d)}
645
+ `);let f=await bn();r={...r,config:f.config}}await Rp(process.cwd());let o=await fp();if(o){let u=await bn();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=pl(r?.config.voice);if(s.resolved)(s.source.appId==="env"||s.source.accessKey==="env")&&console.log(` ${At.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 Cp();if(!u)console.log(" "+At.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??"~",f=Vy(d,".dskcode","settings.json");await mp(f,u.appId,u.accessKey),console.log(` ${At.green("\u2714")} \u8BED\u97F3\u51ED\u636E\u5DF2\u4FDD\u5B58\u5230 ${At.dim(f)}
646
+ `);let h=await bn();r=r?{...r,config:h.config}:{config:h.config,verbose:!1},s=pl(h.config.voice)}}let i=new ze({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-W3XDQASQ.js");c=await u({})}Ea(r,i,n,s,c)}async function Ea(e,t,n=process.cwd(),r,o=null){let[s,i,a,l]=await Promise.all([vp(),kl(process.cwd()),Ap(process.cwd()),Uy(n)]),c=s+i;function u(f){let[h,m]=Wy(e),[g,b]=Wy(0),k=o;eR(()=>k?k.onConfigChanged(j=>{bn().then(O=>{e&&(e.config=O.config,m({...e,config:O.config})),b(ce=>ce+1),console.error(At.cyan(`
647
+ \u27F3 dskcode \u8FD0\u884C\u65F6\u8BBE\u7F6E\u5DF2\u91CD\u65B0\u52A0\u8F7D (source: ${j.source})
648
+ `))}).catch(O=>{console.error(` \u26A0 \u91CD\u65B0\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25: ${O.message}`)})}):void 0,[k]);let T=h??e,A=T?.config.providers.find(oe=>oe.name===(T?.config.defaultProvider??"deepseek")),E=A?.model??"deepseek-v4-flash",I=A?.apiKey,F=A?.baseUrl??"https://api.deepseek.com",M=T?.verbose??!1,C=T?.config.thinking?.enabled??!1,N=T?.config.thinking?.effort??"high";return to(xd,{...f,model:E,apiKey:I,baseUrl:F,verbose:M,thinkingEnabledFromConfig:C,thinkingEffortFromConfig:N,configReloadEpoch:g,mcpServers:T?.config.mcpServers,mcpServerTimeout:T?.config.mcpServerTimeout})}let d=yo(to(u,{skillCount:c,skills:a,files:l,toolCount:e?.config.tools.length??0,costTracker:t,permissionsConfig:e?.config.permissions,voiceConfig:r,permissionBroker:o?.permissionBroker,onLaunchGame:()=>{d.unmount(),setImmediate(()=>{Ed();let f=ys(),{unmount:h}=zy(to(Sa,{games:f,onSelect:async m=>{h(),await m.play(),Ea(e,t,n,r,o)},onBackToChat:()=>{h(),setImmediate(()=>Ea(e,t,n,r,o))}}),{exitOnCtrlC:!1})})},onLaunchStock:()=>{d.unmount(),setImmediate(()=>{let f=e?.config.stock?.symbols?.map(m=>m.code)??["sh000001","sz399006","sh601688"],h=yo(to(Aa,{codes:f,onBackToChat:()=>{h.unmount(),setImmediate(()=>Ea(e,t,n,r))},onExit:()=>process.exit(0)}))})}}))}p();var ks={SUCCESS:0,GENERAL_ERROR:1,CONFIG_ERROR:2,SIGINT:130};var Pd=0,$d=null;async function Ky(e){try{await Promise.all([ze.flushAll(),kn.endAllAndFlush()])}catch{}try{let{McpServerStore:t}=await import("./store-T6ITXKA5.js");await t.sharedInstance().shutdown()}catch{}process.exit(e)}process.on("SIGINT",()=>{if(Pd++,Pd>=2){Ky(ks.SIGINT);return}process.stdout.write(`
640
649
  \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode
641
- `),hd&&clearTimeout(hd),hd=setTimeout(()=>{md=0},1500)});process.on("SIGTERM",()=>{Ey(ds.SIGINT)});var Pv=Ay();try{await Pv.parseAsync(process.argv),await Promise.all([ze.flushAll(),bn.endAllAndFlush()])}catch(e){let t=e;(t.code==="commander.helpDisplayed"||t.code==="commander.version")&&(await Promise.all([ze.flushAll(),bn.endAllAndFlush()]),process.exit(t.exitCode??ds.SUCCESS)),typeof t.exitCode=="number"&&(await Promise.all([ze.flushAll(),bn.endAllAndFlush()]),process.exit(t.exitCode)),console.error(String(e)),await Promise.all([ze.flushAll(),bn.endAllAndFlush()]),process.exit(ds.GENERAL_ERROR)}
650
+ `),$d&&clearTimeout($d),$d=setTimeout(()=>{Pd=0},1500)});process.on("SIGTERM",()=>{Ky(ks.SIGINT)});var rR=qy();try{await rR.parseAsync(process.argv),await Promise.all([ze.flushAll(),kn.endAllAndFlush()])}catch(e){let t=e;(t.code==="commander.helpDisplayed"||t.code==="commander.version")&&(await Promise.all([ze.flushAll(),kn.endAllAndFlush()]),process.exit(t.exitCode??ks.SUCCESS)),typeof t.exitCode=="number"&&(await Promise.all([ze.flushAll(),kn.endAllAndFlush()]),process.exit(t.exitCode)),console.error(String(e)),await Promise.all([ze.flushAll(),kn.endAllAndFlush()]),process.exit(ks.GENERAL_ERROR)}
642
651
  //# sourceMappingURL=index.js.map