@easbot/utils 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,84 +1,65 @@
1
- 'use strict';var chunkYPKMFQLR_cjs=require('./chunks/chunk-YPKMFQLR.cjs'),chunkZHSHEAQD_cjs=require('./chunks/chunk-ZHSHEAQD.cjs'),chunkAHO55TRS_cjs=require('./chunks/chunk-AHO55TRS.cjs'),chunkYC4AEMOP_cjs=require('./chunks/chunk-YC4AEMOP.cjs'),chunkVRQQ33YH_cjs=require('./chunks/chunk-VRQQ33YH.cjs'),oe=require('fs/promises'),De=require('zod'),crypto$1=require('crypto'),he=require('path'),Ne=require('fs'),child_process=require('child_process'),module$1=require('module'),hono=require('hono'),nodeServer=require('@hono/node-server'),nodeWs=require('@hono/node-ws'),streaming=require('hono/streaming'),cors=require('hono/cors'),logger=require('hono/logger'),compress=require('hono/compress'),secureHeaders=require('hono/secure-headers'),timeout=require('hono/timeout'),httpException=require('hono/http-exception'),validator=require('hono/validator'),zodValidator=require('@hono/zod-validator'),minimatch=require('minimatch'),promises=require('timers/promises'),dotenv=require('dotenv'),xdgBasedir=require('xdg-basedir'),url=require('url'),ro=require('markdown-it'),jn=require('yaml'),undici=require('undici'),async_hooks=require('async_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var oe__default=/*#__PURE__*/_interopDefault(oe);var De__default=/*#__PURE__*/_interopDefault(De);var he__default=/*#__PURE__*/_interopDefault(he);var Ne__default=/*#__PURE__*/_interopDefault(Ne);var ro__default=/*#__PURE__*/_interopDefault(ro);var jn__default=/*#__PURE__*/_interopDefault(jn);chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function ir(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n!==void 0&&t(n,r,e))return n}}chunkVRQQ33YH_cjs.j();exports.Binary=void 0;(r=>{function e(n,o,s){let a=0,i=n.length-1;for(;a<=i;){let l=Math.floor((a+i)/2),p=n[l];if(p===void 0)break;let c=s(p);if(c===o)return {found:true,index:l};c<o?a=l+1:i=l-1;}return {found:false,index:a}}r.search=e;function t(n,o,s){let a=s(o),i=0,l=n.length;for(;i<l;){let p=Math.floor((i+l)/2),c=n[p];if(c===void 0)break;s(c)<a?i=p+1:l=p;}return n.splice(i,0,o),n}r.insert=t;})(exports.Binary||(exports.Binary={}));chunkVRQQ33YH_cjs.j();exports.Encode=void 0;(s=>{function e(a){let i=new TextEncoder().encode(a),l=Array.from(i,p=>String.fromCharCode(p)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}s.base64Encode=e;function t(a){let i=atob(a.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(i,p=>p.charCodeAt(0));return new TextDecoder().decode(l)}s.base64Decode=t;async function r(a,i="SHA-256"){let p=new TextEncoder().encode(a),c=await crypto.subtle.digest(i,p);return Array.from(new Uint8Array(c)).map(k=>k.toString(16).padStart(2,"0")).join("")}s.hash=r;function n(a){if(!a)return;let i=2166136261;for(let l=0;l<a.length;l++)i^=a.charCodeAt(l),i=Math.imul(i,16777619);return (i>>>0).toString(36)}s.checksum=n;function o(a,i=5e5){if(!a)return;if(a.length<=i)return n(a);let l=4096,c=[0,Math.floor(a.length*.25),Math.floor(a.length*.5),Math.floor(a.length*.75),a.length-l].map(u=>{let g=Math.max(0,Math.min(a.length-l,u-Math.floor(l/2)));return n(a.slice(g,g+l))??""}).join(":");return `${a.length}:${c}`}s.sampledChecksum=o;})(exports.Encode||(exports.Encode={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();exports.Identifier=void 0;(u=>{let e={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk",command:"cmd",task:"task",heartbeat:"hb",agent:"ag",subagent:"sub",hook:"hok",compaction:"cmp",context:"ctx",experience:"exp",pattern:"pat",knowledge:"knw",evolution:"evo",result:"res"};function t(g){return De__default.default.string().startsWith(e[g])}u.schema=t;let r=26,n=0,o=0;function s(g,k){return i(g,false,k)}u.ascending=s;function a(g,k){return i(g,true,k)}u.descending=a;function i(g,k,E){if(!E)return p(g,k);if(!E.startsWith(e[g]))throw new Error(`ID ${E} does not start with ${e[g]}`);return E}function l(g){let k="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",E="",H=crypto$1.randomBytes(g);for(let U=0;U<g;U++){let q=H[U];q!==void 0&&(E+=k[q%62]);}return E}function p(g,k,E){let H=E??Date.now();H!==n&&(n=H,o=0),o++;let U=BigInt(H)*BigInt(4096)+BigInt(o);U=k?~U:U;let q=Buffer.alloc(6);for(let G=0;G<6;G++)q[G]=Number(U>>BigInt(40-8*G)&BigInt(255));return e[g]+"_"+q.toString("hex")+l(r-12)}u.create=p;function c(g){let k=g.split("_")[0];if(!k)return 0;let E=g.slice(k.length+1,k.length+13),H=BigInt("0x"+E);return Number(H/BigInt(4096))}u.timestamp=c;})(exports.Identifier||(exports.Identifier={}));exports.TruncateContent=void 0;(p=>{p.DEFAULT_MAX_CHARS=4e3,p.DIRECTION="head",p.DIR=chunkYPKMFQLR_cjs.c.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),p.GLOB=chunkYPKMFQLR_cjs.c.join(p.DIR,"*");let o=10080*60*1e3;function s(c,u,g){return g?`[Content truncated. Source: ${g}
1
+ 'use strict';var chunkYC4AEMOP_cjs=require('./chunks/chunk-YC4AEMOP.cjs'),chunkJQNKLHWT_cjs=require('./chunks/chunk-JQNKLHWT.cjs'),chunk6JM5F6FM_cjs=require('./chunks/chunk-6JM5F6FM.cjs'),chunkA2TCSTSM_cjs=require('./chunks/chunk-A2TCSTSM.cjs');require('./chunks/chunk-AHO55TRS.cjs');var chunkVRQQ33YH_cjs=require('./chunks/chunk-VRQQ33YH.cjs'),ue=require('fs/promises'),pe=require('zod'),crypto$1=require('crypto'),dotenv=require('dotenv'),De=require('path'),fs=require('fs'),xdgBasedir=require('xdg-basedir'),url=require('url'),Tn=require('markdown-it'),wt=require('yaml'),undici=require('undici'),async_hooks=require('async_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ue__default=/*#__PURE__*/_interopDefault(ue);var pe__default=/*#__PURE__*/_interopDefault(pe);var De__default=/*#__PURE__*/_interopDefault(De);var Tn__default=/*#__PURE__*/_interopDefault(Tn);var wt__default=/*#__PURE__*/_interopDefault(wt);chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function en(t,e){for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(r!==void 0&&e(r,n,t))return r}}chunkVRQQ33YH_cjs.j();exports.Binary=void 0;(n=>{function t(r,o,i){let a=0,s=r.length-1;for(;a<=s;){let l=Math.floor((a+s)/2),p=r[l];if(p===void 0)break;let c=i(p);if(c===o)return {found:true,index:l};c<o?a=l+1:s=l-1;}return {found:false,index:a}}n.search=t;function e(r,o,i){let a=i(o),s=0,l=r.length;for(;s<l;){let p=Math.floor((s+l)/2),c=r[p];if(c===void 0)break;i(c)<a?s=p+1:l=p;}return r.splice(s,0,o),r}n.insert=e;})(exports.Binary||(exports.Binary={}));chunkVRQQ33YH_cjs.j();exports.Encode=void 0;(i=>{function t(a){let s=new TextEncoder().encode(a),l=Array.from(s,p=>String.fromCharCode(p)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}i.base64Encode=t;function e(a){let s=atob(a.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(s,p=>p.charCodeAt(0));return new TextDecoder().decode(l)}i.base64Decode=e;async function n(a,s="SHA-256"){let p=new TextEncoder().encode(a),c=await crypto.subtle.digest(s,p);return Array.from(new Uint8Array(c)).map(m=>m.toString(16).padStart(2,"0")).join("")}i.hash=n;function r(a){if(!a)return;let s=2166136261;for(let l=0;l<a.length;l++)s^=a.charCodeAt(l),s=Math.imul(s,16777619);return (s>>>0).toString(36)}i.checksum=r;function o(a,s=5e5){if(!a)return;if(a.length<=s)return r(a);let l=4096,c=[0,Math.floor(a.length*.25),Math.floor(a.length*.5),Math.floor(a.length*.75),a.length-l].map(u=>{let d=Math.max(0,Math.min(a.length-l,u-Math.floor(l/2)));return r(a.slice(d,d+l))??""}).join(":");return `${a.length}:${c}`}i.sampledChecksum=o;})(exports.Encode||(exports.Encode={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();exports.Identifier=void 0;(u=>{let t={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk",command:"cmd",task:"task",heartbeat:"hb",agent:"ag",subagent:"sub",hook:"hok",compaction:"cmp",context:"ctx",experience:"exp",pattern:"pat",knowledge:"knw",evolution:"evo",result:"res"};function e(d){return pe__default.default.string().startsWith(t[d])}u.schema=e;let n=26,r=0,o=0;function i(d,m){return s(d,false,m)}u.ascending=i;function a(d,m){return s(d,true,m)}u.descending=a;function s(d,m,g){if(!g)return p(d,m);if(!g.startsWith(t[d]))throw new Error(`ID ${g} does not start with ${t[d]}`);return g}function l(d){let m="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",g="",k=crypto$1.randomBytes(d);for(let S=0;S<d;S++){let R=k[S];R!==void 0&&(g+=m[R%62]);}return g}function p(d,m,g){let k=g??Date.now();k!==r&&(r=k,o=0),o++;let S=BigInt(k)*BigInt(4096)+BigInt(o);S=m?~S:S;let R=Buffer.alloc(6);for(let P=0;P<6;P++)R[P]=Number(S>>BigInt(40-8*P)&BigInt(255));return t[d]+"_"+R.toString("hex")+l(n-12)}u.create=p;function c(d){let m=d.split("_")[0];if(!m)return 0;let g=d.slice(m.length+1,m.length+13),k=BigInt("0x"+g);return Number(k/BigInt(4096))}u.timestamp=c;})(exports.Identifier||(exports.Identifier={}));exports.TruncateContent=void 0;(p=>{p.DEFAULT_MAX_CHARS=4e3,p.DIRECTION="head",p.DIR=chunk6JM5F6FM_cjs.d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),p.GLOB=chunk6JM5F6FM_cjs.d.join(p.DIR,"*");let o=10080*60*1e3;function i(c,u,d){return d?`[Content truncated. Source: ${d}
2
2
  Full ${u} saved to: ${c}
3
3
  Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${u} saved to: ${c}
4
- Use Read tool with offset/limit parameters to view specific sections.]`}async function a(c,u={}){let g=u.maxChars??4e3,k=u.direction??p.DIRECTION,E=u.label??"content",H=u.sourcePath,U=chunkYPKMFQLR_cjs.c.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),q=u.dir??U;if(c.length<=g)return {content:c,truncated:false};let G=exports.Identifier.ascending("context"),V=chunkYPKMFQLR_cjs.c.join(q,G);await oe__default.default.mkdir(q,{recursive:true}).catch(()=>{}),await oe__default.default.writeFile(V,c,"utf-8");let de=c.length-g,se;k==="head"?se=c.slice(0,g):se=c.slice(-g);let fe=s(V,E,H),ke=`${de} characters truncated`;return {content:k==="head"?`${se}
4
+ Use Read tool with offset/limit parameters to view specific sections.]`}async function a(c,u={}){let d=u.maxChars??4e3,m=u.direction??p.DIRECTION,g=u.label??"content",k=u.sourcePath,S=chunk6JM5F6FM_cjs.d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),R=u.dir??S;if(c.length<=d)return {content:c,truncated:false};let P=exports.Identifier.ascending("context"),O=chunk6JM5F6FM_cjs.d.join(R,P);await ue__default.default.mkdir(R,{recursive:true}).catch(()=>{}),await ue__default.default.writeFile(O,c,"utf-8");let ie=c.length-d,U;m==="head"?U=c.slice(0,d):U=c.slice(-d);let ae=i(O,g,k),Me=`${ie} characters truncated`;return {content:m==="head"?`${U}
5
5
 
6
- ...${ke}...
6
+ ...${Me}...
7
7
 
8
- ${fe}`:`...${ke}...
8
+ ${ae}`:`...${Me}...
9
9
 
10
- ${fe}
10
+ ${ae}
11
11
 
12
- ${se}`,truncated:true,outputPath:V,originalLength:c.length,removedLength:de,label:E}}p.truncate=a;function i(c){return c.truncated?s(c.outputPath,c.label):""}p.formatHint=i;async function l(){let c=exports.Identifier.timestamp(exports.Identifier.create("context",false,Date.now()-o)),g=(await oe__default.default.readdir(p.DIR).catch(()=>[])).filter(k=>k.startsWith("context_"));for(let k of g)exports.Identifier.timestamp(k)>=c||await oe__default.default.unlink(chunkYPKMFQLR_cjs.c.join(p.DIR,k)).catch(()=>{});}p.cleanup=l;})(exports.TruncateContent||(exports.TruncateContent={}));chunkVRQQ33YH_cjs.j();exports.SessionTitle=void 0;(i=>{let e="New session - ",t="Child session - ";i.parentTitlePrefix=e,i.childTitlePrefix=t;function o(l=false){return (l?t:e)+chunkZHSHEAQD_cjs.b(new Date)}i.createDefault=o;function s(l){return new RegExp(`^(${e}|${t})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(l)}i.isDefault=s;function a(l){let p=l.match(/^(.+) \(fork #(\d+)\)$/);if(p){let c=p[1]??"",u=parseInt(p[2]??"0",10);return `${c} (fork #${u+1})`}return `${l} (fork #1)`}i.getForked=a;})(exports.SessionTitle||(exports.SessionTitle={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function Gt(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var Le=Gt;function Yt(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var cr=Yt;exports.Lazy=void 0;(r=>(r.lazy=Gt,r.lazyAsync=Yt))(exports.Lazy||(exports.Lazy={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();var ne=chunkZHSHEAQD_cjs.m.create({service:"server"});function ae(e={}){let t=e.port??3e3,r=e.hostname??"0.0.0.0",n=new hono.Hono({strict:true,getPath:a=>{try{return new URL(a.url).pathname}catch{return a.url}}});if(e.onError?n.onError(e.onError):n.onError((a,i)=>(ne.error("Server error",{error:a.message,stack:a.stack}),a instanceof httpException.HTTPException?a.getResponse():i.json({error:"Internal Server Error",message:a.message},500))),e.onNotFound?n.notFound(e.onNotFound):n.notFound(a=>a.json({error:"Not Found",path:a.req.path},404)),!e.websockets&&e.cors&&n.use(cors.cors(typeof e.cors=="boolean"?{origin:"*"}:e.cors)),n.use(logger.logger((a,...i)=>ne.info(a,i))),!e.websockets&&e.secureHeaders&&n.use(secureHeaders.secureHeaders()),!e.websockets&&e.compression&&n.use(compress.compress({encoding:"gzip"})),!e.websockets&&e.timeout&&n.use(timeout.timeout(e.timeout)),e.middlewares)for(let a of e.middlewares)a.path?n.use(a.path,a.handler):n.use(a.handler);if(e.routes)for(let a of e.routes){let i=a.middlewares||[],l=a.method.toUpperCase();a.validation?n.on(l,a.path,zodValidator.zValidator("json",a.validation),...i,a.handler):n.on(l,a.path,...i,a.handler);}e.rpc&&n.post("/rpc/:method",async a=>{let i=a.req.param("method"),l=e.rpc?.[i];if(!l)return a.json({error:"RPC method not found"},404);try{let p=await a.req.json(),c=await l(p,a);return a.json({result:c})}catch(p){return ne.error("RPC error",{method:i,error:p.message}),a.json({error:"RPC execution failed",message:p.message},500)}}),e.fetch&&n.all("*",async a=>await e.fetch(a.req.raw));let o=null,s={url:new URL(`http://${r}:${t}`),port:t,hostname:r,hono:n,async stop(a=false){return o?new Promise((i,l)=>{a&&o.closeAllConnections?.(),o.close(p=>{p?(ne.error("Error closing server",{error:p.message}),l(p)):(o=null,ne.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{ne.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return ne.debug("createServer: calling serve()",{port:t,hostname:r}),o=nodeServer.serve({fetch:n.fetch,port:t,hostname:r}),ne.debug("createServer: serve() returned, server created"),ne.info(`Server running on http://${r}:${t}`),s}function at(e){return ae({rpc:e,port:3e3})}function pr(e,t=3e3,r="0.0.0.0"){return ae({fetch:e,port:t,hostname:r})}function lt(e,t={}){return ae({...t,routes:e})}function ct(e,t={}){return ae({...t,websockets:e})}function ut(e,t={}){let r=Object.entries(e).map(([n,o])=>({method:"get",path:`/stream/${n}`,handler:s=>streaming.streamSSE(s,async a=>{for await(let i of o(s))await a.writeSSE(i);})}));return ae({...t,routes:r,streaming:true})}chunkVRQQ33YH_cjs.j();var le=chunkZHSHEAQD_cjs.m.create({service:"build-api"});async function an(){try{return {available:!0,version:(await import('./chunks/main-RIJAJS2R.cjs')).version||"unknown"}}catch(e){return le.warn("esbuild not available",{error:e.message}),{available:false}}}async function je(){let e=await an();if(!e.available)throw new Error("esbuild is required but not installed. Please install it using: pnpm add -D esbuild");e.version&&e.version<"0.17.0"&&le.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function br(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function ln(e){let t=br(e.compile);t&&le.warn("compile option is no longer supported (Bun runtime removed). The option will be ignored.");let r={entryPoints:e.entrypoints,outdir:e.outdir,bundle:e.bundle??true,conditions:e.conditions,external:e.external,format:e.format??"esm",platform:e.platform??(e.target==="browser"?"browser":"node"),minify:e.minify??false,treeShaking:true,splitting:e.splitting,sourcemap:yr(e.sourcemap),sourcesContent:true,define:e.define,inject:e.inject,legalComments:"eof",loader:e.loader,entryNames:e.entryNames,chunkNames:e.chunkNames,assetNames:e.assetNames,publicPath:e.publicPath,tsconfig:e.tsconfig,charset:"utf8",color:true,logLevel:"info",logLimit:50,plugins:e.plugins??[],metafile:true,write:e.write??true};return t?.outfile&&!e.outdir&&(r.outfile=t.outfile,delete r.outdir),e.target&&(r.target=xr(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),wr(r)}function yr(e){return !e||e==="none"?false:e}function xr(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function wr(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function $e(e){if(e!==void 0)return e.replace(/\\/g,"/")}function nn(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:$e(s.path)||s.path,size:s.contents?.length||0});if(e.metafile?.outputs)for(let[s,a]of Object.entries(e.metafile.outputs)){let i=a;n.some(l=>l.path===s||l.path===$e(s))||n.push({path:$e(s)||s,size:i.bytes||0});}let o=[];if(e.errors?.length>0)for(let s of e.errors)o.push({level:"error",message:s.text||String(s),path:s.location?.file,position:s.location?{line:s.location.line,column:s.location.column}:void 0});if(e.warnings?.length>0)for(let s of e.warnings)o.push({level:"warning",message:s.text||String(s),path:s.location?.file,position:s.location?{line:s.location.line,column:s.location.column}:void 0});return {outputs:n,success:e.errors?.length===0,logs:o,metafile:e.metafile}}async function ft(e){le.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await je();let t=await import('./chunks/main-RIJAJS2R.cjs'),r=Date.now();try{let n=ln(e);le.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return le.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),nn(o,r,s)}catch(n){let o=Date.now(),s=n.message;return le.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?nn(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var Rr={build:ft},cn=Rr;chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function re(e){let t=[],r="",n=0;for(;n<e.length&&(e[n]===" "||e[n]===" ");)n++;for(;n<e.length;){let o=e[n];if(o===" "||o===" "){for(r.length>0&&(t.push(r),r="");n<e.length&&(e[n]===" "||e[n]===" ");)n++;continue}if(o==='"'){for(n++;n<e.length;){let s=e[n];if(s==="\\"&&n+1<e.length){let a=e[n+1];if(a==='"'||a==="\\"||a==="$"||a==="`"){r+=a,n+=2;continue}}if(s==='"'){n++;break}r+=s,n++;}continue}if(o==="'"){for(n++;n<e.length;){let s=e[n];if(s==="'"){n++;break}r+=s,n++;}continue}r+=o,n++;}return r.length>0&&t.push(r),t}function un(e){return /[|&;<>()$`!#]/.test(e)}function dn(e){let t=re(e);if(t.length===0)return {command:"",args:[]};let r={command:t[0],args:t.slice(1)};if(r.args.length>0){let n=r.args[r.args.length-1];try{let o=JSON.parse(n);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(r.options=o,r.args=r.args.slice(0,-1));}catch{}}return r}function pt(e,t=process.platform==="win32"?"windows":"unix"){return t==="windows"?e.includes(" ")||e.includes("&")||e.includes("|")||e.includes("<>")||e.includes("^")||e.includes('"')||e.includes("%")?`"${e.replace(/%/g,"%%").replace(/"/g,'^"')}"`:e:e.includes(" ")||e.includes("'")||e.includes('"')||e.includes("$")||e.includes("`")||e.includes("\\")||e.includes("!")||e.includes("#")||e.includes("&")||e.includes("*")||e.includes("?")||e.includes("|")||e.includes("<")||e.includes(">")||e.includes("(")||e.includes(")")||e.includes(";")?`'${e.replace(/'/g,"'\\''")}'`:e}var Mr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>","2>&1","2>&2","1>&1","1>&2",">&","<&",">&1","<&1",">&2","<&2"]);function fn(e,t=process.platform==="win32"?"windows":"unix"){return Mr.has(e)?e:pt(e,t)}function pn(){return process.platform==="win32"?"windows":"unix"}function me(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>fn(o,r));return [e,...n].join(" ")}function mn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>mn(t)).join(" ");if(e&&typeof e=="object"){if("raw"in e)return String(e.raw);if("toString"in e&&typeof e.toString=="function")return e.toString();if(e instanceof ReadableStream)throw new Error("ReadableStream expressions are not yet supported")}return String(e)}function Er(e,t,r){return {stdout:e,stderr:t,exitCode:r,text(n="utf-8"){return e.toString(n)},json(){let n=e.toString("utf-8");return JSON.parse(n)},arrayBuffer(){let n=e.buffer;if(n instanceof ArrayBuffer)return n.slice(e.byteOffset,e.byteOffset+e.byteLength);let o=new ArrayBuffer(e.byteLength),s=new Uint8Array(o),a=new Uint8Array(n,e.byteOffset,e.byteLength);return s.set(a),o},bytes(){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},blob(){let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return new Blob([n])}}}function ge(e,t={}){let r=re(e);if(r.length===0)throw new Error("Empty shell command");let n=async()=>{let s=await exports.PKG.run(r,{cwd:t.cwd,env:t.env}),a=Er(Buffer.from(s.stdout,"utf-8"),Buffer.from(s.stderr,"utf-8"),s.code);if(s.code!==0&&!t.nothrow)throw Object.assign(new Error(`Command failed with exit code ${s.code}: ${e}
13
- ${s.stderr}`),{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return a},o=n();return Object.defineProperty(o,"stdin",{get(){throw new Error("stdin is not yet supported in EasbotShell. Use PKG.spawn for interactive commands.")},enumerable:true}),o.cwd=function(s){return ge(e,{...t,cwd:s})},o.env=function(s){return ge(e,{...t,env:s})},o.quiet=function(){return ge(e,{...t,quiet:true})},o.lines=async function*(){let i=(await n()).text().split(/\r?\n/);for(let l of i)l.trim()&&(yield l);},o.text=async function(s="utf-8"){return (await n()).text(s)},o.json=async function(){return (await n()).json()},o.arrayBuffer=async function(){return (await n()).arrayBuffer()},o.blob=async function(){return (await n()).blob()},o.nothrow=function(){return ge(e,{...t,nothrow:true})},o.throws=function(s){return ge(e,{...t,nothrow:!s})},o}var Pe=class{constructor(t={}){chunkVRQQ33YH_cjs.c(this,"options");this.options=t;}call(t,...r){let n="";for(let o=0;o<t.length;o++)n+=t[o],o<r.length&&r[o]!==void 0&&(n+=mn(r[o]));return ge(n,this.options)}braces(t){let r=t.match(/^(.*?)\{([^}]+)\}(.*)$/);if(!r)return [t];let[,n="",o="",s=""]=r,a=o.split(",").map(l=>l.trim()),i=[];for(let l of a){let p=`${n}${l}${s}`;p.includes("{")?i.push(...this.braces(p)):i.push(p);}return i}escape(t){return process.platform==="win32"?t.replace(/([&|<>^"%])/g,"^$1"):t.replace(/(["\s'$`\\!*?#&;()<>|])/g,"\\$1")}env(t){return ce({...this.options,env:t})}cwd(t){return ce({...this.options,cwd:t})}nothrow(){return ce({...this.options,nothrow:true})}throws(t){return ce({...this.options,nothrow:!t})}};function ce(e={}){let t=new Pe(e);return new Proxy(t,{apply(r,n,o){return t.call(o[0],...o.slice(1))}})}var gn=ce();function hn(e){return e.replace(/\\/g,"/")}function bn(e){return crypto$1.createHash("md5").update(e).digest("hex").slice(0,8)}var Q=new Map;exports.PKG=void 0;($=>{let e=chunkZHSHEAQD_cjs.m.create({service:"pkg"});async function t(S){let m=S?[S]:["npm","pnpm","bun"];for(let f of m){let d=await $.which(f);if(d)return {name:f,path:d}}}$.packageManager=t;async function r(S,m){if(!S)return process.execPath;let f=m?.PATH||process.env.PATH||process.env.Path||"",d=process.env.EASBOT_BIN_PATH,y=d?f+he__default.default.delimiter+d:f,x=bn(y),h=`${S}:${x}`;if(Q.has(h))return Q.get(h);let P=process.platform==="win32"?"where":"which";try{let{spawn:v}=await import('child_process');return new Promise(T=>{let O=v(P,[S],{env:{...process.env,PATH:y},stdio:["pipe","pipe","ignore"],windowsHide:!0}),D="",B="";O.stdout?.on("data",N=>{D+=N.toString();}),O.stderr?.on("data",N=>{B+=N.toString();}),O.on("close",N=>{if(N===0&&D.trim()){let A=D.trim().split(`
14
- `),F=A.length>0?A[0]?.trim():null;if(F){Q.set(h,F),T(F);return}}Q.set(h,null),T(null);}),setTimeout(()=>{O.kill(),Q.set(h,null),T(null);},5e3);})}catch{return Q.set(h,null),null}}$.which=r;function n(S,m){if(!S)return process.execPath;let f=m?.PATH||process.env.PATH||process.env.Path||"",d=process.env.EASBOT_BIN_PATH,y=d?f+he__default.default.delimiter+d:f,x=bn(y),h=`${S}:${x}`;if(Q.has(h))return Q.get(h);let P=process.platform==="win32"?"where":"which";try{let v=child_process.execSync(`${P} ${S}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"],env:{...process.env,PATH:y},timeout:5e3,windowsHide:!0});if(v.trim()){let T=v.trim().split(`
15
- `),O=T.length>0?T[0]?.trim():null;if(O)return Q.set(h,O),O}}catch{}return Q.set(h,null),null}$.whichSync=n;function o(){Q.clear();}$.clearWhichCache=o;let s=module$1.createRequire(chunkVRQQ33YH_cjs.i);async function a(S,m,f){try{let d=[];if(f?.extraPaths)for(let y of f.extraPaths){let x=he__default.default.join(y,"node_modules");d.push(x);}return m&&d.push(m),d.length>0?s.resolve(S,{paths:d}):s.resolve(S)}catch(d){throw new Error(`Cannot resolve module "${S}"${m?` from "${m}"`:""}: ${d instanceof Error?d.message:String(d)}`)}}$.resolve=a;function i(S){return {get name(){return he__default.default.basename(S)},async exists(){try{return await oe__default.default.access(S),!0}catch{return false}},async getSize(){try{return (await oe__default.default.stat(S)).size}catch{return}},async text(){return await oe__default.default.readFile(S,"utf-8")},textSync(){return Ne__default.default.readFileSync(S,"utf-8")},jsonSync(){let m=Ne__default.default.readFileSync(S,"utf-8");return JSON.parse(m)},async bytes(){e.debug("[PKG.file.bytes] reading file:",{filePath:S});let m=await oe__default.default.readFile(S);return e.debug("[PKG.file.bytes] read succeeded, size:",{size:m.length}),new Uint8Array(m.buffer,m.byteOffset,m.byteLength)},async arrayBuffer(){let m=await oe__default.default.readFile(S);return m.buffer.slice(m.byteOffset,m.byteOffset+m.byteLength)},get type(){let m=he__default.default.extname(S).toLowerCase();return {".txt":"text/plain",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".xml":"application/xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".pdf":"application/pdf",".zip":"application/zip",".wav":"audio/wav",".mp3":"audio/mpeg",".mp4":"video/mp4",".webm":"video/webm"}[m]||"application/octet-stream"},async write(m){let f;if(m instanceof Response){let d=await m.arrayBuffer();f=new Uint8Array(d);}else f=m;await oe__default.default.writeFile(S,f);},async json(){let m=await oe__default.default.readFile(S,"utf-8");return JSON.parse(m)},async stat(){return await oe__default.default.stat(S)}}}$.file=i;async function l(S,m,f){let d;if(m instanceof Response){let y=await m.arrayBuffer();d=new Uint8Array(y);}else d=m;await oe__default.default.writeFile(S,d,f?{mode:f.mode}:void 0);}$.write=l;function p(S,m,f){Ne__default.default.writeFileSync(S,m,f?{mode:f.mode}:void 0);}$.writeSync=p;function c(S,m="utf-8"){return Ne__default.default.readFileSync(S,m)}$.readSync=c;function u(S,m){let f,d;if(typeof S=="object"&&"cmd"in S){let v=S;f=v.cmd,d={cwd:v.cwd,env:v.env,stdout:v.stdout,stderr:v.stderr,stdin:v.stdin,signal:v.signal,windowsHide:v.windowsHide,shell:v.shell};}else f=Array.isArray(S)?S:[S],d=m||{};if(!f||f.length===0||!f[0])throw new Error("Spawn command cannot be empty");let y=[d.stdin==="inherit"?"inherit":d.stdin==="null"?"ignore":"pipe",d.stdout==="inherit"?"inherit":d.stdout==="null"?"ignore":"pipe",d.stderr==="inherit"?"inherit":d.stderr==="null"?"ignore":"pipe"],x={cwd:d.cwd,env:d.env?{...process.env,...d.env}:process.env,stdio:y,timeout:d.timeout};d.shell!==void 0&&(x.shell=d.shell),process.platform==="win32"&&(x.windowsHide=d.windowsHide??true);let h=child_process.spawn(f[0],f.slice(1),x),w;if(d.signal){w=()=>{h.kill();},d.signal.addEventListener("abort",w,{once:true});let v=()=>{w&&(d.signal?.removeEventListener("abort",w),w=void 0);};h.on("close",v),h.on("error",v);}let P=new Promise((v,T)=>{let O=false,D=()=>{O||(O=true,h.removeAllListeners());};if(h.on("close",B=>{D(),v(B??0);}),h.on("error",B=>{D(),T(B);}),d.timeout!==false){let B=d.timeout||3e5;setTimeout(()=>{if(!O){e.debug(`Process timeout after ${B}ms, killing process`,{cmd:f.join(" ")}),D();try{h.kill("SIGKILL");}catch{}T(new Error(`Process timeout after ${B}ms: ${f.join(" ")}`));}},B);}});return {stdout:h.stdout,stderr:h.stderr,stdin:h.stdin,pid:h.pid,exited:P,exitCode:h.exitCode,kill:v=>h.kill(v)}}$.spawn=u;async function g(S,m){let f=m?.stdin??"null",d=m?.stdout??"pipe",y=m?.stderr??"pipe",x=u(S,{cwd:m?.cwd,env:m?.env,stdin:f,stdout:d,stderr:y,windowsHide:m?.windowsHide,shell:m?.shell,timeout:m?.timeout}),h=[],w=[];d==="pipe"&&x.stdout?.on("data",v=>{h.push(v);}),y==="pipe"&&x.stderr?.on("data",v=>{w.push(v);});let P=m?.timeout&&m.timeout>0?setTimeout(()=>{try{x.kill("SIGKILL");}catch{}x.stdout?.destroy(),x.stderr?.destroy(),x.stdin?.end();},m.timeout):void 0;try{let v=await x.exited;return clearTimeout(P),d==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:v,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(w).toString("utf-8")}}catch(v){return clearTimeout(P),d==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:-1,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(w).toString("utf-8")||(v instanceof Error?v.message:String(v))}}}$.run=g;async function k(S,m={},f={}){let d=u(S,{cwd:m.cwd,env:m.env,stdout:"pipe",stderr:"pipe",stdin:"null"}),y="",x="";d.stdout?.on("data",w=>{let P=w.toString("utf-8");y+=P,f.onStdout?.(P);}),d.stderr?.on("data",w=>{let P=w.toString("utf-8");x+=P,f.onStderr?.(P);});let h=m.timeout&&m.timeout>0?setTimeout(()=>{try{d.kill("SIGKILL");}catch{}d.stdout?.destroy(),d.stderr?.destroy();},m.timeout):void 0;try{let w=await d.exited;return clearTimeout(h),f.onExit?.(w),{code:w,stdout:y,stderr:x}}catch(w){clearTimeout(h);let P=w instanceof Error?w.message:String(w);return {code:-1,stdout:y,stderr:x||P}}}$.runWithStream=k;async function E(S){if(typeof S.pipeThrough=="function")try{let y=new TextDecoderStream("utf-8"),h=S.pipeThrough(y).getReader(),w="";try{for(;;){let{done:P,value:v}=await h.read();if(P)break;w+=v;}return w}finally{h.releaseLock();}}catch{}let m=S.getReader(),f=new TextDecoder("utf-8"),d=[];try{for(;;){let{done:y,value:x}=await m.read();if(y)break;d.push(f.decode(x,{stream:!0}));}return d.push(f.decode()),d.join("")}finally{m.releaseLock();}}$.readableStreamToText=E;async function H(S){let m=[];return new Promise((f,d)=>{S.on("data",y=>{typeof y=="string"?m.push(Buffer.from(y)):m.push(y);}),S.on("end",()=>{try{let x=Buffer.concat(m).toString("utf-8");f(x);}catch(y){d(y);}}),S.on("error",y=>{d(y);});})}$.nodeReadableStreamToText=H;function U(S,m=0){let P=new TextEncoder().encode(S),v=P.length,T,O=0;if(v>=16){let A=v-16,F=m+2654435761+2246822519|0,ee=m+2246822519|0,J=m+0|0,K=m-2654435761|0;for(;O<=A;)F=D(F,N(P,O)),O+=4,ee=D(ee,N(P,O)),O+=4,J=D(J,N(P,O)),O+=4,K=D(K,N(P,O)),O+=4;T=B(F,1)+B(ee,7)+B(J,12)+B(K,18)|0;}else T=m+374761393|0;for(T=T+v|0;O+4<=v;)T=T+N(P,O)*3266489917|0,T=B(T,17)*668265263|0,O+=4;for(;O<v;)T=T+P[O]*374761393|0,T=B(T,11)*2654435761|0,O++;return T^=T>>>15,T=T*2246822519|0,T^=T>>>13,T=T*3266489917|0,T^=T>>>16,T>>>0;function D(A,F){return A=A+F*2246822519|0,A=B(A,13),A=A*2654435761|0,A}function B(A,F){return A<<F|A>>>32-F|0}function N(A,F){return (A[F]|A[F+1]<<8|A[F+2]<<16|A[F+3]<<24)>>>0}}$.xxHash32=U;function q(S){let m=0;for(let f of S){let d=f.codePointAt(0)||f.charCodeAt(0);d<127?m+=1:d>=4352&&d<=4447||d>=9001&&d<=9002||d>=11904&&d<=42191&&d!==12351||d>=44032&&d<=55203||d>=63744&&d<=64255||d>=65040&&d<=65049||d>=65072&&d<=65135||d>=65280&&d<=65376||d>=65504&&d<=65510?m+=2:m+=1;}return m}$.stringWidth=q;class G{constructor(m){chunkVRQQ33YH_cjs.c(this,"pattern");this.pattern=m;}async*scan(m){let f=chunkAHO55TRS_cjs.b.stream(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for await(let d of f)yield hn(d);}*scanSync(m){let f=chunkAHO55TRS_cjs.a(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for(let d of f)yield hn(d);}match(m){return minimatch.minimatch(m,this.pattern)}}$.Glob=G,$.stdin=process.stdin,$.stdout=process.stdout,$.stderr=process.stderr,$.sleep=S=>new Promise(m=>setTimeout(m,S)),$.color=(S,m)=>({black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",blink:"\x1B[5m",inverse:"\x1B[7m",hidden:"\x1B[8m",strikethrough:"\x1B[9m",reset:"\x1B[0m"})[S.toLowerCase()]||null,$.hash={xxHash32:$.xxHash32},$.build=cn.build,$.server=ae,$.nodeWebSocket=nodeWs.createNodeWebSocket,$.restServer=lt,$.rpcServer=at,$.streamingServer=ut,$.webSocketServer=ct;})(exports.PKG||(exports.PKG={}));var _r=exports.PKG.readableStreamToText;exports.PKG.nodeReadableStreamToText;exports.PKG.which;var Br=exports.PKG.whichSync;exports.PKG.spawn;exports.PKG.run;var xn=200,wn={bash:{login:true,posix:true},dash:{login:true,posix:true},fish:{deny:true,login:true},ksh:{login:true,posix:true},nu:{deny:true},powershell:{ps:true},pwsh:{ps:true},sh:{login:true,posix:true},zsh:{login:true,posix:true}};exports.Shell=void 0;(m=>{let e=chunkZHSHEAQD_cjs.m.create({service:"shell"});async function t(f,d){let y=f.pid;if(!(!y||d?.exited?.())){if(process.platform==="win32"){await new Promise(x=>{let h=child_process.spawn("taskkill",["/pid",String(y),"/f","/t"],{stdio:"ignore",windowsHide:true});h.once("exit",()=>x()),h.once("error",()=>x());});return}try{process.kill(-y,"SIGTERM"),await promises.setTimeout(xn),d?.exited?.()||process.kill(-y,"SIGKILL");}catch{f.kill("SIGTERM"),await promises.setTimeout(xn),d?.exited?.()||f.kill("SIGKILL");}}}m.killTree=t;function r(f){if(process.platform!=="win32"||!f.includes("/")&&!f.includes("\\")&&!f.includes(":"))return f;let d=chunkYPKMFQLR_cjs.c.normalize(f);return E(d)==="bash"&&g()||d}function n(f){return wn[E(f)]}function o(f){return n(f)?.deny!==true}function s(f){return chunkYPKMFQLR_cjs.c.isAbsolute(f)}function a(f){let d=r(f);if(s(d))return chunkYPKMFQLR_cjs.c.stat(d)?.isFile()?d:void 0;let y=exports.PKG.whichSync(d);return y?chunkYPKMFQLR_cjs.c.normalize(y):void 0}function i(){return Array.from(new Set([exports.PKG.whichSync("pwsh"),exports.PKG.whichSync("powershell"),g(),process.env.COMSPEC||"cmd.exe"].filter(f=>!!f).map(r)))}async function l(){let f=await chunkYPKMFQLR_cjs.c.readText("/etc/shells").catch(()=>"");return f?Array.from(new Set(f.split(`
16
- `).filter(d=>d.trim()&&!d.startsWith("#")))):["/bin/bash","/bin/zsh","/bin/sh"]}function p(f,d){if(f&&(!d?.acceptable||o(f))){let y=a(f);if(y)return y}return process.platform==="win32"?i()[0]:k()}m.defaultPreferred=Le(()=>p(process.env.SHELL)),m.defaultAcceptable=Le(()=>p(process.env.SHELL,{acceptable:true}));function g(){if(process.platform!=="win32")return;if(process.env.EASBOT_GIT_BASH_PATH)return chunkYPKMFQLR_cjs.c.normalize(process.env.EASBOT_GIT_BASH_PATH);let f=exports.PKG.whichSync("git");if(!f)return;let d=chunkYPKMFQLR_cjs.c.normalize(he__default.default.join(f,"..","..","bin","bash.exe"));if((chunkYPKMFQLR_cjs.c.stat(d)?.size??0)>0)return d}m.gitbash=g;function k(){if(process.platform==="win32"){let d=g();return d||"/bin/sh"}if(process.platform==="darwin")return "/bin/zsh";let f=exports.PKG.whichSync("bash");return f?chunkYPKMFQLR_cjs.c.normalize(f):"/bin/sh"}function E(f){return he__default.default.posix.basename(chunkYPKMFQLR_cjs.c.toUnixPath(f)).toLowerCase()}m.name=E;function H(f){return n(f)?.login===true}m.login=H;function U(f){return n(f)?.posix===true}m.posix=U;function q(f){return n(f)?.ps===true}m.ps=q;function G(f){let d=r(f),y=E(d);return {path:d,name:y,acceptable:o(y)}}function V(f,d,y){let x=E(f),h=re(d),w=me(h[0]??d,h.slice(1));return x==="nu"||x==="fish"?["-c",w]:x==="zsh"?["-l","-c",`
17
- [[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
18
- [[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
19
- cd -- "$1"
20
- ${w}
21
- `,"easbot",y]:x==="bash"?["-l","-c",`${process.platform==="win32"?`cmd /c chcp 65001 >nul 2>&1 || true
22
- `:""}shopt -s expand_aliases
23
- [[ -f ~/.bashrc ]] && source ~/.bashrc >/dev/null 2>&1 || true
24
- cd -- "$1"
25
- ${w}
26
- `,"easbot",y]:/^cmd(\.exe)?$/i.test(x)?["/c",`chcp 65001 >nul 2>&1 && ${w}`]:q(x)?["-NoProfile","-Command",`[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${w}`]:["-c",w]}m.args=V;function de(f){return f?p(f):(0, m.defaultPreferred)()}m.preferred=de;function se(f){return f?p(f,{acceptable:true}):(0, m.defaultAcceptable)()}m.acceptable=se;function fe(){m.defaultPreferred.reset(),m.defaultAcceptable.reset();}m.reset=fe;async function ke(){return (process.platform==="win32"?i():await l()).filter(d=>a(d)).map(G)}m.list=ke;function Te(f){return wn[E(f)]}m.metaInfo=Te;function Ht(f){return /[|&;<>()$`!#]/.test(f)}m.needsShell=Ht;function I(){return process.platform==="win32"?i():["/bin/bash","/bin/zsh","/bin/sh"]}m.platformShells=I;function C(f){return f?!!a(f):false}m.isValid=C;async function _(f){let d=a(f);if(!d)return;let y=E(d);if(!/^cmd(\.exe)?$/i.test(y))try{let x;q(y)?x=["-NoProfile","-Command","$PSVersionTable.PSVersion.ToString()"]:x=["--version"],e.debug(`\u83B7\u53D6 Shell \u7248\u672C: ${d}`,{shell:d,args:x});let h=await exports.PKG.run([d,...x]);if(h.code===0){let w=h.stdout.trim().split(`
27
- `)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${w}`),w}e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${h.code}`,{stderr:h.stderr});}catch(x){e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5F02\u5E38: ${x}`);}}m.version=_;class W extends Error{constructor(y,x,h,w){super(y);chunkVRQQ33YH_cjs.c(this,"message",y);chunkVRQQ33YH_cjs.c(this,"pkg",x);chunkVRQQ33YH_cjs.c(this,"version",h);chunkVRQQ33YH_cjs.c(this,"originalError",w);this.name="InstallFailedError";}}m.InstallFailedError=W;async function Y(f,d="latest",y){let{Lock:x}=await import('./chunks/lock-LMCPTUNU.cjs'),{Filesystem:h}=await import('./chunks/filesystem-OYOMZ7F3.cjs'),{PackageRegistry:w}=await import('./chunks/registry-DPBQYUUX.cjs');y=y??process.env.EASBOT_CACHE_PATH??he__default.default.join(".easbot","cache");let P=await x.write("pkg-install");try{let v=he__default.default.posix.join(y,"node_modules",f),T=he__default.default.posix.join(y,"package.json"),D=(await h.readJson(T).catch(async()=>{let X={dependencies:{}};return await h.writeJson(T,X),X})).dependencies??{},B=await h.exists(v),N=D[f],A=!1;if(!B||!N)A=!0;else {if(d!=="latest"&&N===d)return v;if(d==="latest"){if(!await w.isOutdated(f,N,y))return v;e.info("Cached version is outdated, proceeding with install",{pkg:f,cachedVersion:N}),A=!0;}}if(!A)return v;let F=m.acceptable(process.platform==="win32"?"cmd":void 0)??k(),ee=`${f}@${d}`;e.info("installing package",{pkg:f,version:d,cache:y,shell:F});let J=await exports.PKG.packageManager();if(!J)throw new W("No package manager found (npm, pnpm, bun)",f,d,"No package manager available");let K=J.name,Qe=K==="pnpm"?"add":"install",et=`${J.name} ${Qe} --save-exact ${ee}`;e.info(`Using ${K} to install package`,{pkg:f,version:d,shell:F,pmPath:J.path});try{let X=await m.run(F,et,{cwd:y,timeout:6e5,windowsHide:!0});if(X.code!==0)throw new Error(`Package manager exited with code ${X.code}: ${X.stderr}`);e.info(`Successfully installed ${f}@${d} with ${K}`);}catch(X){let Wt=X instanceof Error?X:new Error(String(X));if(!await h.exists(v))throw new W(`Failed to install ${f}@${d}`,f,d,Wt.message);e.warn("Package install failed but module exists, continuing",{error:Wt.message});}let tt=d;d==="latest"&&(tt=(await h.readJson(he__default.default.join(v,"package.json")).catch(()=>({})))?.version??"unknown");let _e=await h.readJson(T);return _e.dependencies=_e.dependencies??{},_e.dependencies[f]=tt,await h.writeJson(T,_e),e.info("Package installation completed",{pkg:f,version:tt,path:v}),v}finally{P[Symbol.dispose]();}}m.install=Y;async function ve(f,d,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),w=m.args(x,d,h);e.debug(`run shell process: ${x} ${w.join(" ")}`,{command:d,cwd:h});let{windowsHide:P,env:v,...T}=y??{},O={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...v};process.platform==="win32"&&(O.CHCP="65001");let{stdin:D,stdout:B,stderr:N,timeout:A,signal:F,...ee}=T??{},J={...ee,cwd:h,env:O,windowsHide:process.platform==="win32"?P??true:void 0,shell:ee.shell,timeout:A},K=E(x),Qe=/^cmd(\.exe)?$/i.test(K),et=process.platform==="win32"&&Qe?"cmd":x;return exports.PKG.run([et,...w],J)}m.run=ve;function $(f,d,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),w=m.args(x,d,h);e.debug(`Spawn shell process: ${x} ${w.join(" ")}`,{command:d,cwd:h});let{stdin:P,stdout:v,stderr:T,timeout:O,signal:D,windowsHide:B,env:N,...A}=y??{},F={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...N};process.platform==="win32"&&(F.CHCP="65001");let ee=E(x),J=/^cmd(\.exe)?$/i.test(ee),K={...A,cwd:h,env:F,windowsHide:process.platform==="win32"?B??true:void 0,shell:A.shell,timeout:O};return exports.PKG.spawn([J?"cmd":x,...w],K)}m.spawn=$;function S(f,...d){let y=f.reduce((h,w,P)=>h+w+(d[P]??""),""),x=(h={})=>({quiet:()=>x({...h,quiet:true}),nothrow:()=>x({...h,nothrow:true}),cwd:w=>x({...h,cwd:w}),env:w=>x({...h,env:w}),stdin:w=>x({...h,stdin:w}),stdout:w=>x({...h,stdout:w}),stderr:w=>x({...h,stderr:w}),text:async()=>{let w=re(y.trim());if(w.length===0)throw new Error("Empty command");let P=w[0]??"",v=E(P),T=/^cmd(\.exe)?$/i.test(v),O=process.platform==="win32"&&T?"cmd":Te(P)?P:void 0,D=me(P,w.slice(1)),B=await m.run(O,D,{cwd:h.cwd,env:h.env,stdin:h.stdin,stdout:h.stdout,stderr:h.stderr,timeout:h.timeout,windowsHide:process.platform==="win32"?h.windowsHide??true:void 0,shell:h.shell});if(B.code!==0&&!h.nothrow)throw new Error(`Command failed with exit code ${B.code}: ${y}
28
- ${B.stderr}`);return B.stdout},lines:async()=>(await x(h).text()).split(`
29
- `).filter(P=>P.trim()),then:(w,P)=>{let v=re(y.trim()),T=v[0]??"",O=E(T),D=/^cmd(\.exe)?$/i.test(O),B=process.platform==="win32"&&D?"cmd":Te(T)?T:void 0,N=me(T,v.slice(1));return m.run(B,N,{cwd:h.cwd,env:h.env,stdin:h.stdin,stdout:h.stdout,stderr:h.stderr,timeout:h.timeout,windowsHide:process.platform==="win32"?h.windowsHide??true:void 0,shell:h.shell}).then(A=>{if(A.code!==0&&!h.nothrow){let F=new Error(`Command failed with exit code ${A.code}: ${y}
30
- ${A.stderr}`);if(P){P(F);return}throw F}return w({exitCode:A.code,stdout:new TextEncoder().encode(A.stdout),stderr:new TextEncoder().encode(A.stderr),text:()=>A.stdout,lines:()=>A.stdout.split(`
31
- `).filter(F=>F.trim())})},P)}});return x()}m.$=S;})(exports.Shell||(exports.Shell={}));var $r=exports.Shell.$;chunkVRQQ33YH_cjs.j();var Me=class Me extends Error{static create(t,r){var s;let n=De__default.default.object({name:De__default.default.literal(t),data:r}).meta({ref:t}),o=(s=class extends Me{constructor(i,l){super(t,l);chunkVRQQ33YH_cjs.c(this,"data",i);chunkVRQQ33YH_cjs.c(this,"name",t);this.name=t;}static isInstance(i){return typeof i=="object"&&"name"in i&&i.name===t}schema(){return n}toObject(){return {name:t,data:this.data}}},chunkVRQQ33YH_cjs.c(s,"Schema",n),s);return Object.defineProperty(o,"name",{value:t}),o}};chunkVRQQ33YH_cjs.c(Me,"Unknown",Me.create("UnknownError",De__default.default.object({message:De__default.default.string()})));var mt=Me;chunkVRQQ33YH_cjs.j();exports.Ignore=void 0;(t=>{function e(r){return new ht(r)}t.create=e;})(exports.Ignore||(exports.Ignore={}));var ht=class{constructor(t){chunkVRQQ33YH_cjs.c(this,"rules",[]);chunkVRQQ33YH_cjs.c(this,"ignorecase");chunkVRQQ33YH_cjs.c(this,"debug");this.ignorecase=t?.ignorecase??false,this.debug=t?.debug??false;}add(t){let r=typeof t=="string"?t.split(`
32
- `):t;for(let n=0;n<r.length;n++){let o=r[n];this.parseRule(o,n+1);}return this}parseRule(t,r){let n=t;if(n.length===0||n.startsWith("#"))return;let s=n.startsWith("!");if(s&&(n=n.slice(1)),n=n.trimEnd(),n.length===0)return;if(n.startsWith("\\#")){n=n.slice(1);return}if(n.startsWith("#"))return;let i=n.endsWith("/");if(i&&(n=n.slice(0,-1)),n.length===0)return;let l=this.patternToRegex(n);l&&this.rules.push({pattern:n,regex:l,negative:s,isDirectory:i,original:t,lineNumber:r});}ignores(t,r){let n=this.normalizePath(t),o=r??t.endsWith("/"),s=this.checkIgnore(n,o);return this.debug&&console.log(`Ignore.ignores("${t}", isDirectory=${o}) => ${s}`),s}checkIgnore(t,r){let n=false;for(let o of this.rules)o.isDirectory&&!r||o.regex.test(t)&&(o.negative?n=false:n=true);return n}filter(t){return t.filter(r=>!this.ignores(r))}createFilter(){return t=>!this.ignores(t)}patternToRegex(t){let r=[],n=0,o=t.length;for(;n<o;){let p=t[n];if(p==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),n+=2;continue}else {r.push("\\\\"),n++;continue}if(p==="*")if(n+1<o&&t[n+1]==="*")if(n+2<o&&t[n+2]==="/")if(n===0||t[n-1]==="/")if(n+3>=o){r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else if(n===0||t[n-1]==="/")if(n+2>=o){r.push(".*"),n+=2;continue}else {r.push("(?:/.*)*"),n+=2;continue}else {r.push(".*"),n+=2;continue}else {r.push("[^/]*"),n++;continue}if(p==="?"){r.push("[^/]"),n++;continue}if(p==="["){let c=this.findMatchingBracket(t,n);if(c!==-1){let u=t.slice(n,c+1);(u.startsWith("[!")||u.startsWith("[^"))&&(u="[^"+u.slice(2)),this.ignorecase&&(u=u.toLowerCase()),r.push(u),n=c+1;continue}}if(p==="/"){r.push("/"),n++;continue}if(".+$^{}|()".includes(p)){r.push("\\"+p),n++;continue}if(this.ignorecase&&p>="A"&&p<="Z"){r.push("["+p.toLowerCase()+p+"]"),n++;continue}r.push(p),n++;}let s=r.join(""),a=s.startsWith("/"),i=s.endsWith("/")&&!s.endsWith("\\/");a||(s="(?:.*/)?"+s),i&&(s=s.slice(0,-1)),!i&&!s.endsWith("(?:/.*)*")&&(s="(?:"+s+")(?:/.*)?");let l=this.ignorecase?"i":"";try{return new RegExp("^"+s+"$",l)}catch(p){return this.debug&&console.error(`Failed to create regex for pattern "${t}":`,p),null}}escapeRegexChar(t){return "\\[]{}().+^$|".includes(t)?"\\"+t:t}findMatchingBracket(t,r){let n=r+1,o=t.length;for((n>=o||t[n]==="!"||t[n]==="^")&&n++;n<o;){let s=t[n];if(s==="\\"&&n+1<o){n+=2;continue}if(s==="]")return n;if(n+2<o&&t[n+1]==="-"&&t[n+2]!=="]"){n+=3;continue}n++;}return -1}normalizePath(t){let r=t.replace(/\\/g,"/");if(r==="/")return "";for(;r.startsWith("./");)r=r.slice(2);return r}};chunkVRQQ33YH_cjs.j();function Sn(e,t){let r=n=>{let o;try{o=e.parse(n);}catch(s){throw console.trace("schema validation failure stack trace:"),s instanceof De.z.ZodError&&console.error("schema validation issues:",JSON.stringify(s.issues,null,2)),s}return t(o)};return r.force=n=>t(n),r.schema=e,r}var Nr=Sn;exports.Fn=void 0;(t=>t.fn=Sn)(exports.Fn||(exports.Fn={}));chunkVRQQ33YH_cjs.j();function Hr(e={}){let t=e.isDevelopment??false,r=t?".env.dev":".env",n=e.globalConfigPath??(xdgBasedir.xdgConfig?he__default.default.join(xdgBasedir.xdgConfig,"easbot"):void 0),o=e.projectRoot??process.cwd(),s=o?he__default.default.join(o,".easbot"):void 0,a=[{root:n,label:"global"},{root:o,label:"project"},{root:s,label:"workspace"}];for(let{root:i}of a){if(!i)continue;let l=he__default.default.join(i,r);if(!Ne.existsSync(l))continue;let p=dotenv.config({path:l,override:true,debug:t,encoding:"utf-8",quiet:!t});if(t&&p.parsed){let u=["XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_CACHE_HOME","XDG_STATE_HOME","XDG_RUNTIME_DIR","EASBOT_CONFIG_PATH","EASBOT_DATA_PATH","EASBOT_CACHE_PATH","EASBOT_STATE_PATH","EASBOT_LOG_PATH","EASBOT_BIN_PATH"].filter(g=>g in p.parsed);u.length>0&&console.warn(`[loadEnv] ${l} contains keys that have no effect: ${u.join(", ")}.
12
+ ${U}`,truncated:true,outputPath:O,originalLength:c.length,removedLength:ie,label:g}}p.truncate=a;function s(c){return c.truncated?i(c.outputPath,c.label):""}p.formatHint=s;async function l(){let c=exports.Identifier.timestamp(exports.Identifier.create("context",false,Date.now()-o)),d=(await ue__default.default.readdir(p.DIR).catch(()=>[])).filter(m=>m.startsWith("context_"));for(let m of d)exports.Identifier.timestamp(m)>=c||await ue__default.default.unlink(chunk6JM5F6FM_cjs.d.join(p.DIR,m)).catch(()=>{});}p.cleanup=l;})(exports.TruncateContent||(exports.TruncateContent={}));chunkVRQQ33YH_cjs.j();exports.SessionTitle=void 0;(s=>{let t="New session - ",e="Child session - ";s.parentTitlePrefix=t,s.childTitlePrefix=e;function o(l=false){return (l?e:t)+chunkA2TCSTSM_cjs.b(new Date)}s.createDefault=o;function i(l){return new RegExp(`^(${t}|${e})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(l)}s.isDefault=i;function a(l){let p=l.match(/^(.+) \(fork #(\d+)\)$/);if(p){let c=p[1]??"",u=parseInt(p[2]??"0",10);return `${c} (fork #${u+1})`}return `${l} (fork #1)`}s.getForked=a;})(exports.SessionTitle||(exports.SessionTitle={}));chunkVRQQ33YH_cjs.j();var Q=class Q extends Error{static create(e,n){var i;let r=pe__default.default.object({name:pe__default.default.literal(e),data:n}).meta({ref:e}),o=(i=class extends Q{constructor(s,l){super(e,l);chunkVRQQ33YH_cjs.c(this,"data",s);chunkVRQQ33YH_cjs.c(this,"name",e);this.name=e;}static isInstance(s){return s!==null&&typeof s=="object"&&"name"in s&&s.name===e}schema(){return r}toObject(){return {name:e,data:this.data}}},chunkVRQQ33YH_cjs.c(i,"Schema",r),i);return Object.defineProperty(o,"name",{value:e}),o}};chunkVRQQ33YH_cjs.c(Q,"Unknown",Q.create("UnknownError",pe__default.default.object({message:pe__default.default.string()})));var Le=Q;chunkVRQQ33YH_cjs.j();exports.Ignore=void 0;(e=>{function t(n){return new Ae(n)}e.create=t;})(exports.Ignore||(exports.Ignore={}));var Ae=class{constructor(e){chunkVRQQ33YH_cjs.c(this,"rules",[]);chunkVRQQ33YH_cjs.c(this,"ignorecase");chunkVRQQ33YH_cjs.c(this,"debug");this.ignorecase=e?.ignorecase??false,this.debug=e?.debug??false;}add(e){let n=typeof e=="string"?e.split(`
13
+ `):e;for(let r=0;r<n.length;r++){let o=n[r];this.parseRule(o,r+1);}return this}parseRule(e,n){let r=e,o=e;if(r.length===0||r.startsWith("#"))return;let i=r.startsWith("!");if(i&&(r=r.slice(1)),r=r.trim(),r.length===0||(r.startsWith("\\#")&&(r=r.slice(1)),r.startsWith("#")))return;let a=r.startsWith("/");a&&(r=r.slice(1));let s=r.endsWith("/");s&&(r=r.slice(0,-1)),r.length!==0&&this.rules.push({pattern:r,negative:i,isDirectory:s,anchored:a,original:o,lineNumber:n});}ignores(e,n){let r=this.normalizePath(e),o=n??e.endsWith("/"),i=this.checkIgnore(r,o);return this.debug&&console.log(`Ignore.ignores("${e}", isDirectory=${o}) => ${i}`),i}checkIgnore(e,n){let r=false;for(let o of this.rules)o.isDirectory&&!n||this.matchPath(o,e)&&(o.negative?r=false:r=true);return r}matchPath(e,n){let r=this.ignorecase?n.toLowerCase():n,i=this.ignorecase?e.pattern.toLowerCase():e.pattern;if(e.anchored)return chunk6JM5F6FM_cjs.a.match(r,i);if(i.includes("/"))return chunk6JM5F6FM_cjs.a.match(r,i);let a=r.split("/");for(let s of a)if(chunk6JM5F6FM_cjs.a.match(s,i))return true;return false}filter(e){return e.filter(n=>!this.ignores(n))}createFilter(){return e=>!this.ignores(e)}normalizePath(e){let n=e.replace(/\\/g,"/");if(n==="/")return "";for(;n.startsWith("./");)n=n.slice(2);return n.endsWith("/")&&n.length>1&&(n=n.slice(0,-1)),n}};chunkVRQQ33YH_cjs.j();function st(t,e){let n=r=>{let o;try{o=t.parse(r);}catch(i){throw console.trace("schema validation failure stack trace:"),i instanceof pe.z.ZodError&&console.error("schema validation issues:",JSON.stringify(i.issues,null,2)),i}return e(o)};return n.force=r=>e(r),n.schema=t,n}var on=st;exports.Fn=void 0;(e=>e.fn=st)(exports.Fn||(exports.Fn={}));chunkVRQQ33YH_cjs.j();function ln(t={}){let e=t.isDevelopment??false,n=e?".env.dev":".env",r=t.globalConfigPath??(xdgBasedir.xdgConfig?De__default.default.join(xdgBasedir.xdgConfig,"easbot"):void 0),o=t.projectRoot??process.cwd(),i=o?De__default.default.join(o,".easbot"):void 0,a=[{root:r,label:"global"},{root:o,label:"project"},{root:i,label:"workspace"}];for(let{root:s}of a){if(!s)continue;let l=De__default.default.join(s,n);if(!fs.existsSync(l))continue;let p=dotenv.config({path:l,override:true,debug:e,encoding:"utf-8",quiet:!e});if(e&&p.parsed){let u=["XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_CACHE_HOME","XDG_STATE_HOME","XDG_RUNTIME_DIR","EASBOT_CONFIG_PATH","EASBOT_DATA_PATH","EASBOT_CACHE_PATH","EASBOT_STATE_PATH","EASBOT_LOG_PATH","EASBOT_BIN_PATH"].filter(d=>d in p.parsed);u.length>0&&console.warn(`[loadEnv] ${l} contains keys that have no effect: ${u.join(", ")}.
33
14
  Reason: xdg-basedir caches XDG_* on import, so this .env file loads too late.
34
- How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}chunkVRQQ33YH_cjs.j();async function Wr(e,t){if(process.env.EASBOT_CLIENT==="acp")try{let s=process.platform==="win32"?"cmd":void 0,a=exports.Shell.spawn(s,`git ${e.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:t.cwd,env:t.env?{...process.env,...t.env}:process.env}),[i,l,p]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),u=Buffer.from(p);return {exitCode:i,text:()=>c.toString(),stdout:c,stderr:u}}catch(s){let a=Buffer.from(s instanceof Error?s.message:String(s));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:a}}let r=t.env?{...process.env,...t.env}:void 0,n=exports.Shell.$`git ${e.join(" ")}`.quiet().nothrow().cwd(t.cwd);r&&(n=n.env(r));let o=await n;return {exitCode:o.exitCode,text:()=>o.text(),stdout:o.stdout,stderr:o.stderr}}chunkVRQQ33YH_cjs.j();function vn(e){return e?he.dirname(url.fileURLToPath(e)):typeof __dirname<"u"?__dirname:process.cwd()}function Tn(e,t,r=3){function n(o,s){if(s>r||!Ne.existsSync(o))return null;try{let a=Ne.readdirSync(o);for(let i of a){let l=he.join(o,i);try{let p=Ne.statSync(l);if(p.isFile()&&l.endsWith(t))return l;if(p.isDirectory()&&s<r){let c=n(l,s+1);if(c)return c}}catch{}}}catch{}return null}return n(e,0)}function Pn(e,t){let r=he.join(e,t);if(Ne.existsSync(r))return r;let n=t.split("/").pop()||t,o=e;for(let s=0;s<5;s++){let a=he.join(o,"assets","txt");if(Ne.existsSync(a)){let p=Tn(a,n,5);if(p)return p}let i=he.join(o,"dist","assets","txt");if(Ne.existsSync(i)){let p=Tn(i,n,5);if(p)return p}let l=he.join(o,"..");if(l===o)break;o=l;}return r}function Vr(e,t){return exports.Lazy.lazy(()=>{try{let r=vn(t),n=Pn(r,e);return exports.PKG.file(n).textSync()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}function Jr(e,t){return exports.Lazy.lazy(async()=>{try{let r=vn(t),n=Pn(r,e);return await exports.PKG.file(n).text()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}chunkVRQQ33YH_cjs.j();function Xr(e){return e()}chunkVRQQ33YH_cjs.j();function Kr(e){if(!e||typeof e!="string")return {provider:"",model:""};let t=e.indexOf("/");return t===-1?{provider:"",model:e}:{provider:e.substring(0,t),model:e.substring(t+1)}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function xt(e,t,r,n=()=>true){let o=-1,s=-1,a=0;for(let i=t;i<r;i++){if(!n(i))continue;let l=e[i];if(l){if(l==="("){a+=1;continue}if(l===")"&&a>0){a-=1;continue}a===0&&(l===`
35
- `?o=i:/\s/.test(l)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function Zr(e,t){if(!e)return [];if(t<=0)return [e];if(e.length<=t)return [e]}function be(e,t,r){try{let n=De.z.string().parse(e),o=De.z.number().int().parse(t),s=Zr(n,o);if(s)return s;let a=wt(n,o,i=>{let{lastNewline:l,lastWhitespace:p}=xt(i,0,i.length);return l>0?l:p});return r?.minLength&&r.minLength>0&&(a=Mn(a,r.minLength)),a}catch(n){return console.warn("Invalid input for chunkText:",n),typeof e=="string"&&e.length>0?[e]:[]}}function Mn(e,t){if(e.length<=1||t<=0)return e;let r=[],n=e[0]??"";for(let o=1;o<e.length;o++){let s=e[o]??"";n.length<t?n=n+`
15
+ How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}chunkVRQQ33YH_cjs.j();async function cn(t,e){if(process.env.EASBOT_CLIENT==="acp")try{let i=process.platform==="win32"?"cmd":void 0,a=chunkJQNKLHWT_cjs.G.spawn(i,`git ${t.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:e.cwd,env:e.env?{...process.env,...e.env}:process.env}),[s,l,p]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),u=Buffer.from(p);return {exitCode:s,text:()=>c.toString(),stdout:c,stderr:u}}catch(i){let a=Buffer.from(i instanceof Error?i.message:String(i));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:a}}let n=e.env?{...process.env,...e.env}:void 0,r=chunkJQNKLHWT_cjs.G.$`git ${t.join(" ")}`.quiet().nothrow().cwd(e.cwd);n&&(r=r.env(n));let o=await r;return {exitCode:o.exitCode,text:()=>o.text(),stdout:o.stdout,stderr:o.stderr}}chunkVRQQ33YH_cjs.j();function lt(t){return t?De.dirname(url.fileURLToPath(t)):typeof __dirname<"u"?__dirname:process.cwd()}function at(t,e,n=3){function r(o,i){if(i>n||!fs.existsSync(o))return null;try{let a=fs.readdirSync(o);for(let s of a){let l=De.join(o,s);try{let p=fs.statSync(l);if(p.isFile()&&l.endsWith(e))return l;if(p.isDirectory()&&i<n){let c=r(l,i+1);if(c)return c}}catch{}}}catch{}return null}return r(t,0)}function ct(t,e){let n=De.join(t,e);if(fs.existsSync(n))return n;let r=e.split("/").pop()||e,o=t;for(let i=0;i<5;i++){let a=De.join(o,"assets","txt");if(fs.existsSync(a)){let p=at(a,r,5);if(p)return p}let s=De.join(o,"dist","assets","txt");if(fs.existsSync(s)){let p=at(s,r,5);if(p)return p}let l=De.join(o,"..");if(l===o)break;o=l;}return n}function mn(t,e){return chunkJQNKLHWT_cjs.c.lazy(()=>{try{let n=lt(e),r=ct(n,t);return chunkJQNKLHWT_cjs.D.file(r).textSync()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}function hn(t,e){return chunkJQNKLHWT_cjs.c.lazy(async()=>{try{let n=lt(e),r=ct(n,t);return await chunkJQNKLHWT_cjs.D.file(r).text()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}chunkVRQQ33YH_cjs.j();function gn(t){return t()}chunkVRQQ33YH_cjs.j();function yn(t){if(!t||typeof t!="string")return {provider:"",model:""};let e=t.indexOf("/");return e===-1?{provider:"",model:t}:{provider:t.substring(0,e),model:t.substring(e+1)}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function ze(t,e,n,r=()=>true){let o=-1,i=-1,a=0;for(let s=e;s<n;s++){if(!r(s))continue;let l=t[s];if(l){if(l==="("){a+=1;continue}if(l===")"&&a>0){a-=1;continue}a===0&&(l===`
16
+ `?o=s:/\s/.test(l)&&(i=s));}}return {lastNewline:o,lastWhitespace:i}}function bn(t,e){if(!t)return [];if(e<=0)return [t];if(t.length<=e)return [t]}function q(t,e,n){try{let r=pe.z.string().parse(t),o=pe.z.number().int().parse(e),i=bn(r,o);if(i)return i;let a=Be(r,o,s=>{let{lastNewline:l,lastWhitespace:p}=ze(s,0,s.length);return l>0?l:p});return n?.minLength&&n.minLength>0&&(a=pt(a,n.minLength)),a}catch(r){return console.warn("Invalid input for chunkText:",r),typeof t=="string"&&t.length>0?[t]:[]}}function pt(t,e){if(t.length<=1||e<=0)return t;let n=[],r=t[0]??"";for(let o=1;o<t.length;o++){let i=t[o]??"";r.length<e?r=r+`
36
17
 
37
- `+s:(r.push(n),n=s);}if(n.length>0)if(n.length<t&&r.length>0){let o=r.pop();r.push(o+`
18
+ `+i:(n.push(r),r=i);}if(r.length>0)if(r.length<e&&n.length>0){let o=n.pop();n.push(o+`
38
19
 
39
- `+n);}else r.push(n);return r}function wt(e,t,r){if(!e)return [];if(t<=0||e.length<=t)return [e];let n=[],o=e;for(;o.length>t;){let s=o.slice(0,t),a=r(s),i=Number.isFinite(a)&&a>0&&a<=t?a:t,p=o.slice(0,i).trimEnd();p.length>0&&n.push(p);let c=i<o.length&&o[i]!==void 0&&/\s/.test(o[i]),u=Math.min(o.length,i+(c?1:0));o=o.slice(u).trimStart();}return o.length>0&&n.push(o),n}chunkVRQQ33YH_cjs.j();var St=De.z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),En=De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),style:St}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),Cn=De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),href:De.z.string().min(1)}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),Ce=De.z.object({text:De.z.string(),styles:De.z.array(En),links:De.z.array(Cn)}).strict(),Oe=De.z.enum(["off","bullets","code"]),He=De.z.object({linkify:De.z.boolean().default(true),enableSpoilers:De.z.boolean().default(false),headingStyle:De.z.enum(["none","bold"]).default("none"),blockquotePrefix:De.z.string().default(""),autolink:De.z.boolean().default(true),tableMode:Oe.default("off")}).partial().default({}),On=De.z.object({open:De.z.string(),close:De.z.string()}).strict(),kt=De.z.object({styleMarkers:De.z.record(St,On).optional(),escapeText:De.z.any().optional(),buildLink:De.z.any().optional()}).strict();De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),open:De.z.string(),close:De.z.string()}).strict();var Tt=De.z.object({indentSize:De.z.number().int().min(1).default(2),listMarker:De.z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:De.z.enum(["```","~~~"]).default("```"),preserveFrontmatter:De.z.boolean().default(true)}).strict(),vt=De.z.record(De.z.string(),De.z.string()),We=De.z.object({open:De.z.boolean(),ticks:De.z.number().int().min(0)}).strict();De.z.object({inlineState:We,isInside:De.z.any()}).strict();De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),openLine:De.z.string(),marker:De.z.string(),indent:De.z.string()}).strict();De.z.object({tables:Oe.optional()}).strict();function oo(e){let t=new ro__default.default({html:false,linkify:e.linkify??true,breaks:false,typographer:false});return t.enable("strikethrough"),e.tableMode&&e.tableMode!=="off"?t.enable("table"):t.disable("table"),e.autolink===false&&t.disable("autolink"),t}function In(e,t){if(e.attrGet)return e.attrGet(t);if(e.attrs){for(let[r,n]of e.attrs)if(r===t)return n}return null}function Pt(e,t){return {...e,type:"text",content:t,children:void 0}}function so(e){for(let t of e)t.children&&t.children.length>0&&(t.children=io(t.children));}function io(e){let t=0;for(let a of e){if(a.type!=="text")continue;let i=a.content??"",l=0;for(;l<i.length;){let p=i.indexOf("||",l);if(p===-1)break;t+=1,l=p+2;}}if(t<2)return e;let r=t-t%2,n=[],o={spoilerOpen:false},s=0;for(let a of e){if(a.type!=="text"){n.push(a);continue}let i=a.content??"";if(!i.includes("||")){n.push(a);continue}let l=0;for(;l<i.length;){let p=i.indexOf("||",l);if(p===-1){l<i.length&&n.push(Pt(a,i.slice(l)));break}if(s>=r){n.push(Pt(a,i.slice(l)));break}p>l&&n.push(Pt(a,i.slice(l,p))),s+=1,o.spoilerOpen=!o.spoilerOpen,n.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=p+2;}}return n}function ao(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function ue(e){return e.table?.currentCell??e}function Ue(e,t){if(!t)return;let r=ue(e);r.text+=t;}function ye(e,t){let r=ue(e);r.openStyles.push({style:t,start:r.text.length});}function xe(e,t){let r=ue(e);for(let n=r.openStyles.length-1;n>=0;n-=1){let o=r.openStyles[n];if(o?.style===t){let s=o.start;r.openStyles.splice(n,1);let a=r.text.length;a>s&&r.styles.push({start:s,end:a,style:t});return}}}function An(e){e.env.listStack.length>0||e.table||(e.text+=`
20
+ `+r);}else n.push(r);return n}function Be(t,e,n){if(!t)return [];if(e<=0||t.length<=e)return [t];let r=[],o=t;for(;o.length>e;){let i=o.slice(0,e),a=n(i),s=Number.isFinite(a)&&a>0&&a<=e?a:e,p=o.slice(0,s).trimEnd();p.length>0&&r.push(p);let c=s<o.length&&o[s]!==void 0&&/\s/.test(o[s]),u=Math.min(o.length,s+(c?1:0));o=o.slice(u).trimStart();}return o.length>0&&r.push(o),r}chunkVRQQ33YH_cjs.j();var Ne=pe.z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),dt=pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),style:Ne}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),ft=pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),href:pe.z.string().min(1)}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),te=pe.z.object({text:pe.z.string(),styles:pe.z.array(dt),links:pe.z.array(ft)}).strict(),ne=pe.z.enum(["off","bullets","code"]),fe=pe.z.object({linkify:pe.z.boolean().default(true),enableSpoilers:pe.z.boolean().default(false),headingStyle:pe.z.enum(["none","bold"]).default("none"),blockquotePrefix:pe.z.string().default(""),autolink:pe.z.boolean().default(true),tableMode:ne.default("off")}).partial().default({}),mt=pe.z.object({open:pe.z.string(),close:pe.z.string()}).strict(),je=pe.z.object({styleMarkers:pe.z.record(Ne,mt).optional(),escapeText:pe.z.any().optional(),buildLink:pe.z.any().optional()}).strict();pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),open:pe.z.string(),close:pe.z.string()}).strict();var He=pe.z.object({indentSize:pe.z.number().int().min(1).default(2),listMarker:pe.z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:pe.z.enum(["```","~~~"]).default("```"),preserveFrontmatter:pe.z.boolean().default(true)}).strict(),Ue=pe.z.record(pe.z.string(),pe.z.string()),me=pe.z.object({open:pe.z.boolean(),ticks:pe.z.number().int().min(0)}).strict();pe.z.object({inlineState:me,isInside:pe.z.any()}).strict();pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),openLine:pe.z.string(),marker:pe.z.string(),indent:pe.z.string()}).strict();pe.z.object({tables:ne.optional()}).strict();function Mn(t){let e=new Tn__default.default({html:false,linkify:t.linkify??true,breaks:false,typographer:false});return e.enable("strikethrough"),t.tableMode&&t.tableMode!=="off"?e.enable("table"):e.disable("table"),t.autolink===false&&e.disable("autolink"),e}function ht(t,e){if(t.attrGet)return t.attrGet(e);if(t.attrs){for(let[n,r]of t.attrs)if(n===e)return r}return null}function We(t,e){return {...t,type:"text",content:e,children:void 0}}function Rn(t){for(let e of t)e.children&&e.children.length>0&&(e.children=vn(e.children));}function vn(t){let e=0;for(let a of t){if(a.type!=="text")continue;let s=a.content??"",l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1)break;e+=1,l=p+2;}}if(e<2)return t;let n=e-e%2,r=[],o={spoilerOpen:false},i=0;for(let a of t){if(a.type!=="text"){r.push(a);continue}let s=a.content??"";if(!s.includes("||")){r.push(a);continue}let l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1){l<s.length&&r.push(We(a,s.slice(l)));break}if(i>=n){r.push(We(a,s.slice(l)));break}p>l&&r.push(We(a,s.slice(l,p))),i+=1,o.spoilerOpen=!o.spoilerOpen,r.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=p+2;}}return r}function In(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function H(t){return t.table?.currentCell??t}function he(t,e){if(!e)return;let n=H(t);n.text+=e;}function G(t,e){let n=H(t);n.openStyles.push({style:e,start:n.text.length});}function Y(t,e){let n=H(t);for(let r=n.openStyles.length-1;r>=0;r-=1){let o=n.openStyles[r];if(o?.style===e){let i=o.start;n.openStyles.splice(r,1);let a=n.text.length;a>i&&n.styles.push({start:i,end:a,style:e});return}}}function gt(t){t.env.listStack.length>0||t.table||(t.text+=`
40
21
 
41
- `);}function lo(e){let t=e.env.listStack,r=t[t.length-1];if(!r)return;r.index+=1;let n=" ".repeat(Math.max(0,t.length-1)),o=r.type==="ordered"?`${r.index}. `:"\u2022 ";e.text+=`${n}${o}`;}function co(e,t){if(!t)return;let r=ue(e),n=r.text.length;r.text+=t,r.styles.push({start:n,end:n+t.length,style:"code"});}function uo(e,t){let r=t??"",n=ue(e),o=n.text.length;n.text+=r,n.styles.push({start:o,end:o+r.length,style:"code_block"});}function fo(e){let t=ue(e),r=t.linkStack.pop();if(!r?.href)return;let n=r.href.trim();if(!n)return;let o=r.labelStart,s=t.text.length;if(s<=o){t.links.push({start:o,end:s,href:n});return}t.links.push({start:o,end:s,href:n});}function po(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function mo(e){return _n(e),{text:e.text,styles:e.styles,links:e.links}}function qe(e){let t=e.text,r=0,n=t.length;for(;r<n&&/\s/.test(t[r]??"");)r+=1;for(;n>r&&/\s/.test(t[n-1]??"");)n-=1;if(r===0&&n===t.length)return e;let o=t.slice(r,n),s=o.length,a=[];for(let l of e.styles){let p=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>p&&a.push({start:p,end:c,style:l.style});}let i=[];for(let l of e.links){let p=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>p&&i.push({start:p,end:c,href:l.href});}return {text:o,styles:a,links:i}}function Rt(e,t){if(!t.text)return;let r=e.text.length;e.text+=t.text;for(let n of t.styles)e.styles.push({start:r+n.start,end:r+n.end,style:n.style});for(let n of t.links)e.links.push({start:r+n.start,end:r+n.end,href:n.href});}function go(e,t){t.text&&(e.text+=t.text);}function Fn(e,t){let{header:r,value:n,columnIndex:o,includeColumnFallback:s}=t;n?.text&&(e.text+="\u2022 ",r?.text?(Rt(e,r),e.text+=": "):s&&(e.text+=`Column ${o}: `),Rt(e,n),e.text+=`
42
- `);}function ho(e){if(!e.table)return;let t=e.table.headers.map(qe),r=e.table.rows.map(o=>o.map(qe));if(t.length===0&&r.length===0)return;if(t.length>1&&r.length>0)for(let o of r){if(o.length===0)continue;let s=o[0];if(s?.text){let a=e.text.length;Rt(e,s);let i=e.text.length;i>a&&e.styles.push({start:a,end:i,style:"bold"}),e.text+=`
43
- `;}for(let a=1;a<o.length;a++)Fn(e,{header:t[a],value:o[a],columnIndex:a,includeColumnFallback:true});e.text+=`
44
- `;}else for(let o of r){for(let s=0;s<o.length;s++)Fn(e,{header:t[s],value:o[s],columnIndex:s,includeColumnFallback:false});e.text+=`
45
- `;}}function bo(e){if(!e.table)return;let t=e.table.headers.map(qe),r=e.table.rows.map(c=>c.map(qe)),n=Math.max(t.length,...r.map(c=>c.length));if(n===0)return;let o=Array.from({length:n},()=>0),s=c=>{for(let u=0;u<n;u+=1){let k=c[u]?.text.length??0;(o[u]??0)<k&&(o[u]=k);}};s(t);for(let c of r)s(c);let a=e.text.length,i=c=>{e.text+="|";for(let u=0;u<n;u+=1){e.text+=" ";let g=c[u];g&&go(e,g);let k=g?.text.length??0,H=(o[u]??0)-k;H>0&&(e.text+=" ".repeat(H)),e.text+=" |";}e.text+=`
46
- `;},l=()=>{e.text+="|";for(let c=0;c<n;c+=1){let u=o[c]??0,g=Math.max(3,u);e.text+=` ${"-".repeat(g)} |`;}e.text+=`
47
- `;};i(t),l();for(let c of r)i(c);let p=e.text.length;p>a&&e.styles.push({start:a,end:p,style:"code_block"});}function Mt(e,t){for(let r of e)switch(r.type){case "inline":r.children&&Mt(r.children,t);break;case "text":Ue(t,r.content??"");break;case "em_open":ye(t,"italic");break;case "em_close":xe(t,"italic");break;case "strong_open":ye(t,"bold");break;case "strong_close":xe(t,"bold");break;case "s_open":ye(t,"strikethrough");break;case "s_close":xe(t,"strikethrough");break;case "code_inline":co(t,r.content??"");break;case "spoiler_open":t.enableSpoilers&&ye(t,"spoiler");break;case "spoiler_close":t.enableSpoilers&&xe(t,"spoiler");break;case "link_open":{let n=In(r,"href")??"",o=ue(t);o.linkStack.push({href:n,labelStart:o.text.length});break}case "link_close":fo(t);break;case "image":Ue(t,r.content??"");break;case "softbreak":case "hardbreak":Ue(t,`
48
- `);break;case "paragraph_close":An(t);break;case "heading_open":t.headingStyle==="bold"&&ye(t,"bold");break;case "heading_close":t.headingStyle==="bold"&&xe(t,"bold"),An(t);break;case "blockquote_open":t.blockquotePrefix&&(t.text+=t.blockquotePrefix),ye(t,"blockquote");break;case "blockquote_close":xe(t,"blockquote");break;case "bullet_list_open":t.env.listStack.length>0&&(t.text+=`
49
- `),t.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":t.env.listStack.pop(),t.env.listStack.length===0&&(t.text+=`
50
- `);break;case "ordered_list_open":{t.env.listStack.length>0&&(t.text+=`
51
- `);let n=Number(In(r,"start")??"1");t.env.listStack.push({type:"ordered",index:n-1});break}case "ordered_list_close":t.env.listStack.pop(),t.env.listStack.length===0&&(t.text+=`
52
- `);break;case "list_item_open":lo(t);break;case "list_item_close":t.text.endsWith(`
53
- `)||(t.text+=`
54
- `);break;case "code_block":case "fence":uo(t,r.content??"");break;case "html_block":case "html_inline":Ue(t,r.content??"");break;case "table_open":t.tableMode!=="off"&&(t.table=po(),t.hasTables=true);break;case "table_close":t.table&&(t.tableMode==="bullets"?ho(t):t.tableMode==="code"&&bo(t)),t.table=null;break;case "thead_open":t.table&&(t.table.inHeader=true);break;case "thead_close":t.table&&(t.table.inHeader=false);break;case "tbody_open":case "tbody_close":break;case "tr_open":t.table&&(t.table.currentRow=[]);break;case "tr_close":t.table&&(t.table.inHeader?t.table.headers=t.table.currentRow:t.table.rows.push(t.table.currentRow),t.table.currentRow=[]);break;case "th_open":case "td_open":t.table&&(t.table.currentCell=ao());break;case "th_close":case "td_close":t.table?.currentCell&&(t.table.currentRow.push(mo(t.table.currentCell)),t.table.currentCell=null);break;case "hr":t.text+=`\u2500\u2500\u2500
22
+ `);}function Pn(t){let e=t.env.listStack,n=e[e.length-1];if(!n)return;n.index+=1;let r=" ".repeat(Math.max(0,e.length-1)),o=n.type==="ordered"?`${n.index}. `:"\u2022 ";t.text+=`${r}${o}`;}function Fn(t,e){if(!e)return;let n=H(t),r=n.text.length;n.text+=e,n.styles.push({start:r,end:r+e.length,style:"code"});}function _n(t,e){let n=e??"",r=H(t),o=r.text.length;r.text+=n,r.styles.push({start:o,end:o+n.length,style:"code_block"});}function Cn(t){let e=H(t),n=e.linkStack.pop();if(!n?.href)return;let r=n.href.trim();if(!r)return;let o=n.labelStart,i=e.text.length;if(i<=o){e.links.push({start:o,end:i,href:r});return}e.links.push({start:o,end:i,href:r});}function On(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function Ln(t){return bt(t),{text:t.text,styles:t.styles,links:t.links}}function ge(t){let e=t.text,n=0,r=e.length;for(;n<r&&/\s/.test(e[n]??"");)n+=1;for(;r>n&&/\s/.test(e[r-1]??"");)r-=1;if(n===0&&r===e.length)return t;let o=e.slice(n,r),i=o.length,a=[];for(let l of t.styles){let p=Math.max(0,l.start-n),c=Math.min(i,l.end-n);c>p&&a.push({start:p,end:c,style:l.style});}let s=[];for(let l of t.links){let p=Math.max(0,l.start-n),c=Math.min(i,l.end-n);c>p&&s.push({start:p,end:c,href:l.href});}return {text:o,styles:a,links:s}}function qe(t,e){if(!e.text)return;let n=t.text.length;t.text+=e.text;for(let r of e.styles)t.styles.push({start:n+r.start,end:n+r.end,style:r.style});for(let r of e.links)t.links.push({start:n+r.start,end:n+r.end,href:r.href});}function En(t,e){e.text&&(t.text+=e.text);}function yt(t,e){let{header:n,value:r,columnIndex:o,includeColumnFallback:i}=e;r?.text&&(t.text+="\u2022 ",n?.text?(qe(t,n),t.text+=": "):i&&(t.text+=`Column ${o}: `),qe(t,r),t.text+=`
23
+ `);}function An(t){if(!t.table)return;let e=t.table.headers.map(ge),n=t.table.rows.map(o=>o.map(ge));if(e.length===0&&n.length===0)return;if(e.length>1&&n.length>0)for(let o of n){if(o.length===0)continue;let i=o[0];if(i?.text){let a=t.text.length;qe(t,i);let s=t.text.length;s>a&&t.styles.push({start:a,end:s,style:"bold"}),t.text+=`
24
+ `;}for(let a=1;a<o.length;a++)yt(t,{header:e[a],value:o[a],columnIndex:a,includeColumnFallback:true});t.text+=`
25
+ `;}else for(let o of n){for(let i=0;i<o.length;i++)yt(t,{header:e[i],value:o[i],columnIndex:i,includeColumnFallback:false});t.text+=`
26
+ `;}}function $n(t){if(!t.table)return;let e=t.table.headers.map(ge),n=t.table.rows.map(c=>c.map(ge)),r=Math.max(e.length,...n.map(c=>c.length));if(r===0)return;let o=Array.from({length:r},()=>0),i=c=>{for(let u=0;u<r;u+=1){let m=c[u]?.text.length??0;(o[u]??0)<m&&(o[u]=m);}};i(e);for(let c of n)i(c);let a=t.text.length,s=c=>{t.text+="|";for(let u=0;u<r;u+=1){t.text+=" ";let d=c[u];d&&En(t,d);let m=d?.text.length??0,k=(o[u]??0)-m;k>0&&(t.text+=" ".repeat(k)),t.text+=" |";}t.text+=`
27
+ `;},l=()=>{t.text+="|";for(let c=0;c<r;c+=1){let u=o[c]??0,d=Math.max(3,u);t.text+=` ${"-".repeat(d)} |`;}t.text+=`
28
+ `;};s(e),l();for(let c of n)s(c);let p=t.text.length;p>a&&t.styles.push({start:a,end:p,style:"code_block"});}function Ge(t,e){for(let n of t)switch(n.type){case "inline":n.children&&Ge(n.children,e);break;case "text":he(e,n.content??"");break;case "em_open":G(e,"italic");break;case "em_close":Y(e,"italic");break;case "strong_open":G(e,"bold");break;case "strong_close":Y(e,"bold");break;case "s_open":G(e,"strikethrough");break;case "s_close":Y(e,"strikethrough");break;case "code_inline":Fn(e,n.content??"");break;case "spoiler_open":e.enableSpoilers&&G(e,"spoiler");break;case "spoiler_close":e.enableSpoilers&&Y(e,"spoiler");break;case "link_open":{let r=ht(n,"href")??"",o=H(e);o.linkStack.push({href:r,labelStart:o.text.length});break}case "link_close":Cn(e);break;case "image":he(e,n.content??"");break;case "softbreak":case "hardbreak":he(e,`
29
+ `);break;case "paragraph_close":gt(e);break;case "heading_open":e.headingStyle==="bold"&&G(e,"bold");break;case "heading_close":e.headingStyle==="bold"&&Y(e,"bold"),gt(e);break;case "blockquote_open":e.blockquotePrefix&&(e.text+=e.blockquotePrefix),G(e,"blockquote");break;case "blockquote_close":Y(e,"blockquote");break;case "bullet_list_open":e.env.listStack.length>0&&(e.text+=`
30
+ `),e.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
31
+ `);break;case "ordered_list_open":{e.env.listStack.length>0&&(e.text+=`
32
+ `);let r=Number(ht(n,"start")??"1");e.env.listStack.push({type:"ordered",index:r-1});break}case "ordered_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
33
+ `);break;case "list_item_open":Pn(e);break;case "list_item_close":e.text.endsWith(`
34
+ `)||(e.text+=`
35
+ `);break;case "code_block":case "fence":_n(e,n.content??"");break;case "html_block":case "html_inline":he(e,n.content??"");break;case "table_open":e.tableMode!=="off"&&(e.table=On(),e.hasTables=true);break;case "table_close":e.table&&(e.tableMode==="bullets"?An(e):e.tableMode==="code"&&$n(e)),e.table=null;break;case "thead_open":e.table&&(e.table.inHeader=true);break;case "thead_close":e.table&&(e.table.inHeader=false);break;case "tbody_open":case "tbody_close":break;case "tr_open":e.table&&(e.table.currentRow=[]);break;case "tr_close":e.table&&(e.table.inHeader?e.table.headers=e.table.currentRow:e.table.rows.push(e.table.currentRow),e.table.currentRow=[]);break;case "th_open":case "td_open":e.table&&(e.table.currentCell=In());break;case "th_close":case "td_close":e.table?.currentCell&&(e.table.currentRow.push(Ln(e.table.currentCell)),e.table.currentCell=null);break;case "hr":e.text+=`\u2500\u2500\u2500
55
36
 
56
- `;break;default:r.children&&Mt(r.children,t);break}}function _n(e){for(let t=e.openStyles.length-1;t>=0;t-=1){let r=e.openStyles[t];if(!r)continue;let n=e.text.length;n>r.start&&e.styles.push({start:r.start,end:n,style:r.style});}e.openStyles=[];}function yo(e,t){let r=[];for(let n of e){let o=Math.max(0,Math.min(n.start,t)),s=Math.max(o,Math.min(n.end,t));s>o&&r.push({start:o,end:s,style:n.style});}return r}function xo(e,t){let r=[];for(let n of e){let o=Math.max(0,Math.min(n.start,t)),s=Math.max(o,Math.min(n.end,t));s>o&&r.push({start:o,end:s,href:n.href});}return r}function Bn(e){let t=[...e].toSorted((n,o)=>n.start!==o.start?n.start-o.start:n.end!==o.end?n.end-o.end:n.style.localeCompare(o.style)),r=[];for(let n of t){let o=r[r.length-1];if(o&&o.style===n.style&&(n.start<o.end||n.start===o.end&&n.style!=="blockquote")){o.end=Math.max(o.end,n.end);continue}r.push({...n});}return r}function Ln(e,t,r){let n=Math.max(e.start,t),o=Math.min(e.end,r);return o<=n?null:{start:n,end:o}}function wo(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Ln(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,style:o.style});}return Bn(n)}function So(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Ln(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,href:o.href});}return n}function we(e,t){try{let r=typeof e=="string"?e:"",n=He.parse(t??{});return Ie(r,n).ir}catch(r){return console.error("Markdown parse error:",r),{text:"",styles:[],links:[]}}}function Ie(e,t){try{let r=typeof e=="string"?e:"",n=He.parse(t),o={listStack:[]},a=oo(n).parse(r||"",o);n.enableSpoilers&&so(a);let i=n.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:n.headingStyle??"none",blockquotePrefix:n.blockquotePrefix??"",enableSpoilers:n.enableSpoilers??!1,tableMode:i,table:null,hasTables:!1};Mt(a,l),_n(l);let c=l.text.trimEnd().length,u=0;for(let E of l.styles)E.style==="code_block"&&E.end>u&&(u=E.end);let g=Math.max(c,u);return {ir:{text:g===l.text.length?l.text:l.text.slice(0,g),styles:Bn(yo(l.styles,g)),links:xo(l.links,g)},hasTables:l.hasTables}}catch(r){return console.error("Markdown parse error:",r),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function $n(e,t){try{let r=Ce.parse(e),n=typeof t=="number"&&t>0?t:0;if(!r.text)return [];if(n<=0||r.text.length<=n)return [r];let o=be(r.text,n),s=[],a=0;return o.forEach((i,l)=>{if(!i)return;if(l>0)for(;a<r.text.length&&/\s/.test(r.text[a]??"");)a+=1;let p=a,c=Math.min(r.text.length,p+i.length);s.push({text:i,styles:wo(r.styles,p,c),links:So(r.links,p,c)}),a=c;}),s}catch(r){return console.error("Chunk IR error:",r),[]}}chunkVRQQ33YH_cjs.j();var ko={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Ae(e,t){try{let r=Ce.parse(e),n=kt.parse(t??{});if(!r.text)return "";let o=n.styleMarkers??ko,s=n.escapeText??(u=>u),a=n.buildLink,i=[];for(let u=0;u<r.styles.length;u++){let g=r.styles[u];g&&(i.push({position:g.start,type:"open",style:g.style,spanIndex:u}),i.push({position:g.end,type:"close",style:g.style,spanIndex:u}));}for(let u=0;u<r.links.length;u++){let g=r.links[u];g&&(i.push({position:g.start,type:"link_open",spanIndex:u,href:g.href}),i.push({position:g.end,type:"link_close",spanIndex:u,href:g.href}));}i.sort((u,g)=>{if(u.position!==g.position)return u.position-g.position;let k=(G,V)=>G==="link_open"?0:G==="open"?1:G==="close"?2:G==="link_close"?3:4,E=u.type==="close"||u.type==="link_close",H=g.type==="close"||g.type==="link_close",U=k(u.type,E),q=k(g.type,H);return U!==q?U-q:u.type==="open"&&g.type==="open"?u.spanIndex-g.spanIndex:u.type==="close"&&g.type==="close"?g.spanIndex-u.spanIndex:u.spanIndex-g.spanIndex});let l="",p=0,c=[];for(let u of i){if(u.position>p){let g=r.text.slice(p,u.position);l+=s?s(g):g;}if(u.type==="open"||u.type==="close"){let g=o[u.style];if(g)if(u.type==="open")l+=g.open,c.push(u);else {l+=g.close,u.style==="code_block"&&u.position<r.text.length&&(l+=`
57
- `);let k=c.findIndex(E=>E.spanIndex===u.spanIndex&&E.type==="open");k!==-1&&c.splice(k,1);}}else if(u.type==="link_open")l+="[",c.push(u);else if(u.type==="link_close"){l+="]("+u.href+")";let g=c.findIndex(k=>k.spanIndex===u.spanIndex&&k.type==="link_open");g!==-1&&c.splice(g,1);}p=u.position;}if(p<r.text.length){let u=r.text.slice(p);l+=s?s(u):u;}return l}catch(r){return console.error("Markdown render error:",r),""}}function Se(e,t){return Ae(e,t)}chunkVRQQ33YH_cjs.j();function To(e){let t=e.replace(/\r\n/g,`
37
+ `;break;default:n.children&&Ge(n.children,e);break}}function bt(t){for(let e=t.openStyles.length-1;e>=0;e-=1){let n=t.openStyles[e];if(!n)continue;let r=t.text.length;r>n.start&&t.styles.push({start:n.start,end:r,style:n.style});}t.openStyles=[];}function Dn(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),i=Math.max(o,Math.min(r.end,e));i>o&&n.push({start:o,end:i,style:r.style});}return n}function zn(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),i=Math.max(o,Math.min(r.end,e));i>o&&n.push({start:o,end:i,href:r.href});}return n}function xt(t){let e=[...t].toSorted((r,o)=>r.start!==o.start?r.start-o.start:r.end!==o.end?r.end-o.end:r.style.localeCompare(o.style)),n=[];for(let r of e){let o=n[n.length-1];if(o&&o.style===r.style&&(r.start<o.end||r.start===o.end&&r.style!=="blockquote")){o.end=Math.max(o.end,r.end);continue}n.push({...r});}return n}function kt(t,e,n){let r=Math.max(t.start,e),o=Math.min(t.end,n);return o<=r?null:{start:r,end:o}}function Bn(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let i=kt(o,e,n);i&&r.push({start:i.start-e,end:i.end-e,style:o.style});}return xt(r)}function Nn(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let i=kt(o,e,n);i&&r.push({start:i.start-e,end:i.end-e,href:o.href});}return r}function X(t,e){try{let n=typeof t=="string"?t:"",r=fe.parse(e??{});return re(n,r).ir}catch(n){return console.error("Markdown parse error:",n),{text:"",styles:[],links:[]}}}function re(t,e){try{let n=typeof t=="string"?t:"",r=fe.parse(e),o={listStack:[]},a=Mn(r).parse(n||"",o);r.enableSpoilers&&Rn(a);let s=r.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:r.headingStyle??"none",blockquotePrefix:r.blockquotePrefix??"",enableSpoilers:r.enableSpoilers??!1,tableMode:s,table:null,hasTables:!1};Ge(a,l),bt(l);let c=l.text.trimEnd().length,u=0;for(let g of l.styles)g.style==="code_block"&&g.end>u&&(u=g.end);let d=Math.max(c,u);return {ir:{text:d===l.text.length?l.text:l.text.slice(0,d),styles:xt(Dn(l.styles,d)),links:zn(l.links,d)},hasTables:l.hasTables}}catch(n){return console.error("Markdown parse error:",n),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function St(t,e){try{let n=te.parse(t),r=typeof e=="number"&&e>0?e:0;if(!n.text)return [];if(r<=0||n.text.length<=r)return [n];let o=q(n.text,r),i=[],a=0;return o.forEach((s,l)=>{if(!s)return;if(l>0)for(;a<n.text.length&&/\s/.test(n.text[a]??"");)a+=1;let p=a,c=Math.min(n.text.length,p+s.length);i.push({text:s,styles:Bn(n.styles,p,c),links:Nn(n.links,p,c)}),a=c;}),i}catch(n){return console.error("Chunk IR error:",n),[]}}chunkVRQQ33YH_cjs.j();var jn={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function oe(t,e){try{let n=te.parse(t),r=je.parse(e??{});if(!n.text)return "";let o=r.styleMarkers??jn,i=r.escapeText??(u=>u),a=r.buildLink,s=[];for(let u=0;u<n.styles.length;u++){let d=n.styles[u];d&&(s.push({position:d.start,type:"open",style:d.style,spanIndex:u}),s.push({position:d.end,type:"close",style:d.style,spanIndex:u}));}for(let u=0;u<n.links.length;u++){let d=n.links[u];d&&(s.push({position:d.start,type:"link_open",spanIndex:u,href:d.href}),s.push({position:d.end,type:"link_close",spanIndex:u,href:d.href}));}s.sort((u,d)=>{if(u.position!==d.position)return u.position-d.position;let m=(P,O)=>P==="link_open"?0:P==="open"?1:P==="close"?2:P==="link_close"?3:4,g=u.type==="close"||u.type==="link_close",k=d.type==="close"||d.type==="link_close",S=m(u.type,g),R=m(d.type,k);return S!==R?S-R:u.type==="open"&&d.type==="open"?u.spanIndex-d.spanIndex:u.type==="close"&&d.type==="close"?d.spanIndex-u.spanIndex:u.spanIndex-d.spanIndex});let l="",p=0,c=[];for(let u of s){if(u.position>p){let d=n.text.slice(p,u.position);l+=i?i(d):d;}if(u.type==="open"||u.type==="close"){let d=o[u.style];if(d)if(u.type==="open")l+=d.open,c.push(u);else {l+=d.close,u.style==="code_block"&&u.position<n.text.length&&(l+=`
38
+ `);let m=c.findIndex(g=>g.spanIndex===u.spanIndex&&g.type==="open");m!==-1&&c.splice(m,1);}}else if(u.type==="link_open")l+="[",c.push(u);else if(u.type==="link_close"){l+="]("+u.href+")";let d=c.findIndex(m=>m.spanIndex===u.spanIndex&&m.type==="link_open");d!==-1&&c.splice(d,1);}p=u.position;}if(p<n.text.length){let u=n.text.slice(p);l+=i?i(u):u;}return l}catch(n){return console.error("Markdown render error:",n),""}}function V(t,e){return oe(t,e)}chunkVRQQ33YH_cjs.j();function Hn(t){let e=t.replace(/\r\n/g,`
58
39
  `).replace(/\r/g,`
59
- `);if(!t.startsWith("---"))return {frontmatter:"",content:e};let r=t.indexOf(`
60
- ---`,3);if(r===-1)return {frontmatter:"",content:e};let n=t.slice(0,r+4),o=t.slice(r+4).trimStart();return {frontmatter:n,content:o}}function Ge(e,t){try{let r=typeof e=="string"?e:"",n=Tt.parse(t??{});if(!r)return "";let{frontmatter:o,content:s}=To(r),a=we(s,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),i=Se(a);return i=i.replace(/\n{3,}/g,`
40
+ `);if(!e.startsWith("---"))return {frontmatter:"",content:t};let n=e.indexOf(`
41
+ ---`,3);if(n===-1)return {frontmatter:"",content:t};let r=e.slice(0,n+4),o=e.slice(n+4).trimStart();return {frontmatter:r,content:o}}function ye(t,e){try{let n=typeof t=="string"?t:"",r=He.parse(e??{});if(!n)return "";let{frontmatter:o,content:i}=Hn(n),a=X(i,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),s=V(a);return s=s.replace(/\n{3,}/g,`
61
42
 
62
- `),i=i.trimEnd()+`
63
- `,n.preserveFrontmatter&&o&&(i=o+`
64
- `+i),i}catch(r){return console.error("Markdown format error:",r),e}}chunkVRQQ33YH_cjs.j();function vo(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Po(e){if(e!=null){if(typeof e=="string")return {value:e.trim(),kind:"scalar"};if(typeof e=="number"||typeof e=="boolean")return {value:String(e),kind:"scalar"};if(typeof e=="object")try{return {value:JSON.stringify(e),kind:"structured"}}catch{return}}}function Ro(e){try{let t=jn__default.default.parse(e,{schema:"core"});if(!t||typeof t!="object"||Array.isArray(t))return null;let r={};for(let[n,o]of Object.entries(t)){let s=n.trim();if(!s)continue;let a=Po(o);a&&(r[s]=a);}return r}catch{return null}}function Mo(e,t){let r=[],n=t+1;for(;n<e.length;){let s=e[n];if(!s){n+=1;continue}if(s.length>0&&!s.startsWith(" ")&&!s.startsWith(" "))break;r.push(s),n+=1;}return {value:r.join(`
65
- `).trim(),linesConsumed:n-t}}function Eo(e){let t={},r=e.split(`
66
- `),n=0;for(;n<r.length;){let o=r[n];if(!o){n+=1;continue}let s=o.match(/^([\w-]+):\s*(.*)$/);if(!s?.[1]||!s[2]){n+=1;continue}let a=s[1],i=s[2].trim();if(!a){n+=1;continue}if(!i&&n+1<r.length){let p=r[n+1];if(p&&(p.startsWith(" ")||p.startsWith(" "))){let{value:c,linesConsumed:u}=Mo(r,n);c&&(t[a]={value:c,kind:"multiline",rawInline:i}),n+=u;continue}}let l=vo(i);l&&(t[a]={value:l,kind:"inline",rawInline:i}),n+=1;}return t}function Co(e){let t={};for(let[r,n]of Object.entries(e))t[r]=n.value;return t}function Oo(e){return /^[|>][+-]?(\d+)?[+-]?$/.test(e)}function Io(e){let{lineEntry:t,yamlValue:r}=e;return r.kind!=="structured"||t.kind!=="inline"||Oo(t.rawInline)?false:t.value.includes(":")}function Ao(e){let t=e.replace(/\r\n/g,`
43
+ `),s=s.trimEnd()+`
44
+ `,r.preserveFrontmatter&&o&&(s=o+`
45
+ `+s),s}catch(n){return console.error("Markdown format error:",n),t}}chunkVRQQ33YH_cjs.j();function Un(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function Wn(t){if(t!=null){if(typeof t=="string")return {value:t.trim(),kind:"scalar"};if(typeof t=="number"||typeof t=="boolean")return {value:String(t),kind:"scalar"};if(typeof t=="object")try{return {value:JSON.stringify(t),kind:"structured"}}catch{return}}}function qn(t){try{let e=wt__default.default.parse(t,{schema:"core"});if(!e||typeof e!="object"||Array.isArray(e))return null;let n={};for(let[r,o]of Object.entries(e)){let i=r.trim();if(!i)continue;let a=Wn(o);a&&(n[i]=a);}return n}catch{return null}}function Gn(t,e){let n=[],r=e+1;for(;r<t.length;){let i=t[r];if(!i){r+=1;continue}if(i.length>0&&!i.startsWith(" ")&&!i.startsWith(" "))break;n.push(i),r+=1;}return {value:n.join(`
46
+ `).trim(),linesConsumed:r-e}}function Yn(t){let e={},n=t.split(`
47
+ `),r=0;for(;r<n.length;){let o=n[r];if(!o){r+=1;continue}let i=o.match(/^([\w-]+):\s*(.*)$/);if(!i?.[1]||!i[2]){r+=1;continue}let a=i[1],s=i[2].trim();if(!a){r+=1;continue}if(!s&&r+1<n.length){let p=n[r+1];if(p&&(p.startsWith(" ")||p.startsWith(" "))){let{value:c,linesConsumed:u}=Gn(n,r);c&&(e[a]={value:c,kind:"multiline",rawInline:s}),r+=u;continue}}let l=Un(s);l&&(e[a]={value:l,kind:"inline",rawInline:s}),r+=1;}return e}function Xn(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.value;return e}function Vn(t){return /^[|>][+-]?(\d+)?[+-]?$/.test(t)}function Kn(t){let{lineEntry:e,yamlValue:n}=t;return n.kind!=="structured"||e.kind!=="inline"||Vn(e.rawInline)?false:e.value.includes(":")}function Zn(t){let e=t.replace(/\r\n/g,`
67
48
  `).replace(/\r/g,`
68
- `);if(!t.startsWith("---"))return;let r=t.indexOf(`
69
- ---`,3);if(r!==-1)return t.slice(4,r)}function Fe(e){try{if(typeof e!="string")return {};let t=Ao(e);if(!t)return {};let r=Eo(t),n=Ro(t);if(n===null)return Co(r);let o={};for(let[s,a]of Object.entries(n)){o[s]=a.value;let i=r[s];i&&Io({lineEntry:i,yamlValue:a})&&(o[s]=i.value);}for(let[s,a]of Object.entries(r))s in o||(o[s]=a.value);return o}catch(t){return console.warn("Failed to parse frontmatter:",t),{}}}function Ye(e){try{let t=vt.parse(e);if(Object.keys(t).length===0)return "";let r={};for(let[o,s]of Object.entries(t))try{let a=JSON.parse(s);r[o]=a;}catch{r[o]=s;}return `---
70
- ${jn__default.default.stringify(r,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
71
- ---`}catch(t){return console.warn("Failed to serialize frontmatter:",t),""}}function Ve(e){try{if(typeof e!="string")return {frontmatter:{},content:""};let t=e.replace(/\r\n/g,`
49
+ `);if(!e.startsWith("---"))return;let n=e.indexOf(`
50
+ ---`,3);if(n!==-1)return e.slice(4,n)}function se(t){try{if(typeof t!="string")return {};let e=Zn(t);if(!e)return {};let n=Yn(e),r=qn(e);if(r===null)return Xn(n);let o={};for(let[i,a]of Object.entries(r)){o[i]=a.value;let s=n[i];s&&Kn({lineEntry:s,yamlValue:a})&&(o[i]=s.value);}for(let[i,a]of Object.entries(n))i in o||(o[i]=a.value);return o}catch(e){return console.warn("Failed to parse frontmatter:",e),{}}}function be(t){try{let e=Ue.parse(t);if(Object.keys(e).length===0)return "";let n={};for(let[o,i]of Object.entries(e))try{let a=JSON.parse(i);n[o]=a;}catch{n[o]=i;}return `---
51
+ ${wt__default.default.stringify(n,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
52
+ ---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function xe(t){try{if(typeof t!="string")return {frontmatter:{},content:""};let e=t.replace(/\r\n/g,`
72
53
  `).replace(/\r/g,`
73
- `);if(!t.startsWith("---"))return {frontmatter:{},content:e};let r=t.indexOf(`
74
- ---`,3);if(r===-1)return {frontmatter:{},content:e};let n=t.slice(4,r),o=t.slice(r+4).trimStart();return {frontmatter:Fe(e),content:o}}catch(t){return console.warn("Failed to extract frontmatter:",t),{frontmatter:{},content:e}}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function Je(e){try{let t=De.z.string().parse(e),r=[],n,o=0;for(;o<=t.length;){let s=t.indexOf(`
75
- `,o),a=s===-1?t.length:s,i=t.slice(o,a),l=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let p=l[1],c=l[2];if(!p||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let g=c.length;if(!n)n={start:o,markerChar:u,markerLen:g,openLine:i,marker:c,indent:p};else if(n.markerChar===u&&g>=n.markerLen){let k=a;r.push({start:n.start,end:k,openLine:n.openLine,marker:n.marker,indent:n.indent}),n=void 0;}}if(s===-1)break;o=s+1;}return n&&r.push({start:n.start,end:t.length,openLine:n.openLine,marker:n.marker,indent:n.indent}),r}catch(t){return console.warn("Invalid input for parseFenceSpans:",t),[]}}function Et(e,t){let r=0,n=e.length-1;for(;r<=n;){let o=Math.floor((r+n)/2),s=e[o];if(!s)break;if(t<=s.start){n=o-1;continue}if(t>=s.end){r=o+1;continue}return s}}function Nn(e,t){return !Et(e,t)}function Xe(){return {open:false,ticks:0}}function Ke(e,t){try{let r=De.z.string().parse(e),n=t?We.parse(t):Xe(),o=Je(r),s={open:n.open,ticks:n.ticks},{spans:a,state:i}=Bo(r,o,s);return {inlineState:i,isInside:l=>$o(l,o)||jo(l,a)}}catch(r){return console.warn("Invalid input for buildCodeSpanIndex:",r),{inlineState:Xe(),isInside:()=>false}}}function Bo(e,t,r){let n=[],o=r.open,s=r.ticks,a=o?0:-1,i=0;for(;i<e.length;){let l=Lo(t,i);if(l){i=l.end;continue}if(e[i]!=="`"){i+=1;continue}let p=i,c=0;for(;i<e.length&&e[i]==="`";)c+=1,i+=1;if(!o){o=true,s=c,a=p;continue}c===s&&(n.push([a,i]),o=false,s=0,a=-1);}return o&&n.push([a,e.length]),{spans:n,state:{open:o,ticks:s}}}function Lo(e,t){return e.find(r=>t>=r.start&&t<r.end)}function $o(e,t){return t.some(r=>e>=r.start&&e<r.end)}function jo(e,t){return t.some(([r,n])=>e>=r&&e<n)}chunkVRQQ33YH_cjs.j();var Do={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Ze(e,t){try{let r=De.z.string().parse(e),n=Oe.parse(t);if(!r||n==="off")return r;let{ir:o,hasTables:s}=Ie(r,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:n});return s?Ae(o,{styleMarkers:Do,escapeText:a=>a,buildLink:(a,i)=>{let l=a.href.trim();return !l||!i.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):r}catch(r){return console.warn("Invalid input for convertMarkdownTables:",r),typeof e=="string"?e:""}}exports.Markdown=void 0;(p=>{function e(c,u){try{return we(c,u)}catch(g){return console.warn("Markdown.parse error:",g),{text:"",styles:[],links:[]}}}p.parse=e;function t(c,u){try{return Se(c,u)}catch(g){return console.warn("Markdown.render error:",g),""}}p.render=t;function r(c,u){try{return Ge(c,u)}catch(g){return console.warn("Markdown.format error:",g),typeof c=="string"?c:""}}p.format=r;function n(c){try{return Fe(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}p.parseFrontmatter=n;function o(c){try{return Ye(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}p.serializeFrontmatter=o;function s(c){try{return Ve(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}p.extractFrontmatter=s;function a(c,u,g){try{return be(c,u,g)}catch(k){return console.warn("Markdown.chunk error:",k),typeof c=="string"&&c.length>0?[c]:[]}}p.chunk=a;function i(c,u){try{return Ke(c,u)}catch(g){return console.warn("Markdown.buildCodeIndex error:",g),{inlineState:{open:false,ticks:0},isInside:()=>false}}}p.buildCodeIndex=i;function l(c,u){try{return Ze(c,u)}catch(g){return console.warn("Markdown.convertTables error:",g),typeof c=="string"?c:""}}p.convertTables=l;})(exports.Markdown||(exports.Markdown={}));chunkVRQQ33YH_cjs.j();function Dn(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r[r.length-1]??""}function zo(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r.slice(0,r.length-1).join("/")+"/"}function Ho(e){if(!e)return "";let t=e.split(".");return t[t.length-1]}function Wo(e,t=20){let r=Dn(e);if(r.length<=t)return r;let n=r.lastIndexOf("."),o=n<=0?"":r.slice(n),s=t-o.length-1;return s<=0?r.slice(0,t-1)+"\u2026":r.slice(0,s)+"\u2026"+o}function Uo(e,t=20){if(e.length<=t)return e;let r=t-1,n=Math.ceil(r/2),o=Math.floor(r/2);return e.slice(0,n)+"\u2026"+e.slice(-o)}chunkVRQQ33YH_cjs.j();var qo=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function Go(e){if(!e)return false;let t=String(e instanceof Error?e.message:e).toLowerCase();return qo.some(r=>t.includes(r))}async function Ot(e,t={}){let{attempts:r=3,delay:n=500,factor:o=2,maxDelay:s=1e4,retryIf:a=Go}=t,i;for(let l=0;l<r;l++)try{return await e()}catch(p){if(i=p,l===r-1||!a(p))throw p;let c=Math.min(n*o**l,s);await new Promise(u=>setTimeout(u,c));}throw i}chunkVRQQ33YH_cjs.j();exports.Fetch=void 0;(Ht=>{let e=chunkZHSHEAQD_cjs.m.create({service:"fetch"}),t=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],r=false,n=null;function o(){return t.some(I=>{let C=process.env[I];return typeof C=="string"&&C.trim().length>0})}Ht.hasProxyConfigured=o;function s(){let I=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||I}Ht.getProxyUrl=s;function a(I={}){let C=I.httpProxy||I.httpsProxy||s();if(!C){e.warn("[Fetch] No proxy configured, HTTP_PROXY/HTTPS_PROXY environment variables not set");return}let _=new undici.ProxyAgent({uri:C,connectTimeout:I.connectTimeout||1e4,keepAliveTimeout:I.keepAliveTimeout||3e4});n=undici.getGlobalDispatcher(),undici.setGlobalDispatcher(_),r=true,e.info(`[Fetch] Global proxy enabled: ${C}`);}Ht.enableProxy=a;function i(){!r||!n||(undici.setGlobalDispatcher(n),r=false,n=null,e.info("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}Ht.disableProxy=i;function l(){return r}Ht.isProxyEnabled=l;async function p(I,C){let _=C?.timeout||3e4,W=C?.responseType||"json",{timeout:Y,responseType:ve,...$}=C||{},S=null,m=null;try{$.signal||(S=new AbortController,m=setTimeout(()=>S.abort(),_));let f=await fetch(I,{...$,signal:$.signal||S.signal});m&&clearTimeout(m);let d;switch(W){case "arrayBuffer":d=await f.arrayBuffer();break;case "blob":d=await f.blob();break;case "buffer":{let y=await f.arrayBuffer();d=Buffer.from(y);break}case "text":d=await f.text();break;default:{let y=await f.text();try{d=JSON.parse(y);}catch{d=y;}break}}return {ok:f.ok,status:f.status,statusText:f.statusText,headers:f.headers,data:d,url:f.url}}catch(f){throw m&&clearTimeout(m),f}}async function c(I,C){let _=C?.retries??0,W=C?.retryDelay??1e3,{retries:Y,retryDelay:ve,responseType:$,...S}=C||{};return Ot(()=>p(I,{...S,responseType:C?.responseType}),{attempts:_+1,delay:W,maxDelay:W*2**(_+1)})}async function u(I,C){return c(I,{method:"GET",...C})}Ht.get=u;async function g(I,C,_){return c(I,{method:"POST",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.post=g;async function k(I,C,_){return c(I,{method:"PUT",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.put=k;async function E(I,C,_){return c(I,{method:"DELETE",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.del=E;async function H(I,C,_){return c(I,{method:"PATCH",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.patch=H;async function U(I,C){return c(I,C)}Ht.request=U;function q(I={}){return o()?(a(I),true):false}Ht.autoProxy=q;let G=5*1024*1024;function V(I){return new TextEncoder().encode(I)}function de(I){return chunkYPKMFQLR_cjs.c.mimeType(I)}function se(I){return I.startsWith("file://")}async function fe(I){let C=url.fileURLToPath(I);return await exports.PKG.file(C).bytes()}async function ke(I,C,_){let W=`----FetchFormBoundary${Date.now()}`,Y=[],$=C.some(h=>h.filename||h.value instanceof Uint8Array||Buffer.isBuffer(h.value))&&!_?.timeout?3e5:_?.timeout;for(let h of C){let w=h.maxSize??G,P=h.filename,v=`Content-Disposition: form-data; name="${h.name}"${P?`; filename="${P}"`:""}`;P&&(v+=`\r
76
- Content-Type: ${de(P)}`),v+=`\r
54
+ `);if(!e.startsWith("---"))return {frontmatter:{},content:t};let n=e.indexOf(`
55
+ ---`,3);if(n===-1)return {frontmatter:{},content:t};let r=e.slice(4,n),o=e.slice(n+4).trimStart();return {frontmatter:se(t),content:o}}catch(e){return console.warn("Failed to extract frontmatter:",e),{frontmatter:{},content:t}}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function ke(t){try{let e=pe.z.string().parse(t),n=[],r,o=0;for(;o<=e.length;){let i=e.indexOf(`
56
+ `,o),a=i===-1?e.length:i,s=e.slice(o,a),l=s.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let p=l[1],c=l[2];if(!p||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let d=c.length;if(!r)r={start:o,markerChar:u,markerLen:d,openLine:s,marker:c,indent:p};else if(r.markerChar===u&&d>=r.markerLen){let m=a;n.push({start:r.start,end:m,openLine:r.openLine,marker:r.marker,indent:r.indent}),r=void 0;}}if(i===-1)break;o=i+1;}return r&&n.push({start:r.start,end:e.length,openLine:r.openLine,marker:r.marker,indent:r.indent}),n}catch(e){return console.warn("Invalid input for parseFenceSpans:",e),[]}}function Ye(t,e){let n=0,r=t.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),i=t[o];if(!i)break;if(e<=i.start){r=o-1;continue}if(e>=i.end){n=o+1;continue}return i}}function Tt(t,e){return !Ye(t,e)}function Se(){return {open:false,ticks:0}}function we(t,e){try{let n=pe.z.string().parse(t),r=e?me.parse(e):Se(),o=ke(n),i={open:r.open,ticks:r.ticks},{spans:a,state:s}=er(n,o,i);return {inlineState:s,isInside:l=>nr(l,o)||rr(l,a)}}catch(n){return console.warn("Invalid input for buildCodeSpanIndex:",n),{inlineState:Se(),isInside:()=>false}}}function er(t,e,n){let r=[],o=n.open,i=n.ticks,a=o?0:-1,s=0;for(;s<t.length;){let l=tr(e,s);if(l){s=l.end;continue}if(t[s]!=="`"){s+=1;continue}let p=s,c=0;for(;s<t.length&&t[s]==="`";)c+=1,s+=1;if(!o){o=true,i=c,a=p;continue}c===i&&(r.push([a,s]),o=false,i=0,a=-1);}return o&&r.push([a,t.length]),{spans:r,state:{open:o,ticks:i}}}function tr(t,e){return t.find(n=>e>=n.start&&e<n.end)}function nr(t,e){return e.some(n=>t>=n.start&&t<n.end)}function rr(t,e){return e.some(([n,r])=>t>=n&&t<r)}chunkVRQQ33YH_cjs.j();var sr={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Te(t,e){try{let n=pe.z.string().parse(t),r=ne.parse(e);if(!n||r==="off")return n;let{ir:o,hasTables:i}=re(n,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:r});return i?oe(o,{styleMarkers:sr,escapeText:a=>a,buildLink:(a,s)=>{let l=a.href.trim();return !l||!s.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):n}catch(n){return console.warn("Invalid input for convertMarkdownTables:",n),typeof t=="string"?t:""}}exports.Markdown=void 0;(p=>{function t(c,u){try{return X(c,u)}catch(d){return console.warn("Markdown.parse error:",d),{text:"",styles:[],links:[]}}}p.parse=t;function e(c,u){try{return V(c,u)}catch(d){return console.warn("Markdown.render error:",d),""}}p.render=e;function n(c,u){try{return ye(c,u)}catch(d){return console.warn("Markdown.format error:",d),typeof c=="string"?c:""}}p.format=n;function r(c){try{return se(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}p.parseFrontmatter=r;function o(c){try{return be(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}p.serializeFrontmatter=o;function i(c){try{return xe(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}p.extractFrontmatter=i;function a(c,u,d){try{return q(c,u,d)}catch(m){return console.warn("Markdown.chunk error:",m),typeof c=="string"&&c.length>0?[c]:[]}}p.chunk=a;function s(c,u){try{return we(c,u)}catch(d){return console.warn("Markdown.buildCodeIndex error:",d),{inlineState:{open:false,ticks:0},isInside:()=>false}}}p.buildCodeIndex=s;function l(c,u){try{return Te(c,u)}catch(d){return console.warn("Markdown.convertTables error:",d),typeof c=="string"?c:""}}p.convertTables=l;})(exports.Markdown||(exports.Markdown={}));chunkVRQQ33YH_cjs.j();function Mt(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n[n.length-1]??""}function ir(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n.slice(0,n.length-1).join("/")+"/"}function ar(t){if(!t)return "";let e=t.split(".");return e[e.length-1]}function lr(t,e=20){let n=Mt(t);if(n.length<=e)return n;let r=n.lastIndexOf("."),o=r<=0?"":n.slice(r),i=e-o.length-1;return i<=0?n.slice(0,e-1)+"\u2026":n.slice(0,i)+"\u2026"+o}function cr(t,e=20){if(t.length<=e)return t;let n=e-1,r=Math.ceil(n/2),o=Math.floor(n/2);return t.slice(0,r)+"\u2026"+t.slice(-o)}chunkVRQQ33YH_cjs.j();var ur=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function pr(t){if(!t)return false;let e=String(t instanceof Error?t.message:t).toLowerCase();return ur.some(n=>e.includes(n))}async function Ve(t,e={}){let{attempts:n=3,delay:r=500,factor:o=2,maxDelay:i=1e4,retryIf:a=pr}=e,s;for(let l=0;l<n;l++)try{return await t()}catch(p){if(s=p,l===n-1||!a(p))throw p;let c=Math.min(r*o**l,i);await new Promise(u=>setTimeout(u,c));}throw s}chunkVRQQ33YH_cjs.j();exports.Fetch=void 0;(Cr=>{let t=chunkA2TCSTSM_cjs.m.create({service:"fetch"}),e=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],n=false,r=null;function o(){return e.some(x=>{let b=process.env[x];return typeof b=="string"&&b.trim().length>0})}Cr.hasProxyConfigured=o;function i(){let x=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||x}Cr.getProxyUrl=i;function a(x={}){let b=x.httpProxy||x.httpsProxy||i();if(!b){t.warn("[Fetch] No proxy configured, HTTP_PROXY/HTTPS_PROXY environment variables not set");return}let w=new undici.ProxyAgent({uri:b,connectTimeout:x.connectTimeout||1e4,keepAliveTimeout:x.keepAliveTimeout||3e4});r=undici.getGlobalDispatcher(),undici.setGlobalDispatcher(w),n=true,t.info(`[Fetch] Global proxy enabled: ${b}`);}Cr.enableProxy=a;function s(){!n||!r||(undici.setGlobalDispatcher(r),n=false,r=null,t.info("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}Cr.disableProxy=s;function l(){return n}Cr.isProxyEnabled=l;async function p(x,b){let w=b?.timeout||3e4,F=b?.responseType||"json",{timeout:_,responseType:Re,...L}=b||{},E=null,$=null;try{L.signal||(E=new AbortController,$=setTimeout(()=>E.abort(),w));let M=await fetch(x,{...L,signal:L.signal||E.signal});$&&clearTimeout($);let C;switch(F){case "arrayBuffer":C=await M.arrayBuffer();break;case "blob":C=await M.blob();break;case "buffer":{let z=await M.arrayBuffer();C=Buffer.from(z);break}case "text":C=await M.text();break;default:{let z=await M.text();try{C=JSON.parse(z);}catch{C=z;}break}}return {ok:M.ok,status:M.status,statusText:M.statusText,headers:M.headers,data:C,url:M.url}}catch(M){throw $&&clearTimeout($),M}}async function c(x,b){let w=b?.retries??0,F=b?.retryDelay??1e3,{retries:_,retryDelay:Re,responseType:L,...E}=b||{};return Ve(()=>p(x,{...E,responseType:b?.responseType}),{attempts:w+1,delay:F,maxDelay:F*2**(w+1)})}async function u(x,b){return c(x,{method:"GET",...b})}Cr.get=u;async function d(x,b,w){return c(x,{method:"POST",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.post=d;async function m(x,b,w){return c(x,{method:"PUT",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.put=m;async function g(x,b,w){return c(x,{method:"DELETE",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.del=g;async function k(x,b,w){return c(x,{method:"PATCH",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.patch=k;async function S(x,b){return c(x,b)}Cr.request=S;function R(x={}){return o()?(a(x),true):false}Cr.autoProxy=R;let P=5*1024*1024;function O(x){return new TextEncoder().encode(x)}function ie(x){return chunk6JM5F6FM_cjs.d.mimeType(x)}function U(x){return x.startsWith("file://")}async function ae(x){let b=url.fileURLToPath(x);return await chunkJQNKLHWT_cjs.D.file(b).bytes()}async function Me(x,b,w){let F=`----FetchFormBoundary${Date.now()}`,_=[],L=b.some(T=>T.filename||T.value instanceof Uint8Array||Buffer.isBuffer(T.value))&&!w?.timeout?3e5:w?.timeout;for(let T of b){let A=T.maxSize??P,D=T.filename,W=`Content-Disposition: form-data; name="${T.name}"${D?`; filename="${D}"`:""}`;D&&(W+=`\r
57
+ Content-Type: ${ie(D)}`),W+=`\r
77
58
  \r
78
- `,Y.push(V(v));let T=h.value;if(typeof T=="string")if(se(T)){let O=await fe(T);if(P||(P=T.split("/").pop()||"file"),O.byteLength>w)throw new Error(`File size ${O.byteLength} exceeds limit ${w} bytes: ${P}`);Y.push(O);}else Y.push(V(T));else if(Buffer.isBuffer(T)){if(T.byteLength>w)throw new Error(`Buffer size ${T.byteLength} exceeds limit ${w} bytes: ${h.name}`);Y.push(new Uint8Array(T.buffer,T.byteOffset,T.byteLength));}else if(T instanceof Uint8Array){if(T.byteLength>w)throw new Error(`File size ${T.byteLength} exceeds limit ${w} bytes: ${h.name}`);Y.push(T);}}let S=V(`\r
79
- --${W}--`),m=V(`\r
80
- --${W}\r
81
- `),f=[];f.push(V(`--${W}\r
82
- `));for(let h=0;h<Y.length;h++)f.push(Y[h]),h%2===1&&h<Y.length-1&&(f.push(m),f.push(V(`--${W}\r
83
- `)));f.push(S);let d=f.reduce((h,w)=>h+w.length,0),y=new Uint8Array(d),x=0;for(let h of f)y.set(h,x),x+=h.length;return c(I,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${W}`,..._?.headers},body:y,timeout:$,..._})}Ht.postForm=ke;function Te(I,C,_){let W=new AbortController,Y=W.signal;return (async()=>{try{let $={Accept:"text/event-stream",..._?.headers||{}},S=await fetch(I,{..._,headers:$,signal:Y});if(!S.ok)throw new Error(`SSE connection failed: ${S.status}`);let m=S.body?.getReader();if(!m)throw new Error("SSE stream not available");let f=new TextDecoder("utf-8"),d="";for(;!Y.aborted;){let{done:y,value:x}=await m.read();if(y)break;let h=f.decode(x,{stream:!0});d+=h;let w=d.split(`
84
- `);d=w.pop()??"";for(let P of w)if(P.startsWith("data: ")){let v=P.slice(6);if(v==="[DONE]"){C.onComplete?.();return}C.onMessage?.(v);}}C.onComplete?.();}catch($){$.name!=="AbortError"&&C.onError?.($);}})(),()=>{W.abort();}}Ht.sse=Te;})(exports.Fetch||(exports.Fetch={}));chunkVRQQ33YH_cjs.j();exports.Slug=void 0;(n=>{let e=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],t=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function r(){return [e[Math.floor(Math.random()*e.length)],t[Math.floor(Math.random()*t.length)]].join("-")}n.create=r;})(exports.Slug||(exports.Slug={}));chunkVRQQ33YH_cjs.j();function Hn(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function Xo(e,...t){let r=Hn(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}chunkVRQQ33YH_cjs.j();exports.Archive=void 0;(t=>{async function e(r,n){if(process.platform==="win32"){let o=he__default.default.resolve(r),s=he__default.default.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await exports.Shell.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${a}"`);if(i.code!==0)throw new Error(`PowerShell exited with code ${i.code}: ${i.stderr}`)}else {let o=`unzip -o -q ${r} -d ${n}`,s=await exports.Shell.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(exports.Archive||(exports.Archive={}));chunkVRQQ33YH_cjs.j();exports.Color=void 0;(n=>{function e(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}n.isValidHex=e;function t(o){let s=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),i=parseInt(o.slice(5,7),16);return {r:s,g:a,b:i}}n.hexToRgb=t;function r(o){if(!e(o))return;let{r:s,g:a,b:i}=t(o);return `\x1B[38;2;${s};${a};${i}m\x1B[1m`}n.hexToAnsiBold=r;})(exports.Color||(exports.Color={}));chunkVRQQ33YH_cjs.j();exports.Context=void 0;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);chunkVRQQ33YH_cjs.c(this,"name",s);}}r.NotFound=e;function t(n){let o=new async_hooks.AsyncLocalStorage;return {use(){let s=o.getStore();if(!s)throw new e(n);return s},provide(s,a){return o.run(s,a)}}}r.create=t;})(exports.Context||(exports.Context={}));chunkVRQQ33YH_cjs.j();function Zo(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}chunkVRQQ33YH_cjs.j();exports.EventLoop=void 0;(t=>{async function e(){return new Promise(r=>{let n=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?r():setImmediate(n);};n();})}t.wait=e;})(exports.EventLoop||(exports.EventLoop={}));chunkVRQQ33YH_cjs.j();function Qo(e){if(e<=0)return "";if(e<60)return `${e}s`;if(e<3600){let r=Math.floor(e/60),n=e%60;return n>0?`${r}m ${n}s`:`${r}m`}if(e<86400){let r=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${r}h ${n}m`:`${r}h`}if(e<604800){let r=Math.floor(e/86400);return r===1?"~1 day":`~${r} days`}let t=Math.floor(e/604800);return t===1?"~1 week":`~${t} weeks`}chunkVRQQ33YH_cjs.j();exports.Keybind=void 0;(a=>{function e(i,l){if(i===l)return true;if(typeof i!="object"||typeof l!="object"||i===null||l===null)return false;let p=Object.keys(i),c=Object.keys(l);if(p.length!==c.length)return false;for(let u of p)if(!c.includes(u)||!e(i[u],l[u]))return false;return true}function t(i){return {...i,super:i.super??false}}function r(i,l){return i?e(t(i),t(l)):false}a.match=r;function n(i,l=false){return {name:i.name,ctrl:i.ctrl,meta:i.meta,shift:i.shift,super:i.super??false,leader:l}}a.fromParsedKey=n;function o(i){if(!i)return "";let l=[];i.ctrl&&l.push("ctrl"),i.meta&&l.push("alt"),i.super&&l.push("super"),i.shift&&l.push("shift"),i.name&&(i.name==="delete"?l.push("del"):l.push(i.name));let p=l.join("+");return i.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}a.keyToString=o;function s(i){return i==="none"?[]:i.split(",").map(l=>{let c=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),u={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let g of c)switch(g){case "ctrl":u.ctrl=true;break;case "alt":case "meta":case "option":u.meta=true;break;case "super":u.super=true;break;case "shift":u.shift=true;break;case "leader":u.leader=true;break;case "esc":u.name="escape";break;default:u.name=g;break}return u})}a.parse=s;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(p=>{function e(c){return c.replace(/\b\w/g,u=>u.toUpperCase())}p.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}p.time=t;function r(c){let u=new Date(c),g=t(c),k=u.toLocaleDateString();return `${g} \xB7 ${k}`}p.datetime=r;function n(c){let u=new Date(c),g=new Date;return u.getFullYear()===g.getFullYear()&&u.getMonth()===g.getMonth()&&u.getDate()===g.getDate()?t(c):r(c)}p.todayTimeOrDateTime=n;function o(c){return c>=1e6?(c/1e6).toFixed(1)+"M":c>=1e3?(c/1e3).toFixed(1)+"K":c.toString()}p.number=o;function s(c){if(c<1e3)return `${c}ms`;if(c<6e4)return `${(c/1e3).toFixed(1)}s`;if(c<36e5){let k=Math.floor(c/6e4),E=Math.floor(c%6e4/1e3);return `${k}m ${E}s`}if(c<864e5){let k=Math.floor(c/36e5),E=Math.floor(c%36e5/6e4);return `${k}h ${E}m`}let u=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${u}h`}p.duration=s;function a(c,u){return c.length<=u?c:c.slice(0,u-1)+"\u2026"}p.truncate=a;function i(c,u=35){if(c.length<=u)return c;let g="\u2026",k=Math.ceil((u-g.length)/2),E=Math.floor((u-g.length)/2);return c.slice(0,k)+g+c.slice(-E)}p.truncateMiddle=i;function l(c,u,g){return (c===1?u:g).replace("{}",c.toString())}p.pluralize=l;})(exports.Locale||(exports.Locale={}));chunkVRQQ33YH_cjs.j();var es=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function ts(){return es.some(e=>process.env[e])}function ns(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function rs(){let e=process.env.HTTP_PROXY||process.env.http_proxy,t=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:e,https:t,enabled:!!(e||t)}}chunkVRQQ33YH_cjs.j();var Nt=class{constructor(){chunkVRQQ33YH_cjs.c(this,"queue",[]);chunkVRQQ33YH_cjs.c(this,"resolvers",[]);}push(t){let r=this.resolvers.shift();r?r(t):this.queue.push(t);}async next(){return this.queue.length>0?this.queue.shift():new Promise(t=>this.resolvers.push(t))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function os(e,t,r){let n=[...t];await Promise.all(Array.from({length:e},async()=>{for(;;){let o=n.pop();if(o===void 0)return;await r(o);}}));}chunkVRQQ33YH_cjs.j();function ss(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}chunkVRQQ33YH_cjs.j();function is(e,t){let r;return Promise.race([e.then(n=>(clearTimeout(r),n)),new Promise((n,o)=>{r=setTimeout(()=>{o(new Error(`Operation timed out after ${t}ms`));},t);})])}chunkVRQQ33YH_cjs.j();exports.Token=void 0;(a=>{let r=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function n(i){if(!i)return 0;let l=String(i),p=(l.match(r)||[]).length,c=l.length-p,u=Math.round(p/1.5),g=Math.round(c/4);return Math.max(0,u+g)}a.estimate=n;function o(i){if(i==null)return 0;try{let l=typeof i=="string"?i:JSON.stringify(i);return n(l)}catch{return 0}}a.estimateObject=o;function s(i){if(i.total!==void 0&&i.total>0)return i.total;let l=i.input??0,p=i.output??0,c=i.cache?.read??0,u=i.cache?.write??0;return l+p+c+u}a.total=s;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function ls(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return De__default.default.object(t)}chunkVRQQ33YH_cjs.j();exports.Wildcard=void 0;(s=>{function e(a,i){let l=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return l.endsWith(" .*")&&(l=l.slice(0,-3)+"( .*)?"),new RegExp("^"+l+"$","s").test(a)}s.match=e;function t(a){return a.sort((i,l)=>{let p=i[0].length-l[0].length;return p!==0?p:i[0].localeCompare(l[0])})}function r(a,i){let l=Object.entries(i),p=t(l),c;for(let[u,g]of p)e(a,u)&&(c=g);return c}s.all=r;function n(a,i){let l=Object.entries(i),p=t(l),c;for(let[u,g]of p){let k=u.split(/\s+/);e(a.head,k[0])&&(k.length===1||o(a.tail,k.slice(1)))&&(c=g);}return c}s.allStructured=n;function o(a,i){if(i.length===0)return true;if(a.length<i.length)return false;for(let l=0;l<i.length;l++)if(!e(a[l],i[l]))return false;return true}})(exports.Wildcard||(exports.Wildcard={}));Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.c}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.a}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.b}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.e}});Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkYC4AEMOP_cjs.a}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return hono.Hono}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return nodeWs.createNodeWebSocket}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return cors.cors}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return logger.logger}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return compress.compress}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return secureHeaders.secureHeaders}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return timeout.timeout}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return httpException.HTTPException}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return validator.validator}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return zodValidator.zValidator}});exports.$=$r;exports.AsyncQueue=Nt;exports.NamedError=mt;exports.PkgShell=Pe;exports.abortAfter=Hn;exports.abortAfterAny=Xo;exports.buildCodeSpanIndex=Ke;exports.chunkMarkdownIR=$n;exports.chunkText=be;exports.chunkTextByBreakResolver=wt;exports.convertMarkdownTables=Ze;exports.createInlineCodeState=Xe;exports.createPkgShell=ce;exports.createRESTServer=lt;exports.createRPCServer=at;exports.createServer=ae;exports.createStreamingServer=ut;exports.createWebSocketServer=ct;exports.defer=Zo;exports.detectPlatform=pn;exports.escapeCommandArg=pt;exports.escapeCommandArgSafe=fn;exports.extractFrontmatter=Ve;exports.findFenceSpanAt=Et;exports.findLast=ir;exports.fn=Nr;exports.formatDuration=Qo;exports.formatMarkdown=Ge;exports.getDirectory=zo;exports.getFileExtension=Ho;exports.getFilename=Dn;exports.getFilenameTruncated=Wo;exports.getProxyConfig=rs;exports.getProxyUrl=ns;exports.git=Wr;exports.iife=Xr;exports.isSafeFenceBreak=Nn;exports.joinCommandArgs=me;exports.lazy=Le;exports.lazyAsync=cr;exports.loadEnv=Hr;exports.loadTextFile=Vr;exports.loadTextFileAsync=Jr;exports.markdownToIR=we;exports.markdownToIRWithMeta=Ie;exports.needsShellExecution=un;exports.parseCommand=re;exports.parseCommandWithOptions=dn;exports.parseFenceSpans=Je;exports.parseFrontmatterBlock=Fe;exports.parseModelId=Kr;exports.proxied=ts;exports.readableStreamToText=_r;exports.renderMarkdown=Se;exports.renderMarkdownWithMarkers=Ae;exports.retry=Ot;exports.scanParenAwareBreakpoints=xt;exports.serializeFrontmatter=Ye;exports.shell=gn;exports.signal=ss;exports.startServer=pr;exports.truncateMiddle=Uo;exports.updateSchema=ls;exports.whichSync=Br;exports.withTimeout=is;exports.work=os;
59
+ `,_.push(O(W));let v=T.value;if(typeof v=="string")if(U(v)){let ve=await ae(v);if(D||(D=v.split("/").pop()||"file"),ve.byteLength>A)throw new Error(`File size ${ve.byteLength} exceeds limit ${A} bytes: ${D}`);_.push(ve);}else _.push(O(v));else if(Buffer.isBuffer(v)){if(v.byteLength>A)throw new Error(`Buffer size ${v.byteLength} exceeds limit ${A} bytes: ${T.name}`);_.push(new Uint8Array(v.buffer,v.byteOffset,v.byteLength));}else if(v instanceof Uint8Array){if(v.byteLength>A)throw new Error(`File size ${v.byteLength} exceeds limit ${A} bytes: ${T.name}`);_.push(v);}}let E=O(`\r
60
+ --${F}--`),$=O(`\r
61
+ --${F}\r
62
+ `),M=[];M.push(O(`--${F}\r
63
+ `));for(let T=0;T<_.length;T++)M.push(_[T]),T%2===1&&T<_.length-1&&(M.push($),M.push(O(`--${F}\r
64
+ `)));M.push(E);let C=M.reduce((T,A)=>T+A.length,0),z=new Uint8Array(C),le=0;for(let T of M)z.set(T,le),le+=T.length;return c(x,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${F}`,...w?.headers},body:z,timeout:L,...w})}Cr.postForm=Me;function Pt(x,b,w){let F=new AbortController,_=F.signal;return (async()=>{try{let L={Accept:"text/event-stream",...w?.headers||{}},E=await fetch(x,{...w,headers:L,signal:_});if(!E.ok)throw new Error(`SSE connection failed: ${E.status}`);let $=E.body?.getReader();if(!$)throw new Error("SSE stream not available");let M=new TextDecoder("utf-8"),C="";for(;!_.aborted;){let{done:z,value:le}=await $.read();if(z)break;let T=M.decode(le,{stream:!0});C+=T;let A=C.split(`
65
+ `);C=A.pop()??"";for(let D of A)if(D.startsWith("data: ")){let W=D.slice(6);if(W==="[DONE]"){b.onComplete?.();return}b.onMessage?.(W);}}b.onComplete?.();}catch(L){L.name!=="AbortError"&&b.onError?.(L);}})(),()=>{F.abort();}}Cr.sse=Pt;})(exports.Fetch||(exports.Fetch={}));chunkVRQQ33YH_cjs.j();exports.Slug=void 0;(r=>{let t=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],e=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function n(){return [t[Math.floor(Math.random()*t.length)],e[Math.floor(Math.random()*e.length)]].join("-")}r.create=n;})(exports.Slug||(exports.Slug={}));chunkVRQQ33YH_cjs.j();function vt(t){let e=new AbortController,n=setTimeout(e.abort.bind(e),t);return {controller:e,signal:e.signal,clearTimeout:()=>globalThis.clearTimeout(n)}}function hr(t,...e){let n=vt(t);return {signal:AbortSignal.any([n.signal,...e]),clearTimeout:n.clearTimeout}}chunkVRQQ33YH_cjs.j();exports.Archive=void 0;(e=>{async function t(n,r){if(process.platform==="win32"){let o=De__default.default.resolve(n),i=De__default.default.resolve(r),a=`Expand-Archive -Path '${o}' -DestinationPath '${i}' -Force`,s=await chunkJQNKLHWT_cjs.G.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${a}"`);if(s.code!==0)throw new Error(`PowerShell exited with code ${s.code}: ${s.stderr}`)}else {let o=`unzip -o -q ${n} -d ${r}`,i=await chunkJQNKLHWT_cjs.G.run(void 0,o);if(i.code!==0)throw new Error(`unzip exited with code ${i.code}: ${i.stderr}`)}}e.extractZip=t;})(exports.Archive||(exports.Archive={}));chunkVRQQ33YH_cjs.j();exports.Color=void 0;(r=>{function t(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}r.isValidHex=t;function e(o){let i=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),s=parseInt(o.slice(5,7),16);return {r:i,g:a,b:s}}r.hexToRgb=e;function n(o){if(!t(o))return;let{r:i,g:a,b:s}=e(o);return `\x1B[38;2;${i};${a};${s}m\x1B[1m`}r.hexToAnsiBold=n;})(exports.Color||(exports.Color={}));chunkVRQQ33YH_cjs.j();exports.Context=void 0;(n=>{class t extends Error{constructor(i){super(`No context found for ${i}`);chunkVRQQ33YH_cjs.c(this,"name",i);}}n.NotFound=t;function e(r){let o=new async_hooks.AsyncLocalStorage;return {use(){let i=o.getStore();if(!i)throw new t(r);return i},provide(i,a){return o.run(i,a)}}}n.create=e;})(exports.Context||(exports.Context={}));chunkVRQQ33YH_cjs.j();function yr(t){return {[Symbol.dispose](){t();},[Symbol.asyncDispose](){return Promise.resolve(t())}}}chunkVRQQ33YH_cjs.j();exports.EventLoop=void 0;(e=>{async function t(){return new Promise(n=>{let r=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?n():setImmediate(r);};r();})}e.wait=t;})(exports.EventLoop||(exports.EventLoop={}));chunkVRQQ33YH_cjs.j();function br(t){if(t<=0)return "";if(t<60)return `${t}s`;if(t<3600){let n=Math.floor(t/60),r=t%60;return r>0?`${n}m ${r}s`:`${n}m`}if(t<86400){let n=Math.floor(t/3600),r=Math.floor(t%3600/60);return r>0?`${n}h ${r}m`:`${n}h`}if(t<604800){let n=Math.floor(t/86400);return n===1?"~1 day":`~${n} days`}let e=Math.floor(t/604800);return e===1?"~1 week":`~${e} weeks`}chunkVRQQ33YH_cjs.j();exports.Keybind=void 0;(a=>{function t(s,l){if(s===l)return true;if(typeof s!="object"||typeof l!="object"||s===null||l===null)return false;let p=Object.keys(s),c=Object.keys(l);if(p.length!==c.length)return false;for(let u of p)if(!c.includes(u)||!t(s[u],l[u]))return false;return true}function e(s){return {...s,super:s.super??false}}function n(s,l){return s?t(e(s),e(l)):false}a.match=n;function r(s,l=false){return {name:s.name,ctrl:s.ctrl,meta:s.meta,shift:s.shift,super:s.super??false,leader:l}}a.fromParsedKey=r;function o(s){if(!s)return "";let l=[];s.ctrl&&l.push("ctrl"),s.meta&&l.push("alt"),s.super&&l.push("super"),s.shift&&l.push("shift"),s.name&&(s.name==="delete"?l.push("del"):l.push(s.name));let p=l.join("+");return s.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}a.keyToString=o;function i(s){return s==="none"?[]:s.split(",").map(l=>{let c=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),u={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let d of c)switch(d){case "ctrl":u.ctrl=true;break;case "alt":case "meta":case "option":u.meta=true;break;case "super":u.super=true;break;case "shift":u.shift=true;break;case "leader":u.leader=true;break;case "esc":u.name="escape";break;default:u.name=d;break}return u})}a.parse=i;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(d=>{d.SUPPORTED_LANGS=["zh-CN","en-US"],d.DEFAULT_LANG="zh-CN";function n(m,g="EASBOT_LANG"){let k=[m,process.env[g]?.trim()];for(let S of k)if(S&&d.SUPPORTED_LANGS.includes(S))return S;return d.DEFAULT_LANG}d.resolveLocaleLang=n;function r(m){return m.replace(/\b\w/g,g=>g.toUpperCase())}d.titlecase=r;function o(m){return new Date(m).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=o;function i(m){let g=new Date(m),k=o(m),S=g.toLocaleDateString();return `${k} \xB7 ${S}`}d.datetime=i;function a(m){let g=new Date(m),k=new Date;return g.getFullYear()===k.getFullYear()&&g.getMonth()===k.getMonth()&&g.getDate()===k.getDate()?o(m):i(m)}d.todayTimeOrDateTime=a;function s(m){return m>=1e6?(m/1e6).toFixed(1)+"M":m>=1e3?(m/1e3).toFixed(1)+"K":m.toString()}d.number=s;function l(m){if(m<1e3)return `${m}ms`;if(m<6e4)return `${(m/1e3).toFixed(1)}s`;if(m<36e5){let S=Math.floor(m/6e4),R=Math.floor(m%6e4/1e3);return `${S}m ${R}s`}if(m<864e5){let S=Math.floor(m/36e5),R=Math.floor(m%36e5/6e4);return `${S}h ${R}m`}let g=Math.floor(m/36e5);return `${Math.floor(m%36e5/864e5)}d ${g}h`}d.duration=l;function p(m,g){return m.length<=g?m:m.slice(0,g-1)+"\u2026"}d.truncate=p;function c(m,g=35){if(m.length<=g)return m;let k="\u2026",S=Math.ceil((g-k.length)/2),R=Math.floor((g-k.length)/2);return m.slice(0,S)+k+m.slice(-R)}d.truncateMiddle=c;function u(m,g,k){return (m===1?g:k).replace("{}",m.toString())}d.pluralize=u;})(exports.Locale||(exports.Locale={}));var xr=exports.Locale.resolveLocaleLang,kr=exports.Locale.SUPPORTED_LANGS,Sr=exports.Locale.DEFAULT_LANG;chunkVRQQ33YH_cjs.j();var wr=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function Tr(){return wr.some(t=>process.env[t])}function Mr(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function Rr(){let t=process.env.HTTP_PROXY||process.env.http_proxy,e=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:t,https:e,enabled:!!(t||e)}}chunkVRQQ33YH_cjs.j();var rt=class{constructor(){chunkVRQQ33YH_cjs.c(this,"queue",[]);chunkVRQQ33YH_cjs.c(this,"resolvers",[]);}push(e){let n=this.resolvers.shift();n?n(e):this.queue.push(e);}async next(){return this.queue.length>0?this.queue.shift():new Promise(e=>this.resolvers.push(e))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function vr(t,e,n){let r=[...e];await Promise.all(Array.from({length:t},async()=>{for(;;){let o=r.pop();if(o===void 0)return;await n(o);}}));}chunkVRQQ33YH_cjs.j();function Ir(){let t,e=new Promise(n=>t=n);return {trigger(){return t()},wait(){return e}}}chunkVRQQ33YH_cjs.j();function Pr(t,e){let n;return Promise.race([t.then(r=>(clearTimeout(n),r)),new Promise((r,o)=>{n=setTimeout(()=>{o(new Error(`Operation timed out after ${e}ms`));},e);})])}chunkVRQQ33YH_cjs.j();exports.Token=void 0;(a=>{let n=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function r(s){if(!s)return 0;let l=String(s),p=(l.match(n)||[]).length,c=l.length-p,u=Math.round(p/1.5),d=Math.round(c/4);return Math.max(0,u+d)}a.estimate=r;function o(s){if(s==null)return 0;try{let l=typeof s=="string"?s:JSON.stringify(s);return r(l)}catch{return 0}}a.estimateObject=o;function i(s){if(s.total!==void 0&&s.total>0)return s.total;let l=s.input??0,p=s.output??0,c=s.cache?.read??0,u=s.cache?.write??0;return l+p+c+u}a.total=i;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function _r(t){let e={},n=t.shape??t.required().shape;for(let[r,o]of Object.entries(n))e[r]=o.nullable().optional();return pe__default.default.object(e)}Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkYC4AEMOP_cjs.a}});Object.defineProperty(exports,"$",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.H}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.j}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.d}});Object.defineProperty(exports,"Lazy",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.c}});Object.defineProperty(exports,"PKG",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.D}});Object.defineProperty(exports,"PkgShell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.A}});Object.defineProperty(exports,"Shell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.G}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.g}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.e}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.s}});Object.defineProperty(exports,"createPkgShell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.B}});Object.defineProperty(exports,"createRESTServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.p}});Object.defineProperty(exports,"createRPCServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.n}});Object.defineProperty(exports,"createServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.m}});Object.defineProperty(exports,"createStreamingServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.r}});Object.defineProperty(exports,"createWebSocketServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.q}});Object.defineProperty(exports,"detectPlatform",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.y}});Object.defineProperty(exports,"escapeCommandArg",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.w}});Object.defineProperty(exports,"escapeCommandArgSafe",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.x}});Object.defineProperty(exports,"joinCommandArgs",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.z}});Object.defineProperty(exports,"lazy",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.a}});Object.defineProperty(exports,"lazyAsync",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.b}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.f}});Object.defineProperty(exports,"needsShellExecution",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.u}});Object.defineProperty(exports,"parseCommand",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.t}});Object.defineProperty(exports,"parseCommandWithOptions",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.v}});Object.defineProperty(exports,"readableStreamToText",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.E}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.h}});Object.defineProperty(exports,"shell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.C}});Object.defineProperty(exports,"startServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.o}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.i}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.k}});Object.defineProperty(exports,"whichSync",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.F}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.l}});Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.d}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.b}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.c}});Object.defineProperty(exports,"Wildcard",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.a}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.e}});exports.AsyncQueue=rt;exports.DEFAULT_LANG=Sr;exports.NamedError=Le;exports.SUPPORTED_LANGS=kr;exports.abortAfter=vt;exports.abortAfterAny=hr;exports.buildCodeSpanIndex=we;exports.chunkMarkdownIR=St;exports.chunkText=q;exports.chunkTextByBreakResolver=Be;exports.convertMarkdownTables=Te;exports.createInlineCodeState=Se;exports.defer=yr;exports.extractFrontmatter=xe;exports.findFenceSpanAt=Ye;exports.findLast=en;exports.fn=on;exports.formatDuration=br;exports.formatMarkdown=ye;exports.getDirectory=ir;exports.getFileExtension=ar;exports.getFilename=Mt;exports.getFilenameTruncated=lr;exports.getProxyConfig=Rr;exports.getProxyUrl=Mr;exports.git=cn;exports.iife=gn;exports.isSafeFenceBreak=Tt;exports.loadEnv=ln;exports.loadTextFile=mn;exports.loadTextFileAsync=hn;exports.markdownToIR=X;exports.markdownToIRWithMeta=re;exports.parseFenceSpans=ke;exports.parseFrontmatterBlock=se;exports.parseModelId=yn;exports.proxied=Tr;exports.renderMarkdown=V;exports.renderMarkdownWithMarkers=oe;exports.resolveLocaleLang=xr;exports.retry=Ve;exports.scanParenAwareBreakpoints=ze;exports.serializeFrontmatter=be;exports.signal=Ir;exports.truncateMiddle=cr;exports.updateSchema=_r;exports.withTimeout=Pr;exports.work=vr;