@easbot/utils 0.3.8 → 0.3.10
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/chunks/chunk-3U5YF6EI.cjs +20 -0
- package/dist/chunks/chunk-6BCTOX3Z.mjs +2 -0
- package/dist/chunks/chunk-AUS6KQNI.cjs +5 -0
- package/dist/chunks/chunk-DELWLFU5.mjs +5 -0
- package/dist/chunks/chunk-EN7LFV4R.cjs +2 -0
- package/dist/chunks/{chunk-UZ52E7FE.mjs → chunk-EWRFKUXM.mjs} +1 -1
- package/dist/chunks/chunk-MHARKEDN.mjs +1 -0
- package/dist/chunks/{chunk-YC4AEMOP.cjs → chunk-PJIZPZPO.cjs} +1 -1
- package/dist/chunks/chunk-WW6DVU53.mjs +20 -0
- package/dist/chunks/chunk-XBAP2B6J.cjs +1 -0
- package/dist/chunks/filesystem-26SI2VQU.cjs +1 -0
- package/dist/chunks/filesystem-GHRTFLEY.mjs +1 -0
- package/dist/chunks/lock-BQX6RGCF.mjs +1 -0
- package/dist/chunks/lock-RMTHF4F6.cjs +1 -0
- package/dist/chunks/{main-ZMRSNK7G.mjs → main-GVYBF75T.mjs} +4 -4
- package/dist/chunks/{main-RIJAJS2R.cjs → main-K27GCHMT.cjs} +4 -4
- package/dist/chunks/registry-5BYC5NYM.mjs +1 -0
- package/dist/chunks/registry-Z3XETZ6O.cjs +1 -0
- package/dist/chunks/shell-52EI6MQK.cjs +1 -0
- package/dist/chunks/shell-JJRFPZC7.mjs +1 -0
- package/dist/index.cjs +40 -39
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.mjs +41 -40
- package/package.json +3 -2
- package/dist/chunks/chunk-6HZ7Q7NO.mjs +0 -2
- package/dist/chunks/chunk-6JM5F6FM.cjs +0 -2
- package/dist/chunks/chunk-A2TCSTSM.cjs +0 -5
- package/dist/chunks/chunk-AHO55TRS.cjs +0 -4
- package/dist/chunks/chunk-DAYGB2XR.mjs +0 -4
- package/dist/chunks/chunk-JQNKLHWT.cjs +0 -20
- package/dist/chunks/chunk-LBWRSUJC.mjs +0 -20
- package/dist/chunks/chunk-T3MZ3YS3.mjs +0 -5
- package/dist/chunks/chunk-V6YNYGNC.mjs +0 -1
- package/dist/chunks/chunk-VRQQ33YH.cjs +0 -1
- package/dist/chunks/filesystem-HQDKXRWJ.cjs +0 -1
- package/dist/chunks/filesystem-XE6UYBAE.mjs +0 -1
- package/dist/chunks/lock-EGXJVIO5.mjs +0 -1
- package/dist/chunks/lock-LMCPTUNU.cjs +0 -1
- package/dist/chunks/registry-BGNK5LJC.cjs +0 -1
- package/dist/chunks/registry-NQR4SFLJ.mjs +0 -1
- package/dist/chunks/shell-PXZK5BNW.mjs +0 -1
- package/dist/chunks/shell-RJBXISIH.cjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
export{a as Lock}from'./chunks/chunk-
|
|
1
|
+
export{a as Lock}from'./chunks/chunk-EWRFKUXM.mjs';import {b,D,a,G,c as c$1}from'./chunks/chunk-WW6DVU53.mjs';export{H as $,j as HTTPException,d as Hono,c as Lazy,D as PKG,A as PkgShell,G as Shell,g as compress,e as cors,s as createNodeWebSocket,B as createPkgShell,p as createRESTServer,n as createRPCServer,m as createServer,r as createStreamingServer,q as createWebSocketServer,y as detectPlatform,w as escapeCommandArg,x as escapeCommandArgSafe,z as joinCommandArgs,a as lazy,b as lazyAsync,f as logger,u as needsShellExecution,t as parseCommand,v as parseCommandWithOptions,E as readableStreamToText,h as secureHeaders,C as shell,o as startServer,i as timeout,k as validator,F as whichSync,l as zValidator}from'./chunks/chunk-WW6DVU53.mjs';import {d,b as b$2,a as a$1}from'./chunks/chunk-6BCTOX3Z.mjs';export{d as Filesystem,b as Glob,c as MIME_TYPES,a as Wildcard}from'./chunks/chunk-6BCTOX3Z.mjs';import {m,b as b$1}from'./chunks/chunk-DELWLFU5.mjs';export{m as Log,o as PackageRegistry,n as Semver,l as addMinutesInTimezone,a as formatLocalISO,b as formatLocalISOCompact,f as formatLogTime,g as formatLogTimeMs,h as getTimezoneOffset,i as getTimezoneParts,j as isValidTimezone,k as normalizeTimezone,c as now,d as nowLocalISO,e as parseLocalISO}from'./chunks/chunk-DELWLFU5.mjs';import {f,c,d as d$1}from'./chunks/chunk-MHARKEDN.mjs';import he from'fs/promises';import ke,{z}from'zod';import {randomBytes}from'crypto';import {config}from'dotenv';import Ue,{dirname,join}from'path';import {existsSync,readdirSync,statSync}from'fs';import {xdgConfig}from'xdg-basedir';import {fileURLToPath}from'url';import Pn from'markdown-it';import Ft from'yaml';import {ProxyAgent,getGlobalDispatcher,setGlobalDispatcher}from'undici';import {AsyncLocalStorage}from'async_hooks';f();f();function on(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}}f();var De;(n=>{function t(r,o,i){let a=0,s=r.length-1;for(;a<=s;){let l=Math.floor((a+s)/2),f=r[l];if(f===void 0)break;let c=i(f);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 f=Math.floor((s+l)/2),c=r[f];if(c===void 0)break;i(c)<a?s=f+1:l=f;}return r.splice(s,0,o),r}n.insert=e;})(De||(De={}));f();var $e;(i=>{function t(a){let s=new TextEncoder().encode(a),l=Array.from(s,f=>String.fromCharCode(f)).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,f=>f.charCodeAt(0));return new TextDecoder().decode(l)}i.base64Decode=e;async function n(a,s="SHA-256"){let f=new TextEncoder().encode(a),c=await crypto.subtle.digest(s,f);return Array.from(new Uint8Array(c)).map(h=>h.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;})($e||($e={}));f();f();var J;(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 ke.string().startsWith(t[d])}u.schema=e;let n=26,r=0,o=0;function i(d,h){return s(d,false,h)}u.ascending=i;function a(d,h){return s(d,true,h)}u.descending=a;function s(d,h,k){if(!k)return f(d,h);if(!k.startsWith(t[d]))throw new Error(`ID ${k} does not start with ${t[d]}`);return k}function l(d){let h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",k="",v=randomBytes(d);for(let p=0;p<d;p++){let g=v[p];g!==void 0&&(k+=h[g%62]);}return k}function f(d,h,k){let v=k??Date.now();v!==r&&(r=v,o=0),o++;let p=BigInt(v)*BigInt(4096)+BigInt(o);p=h?~p:p;let g=Buffer.alloc(6);for(let R=0;R<6;R++)g[R]=Number(p>>BigInt(40-8*R)&BigInt(255));return t[d]+"_"+g.toString("hex")+l(n-12)}u.create=f;function c(d){let h=d.split("_")[0];if(!h)return 0;let k=d.slice(h.length+1,h.length+13),v=BigInt("0x"+k);return Number(v/BigInt(4096))}u.timestamp=c;})(J||(J={}));var Ne;(f=>{f.DEFAULT_MAX_CHARS=4e3,f.DIRECTION="head",f.DIR=d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),f.GLOB=d.join(f.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
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}async function a(c,u={}){let d$1=u.maxChars??4e3,h=u.direction??f.DIRECTION,k=u.label??"content",v=u.sourcePath,p=d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),g=u.dir??p;if(c.length<=d$1)return {content:c,truncated:false};let R=J.ascending("context"),F=d.join(g,R);await he.mkdir(g,{recursive:true}).catch(()=>{}),await he.writeFile(F,c,"utf-8");let z=c.length-d$1,L;h==="head"?L=c.slice(0,d$1):L=c.slice(-d$1);let E=i(F,k,v),A=`${z} characters truncated`;return {content:h==="head"?`${L}
|
|
5
5
|
|
|
6
|
-
...${
|
|
6
|
+
...${A}...
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${E}`:`...${A}...
|
|
9
9
|
|
|
10
|
-
${
|
|
10
|
+
${E}
|
|
11
11
|
|
|
12
|
-
${
|
|
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 a.match(r,i);if(i.includes("/"))return a.match(r,i);let a
|
|
12
|
+
${L}`,truncated:true,outputPath:F,originalLength:c.length,removedLength:z,label:k}}f.truncate=a;function s(c){return c.truncated?i(c.outputPath,c.label):""}f.formatHint=s;async function l(){let c=J.timestamp(J.create("context",false,Date.now()-o)),d$1=(await he.readdir(f.DIR).catch(()=>[])).filter(h=>h.startsWith("context_"));for(let h of d$1)J.timestamp(h)>=c||await he.unlink(d.join(f.DIR,h)).catch(()=>{});}f.cleanup=l;})(Ne||(Ne={}));f();var ze;(s=>{let t="New session - ",e="Child session - ";s.parentTitlePrefix=t,s.childTitlePrefix=e;function o(l=false){return (l?e:t)+b$1(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 f=l.match(/^(.+) \(fork #(\d+)\)$/);if(f){let c=f[1]??"",u=parseInt(f[2]??"0",10);return `${c} (fork #${u+1})`}return `${l} (fork #1)`}s.getForked=a;})(ze||(ze={}));f();var le=class le extends Error{static create(e,n){var i;let r=ke.object({name:ke.literal(e),data:n}).meta({ref:e}),o=(i=class extends le{constructor(s,l){super(e,l);c(this,"data",s);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}}},c(i,"Schema",r),i);return Object.defineProperty(o,"name",{value:e}),o}};c(le,"Unknown",le.create("UnknownError",ke.object({message:ke.string()})));var Be=le;f();var je;(e=>{function t(n){return new We(n)}e.create=t;})(je||(je={}));var We=class{constructor(e){c(this,"rules",[]);c(this,"ignorecase");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 a$1.match(r,i);if(i.includes("/"))return a$1.match(r,i);let a=r.split("/");for(let s of a)if(a$1.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}};f();function pt(t,e){let n=r=>{let o;try{o=t.parse(r);}catch(i){throw console.trace("schema validation failure stack trace:"),i instanceof 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 cn=pt,He;(e=>e.fn=pt)(He||(He={}));f();function dn(t={}){let e=t.isDevelopment??false,n=e?".env.dev":".env",r=t.globalConfigPath??(xdgConfig?Ue.join(xdgConfig,"easbot"):void 0),o=t.projectRoot??process.cwd(),i=o?Ue.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=Ue.join(s,n);if(!existsSync(l))continue;let f=config({path:l,override:true,debug:e,encoding:"utf-8",quiet:!e});if(e&&f.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 f.parsed);u.length>0&&console.warn(`[loadEnv] ${l} contains keys that have no effect: ${u.join(", ")}.
|
|
14
14
|
Reason: xdg-basedir caches XDG_* on import, so this .env file loads too late.
|
|
15
|
-
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}
|
|
16
|
-
`?o=s:/\s/.test(l)&&(i=s));}}return {lastNewline:o,lastWhitespace:i}}function
|
|
15
|
+
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}f();async function pn(t,e){if(process.env.EASBOT_CLIENT==="acp")try{let i=process.platform==="win32"?"cmd":void 0,a=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,f]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),u=Buffer.from(f);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=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}}f();function gt(t){return t?dirname(fileURLToPath(t)):typeof d$1<"u"?d$1:process.cwd()}function ht(t,e,n=3){function r(o,i){if(i>n||!existsSync(o))return null;try{let a=readdirSync(o);for(let s of a){let l=join(o,s);try{let f=statSync(l);if(f.isFile()&&l.endsWith(e))return l;if(f.isDirectory()&&i<n){let c=r(l,i+1);if(c)return c}}catch{}}}catch{}return null}return r(t,0)}function yt(t,e){let n=join(t,e);if(existsSync(n))return n;let r=e.split("/").pop()||e,o=t;for(let i=0;i<5;i++){let a=join(o,"assets","txt");if(existsSync(a)){let f=ht(a,r,5);if(f)return f}let s=join(o,"dist","assets","txt");if(existsSync(s)){let f=ht(s,r,5);if(f)return f}let l=join(o,"..");if(l===o)break;o=l;}return n}function bn(t,e){return c$1.lazy(()=>{try{let n=gt(e),r=yt(n,t);return D.file(r).textSync()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}function xn(t,e){return c$1.lazy(async()=>{try{let n=gt(e),r=yt(n,t);return await D.file(r).text()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}f();function kn(t){return t()}f();function wn(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)}}f();f();f();function qe(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 Sn(t,e){if(!t)return [];if(e<=0)return [t];if(t.length<=e)return [t]}function te(t,e,n){try{let r=z.string().parse(t),o=z.number().int().parse(e),i=Sn(r,o);if(i)return i;let a=Ge(r,o,s=>{let{lastNewline:l,lastWhitespace:f}=qe(s,0,s.length);return l>0?l:f});return n?.minLength&&n.minLength>0&&(a=xt(a,n.minLength)),a}catch(r){return console.warn("Invalid input for chunkText:",r),typeof t=="string"&&t.length>0?[t]:[]}}function xt(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+`
|
|
17
17
|
|
|
18
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+`
|
|
19
19
|
|
|
20
|
-
`+r);}else n.push(r);return n}function
|
|
20
|
+
`+r);}else n.push(r);return n}function Ge(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,f=o.slice(0,s).trimEnd();f.length>0&&r.push(f);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}f();var Ye=z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),kt=z.object({start:z.number().int().min(0),end:z.number().int().min(0),style:Ye}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),wt=z.object({start:z.number().int().min(0),end:z.number().int().min(0),href:z.string().min(1)}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),ue=z.object({text:z.string(),styles:z.array(kt),links:z.array(wt)}).strict(),fe=z.enum(["off","bullets","code"]),Se=z.object({linkify:z.boolean().default(true),enableSpoilers:z.boolean().default(false),headingStyle:z.enum(["none","bold"]).default("none"),blockquotePrefix:z.string().default(""),autolink:z.boolean().default(true),tableMode:fe.default("off")}).partial().default({}),St=z.object({open:z.string(),close:z.string()}).strict(),Xe=z.object({styleMarkers:z.record(Ye,St).optional(),escapeText:z.any().optional(),buildLink:z.any().optional()}).strict();z.object({start:z.number().int().min(0),end:z.number().int().min(0),open:z.string(),close:z.string()}).strict();var Ve=z.object({indentSize:z.number().int().min(1).default(2),listMarker:z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:z.enum(["```","~~~"]).default("```"),preserveFrontmatter:z.boolean().default(true)}).strict(),Je=z.record(z.string(),z.string()),Te=z.object({open:z.boolean(),ticks:z.number().int().min(0)}).strict();z.object({inlineState:Te,isInside:z.any()}).strict();z.object({start:z.number().int().min(0),end:z.number().int().min(0),openLine:z.string(),marker:z.string(),indent:z.string()}).strict();z.object({tables:fe.optional()}).strict();function vn(t){let e=new Pn({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 Tt(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 Ke(t,e){return {...t,type:"text",content:e,children:void 0}}function On(t){for(let e of t)e.children&&e.children.length>0&&(e.children=Fn(e.children));}function Fn(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 f=s.indexOf("||",l);if(f===-1)break;e+=1,l=f+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 f=s.indexOf("||",l);if(f===-1){l<s.length&&r.push(Ke(a,s.slice(l)));break}if(i>=n){r.push(Ke(a,s.slice(l)));break}f>l&&r.push(Ke(a,s.slice(l,f))),i+=1,o.spoilerOpen=!o.spoilerOpen,r.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=f+2;}}return r}function En(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function Q(t){return t.table?.currentCell??t}function Me(t,e){if(!e)return;let n=Q(t);n.text+=e;}function ne(t,e){let n=Q(t);n.openStyles.push({style:e,start:n.text.length});}function re(t,e){let n=Q(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 Mt(t){t.env.listStack.length>0||t.table||(t.text+=`
|
|
21
21
|
|
|
22
|
-
`);}function
|
|
23
|
-
`);}function
|
|
24
|
-
`;}for(let a=1;a<o.length;a++)
|
|
25
|
-
`;}else for(let o of n){for(let i=0;i<o.length;i++)
|
|
26
|
-
`;}}function
|
|
27
|
-
`;},l=()=>{t.text+="|";for(let c=0;c<r;c+=1){let u=o[c]??0,
|
|
28
|
-
`;};s(e),l();for(let c of n)s(c);let
|
|
29
|
-
`);break;case "paragraph_close":
|
|
22
|
+
`);}function _n(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 Cn(t,e){if(!e)return;let n=Q(t),r=n.text.length;n.text+=e,n.styles.push({start:r,end:r+e.length,style:"code"});}function An(t,e){let n=e??"",r=Q(t),o=r.text.length;r.text+=n,r.styles.push({start:o,end:o+n.length,style:"code_block"});}function Ln(t){let e=Q(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 Dn(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function $n(t){return It(t),{text:t.text,styles:t.styles,links:t.links}}function Re(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 f=Math.max(0,l.start-n),c=Math.min(i,l.end-n);c>f&&a.push({start:f,end:c,style:l.style});}let s=[];for(let l of t.links){let f=Math.max(0,l.start-n),c=Math.min(i,l.end-n);c>f&&s.push({start:f,end:c,href:l.href});}return {text:o,styles:a,links:s}}function Ze(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 Nn(t,e){e.text&&(t.text+=e.text);}function Rt(t,e){let{header:n,value:r,columnIndex:o,includeColumnFallback:i}=e;r?.text&&(t.text+="\u2022 ",n?.text?(Ze(t,n),t.text+=": "):i&&(t.text+=`Column ${o}: `),Ze(t,r),t.text+=`
|
|
23
|
+
`);}function zn(t){if(!t.table)return;let e=t.table.headers.map(Re),n=t.table.rows.map(o=>o.map(Re));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;Ze(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++)Rt(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++)Rt(t,{header:e[i],value:o[i],columnIndex:i,includeColumnFallback:false});t.text+=`
|
|
26
|
+
`;}}function Bn(t){if(!t.table)return;let e=t.table.headers.map(Re),n=t.table.rows.map(c=>c.map(Re)),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 h=c[u]?.text.length??0;(o[u]??0)<h&&(o[u]=h);}};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&&Nn(t,d);let h=d?.text.length??0,v=(o[u]??0)-h;v>0&&(t.text+=" ".repeat(v)),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 f=t.text.length;f>a&&t.styles.push({start:a,end:f,style:"code_block"});}function Qe(t,e){for(let n of t)switch(n.type){case "inline":n.children&&Qe(n.children,e);break;case "text":Me(e,n.content??"");break;case "em_open":ne(e,"italic");break;case "em_close":re(e,"italic");break;case "strong_open":ne(e,"bold");break;case "strong_close":re(e,"bold");break;case "s_open":ne(e,"strikethrough");break;case "s_close":re(e,"strikethrough");break;case "code_inline":Cn(e,n.content??"");break;case "spoiler_open":e.enableSpoilers&&ne(e,"spoiler");break;case "spoiler_close":e.enableSpoilers&&re(e,"spoiler");break;case "link_open":{let r=Tt(n,"href")??"",o=Q(e);o.linkStack.push({href:r,labelStart:o.text.length});break}case "link_close":Ln(e);break;case "image":Me(e,n.content??"");break;case "softbreak":case "hardbreak":Me(e,`
|
|
29
|
+
`);break;case "paragraph_close":Mt(e);break;case "heading_open":e.headingStyle==="bold"&&ne(e,"bold");break;case "heading_close":e.headingStyle==="bold"&&re(e,"bold"),Mt(e);break;case "blockquote_open":e.blockquotePrefix&&(e.text+=e.blockquotePrefix),ne(e,"blockquote");break;case "blockquote_close":re(e,"blockquote");break;case "bullet_list_open":e.env.listStack.length>0&&(e.text+=`
|
|
30
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
31
|
`);break;case "ordered_list_open":{e.env.listStack.length>0&&(e.text+=`
|
|
32
|
-
`);let r=Number(
|
|
33
|
-
`);break;case "list_item_open":
|
|
32
|
+
`);let r=Number(Tt(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":_n(e);break;case "list_item_close":e.text.endsWith(`
|
|
34
34
|
`)||(e.text+=`
|
|
35
|
-
`);break;case "code_block":case "fence":
|
|
35
|
+
`);break;case "code_block":case "fence":An(e,n.content??"");break;case "html_block":case "html_inline":Me(e,n.content??"");break;case "table_open":e.tableMode!=="off"&&(e.table=Dn(),e.hasTables=true);break;case "table_close":e.table&&(e.tableMode==="bullets"?zn(e):e.tableMode==="code"&&Bn(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=En());break;case "th_close":case "td_close":e.table?.currentCell&&(e.table.currentRow.push($n(e.table.currentCell)),e.table.currentCell=null);break;case "hr":e.text+=`\u2500\u2500\u2500
|
|
36
36
|
|
|
37
|
-
`;break;default:n.children&&
|
|
38
|
-
`);let
|
|
37
|
+
`;break;default:n.children&&Qe(n.children,e);break}}function It(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 jn(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 Wn(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 Pt(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 vt(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 Hn(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let i=vt(o,e,n);i&&r.push({start:i.start-e,end:i.end-e,style:o.style});}return Pt(r)}function Un(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let i=vt(o,e,n);i&&r.push({start:i.start-e,end:i.end-e,href:o.href});}return r}function oe(t,e){try{let n=typeof t=="string"?t:"",r=Se.parse(e??{});return de(n,r).ir}catch(n){return console.error("Markdown parse error:",n),{text:"",styles:[],links:[]}}}function de(t,e){try{let n=typeof t=="string"?t:"",r=Se.parse(e),o={listStack:[]},a=vn(r).parse(n||"",o);r.enableSpoilers&&On(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};Qe(a,l),It(l);let c=l.text.trimEnd().length,u=0;for(let k of l.styles)k.style==="code_block"&&k.end>u&&(u=k.end);let d=Math.max(c,u);return {ir:{text:d===l.text.length?l.text:l.text.slice(0,d),styles:Pt(jn(l.styles,d)),links:Wn(l.links,d)},hasTables:l.hasTables}}catch(n){return console.error("Markdown parse error:",n),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function Ot(t,e){try{let n=ue.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=te(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 f=a,c=Math.min(n.text.length,f+s.length);i.push({text:s,styles:Hn(n.styles,f,c),links:Un(n.links,f,c)}),a=c;}),i}catch(n){return console.error("Chunk IR error:",n),[]}}f();var qn={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function pe(t,e){try{let n=ue.parse(t),r=Xe.parse(e??{});if(!n.text)return "";let o=r.styleMarkers??qn,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 h=(R,F)=>R==="link_open"?0:R==="open"?1:R==="close"?2:R==="link_close"?3:4,k=u.type==="close"||u.type==="link_close",v=d.type==="close"||d.type==="link_close",p=h(u.type,k),g=h(d.type,v);return p!==g?p-g: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="",f=0,c=[];for(let u of s){if(u.position>f){let d=n.text.slice(f,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 h=c.findIndex(k=>k.spanIndex===u.spanIndex&&k.type==="open");h!==-1&&c.splice(h,1);}}else if(u.type==="link_open")l+="[",c.push(u);else if(u.type==="link_close"){l+="]("+u.href+")";let d=c.findIndex(h=>h.spanIndex===u.spanIndex&&h.type==="link_open");d!==-1&&c.splice(d,1);}f=u.position;}if(f<n.text.length){let u=n.text.slice(f);l+=i?i(u):u;}return l}catch(n){return console.error("Markdown render error:",n),""}}function se(t,e){return pe(t,e)}f();function Gn(t){let e=t.replace(/\r\n/g,`
|
|
39
39
|
`).replace(/\r/g,`
|
|
40
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
|
|
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 Ie(t,e){try{let n=typeof t=="string"?t:"",r=Ve.parse(e??{});if(!n)return "";let{frontmatter:o,content:i}=Gn(n),a=oe(i,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),s=se(a);return s=s.replace(/\n{3,}/g,`
|
|
42
42
|
|
|
43
43
|
`),s=s.trimEnd()+`
|
|
44
44
|
`,r.preserveFrontmatter&&o&&(s=o+`
|
|
45
|
-
`+s),s}catch(n){return console.error("Markdown format error:",n),t}}
|
|
46
|
-
`).trim(),linesConsumed:r-e}}function
|
|
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
|
|
45
|
+
`+s),s}catch(n){return console.error("Markdown format error:",n),t}}f();function Yn(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function Xn(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 Vn(t){try{let e=Ft.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=Xn(o);a&&(n[i]=a);}return n}catch{return null}}function Jn(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 Kn(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 f=n[r+1];if(f&&(f.startsWith(" ")||f.startsWith(" "))){let{value:c,linesConsumed:u}=Jn(n,r);c&&(e[a]={value:c,kind:"multiline",rawInline:s}),r+=u;continue}}let l=Yn(s);l&&(e[a]={value:l,kind:"inline",rawInline:s}),r+=1;}return e}function Zn(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.value;return e}function Qn(t){return /^[|>][+-]?(\d+)?[+-]?$/.test(t)}function er(t){let{lineEntry:e,yamlValue:n}=t;return n.kind!=="structured"||e.kind!=="inline"||Qn(e.rawInline)?false:e.value.includes(":")}function tr(t){let e=t.replace(/\r\n/g,`
|
|
48
48
|
`).replace(/\r/g,`
|
|
49
49
|
`);if(!e.startsWith("---"))return;let n=e.indexOf(`
|
|
50
|
-
---`,3);if(n!==-1)return e.slice(4,n)}function
|
|
51
|
-
${
|
|
52
|
-
---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function
|
|
50
|
+
---`,3);if(n!==-1)return e.slice(4,n)}function me(t){try{if(typeof t!="string")return {};let e=tr(t);if(!e)return {};let n=Kn(e),r=Vn(e);if(r===null)return Zn(n);let o={};for(let[i,a]of Object.entries(r)){o[i]=a.value;let s=n[i];s&&er({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 Pe(t){try{let e=Je.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
|
+
${Ft.stringify(n,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
52
|
+
---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function ve(t){try{if(typeof t!="string")return {frontmatter:{},content:""};let e=t.replace(/\r\n/g,`
|
|
53
53
|
`).replace(/\r/g,`
|
|
54
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:
|
|
56
|
-
`,o),a=i===-1?e.length:i,s=e.slice(o,a),l=s.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let
|
|
57
|
-
Content-Type: ${
|
|
55
|
+
---`,3);if(n===-1)return {frontmatter:{},content:t};let r=e.slice(4,n),o=e.slice(n+4).trimStart();return {frontmatter:me(t),content:o}}catch(e){return console.warn("Failed to extract frontmatter:",e),{frontmatter:{},content:t}}}f();f();function Oe(t){try{let e=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 f=l[1],c=l[2];if(!f||!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:f};else if(r.markerChar===u&&d>=r.markerLen){let h=a;n.push({start:r.start,end:h,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 et(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 Et(t,e){return !et(t,e)}function Fe(){return {open:false,ticks:0}}function Ee(t,e){try{let n=z.string().parse(t),r=e?Te.parse(e):Fe(),o=Oe(n),i={open:r.open,ticks:r.ticks},{spans:a,state:s}=or(n,o,i);return {inlineState:s,isInside:l=>ir(l,o)||ar(l,a)}}catch(n){return console.warn("Invalid input for buildCodeSpanIndex:",n),{inlineState:Fe(),isInside:()=>false}}}function or(t,e,n){let r=[],o=n.open,i=n.ticks,a=o?0:-1,s=0;for(;s<t.length;){let l=sr(e,s);if(l){s=l.end;continue}if(t[s]!=="`"){s+=1;continue}let f=s,c=0;for(;s<t.length&&t[s]==="`";)c+=1,s+=1;if(!o){o=true,i=c,a=f;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 sr(t,e){return t.find(n=>e>=n.start&&e<n.end)}function ir(t,e){return e.some(n=>t>=n.start&&t<n.end)}function ar(t,e){return e.some(([n,r])=>t>=n&&t<r)}f();var cr={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function _e(t,e){try{let n=z.string().parse(t),r=fe.parse(e);if(!n||r==="off")return n;let{ir:o,hasTables:i}=de(n,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:r});return i?pe(o,{styleMarkers:cr,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:""}}var tt;(f=>{function t(c,u){try{return oe(c,u)}catch(d){return console.warn("Markdown.parse error:",d),{text:"",styles:[],links:[]}}}f.parse=t;function e(c,u){try{return se(c,u)}catch(d){return console.warn("Markdown.render error:",d),""}}f.render=e;function n(c,u){try{return Ie(c,u)}catch(d){return console.warn("Markdown.format error:",d),typeof c=="string"?c:""}}f.format=n;function r(c){try{return me(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}f.parseFrontmatter=r;function o(c){try{return Pe(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}f.serializeFrontmatter=o;function i(c){try{return ve(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}f.extractFrontmatter=i;function a(c,u,d){try{return te(c,u,d)}catch(h){return console.warn("Markdown.chunk error:",h),typeof c=="string"&&c.length>0?[c]:[]}}f.chunk=a;function s(c,u){try{return Ee(c,u)}catch(d){return console.warn("Markdown.buildCodeIndex error:",d),{inlineState:{open:false,ticks:0},isInside:()=>false}}}f.buildCodeIndex=s;function l(c,u){try{return _e(c,u)}catch(d){return console.warn("Markdown.convertTables error:",d),typeof c=="string"?c:""}}f.convertTables=l;})(tt||(tt={}));f();function _t(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n[n.length-1]??""}function ur(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n.slice(0,n.length-1).join("/")+"/"}function fr(t){if(!t)return "";let e=t.split(".");return e[e.length-1]}function dr(t,e=20){let n=_t(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 pr(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)}f();var mr=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function hr(t){if(!t)return false;let e=String(t instanceof Error?t.message:t).toLowerCase();return mr.some(n=>e.includes(n))}async function nt(t,e={}){let{attempts:n=3,delay:r=500,factor:o=2,maxDelay:i=1e4,retryIf:a=hr}=e,s;for(let l=0;l<n;l++)try{return await t()}catch(f){if(s=f,l===n-1||!a(f))throw f;let c=Math.min(r*o**l,i);await new Promise(u=>setTimeout(u,c));}throw s}f();var rt;(T=>{let t=m.create({service:"fetch"}),e=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],n=false,r=null;function o(){return e.some(x=>{let y=process.env[x];return typeof y=="string"&&y.trim().length>0})}T.hasProxyConfigured=o;function i(){let x=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||x}T.getProxyUrl=i;function a(x={}){let y=x.httpProxy||x.httpsProxy||i();if(!y){t.warn("[Fetch] No proxy configured, HTTP_PROXY/HTTPS_PROXY environment variables not set");return}let I=new ProxyAgent({uri:y,connectTimeout:x.connectTimeout||1e4,keepAliveTimeout:x.keepAliveTimeout||3e4});r=getGlobalDispatcher(),setGlobalDispatcher(I),n=true,t.info(`[Fetch] Global proxy enabled: ${y}`);}T.enableProxy=a;function s(){!n||!r||(setGlobalDispatcher(r),n=false,r=null,t.info("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}T.disableProxy=s;function l(){return n}T.isProxyEnabled=l;async function f(x,y){let I=y?.timeout||3e4,D=y?.responseType||"json",{timeout:C,responseType:U,...N}=y||{},M=null,O=null;try{N.signal||(M=new AbortController,O=setTimeout(()=>M.abort(),I));let P=await fetch(x,{...N,signal:N.signal||M.signal});O&&clearTimeout(O);let $;switch(D){case "arrayBuffer":$=await P.arrayBuffer();break;case "blob":$=await P.blob();break;case "buffer":{let X=await P.arrayBuffer();$=Buffer.from(X);break}case "text":$=await P.text();break;default:{let X=await P.text();try{$=JSON.parse(X);}catch{$=X;}break}}return {ok:P.ok,status:P.status,statusText:P.statusText,headers:P.headers,data:$,url:P.url}}catch(P){throw O&&clearTimeout(O),P}}async function c(x,y){let I=y?.retries??0,D=y?.retryDelay??1e3,{retries:C,retryDelay:U,responseType:N,...M}=y||{};return nt(()=>f(x,{...M,responseType:y?.responseType}),{attempts:I+1,delay:D,maxDelay:D*2**(I+1)})}async function u(x,y){return c(x,{method:"GET",...y})}T.get=u;async function d$1(x,y,I){return c(x,{method:"POST",headers:{"Content-Type":"application/json",...I?.headers},body:y?JSON.stringify(y):void 0,...I})}T.post=d$1;async function h(x,y,I){return c(x,{method:"PUT",headers:{"Content-Type":"application/json",...I?.headers},body:y?JSON.stringify(y):void 0,...I})}T.put=h;async function k(x,y,I){return c(x,{method:"DELETE",headers:{"Content-Type":"application/json",...I?.headers},body:y?JSON.stringify(y):void 0,...I})}T.del=k;async function v(x,y,I){return c(x,{method:"PATCH",headers:{"Content-Type":"application/json",...I?.headers},body:y?JSON.stringify(y):void 0,...I})}T.patch=v;async function p(x,y){return c(x,y)}T.request=p;function g(x={}){return o()?(a(x),true):false}T.autoProxy=g;let R=5*1024*1024;function F(x){return new TextEncoder().encode(x)}function z(x){return d.mimeType(x)}function L(x){return x.startsWith("file://")}async function E(x){let y=fileURLToPath(x);return await D.file(y).bytes()}async function A(x,y,I){let D=`----FetchFormBoundary${Date.now()}`,C=[],N=y.some(_=>_.filename||_.value instanceof Uint8Array||Buffer.isBuffer(_.value))&&!I?.timeout?3e5:I?.timeout;for(let _ of y){let q=_.maxSize??R,G=_.filename,ee=`Content-Disposition: form-data; name="${_.name}"${G?`; filename="${G}"`:""}`;G&&(ee+=`\r
|
|
57
|
+
Content-Type: ${z(G)}`),ee+=`\r
|
|
58
58
|
\r
|
|
59
|
-
`,
|
|
60
|
-
--${
|
|
61
|
-
--${
|
|
62
|
-
`),
|
|
63
|
-
`));for(let
|
|
64
|
-
`)));
|
|
65
|
-
`)
|
|
59
|
+
`,C.push(F(ee));let B=_.value;if(typeof B=="string")if(L(B)){let Ce=await E(B);if(G||(G=B.split("/").pop()||"file"),Ce.byteLength>q)throw new Error(`File size ${Ce.byteLength} exceeds limit ${q} bytes: ${G}`);C.push(Ce);}else C.push(F(B));else if(Buffer.isBuffer(B)){if(B.byteLength>q)throw new Error(`Buffer size ${B.byteLength} exceeds limit ${q} bytes: ${_.name}`);C.push(new Uint8Array(B.buffer,B.byteOffset,B.byteLength));}else if(B instanceof Uint8Array){if(B.byteLength>q)throw new Error(`File size ${B.byteLength} exceeds limit ${q} bytes: ${_.name}`);C.push(B);}}let M=F(`\r
|
|
60
|
+
--${D}--`),O=F(`\r
|
|
61
|
+
--${D}\r
|
|
62
|
+
`),P=[];P.push(F(`--${D}\r
|
|
63
|
+
`));for(let _=0;_<C.length;_++)P.push(C[_]),_%2===1&&_<C.length-1&&(P.push(O),P.push(F(`--${D}\r
|
|
64
|
+
`)));P.push(M);let $=P.reduce((_,q)=>_+q.length,0),X=new Uint8Array($),ge=0;for(let _ of P)X.set(_,ge),ge+=_.length;return c(x,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${D}`,...I?.headers},body:X,timeout:N,...I})}T.postForm=A;function j(x,y,I){let D=new AbortController,C=D.signal;return (async()=>{try{let N={Accept:"text/event-stream",...I?.headers||{}},M=await fetch(x,{...I,headers:N,signal:C});if(!M.ok)throw new Error(`SSE connection failed: ${M.status}`);let O=M.body?.getReader();if(!O)throw new Error("SSE stream not available");let P=new TextDecoder("utf-8"),$="";for(;!C.aborted;){let{done:X,value:ge}=await O.read();if(X)break;let _=P.decode(ge,{stream:!0});$+=_;let q=$.split(`
|
|
65
|
+
`);$=q.pop()??"";for(let G of q)if(G.startsWith("data: ")){let ee=G.slice(6);if(ee==="[DONE]"){y.onComplete?.();return}y.onMessage?.(ee);}}y.onComplete?.();}catch(N){N.name!=="AbortError"&&y.onError?.(N);}})(),()=>{D.abort();}}T.sse=j;})(rt||(rt={}));f();var ot;(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;})(ot||(ot={}));f();function At(t){let e=new AbortController,n=setTimeout(e.abort.bind(e),t);return {controller:e,signal:e.signal,clearTimeout:()=>globalThis.clearTimeout(n)}}function xr(t,...e){let n=At(t);return {signal:AbortSignal.any([n.signal,...e]),clearTimeout:n.clearTimeout}}f();var st;(e=>{async function t(n,r){if(process.platform==="win32"){let o=Ue.resolve(n),i=Ue.resolve(r),a=`Expand-Archive -Path '${o}' -DestinationPath '${i}' -Force`,s=await 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 G.run(void 0,o);if(i.code!==0)throw new Error(`unzip exited with code ${i.code}: ${i.stderr}`)}}e.extractZip=t;})(st||(st={}));f();var it;(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;})(it||(it={}));f();var at;(n=>{class t extends Error{constructor(i){super(`No context found for ${i}`);c(this,"name",i);}}n.NotFound=t;function e(r){let o=new 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;})(at||(at={}));f();function wr(t){return {[Symbol.dispose](){t();},[Symbol.asyncDispose](){return Promise.resolve(t())}}}f();var lt;(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;})(lt||(lt={}));f();function Sr(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`}f();var ct;(v=>{let t=m.create({service:"grep"});async function e(){return n()}v.filepath=e;let n=b(async()=>{let p=await D.which("rg");if(!p)return null;try{if(!(await he.stat(p)).isFile())return null}catch{return null}try{let g=await D.run([p,"--version"],{timeout:5e3});if(g.code!==0||!g.stdout.startsWith("ripgrep "))return t.warn("rg failed self-test, falling back to pure JS",{filepath:p,code:g.code,stderr:g.stderr.slice(0,200)}),null}catch(g){return t.warn("rg spawn failed during self-test, falling back to pure JS",{filepath:p,error:g.message.slice(0,200)}),null}return p});async function r(){return await e()!==null}v.isUsingRipgrep=r;async function*o(p){p.signal?.throwIfAborted();let g=await e();g?yield*i(g,p):(t.debug("ripgrep not available, using pure JS fallback for files()",{cwd:p.cwd}),yield*a$2(p));}v.files=o;async function*i(p,g){g.signal?.throwIfAborted();let R=["--files","--glob=!.git/*"];g.follow&&R.push("--follow");let F=g.hidden!==false;if(g.maxDepth!==void 0&&R.push(`--max-depth=${g.maxDepth}`),g.glob)for(let E of g.glob)R.push(`--glob=${E}`);try{if(!(await he.stat(g.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${g.cwd}'`),{code:"ENOTDIR",errno:-20,path:g.cwd})}catch(E){throw E.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${g.cwd}'`),{code:"ENOENT",errno:-2,path:g.cwd}):E}let z=await D.run([p,...R],{cwd:g.cwd});if(z.code!==0&&z.code!==1)return;let L=z.stdout.split(/\r?\n/);for(let E of L){g.signal?.throwIfAborted();let A=E.trim();if(!A)continue;let j=d.toUnixPath(A);!F&&j.split("/").some(T=>T.startsWith("."))||(yield j);}}async function*a$2(p){p.signal?.throwIfAborted();try{if(!(await he.stat(p.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${p.cwd}'`),{code:"ENOTDIR",errno:-20,path:p.cwd})}catch(T){throw T.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${p.cwd}'`),{code:"ENOENT",errno:-2,path:p.cwd}):T}let g=[],R=[];if(p.glob)for(let T of p.glob)T.startsWith("!")?R.push(T.slice(1)):g.push(T);let F=g.length>0?g:["**/*"],z=p.hidden!==false,L=new Set,E=b$2.DEFAULT_MAX_DEPTH,A;p.maxDepth===void 0?A=E:p.maxDepth<0?A=1:A=p.maxDepth+1;let j=Math.min(Math.max(A,1),E);for(let T of F){p.signal?.throwIfAborted();let x=await b$2.scan(T,{cwd:p.cwd,absolute:false,include:"file",dot:z,symlink:p.follow??false,maxDepth:j,ignore:R});for(let y of x)!z&&y.split("/").some(I=>I.startsWith("."))||L.add(y);}for(let T of Array.from(L).sort())p.signal?.throwIfAborted(),yield T;p.signal?.throwIfAborted();}async function s(p){t.debug("tree",{cwd:p.cwd}),p.signal?.throwIfAborted();let g=p.hidden!==false,R=p.glob??[],F=R.filter(M=>!M.startsWith("!")),z=R.filter(M=>M.startsWith("!")).map(M=>M.slice(1)),L=F.length>0?F:["**/*"],E=new Set,A=[];for(let M of L){p.signal?.throwIfAborted();let O=await b$2.scan(M,{cwd:p.cwd,absolute:false,include:"file",dot:g,symlink:false,maxDepth:b$2.DEFAULT_MAX_DEPTH});for(let P of O)E.has(P)||(E.add(P),A.push(P));}let j=A.filter(M=>{for(let O of z)if(b$2.match(O,M))return false;return true});function T(M,O){let P=M.children.get(O);if(P)return P;let $={name:O,children:new Map};return M.children.set(O,$),$}let x={children:new Map};for(let M of j){let O=M.split("/");if(O.length<2)continue;let P=x;for(let $ of O.slice(0,-1))P=T(P,$);}let y=Array.from(x.children.values()).sort((M,O)=>M.name.localeCompare(O.name)),I=p.limit??Number.POSITIVE_INFINITY,D=[],C=y.map(M=>({node:M,path:M.name})),U=0,N=0;for(;C.length>0;){let M=C.shift();if(!M)break;if(U++,N<I){D.push(M.path),N++;for(let O of Array.from(M.node.children.values()).sort((P,$)=>P.name.localeCompare($.name))){if(N>=I)break;C.push({node:O,path:`${M.path}/${O.name}`});}}}return U>N&&D.push(`[${N}/${U} shown, ${U-N} truncated]`),D.join(`
|
|
66
|
+
`)}v.tree=s;async function l(p){let g=await e();return g?f(g,p):(t.debug("ripgrep not available, using pure JS fallback for search()",{cwd:p.cwd,pattern:p.pattern}),c(p))}v.search=l;async function f(p,g){let R=["--json","--glob=!.git/*"];if(g.follow&&R.push("--follow"),g.glob)for(let A of g.glob)R.push(`--glob=${A}`);g.limit&&R.push(`--max-count=${g.limit}`),R.push("--"),R.push(g.pattern);let F=await D.run([p,...R],{cwd:g.cwd});if(F.code!==0)return [];let z=g.hidden!==false,L=F.stdout.split(/\r?\n/).filter(Boolean),E=[];for(let A of L)try{let j=JSON.parse(A);if(j?.type!=="match")continue;let T=j.data;if(!T?.path?.text||!T?.lines?.text)continue;let x=d.toUnixPath(T.path.text);if(!z&&x.split("/").some(y=>y.startsWith(".")))continue;if(E.push({path:x,lines:T.lines.text,line_number:T.line_number,absolute_offset:T.absolute_offset??0}),g.limit&&E.length>=g.limit)break}catch{}return E}async function c(p){let g;try{g=new RegExp(p.pattern);}catch{return []}try{if(!(await he.stat(p.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${p.cwd}'`),{code:"ENOTDIR",errno:-20,path:p.cwd})}catch(T){throw T.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${p.cwd}'`),{code:"ENOENT",errno:-2,path:p.cwd}):T}let R=[],F=[];if(p.glob)for(let T of p.glob)T.startsWith("!")?F.push(T.slice(1)):R.push(T);let z=p.hidden!==false,L=[],E=R.length>0?R:["**/*"],A=new Set,j=[];for(let T of E){p.signal?.throwIfAborted();let x=await b$2.scan(T,{cwd:p.cwd,absolute:false,include:"file",dot:z,symlink:p.follow??false,maxDepth:void 0,ignore:F});for(let y of x)A.has(y)||(A.add(y),j.push(y));}for(let T of j){if(p.signal?.throwIfAborted(),p.limit&&L.length>=p.limit)break;let x=d.join(p.cwd,T),y;try{y=await he.readFile(x,"utf-8");}catch{continue}let I=y.split(/\r?\n/),D=0;for(let C=0;C<I.length;C++){let U=I[C]??"";if(g.test(U)&&(L.push({path:T,lines:U,line_number:C+1,absolute_offset:D}),p.limit&&L.length>=p.limit))break;D+=Buffer.byteLength(U,"utf-8")+1;}}return L}function u(p,g){return a$1.match(p,g)}v.match=u;let d$1=a(async()=>await e());async function h(){return await d$1()}v.filepathCached=h,v._ready=a(async()=>{let p=await e();return t.debug("Grep initialized",{ripgrep:p?"available":"fallback (pure JS)"}),p});})(ct||(ct={}));f();var ut;(a=>{function t(s,l){if(s===l)return true;if(typeof s!="object"||typeof l!="object"||s===null||l===null)return false;let f=Object.keys(s),c=Object.keys(l);if(f.length!==c.length)return false;for(let u of f)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 f=l.join("+");return s.leader&&(f=f?`<leader> ${f}`:"<leader>"),f}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;})(ut||(ut={}));f();var ie;(d=>{d.SUPPORTED_LANGS=["zh-CN","en-US"],d.DEFAULT_LANG="zh-CN";function n(h,k="EASBOT_LANG"){let v=[h,process.env[k]?.trim()];for(let p of v)if(p&&d.SUPPORTED_LANGS.includes(p))return p;return d.DEFAULT_LANG}d.resolveLocaleLang=n;function r(h){return h.replace(/\b\w/g,k=>k.toUpperCase())}d.titlecase=r;function o(h){return new Date(h).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=o;function i(h){let k=new Date(h),v=o(h),p=k.toLocaleDateString();return `${v} \xB7 ${p}`}d.datetime=i;function a(h){let k=new Date(h),v=new Date;return k.getFullYear()===v.getFullYear()&&k.getMonth()===v.getMonth()&&k.getDate()===v.getDate()?o(h):i(h)}d.todayTimeOrDateTime=a;function s(h){return h>=1e6?(h/1e6).toFixed(1)+"M":h>=1e3?(h/1e3).toFixed(1)+"K":h.toString()}d.number=s;function l(h){if(h<1e3)return `${h}ms`;if(h<6e4)return `${(h/1e3).toFixed(1)}s`;if(h<36e5){let p=Math.floor(h/6e4),g=Math.floor(h%6e4/1e3);return `${p}m ${g}s`}if(h<864e5){let p=Math.floor(h/36e5),g=Math.floor(h%36e5/6e4);return `${p}h ${g}m`}let k=Math.floor(h/36e5);return `${Math.floor(h%36e5/864e5)}d ${k}h`}d.duration=l;function f(h,k){return h.length<=k?h:h.slice(0,k-1)+"\u2026"}d.truncate=f;function c(h,k=35){if(h.length<=k)return h;let v="\u2026",p=Math.ceil((k-v.length)/2),g=Math.floor((k-v.length)/2);return h.slice(0,p)+v+h.slice(-g)}d.truncateMiddle=c;function u(h,k,v){return (h===1?k:v).replace("{}",h.toString())}d.pluralize=u;})(ie||(ie={}));var Tr=ie.resolveLocaleLang,Mr=ie.SUPPORTED_LANGS,Rr=ie.DEFAULT_LANG;f();var Ir=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function Pr(){return Ir.some(t=>process.env[t])}function vr(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function Or(){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)}}f();var ft=class{constructor(){c(this,"queue",[]);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 Fr(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);}}));}f();function Er(){let t,e=new Promise(n=>t=n);return {trigger(){return t()},wait(){return e}}}f();function _r(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);})])}f();var dt;(a=>{let n=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function r(s){if(!s)return 0;let l=String(s),f=(l.match(n)||[]).length,c=l.length-f,u=Math.round(f/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,f=s.output??0,c=s.cache?.read??0,u=s.cache?.write??0;return l+f+c+u}a.total=i;})(dt||(dt={}));f();function Ar(t){let e={},n=t.shape??t.required().shape;for(let[r,o]of Object.entries(n))e[r]=o.nullable().optional();return ke.object(e)}export{st as Archive,ft as AsyncQueue,De as Binary,it as Color,at as Context,Rr as DEFAULT_LANG,$e as Encode,lt as EventLoop,rt as Fetch,He as Fn,ct as Grep,J as Identifier,je as Ignore,ut as Keybind,ie as Locale,tt as Markdown,Be as NamedError,Mr as SUPPORTED_LANGS,ze as SessionTitle,ot as Slug,dt as Token,Ne as TruncateContent,At as abortAfter,xr as abortAfterAny,Ee as buildCodeSpanIndex,Ot as chunkMarkdownIR,te as chunkText,Ge as chunkTextByBreakResolver,_e as convertMarkdownTables,Fe as createInlineCodeState,wr as defer,ve as extractFrontmatter,et as findFenceSpanAt,on as findLast,cn as fn,Sr as formatDuration,Ie as formatMarkdown,ur as getDirectory,fr as getFileExtension,_t as getFilename,dr as getFilenameTruncated,Or as getProxyConfig,vr as getProxyUrl,pn as git,kn as iife,Et as isSafeFenceBreak,dn as loadEnv,bn as loadTextFile,xn as loadTextFileAsync,oe as markdownToIR,de as markdownToIRWithMeta,Oe as parseFenceSpans,me as parseFrontmatterBlock,wn as parseModelId,Pr as proxied,se as renderMarkdown,pe as renderMarkdownWithMarkers,Tr as resolveLocaleLang,nt as retry,qe as scanParenAwareBreakpoints,Pe as serializeFrontmatter,Er as signal,pr as truncateMiddle,Ar as updateSchema,_r as withTimeout,Fr as work};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Shared utilities library for EASBOT ecosystem",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"@hono/standard-validator": "^0.2.2",
|
|
47
47
|
"@hono/zod-validator": "^0.7.6",
|
|
48
48
|
"dotenv": "^17.4.2",
|
|
49
|
+
"glob": "^13.0.6",
|
|
49
50
|
"hono": "^4.12.18",
|
|
50
51
|
"hono-openapi": "^1.3.0",
|
|
51
52
|
"markdown-it": "^14.1.1",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"xdg-basedir": "^5.1.0",
|
|
55
56
|
"yaml": "^2.9.0",
|
|
56
57
|
"zod": "^4.4.3",
|
|
57
|
-
"@easbot/types": "0.3.
|
|
58
|
+
"@easbot/types": "0.3.10"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@biomejs/biome": "^2.4.14",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {b,a}from'./chunk-DAYGB2XR.mjs';import {k}from'./chunk-V6YNYGNC.mjs';import ft,{mkdir,readFile,writeFile,chmod}from'fs/promises';import {existsSync,statSync,createWriteStream,realpathSync}from'fs';import {extname,basename,resolve,relative,sep}from'path';import {Readable}from'stream';import {pipeline}from'stream/promises';import B from'os';k();k();k();function tt(e,n){let r=new Set,i=0;for(;i<e.length;){let c=e[i];if(e[i+1]==="-"&&i+2<e.length){let l=e[i+2],g=c.charCodeAt(0),h=l.charCodeAt(0);if(g>h)return null;for(let u=g;u<=h;u++)r.add(String.fromCharCode(u));i+=3;}else r.add(c),i++;}return {kind:"class",chars:r,negate:n}}function A(e){let n=[],r="",i=0;for(;i<e.length;){let c=e[i];if(c==="\\"&&i+1<e.length){r+=e[i+1],i+=2;continue}if(c==="["){let a=e.indexOf("]",i+1);if(a!==-1){let l=e.slice(i+1,a),g=false,h=0;(l.startsWith("!")||l.startsWith("^"))&&(g=true,h=1);let u=tt(l.slice(h),g);if(u){r&&(n.push({kind:"literal",text:r}),r=""),n.push(u),i=a+1;continue}}}r+=c,i++;}return r&&n.push({kind:"literal",text:r}),n}function et(e){let n=nt(e);if(n===-1)return null;let r=it(e,n);if(r===-1)return null;let i=e.slice(n+1,r),c=rt(i);if(!c)return null;let a=e.slice(0,n),l=e.slice(r+1),g=[];for(let h of c)g.push(a+h+l);return g}function nt(e){for(let n=0;n<e.length;n++){if(e[n]==="\\"&&n+1<e.length){n++;continue}if(e[n]==="{")return n}return -1}function it(e,n){let r=1;for(let i=n+1;i<e.length;i++){if(e[i]==="\\"&&i+1<e.length){i++;continue}if(e[i]==="{")r++;else if(e[i]==="}"&&(r--,r===0))return i}return -1}function rt(e){let n=[],r="",i=0;for(let c=0;c<e.length;c++){let a=e[c];if(a==="\\"&&c+1<e.length){r+=e[c+1],c++;continue}if(a==="{")i++,r+=a;else if(a==="}"){if(i--,r+=a,i<0)return null}else a===","&&i===0?(n.push(r),r=""):r+=a;}return i!==0?null:(n.push(r),n)}function ot(e){let n=et(e);return n?[{kind:"brace",alternatives:n.map(i=>I(i))}]:I(e)}function I(e,n=false){let r=[],i="",c=0,a=n?e.length-2:e.length;for(;c<a;){let l=e[c];if(l==="\\"&&c+1<a){i+=e[c+1],c+=2;continue}if(l==="*"&&e[c+1]==="*"&&(c+2>=a||e[c+2]==="/")&&(c===0||e[c-1]==="/")){i&&(r.push(...A(i)),i=""),r.push({kind:"starstar"}),c+=2,e[c]==="/"&&c++;continue}if(l==="*"){i&&(r.push(...A(i)),i=""),r.push({kind:"star"}),c++;continue}if(l==="?"){i&&(r.push(...A(i)),i=""),r.push({kind:"question"}),c++;continue}i+=l,c++;}return i&&r.push(...A(i)),r}function st(e){let n=0;for(;n<e.length;){let r=e[n];if(r==="\\"&&n+1<e.length){n+=2;continue}if(r===" ")return e[n+1]==="*"&&n+2===e.length;n++;}return false}function E(e,n,r=0,i=0){for(;r<e.length;){let c=e[r];if(c.kind==="literal"){if(!n.startsWith(c.text,i))return false;i+=c.text.length;}else if(c.kind==="star"){let a=r+1;for(;a<e.length&&e[a].kind==="star";)a++;if(a>=e.length){for(let l=i;l<n.length;l++)if(n[l]==="/")return false;return true}for(let l=i;l<=n.length;l++){if(E(e,n,a,l))return true;if(n[l]==="/")break}return false}else if(c.kind==="starstar"){let a=r+1;for(;a<e.length&&e[a].kind==="starstar";)a++;if(a>=e.length)return true;for(let l=i;l<=n.length;l++)if(E(e,n,a,l))return true;return false}else if(c.kind==="question"){if(i>=n.length||n[i]==="/")return false;i++;}else if(c.kind==="class"){let a=n[i];if(a===void 0||c.chars.has(a)===c.negate)return false;i++;}else if(c.kind==="brace"){for(let a of c.alternatives)if(E(a,n,0,i))return true;return false}r++;}return i===n.length}function F(e){return e.sort((n,r)=>{let i=n[0].length-r[0].length;return i!==0?i:n[0].localeCompare(r[0])})}var z=new Map,at=1024;function H(e){let n=z.get(e);if(n)return n;let r=ot(e);if(z.size>=at){let i=z.keys().next().value;i!==void 0&&z.delete(i);}return z.set(e,r),r}var v;(c=>{function e(a,l){if(!l)return a==="";try{if(n(a,l))return !0;if(st(l)){let g=l.slice(0,-2);if(n(a,g))return !0}return !1}catch{return false}}c.match=e;function n(a,l){if(!a)return lt(l);let g=H(l);return E(g,a)}function r(a,l){let g=F(Object.entries(l)),h;for(let[u,m]of g)e(a,u)&&(h=m);return h}c.all=r;function i(a,l){let g=F(Object.entries(l)),h;for(let[u,m]of g){let x=u.split(/\s+/);x.length!==0&&e(a.head,x[0])&&(x.length===1||ct(a.tail,x.slice(1)))&&(h=m);}return h}c.allStructured=i;})(v||(v={}));function ct(e,n){if(n.length===0)return true;if(e.length<n.length)return false;for(let r=0;r<n.length;r++)if(!v.match(e[r],n[r]))return false;return true}function lt(e){let n=H(e);return E(n,"")}var W;(h=>{function e(u){return {...u,follow:u.symlink??false,nodir:u.include!=="all",maxDepth:u.maxDepth??20}}async function n(u,m={}){return b(u,e(m))}h.scan=n;function r(u,m={}){return a(u,e(m))}h.scanSync=r;function i(u,m){return v.match(m,u)}h.match=i;async function c(u){try{let m=await ft.readFile(u,"utf-8");return a$1(m)}catch{return []}}h.parseGitignore=c;function a$1(u){let m=[],x=u.split(/\r?\n/);for(let P of x){let T=P.trim();if(!T||T.startsWith("#")||T.startsWith("!"))continue;let b=T;b.endsWith("/")&&(b=`${b}**`),!b.includes("*")&&!b.includes("?")&&!b.includes("[")&&(b=`**/${b}/**`),m.push(b);}return m}h.parseGitignoreContent=a$1;function l(u,m){let x=u.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");for(let P of m)if(v.match(x,P)||v.match(x,`${P}/**`))return true;return false}h.isIgnored=l,h.DEFAULT_IGNORE_PATTERNS=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/__pycache__/**","**/*.min.js","**/*.min.ts","**/coverage/**","**/data/**","**/*.db","**/logs/**","**/*.log","**/.DS_Store","**/Thumbs.db"];})(W||(W={}));var St=sep,U=St==="\\";var V={".html":"text/html",".htm":"text/html",".css":"text/css",".csv":"text/csv",".txt":"text/plain",".md":"text/markdown",".xml":"application/xml",".yaml":"application/yaml",".yml":"application/yaml",".toml":"application/toml",".ini":"text/plain",".cfg":"text/plain",".conf":"text/plain",".log":"text/plain",".sh":"text/x-sh",".bash":"text/x-bash",".zsh":"text/x-zsh",".fish":"text/x-fish",".ps1":"text/x-powershell",".bat":"text/x-batch",".cmd":"text/x-batch",".dockerfile":"text/x-dockerfile",".makefile":"text/x-makefile",".properties":"text/plain",".js":"application/javascript",".mjs":"application/javascript",".cjs":"application/javascript",".jsx":"text/javascript",".ts":"application/typescript",".tsx":"text/typescript",".mts":"application/typescript",".json":"application/json",".jsonc":"application/json",".json5":"application/json",".webmanifest":"application/manifest+json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".webp":"image/webp",".avif":"image/avif",".heic":"image/heic",".heif":"image/heif",".bmp":"image/bmp",".tiff":"image/tiff",".tif":"image/tiff",".mp4":"video/mp4",".webm":"video/webm",".ogg":"video/ogg",".avi":"video/x-msvideo",".mkv":"video/x-matroska",".mov":"video/quicktime",".mp3":"audio/mpeg",".wav":"audio/wav",".flac":"audio/flac",".aac":"audio/aac",".opus":"audio/opus",".m4a":"audio/mp4",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".rtf":"application/rtf",".epub":"application/epub+zip",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".bz2":"application/x-bzip2",".xz":"application/x-xz",".7z":"application/x-7z-compressed",".rar":"application/vnd.rar",".wasm":"application/wasm",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".db":"application/x-sqlite3",".sqlite":"application/vnd.sqlite3",".proto":"application/protobuf"},yt=Object.fromEntries(Object.entries(V).map(([e,n])=>[n,e])),Y;(Ot=>{async function e(t,o){await mkdir(t,{recursive:o?.recursive??true});}Ot.mkdir=e;async function n(t){return existsSync(t)}Ot.exists=n;async function r(t){try{return statSync(t).isDirectory()}catch{return false}}Ot.isDir=r;function i(t){return statSync(t,{throwIfNoEntry:false})??void 0}Ot.stat=i;async function c(t){let o=i(t)?.size??0;return typeof o=="bigint"?Number(o):o}Ot.size=c;async function a(t){return readFile(t,"utf-8")}Ot.readText=a;async function l(t){return JSON.parse(await readFile(t,"utf-8"))}Ot.readJson=l;async function g(t){return readFile(t)}Ot.readBytes=g;async function h(t){let o=await readFile(t);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}Ot.readArrayBuffer=h;function u(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}async function m(t,o,s){try{s?await writeFile(t,o,{mode:s}):await writeFile(t,o);}catch(f){if(u(f)){await mkdir(j(t),{recursive:true}),s?await writeFile(t,o,{mode:s}):await writeFile(t,o);return}throw f}}Ot.write=m;async function x(t,o,s){return m(t,JSON.stringify(o,null,2),s)}Ot.writeJson=x;async function P(t,o,s){let f=j(t);existsSync(f)||await mkdir(f,{recursive:true});let p=o instanceof ReadableStream?Readable.fromWeb(o):o,d=createWriteStream(t);await pipeline(p,d),s&&await chmod(t,s);}Ot.writeStream=P;function T(t){let o=extname(t).toLowerCase();return V[o]||"application/octet-stream"}Ot.mimeType=T;function b(t){return yt[t]}Ot.mimeTypeToExt=b;function wt(t){return t?!!(t.startsWith("text/")||t==="application/json"||t==="application/json5"||t==="application/jsonc"||t==="application/xml"||t==="application/javascript"||t==="application/typescript"||t==="application/x-javascript"||t==="application/yaml"||t==="application/x-yaml"||t==="application/toml"||t==="application/x-sh"||t==="application/x-bash"||t==="application/x-zsh"||t==="application/x-powershell"||t==="application/x-batch"||t==="application/x-dockerfile"||t==="application/x-makefile"):false}Ot.isTextMime=wt;function j(t){if(!t||t.length===0)return ".";let o=y(t);if(o=o.replace(/\/+$/,""),!o||o===""||o==="/")return "/";let s=o.lastIndexOf("/");return s===-1?".":s===0?"/":o.slice(0,s)}Ot.dirname=j;function vt(t,o){if(!t||t.length===0)return "";let s=y(t);if(s=s.replace(/\/+$/,""),!s||s===""||s==="/")return "";let f=s.lastIndexOf("/"),p=f===-1?s:s.slice(f+1);return p?(o&&p.endsWith(o)&&(p=p.slice(0,-o.length)),p):""}Ot.basename=vt;function kt(t){if(!t)return "";let o=y(t);if(!o)return "";let s=basename(o);if(!s||s===".")return "";let f=s.lastIndexOf(".");return f===-1||f===0?"":s.slice(f)}Ot.extname=kt;function y(t){return t?t.replace(/\\/g,"/"):""}Ot.toUnixPath=y;function S(t){if(!t||t.length===0)return B.homedir();if(U&&(t=D(t)),t.startsWith("~/")||t==="~"?t=O(B.homedir(),t.slice(1)):R(t)||(t=resolve(t)),t=y(t),U)try{t=realpathSync.native(t),t=y(t);}catch{}return t}Ot.normalize=S;function Ct(t){return !t||t.length===0?B.homedir():(U&&(t=D(t)),t.startsWith("~/")||t==="~"?t=O(B.homedir(),t.slice(1)):R(t)||(t=resolve(t)),y(t))}Ot.resolve=Ct;function R(t){return !!(t.startsWith("/")||/^[a-zA-Z]:[/\\]/.test(t)||/^[a-zA-Z]:$/.test(t))}Ot.isAbsolute=R;function O(t,...o){let s=y(t);for(let f of o){let p=y(f);R(p)?s=p:(s.endsWith("/")||(s+="/"),s+=p);}return s.replace(/\\/g,"/")}Ot.join=O;function D(t){return process.platform!=="win32"?t:t.replace(/^\/([a-zA-Z]):(?:[\\/]|$)/,(o,s)=>`${s.toUpperCase()}:/`).replace(/^\/([a-zA-Z])(?:\/|$)/,(o,s)=>`${s.toUpperCase()}:/`).replace(/^\/cygdrive\/([a-zA-Z])(?:\/|$)/,(o,s)=>`${s.toUpperCase()}:/`).replace(/^\/mnt\/([a-zA-Z])(?:\/|$)/,(o,s)=>`${s.toUpperCase()}:/`)}Ot.windowsPath=D;function Pt(t,o){let s=S(t),f=S(o),p=relative(s,f),d=relative(f,s);return !p?.startsWith("..")||!d?.startsWith("..")}Ot.overlaps=Pt;function Tt(t,o){let s=S(t),f=S(o);return !relative(s,f).startsWith("..")}Ot.contains=Tt;async function jt(t,o,s){let f=S(o),p=s?S(s):void 0,d=[];for(;;){let w=O(f,t);if(await n(w)&&d.push(w),p&&f===p)break;let k=j(f);if(k===f)break;f=k;}return d}Ot.findUp=jt;async function*zt(t){let{targets:o,start:s,stop:f}=t,p=S(s),d=f?S(f):void 0;for(;;){for(let k of o){let q=O(p,k);await n(q)&&(yield q);}if(d&&p===d)break;let w=j(p);if(w===p)break;p=w;}}Ot.up=zt;async function Et(t,o,s){let f=S(o),p=s?S(s):void 0,d=[];for(;;){try{let k=await W.scan(t,{cwd:f,absolute:!0,include:"file",dot:!0});d.push(...k);}catch{}if(p&&f===p)break;let w=j(f);if(w===f)break;f=w;}return d}Ot.globUp=Et;})(Y||(Y={}));
|
|
2
|
-
export{v as a,W as b,V as c,Y as d};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkAHO55TRS_cjs=require('./chunk-AHO55TRS.cjs'),chunkVRQQ33YH_cjs=require('./chunk-VRQQ33YH.cjs'),lt=require('fs/promises'),fs=require('fs'),path=require('path'),stream=require('stream'),promises=require('stream/promises'),B=require('os');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var lt__default=/*#__PURE__*/_interopDefault(lt);var B__default=/*#__PURE__*/_interopDefault(B);chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function V(e,n){let r=new Set,i=0;for(;i<e.length;){let c=e[i];if(e[i+1]==="-"&&i+2<e.length){let l=e[i+2],g=c.charCodeAt(0),h=l.charCodeAt(0);if(g>h)return null;for(let u=g;u<=h;u++)r.add(String.fromCharCode(u));i+=3;}else r.add(c),i++;}return {kind:"class",chars:r,negate:n}}function A(e){let n=[],r="",i=0;for(;i<e.length;){let c=e[i];if(c==="\\"&&i+1<e.length){r+=e[i+1],i+=2;continue}if(c==="["){let a=e.indexOf("]",i+1);if(a!==-1){let l=e.slice(i+1,a),g=false,h=0;(l.startsWith("!")||l.startsWith("^"))&&(g=true,h=1);let u=V(l.slice(h),g);if(u){r&&(n.push({kind:"literal",text:r}),r=""),n.push(u),i=a+1;continue}}}r+=c,i++;}return r&&n.push({kind:"literal",text:r}),n}function tt(e){let n=et(e);if(n===-1)return null;let r=nt(e,n);if(r===-1)return null;let i=e.slice(n+1,r),c=it(i);if(!c)return null;let a=e.slice(0,n),l=e.slice(r+1),g=[];for(let h of c)g.push(a+h+l);return g}function et(e){for(let n=0;n<e.length;n++){if(e[n]==="\\"&&n+1<e.length){n++;continue}if(e[n]==="{")return n}return -1}function nt(e,n){let r=1;for(let i=n+1;i<e.length;i++){if(e[i]==="\\"&&i+1<e.length){i++;continue}if(e[i]==="{")r++;else if(e[i]==="}"&&(r--,r===0))return i}return -1}function it(e){let n=[],r="",i=0;for(let c=0;c<e.length;c++){let a=e[c];if(a==="\\"&&c+1<e.length){r+=e[c+1],c++;continue}if(a==="{")i++,r+=a;else if(a==="}"){if(i--,r+=a,i<0)return null}else a===","&&i===0?(n.push(r),r=""):r+=a;}return i!==0?null:(n.push(r),n)}function rt(e){let n=tt(e);return n?[{kind:"brace",alternatives:n.map(i=>I(i))}]:I(e)}function I(e,n=false){let r=[],i="",c=0,a=n?e.length-2:e.length;for(;c<a;){let l=e[c];if(l==="\\"&&c+1<a){i+=e[c+1],c+=2;continue}if(l==="*"&&e[c+1]==="*"&&(c+2>=a||e[c+2]==="/")&&(c===0||e[c-1]==="/")){i&&(r.push(...A(i)),i=""),r.push({kind:"starstar"}),c+=2,e[c]==="/"&&c++;continue}if(l==="*"){i&&(r.push(...A(i)),i=""),r.push({kind:"star"}),c++;continue}if(l==="?"){i&&(r.push(...A(i)),i=""),r.push({kind:"question"}),c++;continue}i+=l,c++;}return i&&r.push(...A(i)),r}function ot(e){let n=0;for(;n<e.length;){let r=e[n];if(r==="\\"&&n+1<e.length){n+=2;continue}if(r===" ")return e[n+1]==="*"&&n+2===e.length;n++;}return false}function E(e,n,r=0,i=0){for(;r<e.length;){let c=e[r];if(c.kind==="literal"){if(!n.startsWith(c.text,i))return false;i+=c.text.length;}else if(c.kind==="star"){let a=r+1;for(;a<e.length&&e[a].kind==="star";)a++;if(a>=e.length){for(let l=i;l<n.length;l++)if(n[l]==="/")return false;return true}for(let l=i;l<=n.length;l++){if(E(e,n,a,l))return true;if(n[l]==="/")break}return false}else if(c.kind==="starstar"){let a=r+1;for(;a<e.length&&e[a].kind==="starstar";)a++;if(a>=e.length)return true;for(let l=i;l<=n.length;l++)if(E(e,n,a,l))return true;return false}else if(c.kind==="question"){if(i>=n.length||n[i]==="/")return false;i++;}else if(c.kind==="class"){let a=n[i];if(a===void 0||c.chars.has(a)===c.negate)return false;i++;}else if(c.kind==="brace"){for(let a of c.alternatives)if(E(a,n,0,i))return true;return false}r++;}return i===n.length}function F(e){return e.sort((n,r)=>{let i=n[0].length-r[0].length;return i!==0?i:n[0].localeCompare(r[0])})}var z=new Map,st=1024;function J(e){let n=z.get(e);if(n)return n;let r=rt(e);if(z.size>=st){let i=z.keys().next().value;i!==void 0&&z.delete(i);}return z.set(e,r),r}exports.a=void 0;(c=>{function e(a,l){if(!l)return a==="";try{if(n(a,l))return !0;if(ot(l)){let g=l.slice(0,-2);if(n(a,g))return !0}return !1}catch{return false}}c.match=e;function n(a,l){if(!a)return ct(l);let g=J(l);return E(g,a)}function r(a,l){let g=F(Object.entries(l)),h;for(let[u,m]of g)e(a,u)&&(h=m);return h}c.all=r;function i(a,l){let g=F(Object.entries(l)),h;for(let[u,m]of g){let x=u.split(/\s+/);x.length!==0&&e(a.head,x[0])&&(x.length===1||at(a.tail,x.slice(1)))&&(h=m);}return h}c.allStructured=i;})(exports.a||(exports.a={}));function at(e,n){if(n.length===0)return true;if(e.length<n.length)return false;for(let r=0;r<n.length;r++)if(!exports.a.match(e[r],n[r]))return false;return true}function ct(e){let n=J(e);return E(n,"")}exports.b=void 0;(h=>{function e(u){return {...u,follow:u.symlink??false,nodir:u.include!=="all",maxDepth:u.maxDepth??20}}async function n(u,m={}){return chunkAHO55TRS_cjs.b(u,e(m))}h.scan=n;function r(u,m={}){return chunkAHO55TRS_cjs.a(u,e(m))}h.scanSync=r;function i(u,m){return exports.a.match(m,u)}h.match=i;async function c(u){try{let m=await lt__default.default.readFile(u,"utf-8");return a(m)}catch{return []}}h.parseGitignore=c;function a(u){let m=[],x=u.split(/\r?\n/);for(let P of x){let T=P.trim();if(!T||T.startsWith("#")||T.startsWith("!"))continue;let b=T;b.endsWith("/")&&(b=`${b}**`),!b.includes("*")&&!b.includes("?")&&!b.includes("[")&&(b=`**/${b}/**`),m.push(b);}return m}h.parseGitignoreContent=a;function l(u,m){let x=u.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");for(let P of m)if(exports.a.match(x,P)||exports.a.match(x,`${P}/**`))return true;return false}h.isIgnored=l,h.DEFAULT_IGNORE_PATTERNS=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/__pycache__/**","**/*.min.js","**/*.min.ts","**/coverage/**","**/data/**","**/*.db","**/logs/**","**/*.log","**/.DS_Store","**/Thumbs.db"];})(exports.b||(exports.b={}));var bt=path.sep,U=bt==="\\";var Y={".html":"text/html",".htm":"text/html",".css":"text/css",".csv":"text/csv",".txt":"text/plain",".md":"text/markdown",".xml":"application/xml",".yaml":"application/yaml",".yml":"application/yaml",".toml":"application/toml",".ini":"text/plain",".cfg":"text/plain",".conf":"text/plain",".log":"text/plain",".sh":"text/x-sh",".bash":"text/x-bash",".zsh":"text/x-zsh",".fish":"text/x-fish",".ps1":"text/x-powershell",".bat":"text/x-batch",".cmd":"text/x-batch",".dockerfile":"text/x-dockerfile",".makefile":"text/x-makefile",".properties":"text/plain",".js":"application/javascript",".mjs":"application/javascript",".cjs":"application/javascript",".jsx":"text/javascript",".ts":"application/typescript",".tsx":"text/typescript",".mts":"application/typescript",".json":"application/json",".jsonc":"application/json",".json5":"application/json",".webmanifest":"application/manifest+json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".webp":"image/webp",".avif":"image/avif",".heic":"image/heic",".heif":"image/heif",".bmp":"image/bmp",".tiff":"image/tiff",".tif":"image/tiff",".mp4":"video/mp4",".webm":"video/webm",".ogg":"video/ogg",".avi":"video/x-msvideo",".mkv":"video/x-matroska",".mov":"video/quicktime",".mp3":"audio/mpeg",".wav":"audio/wav",".flac":"audio/flac",".aac":"audio/aac",".opus":"audio/opus",".m4a":"audio/mp4",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".rtf":"application/rtf",".epub":"application/epub+zip",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".bz2":"application/x-bzip2",".xz":"application/x-xz",".7z":"application/x-7z-compressed",".rar":"application/vnd.rar",".wasm":"application/wasm",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".db":"application/x-sqlite3",".sqlite":"application/vnd.sqlite3",".proto":"application/protobuf"},St=Object.fromEntries(Object.entries(Y).map(([e,n])=>[n,e]));exports.d=void 0;(Et=>{async function e(t,o){await lt.mkdir(t,{recursive:o?.recursive??true});}Et.mkdir=e;async function n(t){return fs.existsSync(t)}Et.exists=n;async function r(t){try{return fs.statSync(t).isDirectory()}catch{return false}}Et.isDir=r;function i(t){return fs.statSync(t,{throwIfNoEntry:false})??void 0}Et.stat=i;async function c(t){let o=i(t)?.size??0;return typeof o=="bigint"?Number(o):o}Et.size=c;async function a(t){return lt.readFile(t,"utf-8")}Et.readText=a;async function l(t){return JSON.parse(await lt.readFile(t,"utf-8"))}Et.readJson=l;async function g(t){return lt.readFile(t)}Et.readBytes=g;async function h(t){let o=await lt.readFile(t);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}Et.readArrayBuffer=h;function u(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}async function m(t,o,s){try{s?await lt.writeFile(t,o,{mode:s}):await lt.writeFile(t,o);}catch(f){if(u(f)){await lt.mkdir(j(t),{recursive:true}),s?await lt.writeFile(t,o,{mode:s}):await lt.writeFile(t,o);return}throw f}}Et.write=m;async function x(t,o,s){return m(t,JSON.stringify(o,null,2),s)}Et.writeJson=x;async function P(t,o,s){let f=j(t);fs.existsSync(f)||await lt.mkdir(f,{recursive:true});let p=o instanceof ReadableStream?stream.Readable.fromWeb(o):o,d=fs.createWriteStream(t);await promises.pipeline(p,d),s&&await lt.chmod(t,s);}Et.writeStream=P;function T(t){let o=path.extname(t).toLowerCase();return Y[o]||"application/octet-stream"}Et.mimeType=T;function b(t){return St[t]}Et.mimeTypeToExt=b;function yt(t){return t?!!(t.startsWith("text/")||t==="application/json"||t==="application/json5"||t==="application/jsonc"||t==="application/xml"||t==="application/javascript"||t==="application/typescript"||t==="application/x-javascript"||t==="application/yaml"||t==="application/x-yaml"||t==="application/toml"||t==="application/x-sh"||t==="application/x-bash"||t==="application/x-zsh"||t==="application/x-powershell"||t==="application/x-batch"||t==="application/x-dockerfile"||t==="application/x-makefile"):false}Et.isTextMime=yt;function j(t){if(!t||t.length===0)return ".";let o=y(t);if(o=o.replace(/\/+$/,""),!o||o===""||o==="/")return "/";let s=o.lastIndexOf("/");return s===-1?".":s===0?"/":o.slice(0,s)}Et.dirname=j;function wt(t,o){if(!t||t.length===0)return "";let s=y(t);if(s=s.replace(/\/+$/,""),!s||s===""||s==="/")return "";let f=s.lastIndexOf("/"),p=f===-1?s:s.slice(f+1);return p?(o&&p.endsWith(o)&&(p=p.slice(0,-o.length)),p):""}Et.basename=wt;function vt(t){if(!t)return "";let o=y(t);if(!o)return "";let s=path.basename(o);if(!s||s===".")return "";let f=s.lastIndexOf(".");return f===-1||f===0?"":s.slice(f)}Et.extname=vt;function y(t){return t?t.replace(/\\/g,"/"):""}Et.toUnixPath=y;function S(t){if(!t||t.length===0)return B__default.default.homedir();if(U&&(t=D(t)),t.startsWith("~/")||t==="~"?t=O(B__default.default.homedir(),t.slice(1)):R(t)||(t=path.resolve(t)),t=y(t),U)try{t=fs.realpathSync.native(t),t=y(t);}catch{}return t}Et.normalize=S;function kt(t){return !t||t.length===0?B__default.default.homedir():(U&&(t=D(t)),t.startsWith("~/")||t==="~"?t=O(B__default.default.homedir(),t.slice(1)):R(t)||(t=path.resolve(t)),y(t))}Et.resolve=kt;function R(t){return !!(t.startsWith("/")||/^[a-zA-Z]:[/\\]/.test(t)||/^[a-zA-Z]:$/.test(t))}Et.isAbsolute=R;function O(t,...o){let s=y(t);for(let f of o){let p=y(f);R(p)?s=p:(s.endsWith("/")||(s+="/"),s+=p);}return s.replace(/\\/g,"/")}Et.join=O;function D(t){return process.platform!=="win32"?t:t.replace(/^\/([a-zA-Z]):(?:[\\/]|$)/,(o,s)=>`${s.toUpperCase()}:/`).replace(/^\/([a-zA-Z])(?:\/|$)/,(o,s)=>`${s.toUpperCase()}:/`).replace(/^\/cygdrive\/([a-zA-Z])(?:\/|$)/,(o,s)=>`${s.toUpperCase()}:/`).replace(/^\/mnt\/([a-zA-Z])(?:\/|$)/,(o,s)=>`${s.toUpperCase()}:/`)}Et.windowsPath=D;function Ct(t,o){let s=S(t),f=S(o),p=path.relative(s,f),d=path.relative(f,s);return !p?.startsWith("..")||!d?.startsWith("..")}Et.overlaps=Ct;function Pt(t,o){let s=S(t),f=S(o);return !path.relative(s,f).startsWith("..")}Et.contains=Pt;async function Tt(t,o,s){let f=S(o),p=s?S(s):void 0,d=[];for(;;){let w=O(f,t);if(await n(w)&&d.push(w),p&&f===p)break;let k=j(f);if(k===f)break;f=k;}return d}Et.findUp=Tt;async function*jt(t){let{targets:o,start:s,stop:f}=t,p=S(s),d=f?S(f):void 0;for(;;){for(let k of o){let q=O(p,k);await n(q)&&(yield q);}if(d&&p===d)break;let w=j(p);if(w===p)break;p=w;}}Et.up=jt;async function zt(t,o,s){let f=S(o),p=s?S(s):void 0,d=[];for(;;){try{let k=await exports.b.scan(t,{cwd:f,absolute:!0,include:"file",dot:!0});d.push(...k);}catch{}if(p&&f===p)break;let w=j(f);if(w===f)break;f=w;}return d}Et.globUp=zt;})(exports.d||(exports.d={}));
|
|
2
|
-
exports.c=Y;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkAHO55TRS_cjs=require('./chunk-AHO55TRS.cjs'),chunkVRQQ33YH_cjs=require('./chunk-VRQQ33YH.cjs'),U=require('path'),V=require('fs/promises'),fs=require('fs'),ie=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var U__default=/*#__PURE__*/_interopDefault(U);var V__default=/*#__PURE__*/_interopDefault(V);var ie__default=/*#__PURE__*/_interopDefault(ie);chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function K(t,e=true){let n=typeof t=="number"?new Date(t):t,r=n.getTimezoneOffset(),i=Math.floor(Math.abs(r)/60),o=Math.abs(r)%60,l=`${r<=0?"+":"-"}${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`,p=n.getFullYear(),g=String(n.getMonth()+1).padStart(2,"0"),L=String(n.getDate()).padStart(2,"0"),N=String(n.getHours()).padStart(2,"0"),T=String(n.getMinutes()).padStart(2,"0"),P=String(n.getSeconds()).padStart(2,"0"),W=`${p}-${g}-${L}T${N}:${T}:${P}`;if(e){let s=String(n.getMilliseconds()).padStart(3,"0");W+=`.${s}`;}return W+=l,W}function ge(t){return K(t,false)}function re(){return Date.now()}function de(t=true){return K(re(),t)}function pe(t){return t.includes("+")||t.includes("-")?new Date(t):new Date(t)}function Y(t){let e=typeof t=="number"?new Date(t):t,n=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),m=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return `${n}-${r}-${i}T${o}:${m}:${l}`}function X(t){let e=typeof t=="number"?new Date(t):t,n=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),m=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0"),p=String(e.getMilliseconds()).padStart(3,"0");return `${n}-${r}-${i}T${o}:${m}:${l}.${p}`}function he(t=new Date){let e=t.getTimezoneOffset(),n=Math.floor(Math.abs(e)/60),r=Math.abs(e)%60;return `${e<=0?"+":"-"}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`}function J(t,e){let n=ne(e),i=new Intl.DateTimeFormat("en-US",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:false,weekday:"short"}).formatToParts(t),o={};for(let g of i)g.type!=="literal"&&(o[g.type]=g.value);let m={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},l=Number.parseInt(o.hour??"0",10),p=l===24?0:l;return {year:Number.parseInt(o.year??"1970",10),month:Number.parseInt(o.month??"1",10),day:Number.parseInt(o.day??"1",10),hour:p,minute:Number.parseInt(o.minute??"0",10),second:Number.parseInt(o.second??"0",10),weekday:m[o.weekday??"Sun"]??0,timestamp:t.getTime()}}function ye(t){if(!t||t.trim()==="")return true;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return false}}function ne(t){let e=A(t);if(e)return e;let n=A(process.env.EASBOT_TIMEZONE);if(n)return n}function A(t){if(!t)return;let e=t.trim();return e===""?void 0:e}function be(t,e,n){let r=A(n);if(!r){let L=new Date(t.getTime());return L.setSeconds(0,0),L.setMinutes(L.getMinutes()+e),L}let i=J(t,r),o=new Date(Date.UTC(i.year,i.month-1,i.day,i.hour,i.minute,0)),m=new Date(o.getTime()+e*6e4),l=J(m,r),g=new Date(Date.UTC(l.year,l.month-1,l.day,l.hour,l.minute,0)).getTime()-m.getTime();return new Date(m.getTime()-g)}exports.m=void 0;(z=>{z.Level=ie__default.default.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let e={DEBUG:0,INFO:1,WARN:2,ERROR:3},n="INFO";function r(c){return e[c]>=e[n]}function i(){return n}z.getLevel=i;function o(c,h,d){let f=l.get(c);if(!f){d();return}let u=f.currentBaseTimestamp;f.currentBaseTimestamp=h;try{d();}finally{f.currentBaseTimestamp=u;}}z.withBaseTimestamp=o;let m=new Map,l=new WeakMap;z.Default=te({service:"default"});let g="";function L(){return g}z.file=L;let N,T,P=false,W=false,s=c=>{try{W&&process.stderr.write(c);}catch{}},a=false,x=false;async function C(c){if(P)return;c.level&&(n=c.level),c.print&&(W=c.print??false);let h=c.logDir||U__default.default.join(process.env.EASBOT_LOG_PATH??process.cwd(),"logs");if(ee(h).catch(d=>{}),c.print){P=true;return}if(c.logFile)g=U__default.default.join(h,c.logFile);else {let f=Y(new Date).replace(/:/g,"");g=U__default.default.join(h,c.dev?"dev.log":f+".log");}try{await V__default.default.mkdir(h,{recursive:!0}),N=await V__default.default.open(g,"w"),T=fs.createWriteStream("",{fd:N.fd,autoClose:!1}),s=d=>{if(!(a||x||!T||T.destroyed))try{if(!T.writable)return;T.write(d,f=>{if(f&&!a){let u=f;if(u.code==="EPIPE"||u.code==="EIO"){x=!0,T?.destroy();return}a=!0,setTimeout(()=>{a=!1;},1e3);}});}catch(f){let u=f;if(u.code==="EPIPE"||u.code==="EIO"){x=!0,T?.destroy();return}a||(a=!0,setTimeout(()=>{a=!1;},1e3));}},P=!0;}catch(d){process.stderr.write(`[LOG ERROR] Failed to init log file: ${d}
|
|
2
|
-
`),s=f=>{try{process.stderr.write(f);}catch{}},P=true;}}z.init=C;async function me(){P&&(T&&!T.destroyed&&(await new Promise((c,h)=>{T.end(d=>{d?h(d):c();});}).catch(c=>{process.stderr.write(`[LOG ERROR] Failed to close log stream: ${c}
|
|
3
|
-
`);}),T=void 0),N&&(await N.close().catch(c=>{process.stderr.write(`[LOG ERROR] Failed to close log file: ${c}
|
|
4
|
-
`);}),N=void 0),s=c=>{try{process.stderr.write(c);}catch{}},P=false);}z.close=me;async function ee(c){let d=await chunkAHO55TRS_cjs.b("??????????T??????.log",{cwd:c,absolute:true});if(d.sort(),d.length<=10)return;let f=d.slice(0,-10);await Promise.all(f.map(u=>V__default.default.unlink(u).catch(()=>{})));}function Z(c,h=0){let d=c.message;return c.cause instanceof Error&&h<10?d+" Caused by: "+Z(c.cause,h+1):d}function te(c){c=c||{};let h=c.service;if(h&&typeof h=="string"){let u=m.get(h);if(u)return u}function d(u,y){let M=Object.entries({...c,...y??{}}).filter(([I,D])=>D!=null).map(([I,D])=>{let $=`${I}=`;return D instanceof Error?$+Z(D):typeof D=="object"?$+JSON.stringify(D):$+D}).join(" "),E=new Date,O=E.getTime(),b=l.get(f),S=0,w;if(b){if(!b.hasEmitted)w="+<init>";else {let I=typeof b.currentBaseTimestamp=="number"?b.currentBaseTimestamp:b.lastSeen;S=Number.isFinite(I)&&I>0?O-I:0,w=S<1?"+<1ms":`+${S}ms`;}b.hasEmitted=true,b.lastSeen=O,b.currentBaseTimestamp=void 0;}else w=S<1?"+<1ms":`+${S}ms`;return [X(E),w,M,u].filter(Boolean).join(" ")+`
|
|
5
|
-
`}let f={debug(u,y){r("DEBUG")&&s("DEBUG "+d(u,y));},info(u,y){r("INFO")&&s("INFO "+d(u,y));},error(u,y){r("ERROR")&&s("ERROR "+d(u,y));},warn(u,y){r("WARN")&&s("WARN "+d(u,y));},tag(u,y){return c&&(c[u]=y),f},clone(){return z.create({...c})},scope(u){let y=Date.now(),M=false,E=b=>(S,w)=>{let B=l.get(f);B&&(B.currentBaseTimestamp=y);try{b==="DEBUG"?f.debug(S,{scope:u,...w??{}}):b==="INFO"?f.info(S,{scope:u,...w??{}}):b==="WARN"?f.warn(S,{scope:u,...w??{}}):f.error(S,{scope:u,...w??{}});}finally{B&&(B.currentBaseTimestamp=void 0);}},O={baseTimestampMs:y,debug:E("DEBUG"),info:E("INFO"),warn:E("WARN"),error:E("ERROR"),end(b){if(M)return;M=true;let S=Date.now()-y,w=l.get(f);w&&(w.currentBaseTimestamp=y);try{f.info(`${u} completed`,{scope:u,status:"completed",duration:S,...b??{}});}finally{w&&(w.currentBaseTimestamp=void 0);}},async run(b){try{return await b(O)}finally{O.end();}}};return O},time(u,y){let M=l.get(f);if(!M)return {stop:()=>{},[Symbol.dispose](){}};let E=y?.level,O=E==="DEBUG"||E==="INFO"||E==="WARN"||E==="ERROR"?E:"INFO",{level:b,...S}=y??{},w=(D,$)=>{M.currentBaseTimestamp=B;try{O==="DEBUG"?f.debug(u,{status:D,...$!==void 0?{duration:$}:{},...S}):O==="WARN"?f.warn(u,{status:D,...$!==void 0?{duration:$}:{},...S}):O==="ERROR"?f.error(u,{status:D,...$!==void 0?{duration:$}:{},...S}):f.info(u,{status:D,...$!==void 0?{duration:$}:{},...S});}finally{M.currentBaseTimestamp=void 0;}},B=Date.now();w("started");function I(){w("completed",Date.now()-B);}return {stop:I,[Symbol.dispose](){I();}}}};return l.set(f,{lastSeen:Date.now(),hasEmitted:false}),h&&typeof h=="string"&&m.set(h,f),f}z.create=te;})(exports.m||(exports.m={}));chunkVRQQ33YH_cjs.j();exports.n=void 0;(W=>{function t(s){return /^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/.test(s)}W.isValid=t;function e(s){let a=s.match(/^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9.-]+))?(?:\+([a-zA-Z0-9.-]+))?$/);if(!a)throw new Error(`\u65E0\u6548\u7684\u7248\u672C\u683C\u5F0F: ${s}`);return new k(parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),a[4]?a[4].split(".").filter(Boolean):[],a[5]?a[5].split(".").filter(Boolean):[])}W.parse=e;function n(s){let a=`${s.major}.${s.minor}.${s.patch}`;return s.prerelease.length>0&&(a+=`-${s.prerelease.join(".")}`),s.build.length>0&&(a+=`+${s.build.join(".")}`),a}W.format=n;function r(s,a){let x=e(s),C=e(a);return x.compare(C)}W.compare=r;function i(s,a){return oe(e(s),a)}W.satisfies=i;function o(s,a){return r(s,a)>0}W.gt=o;function m(s,a){return r(s,a)>=0}W.gte=m;function l(s,a){return r(s,a)<0}W.lt=l;function p(s,a){return r(s,a)<=0}W.lte=p;function g(s,a){return r(s,a)===0}W.eq=g;function L(s){return [...s].sort((a,x)=>r(a,x))}W.sort=L;function N(s){return s.length===0?null:s.reduce((a,x)=>r(x,a)>0?x:a)}W.max=N;function T(s){return s.length===0?null:s.reduce((a,x)=>r(x,a)<0?x:a)}W.min=T;function P(s,a,x){return m(s,a)&&p(s,x)}W.inRange=P;})(exports.n||(exports.n={}));var k=class{constructor(e,n,r,i=[],o=[]){chunkVRQQ33YH_cjs.c(this,"major");chunkVRQQ33YH_cjs.c(this,"minor");chunkVRQQ33YH_cjs.c(this,"patch");chunkVRQQ33YH_cjs.c(this,"prerelease");chunkVRQQ33YH_cjs.c(this,"build");this.major=e,this.minor=n,this.patch=r,this.prerelease=i,this.build=o;}compare(e){return this.major!==e.major?this.major<e.major?-1:1:this.minor!==e.minor?this.minor<e.minor?-1:1:this.patch!==e.patch?this.patch<e.patch?-1:1:this.comparePrerelease(e)}comparePrerelease(e){if(this.prerelease.length===0&&e.prerelease.length>0)return 1;if(this.prerelease.length>0&&e.prerelease.length===0)return -1;if(this.prerelease.length===0&&e.prerelease.length===0)return 0;let n=Math.min(this.prerelease.length,e.prerelease.length);for(let r=0;r<n;r++){let i=this.prerelease[r],o=e.prerelease[r],m=/^\d+$/.test(i),l=/^\d+$/.test(o);if(m&&l){let p=parseInt(i,10),g=parseInt(o,10);if(p!==g)return p<g?-1:1}else {if(m)return -1;if(l)return 1;{let p=i.localeCompare(o);if(p!==0)return p<0?-1:1}}}return this.prerelease.length!==e.prerelease.length?this.prerelease.length<e.prerelease.length?-1:1:0}};function oe(t,e){return ae(e).some(r=>ce(t,r))}function ae(t){let e=[],n="",r=0;for(let i=0;i<t.length;i++){let o=t[i];o==="("||o==="["?(r++,n+=o):o===")"||o==="]"?(r--,n+=o):o==="|"&&r===0?(n.trim()&&e.push(n.trim()),n=""):n+=o;}return n.trim()&&e.push(n.trim()),e}function ce(t,e){if(e=e.trim(),e.startsWith("[")||e.startsWith("("))return ue(t,e);let n=e.match(/^(\S+)\s+-\s+(\S+)$/);if(n){let r=exports.n.parse(n[1]),i=exports.n.parse(n[2]);return t.compare(r)>=0&&t.compare(i)<=0}return e.includes(" ")||e.includes(" ")?le(t,e):H(t,e)}function ue(t,e){let r=e.replace(/^\[|\]$/g,"").split(/\s+-\s+/);if(r.length!==2)return H(t,e);let[i,o]=r,m=exports.n.parse(i),l=exports.n.parse(o),p=e.startsWith("["),g=e.endsWith("]");if(p){if(t.compare(m)<0)return false}else if(t.compare(m)<=0)return false;if(g){if(t.compare(l)>0)return false}else if(t.compare(l)>=0)return false;return true}function le(t,e){return e.split(/\s+/).every(r=>H(t,r))}function H(t,e){if(e=e.trim(),e.startsWith("^")){let n=exports.n.parse(e.slice(1));return t.major!==n.major||t.minor<n.minor?false:t.patch>=n.patch}if(e.startsWith("~")){let n=exports.n.parse(e.slice(1));return t.major!==n.major||t.minor!==n.minor?false:t.patch>=n.patch}return e==="*"?true:e.endsWith(".x")||e.endsWith(".*")?fe(t,e):e.startsWith(">=")?t.compare(exports.n.parse(e.slice(2)))>=0:e.startsWith("<=")?t.compare(exports.n.parse(e.slice(2)))<=0:e.startsWith(">")?t.compare(exports.n.parse(e.slice(1)))>0:e.startsWith("<")?t.compare(exports.n.parse(e.slice(1)))<0:e.startsWith("=")?t.compare(exports.n.parse(e.slice(1).trim()))===0:t.compare(exports.n.parse(e))===0}function fe(t,e){let r=e.replace(/\.x|\.\*/g,".0").replace(/^\*$/,"0.0.0").split(".");for(let i=0;i<r.length;i++){let o=r[i],m=i===0?t.major:i===1?t.minor:t.patch,l=String(m);if(o==="0")continue;let p=parseInt(o,10);if(Number.isNaN(p)){if(o!==l&&o!=="*")return false}else if(p!==m)return false}return true}var q=exports.m.create({service:"pkg-registry"});exports.o=void 0;(n=>{async function t(r,i,o){let{Shell:m}=await import('./shell-RJBXISIH.cjs'),l=process.platform==="win32"?"cmd":void 0,p=`npm view ${r} ${i} --loglevel error`,g=await m.run(l,p,{cwd:o});return g.code!==0?(q.warn("npm view failed",{pkg:r,field:i,code:g.code,stderr:g.stderr}),null):g.stdout.trim()}n.info=t;async function e(r,i,o){let m=await t(r,"version",o);return m?/[\s^~*xX<>|=]/.test(i)?!exports.n.satisfies(m,i):exports.n.compare(i,m)===-1:(q.warn("Failed to resolve latest version, using cached",{pkg:r,cachedVersion:i}),false)}n.isOutdated=e;})(exports.o||(exports.o={}));exports.a=K;exports.b=ge;exports.c=re;exports.d=de;exports.e=pe;exports.f=Y;exports.g=X;exports.h=he;exports.i=J;exports.j=ye;exports.k=A;exports.l=be;
|