dsh-edge 0.19.0-alpha.2 → 0.19.0
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/worker/isolated/index.js
CHANGED
|
@@ -152,7 +152,7 @@ Known schemas:
|
|
|
152
152
|
- `)}`,new Error(He)}let ht=`${l}/$ref`,tt=ps(e,Me,n,r,i,s,a,ht,c);if(tt.valid||we.push({instanceLocation:a,keyword:"$ref",keywordLocation:ht,error:"A subschema had errors."},...tt.errors),n==="4"||n==="7")return{valid:we.length===0,errors:we}}if(Array.isArray(g)){let qe=g.length,Me=!1;for(let ht=0;ht<qe;ht++)if(d===g[ht]||g[ht]==="integer"&&d==="number"&&e%1===0&&e===e){Me=!0;break}Me||we.push({instanceLocation:a,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${g.join('", "')}".`})}else g==="integer"?(d!=="number"||e%1||e!==e)&&we.push({instanceLocation:a,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${g}".`}):g!==void 0&&d!==g&&we.push({instanceLocation:a,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${g}".`});if(y!==void 0&&(d==="object"||d==="array"?Gv(e,y)||we.push({instanceLocation:a,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(y)}.`}):e!==y&&we.push({instanceLocation:a,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(y)}.`})),v!==void 0&&(d==="object"||d==="array"?v.some(qe=>Gv(e,qe))||we.push({instanceLocation:a,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`}):v.some(qe=>e===qe)||we.push({instanceLocation:a,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})),S!==void 0){let qe=`${l}/not`;ps(e,S,n,r,i,s,a,qe).valid&&we.push({instanceLocation:a,keyword:"not",keywordLocation:qe,error:'Instance matched "not" schema.'})}let st=[];if(k!==void 0){let qe=`${l}/anyOf`,Me=we.length,ht=!1;for(let tt=0;tt<k.length;tt++){let He=k[tt],pt=Object.create(c),Ce=ps(e,He,n,r,i,f===!0?s:null,a,`${qe}/${tt}`,pt);we.push(...Ce.errors),ht=ht||Ce.valid,Ce.valid&&st.push(pt)}ht?we.length=Me:we.splice(Me,0,{instanceLocation:a,keyword:"anyOf",keywordLocation:qe,error:"Instance does not match any subschemas."})}if(w!==void 0){let qe=`${l}/allOf`,Me=we.length,ht=!0;for(let tt=0;tt<w.length;tt++){let He=w[tt],pt=Object.create(c),Ce=ps(e,He,n,r,i,f===!0?s:null,a,`${qe}/${tt}`,pt);we.push(...Ce.errors),ht=ht&&Ce.valid,Ce.valid&&st.push(pt)}ht?we.length=Me:we.splice(Me,0,{instanceLocation:a,keyword:"allOf",keywordLocation:qe,error:"Instance does not match every subschema."})}if(E!==void 0){let qe=`${l}/oneOf`,Me=we.length,ht=E.filter((tt,He)=>{let pt=Object.create(c),Ce=ps(e,tt,n,r,i,f===!0?s:null,a,`${qe}/${He}`,pt);return we.push(...Ce.errors),Ce.valid&&st.push(pt),Ce.valid}).length;ht===1?we.length=Me:we.splice(Me,0,{instanceLocation:a,keyword:"oneOf",keywordLocation:qe,error:`Instance does not match exactly one subschema (${ht} matches).`})}if((d==="object"||d==="array")&&Object.assign(c,...st),I!==void 0){let qe=`${l}/if`;if(ps(e,I,n,r,i,s,a,qe,c).valid){if(R!==void 0){let ht=ps(e,R,n,r,i,s,a,`${l}/then`,c);ht.valid||we.push({instanceLocation:a,keyword:"if",keywordLocation:qe,error:'Instance does not match "then" schema.'},...ht.errors)}}else if(Z!==void 0){let ht=ps(e,Z,n,r,i,s,a,`${l}/else`,c);ht.valid||we.push({instanceLocation:a,keyword:"if",keywordLocation:qe,error:'Instance does not match "else" schema.'},...ht.errors)}}if(d==="object"){if(x!==void 0)for(let tt of x)tt in e||we.push({instanceLocation:a,keyword:"required",keywordLocation:`${l}/required`,error:`Instance does not have required property "${tt}".`});let qe=Object.keys(e);if(C!==void 0&&qe.length<C&&we.push({instanceLocation:a,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${C} properties.`}),B!==void 0&&qe.length>B&&we.push({instanceLocation:a,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${B} properties.`}),T!==void 0){let tt=`${l}/propertyNames`;for(let He in e){let pt=`${a}/${gc(He)}`,Ce=ps(He,T,n,r,i,s,pt,tt);Ce.valid||we.push({instanceLocation:a,keyword:"propertyNames",keywordLocation:tt,error:`Property name "${He}" does not match schema.`},...Ce.errors)}}if(A!==void 0){let tt=`${l}/dependantRequired`;for(let He in A)if(He in e){let pt=A[He];for(let Ce of pt)Ce in e||we.push({instanceLocation:a,keyword:"dependentRequired",keywordLocation:tt,error:`Instance has "${He}" but does not have "${Ce}".`})}}if($!==void 0)for(let tt in $){let He=`${l}/dependentSchemas`;if(tt in e){let pt=ps(e,$[tt],n,r,i,s,a,`${He}/${gc(tt)}`,c);pt.valid||we.push({instanceLocation:a,keyword:"dependentSchemas",keywordLocation:He,error:`Instance has "${tt}" but does not match dependant schema.`},...pt.errors)}}if(M!==void 0){let tt=`${l}/dependencies`;for(let He in M)if(He in e){let pt=M[He];if(Array.isArray(pt))for(let Ce of pt)Ce in e||we.push({instanceLocation:a,keyword:"dependencies",keywordLocation:tt,error:`Instance has "${He}" but does not have "${Ce}".`});else{let Ce=ps(e,pt,n,r,i,s,a,`${tt}/${gc(He)}`);Ce.valid||we.push({instanceLocation:a,keyword:"dependencies",keywordLocation:tt,error:`Instance has "${He}" but does not match dependant schema.`},...Ce.errors)}}}let Me=Object.create(null),ht=!1;if(q!==void 0){let tt=`${l}/properties`;for(let He in q){if(!(He in e))continue;let pt=`${a}/${gc(He)}`,Ce=ps(e[He],q[He],n,r,i,s,pt,`${tt}/${gc(He)}`);if(Ce.valid)c[He]=Me[He]=!0;else if(ht=i,we.push({instanceLocation:a,keyword:"properties",keywordLocation:tt,error:`Property "${He}" does not match schema.`},...Ce.errors),ht)break}}if(!ht&&N!==void 0){let tt=`${l}/patternProperties`;for(let He in N){let pt=new RegExp(He,"u"),Ce=N[He];for(let xt in e){if(!pt.test(xt))continue;let Ft=`${a}/${gc(xt)}`,ct=ps(e[xt],Ce,n,r,i,s,Ft,`${tt}/${gc(He)}`);ct.valid?c[xt]=Me[xt]=!0:(ht=i,we.push({instanceLocation:a,keyword:"patternProperties",keywordLocation:tt,error:`Property "${xt}" matches pattern "${He}" but does not match associated schema.`},...ct.errors))}}}if(!ht&&V!==void 0){let tt=`${l}/additionalProperties`;for(let He in e){if(Me[He])continue;let pt=`${a}/${gc(He)}`,Ce=ps(e[He],V,n,r,i,s,pt,tt);Ce.valid?c[He]=!0:(ht=i,we.push({instanceLocation:a,keyword:"additionalProperties",keywordLocation:tt,error:`Property "${He}" does not match additional properties schema.`},...Ce.errors))}}else if(!ht&&Q!==void 0){let tt=`${l}/unevaluatedProperties`;for(let He in e)if(!c[He]){let pt=`${a}/${gc(He)}`,Ce=ps(e[He],Q,n,r,i,s,pt,tt);Ce.valid?c[He]=!0:we.push({instanceLocation:a,keyword:"unevaluatedProperties",keywordLocation:tt,error:`Property "${He}" does not match unevaluated properties schema.`},...Ce.errors)}}}else if(d==="array"){le!==void 0&&e.length>le&&we.push({instanceLocation:a,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${e.length} > ${le}).`}),be!==void 0&&e.length<be&&we.push({instanceLocation:a,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${e.length} < ${be}).`});let qe=e.length,Me=0,ht=!1;if(P!==void 0){let tt=`${l}/prefixItems`,He=Math.min(P.length,qe);for(;Me<He;Me++){let pt=ps(e[Me],P[Me],n,r,i,s,`${a}/${Me}`,`${tt}/${Me}`);if(c[Me]=!0,!pt.valid&&(ht=i,we.push({instanceLocation:a,keyword:"prefixItems",keywordLocation:tt,error:"Items did not match schema."},...pt.errors),ht))break}}if(H!==void 0){let tt=`${l}/items`;if(Array.isArray(H)){let He=Math.min(H.length,qe);for(;Me<He;Me++){let pt=ps(e[Me],H[Me],n,r,i,s,`${a}/${Me}`,`${tt}/${Me}`);if(c[Me]=!0,!pt.valid&&(ht=i,we.push({instanceLocation:a,keyword:"items",keywordLocation:tt,error:"Items did not match schema."},...pt.errors),ht))break}}else for(;Me<qe;Me++){let He=ps(e[Me],H,n,r,i,s,`${a}/${Me}`,tt);if(c[Me]=!0,!He.valid&&(ht=i,we.push({instanceLocation:a,keyword:"items",keywordLocation:tt,error:"Items did not match schema."},...He.errors),ht))break}if(!ht&&Y!==void 0){let He=`${l}/additionalItems`;for(;Me<qe;Me++){let pt=ps(e[Me],Y,n,r,i,s,`${a}/${Me}`,He);c[Me]=!0,pt.valid||(ht=i,we.push({instanceLocation:a,keyword:"additionalItems",keywordLocation:He,error:"Items did not match additional items schema."},...pt.errors))}}}if(j!==void 0)if(qe===0&&ee===void 0)we.push({instanceLocation:a,keyword:"contains",keywordLocation:`${l}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(ee!==void 0&&qe<ee)we.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${qe}) than minContains (${ee}).`});else{let tt=`${l}/contains`,He=we.length,pt=0;for(let Ce=0;Ce<qe;Ce++){let xt=ps(e[Ce],j,n,r,i,s,`${a}/${Ce}`,tt);xt.valid?(c[Ce]=!0,pt++):we.push(...xt.errors)}pt>=(ee||0)&&(we.length=He),ee===void 0&&ge===void 0&&pt===0?we.splice(He,0,{instanceLocation:a,keyword:"contains",keywordLocation:tt,error:"Array does not contain item matching schema."}):ee!==void 0&&pt<ee?we.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${ee} items matching schema. Only ${pt} items were found.`}):ge!==void 0&&pt>ge&&we.push({instanceLocation:a,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${ge} items matching schema. ${pt} items were found.`})}if(!ht&&K!==void 0){let tt=`${l}/unevaluatedItems`;for(Me;Me<qe;Me++){if(c[Me])continue;let He=ps(e[Me],K,n,r,i,s,`${a}/${Me}`,tt);c[Me]=!0,He.valid||we.push({instanceLocation:a,keyword:"unevaluatedItems",keywordLocation:tt,error:"Items did not match unevaluated items schema."},...He.errors)}}if(Se)for(let tt=0;tt<qe;tt++){let He=e[tt],pt=typeof He=="object"&&He!==null;for(let Ce=0;Ce<qe;Ce++){if(tt===Ce)continue;let xt=e[Ce];(He===xt||pt&&(typeof xt=="object"&&xt!==null)&&Gv(He,xt))&&(we.push({instanceLocation:a,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${tt} and ${Ce}.`}),tt=Number.MAX_SAFE_INTEGER,Ce=Number.MAX_SAFE_INTEGER)}}}else if(d==="number"){if(n==="4"?(ke!==void 0&&(ue===!0&&e<=ke||e<ke)&&we.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${e} is less than ${ue?"or equal to ":""} ${ke}.`}),ce!==void 0&&(nt===!0&&e>=ce||e>ce)&&we.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${e} is greater than ${nt?"or equal to ":""} ${ce}.`})):(ke!==void 0&&e<ke&&we.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${e} is less than ${ke}.`}),ce!==void 0&&e>ce&&we.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${e} is greater than ${ce}.`}),ue!==void 0&&e<=ue&&we.push({instanceLocation:a,keyword:"exclusiveMinimum",keywordLocation:`${l}/exclusiveMinimum`,error:`${e} is less than ${ue}.`}),nt!==void 0&&e>=nt&&we.push({instanceLocation:a,keyword:"exclusiveMaximum",keywordLocation:`${l}/exclusiveMaximum`,error:`${e} is greater than or equal to ${nt}.`})),ze!==void 0){let qe=e%ze;Math.abs(0-qe)>=11920929e-14&&Math.abs(ze-qe)>=11920929e-14&&we.push({instanceLocation:a,keyword:"multipleOf",keywordLocation:`${l}/multipleOf`,error:`${e} is not a multiple of ${ze}.`})}}else if(d==="string"){let qe=et===void 0&&Ae===void 0?0:Aye(e);et!==void 0&&qe<et&&we.push({instanceLocation:a,keyword:"minLength",keywordLocation:`${l}/minLength`,error:`String is too short (${qe} < ${et}).`}),Ae!==void 0&&qe>Ae&&we.push({instanceLocation:a,keyword:"maxLength",keywordLocation:`${l}/maxLength`,error:`String is too long (${qe} > ${Ae}).`}),xe!==void 0&&!new RegExp(xe,"u").test(e)&&we.push({instanceLocation:a,keyword:"pattern",keywordLocation:`${l}/pattern`,error:"String does not match pattern."}),G!==void 0&&TW[G]&&!TW[G](e)&&we.push({instanceLocation:a,keyword:"format",keywordLocation:`${l}/format`,error:`String does not match format "${G}".`})}return{valid:we.length===0,errors:we}}var CW=oe(()=>{_W();D5();AW();P5();IW();o(ps,"validate")});var M5,Iye=oe(()=>{D5();CW();M5=class{static{o(this,"Validator")}schema;draft;shortCircuit;lookup;constructor(t,n="2019-09",r=!0){this.schema=t,this.draft=n,this.shortCircuit=r,this.lookup=Of(t)}validate(t){return ps(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,n){n&&(t={...t,$id:n}),Of(t,this.lookup)}}});var Cye=oe(()=>{_W();D5();AW();P5();Tye();IW();CW();Iye()});var L5,Rye=oe(()=>{Cye();L5=class{static{o(this,"CfWorkerJsonSchemaValidator")}constructor(t){this.shortcircuit=t?.shortcircuit??!0,this.draft=t?.draft??"2020-12"}getValidator(t){let n=new M5(t,this.draft,this.shortcircuit);return r=>{let i=n.validate(r);return i.valid?{valid:!0,data:r,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:i.errors.map(s=>`${s.instanceLocation}: ${s.error}`).join("; ")}}}}});var Ks,j5=oe(()=>{"use strict";Ks={probeTimeoutMs:3e4,callTimeoutMs:6e4,maxToolsPerServer:128,maxCatalogPages:10,maxCatalogBytes:131072,maxDescriptionLength:512,maxErrorMessageChars:300,maxPublicNameLength:64,maxInstructionsLength:1024,metaToolThreshold:20}});import{createHash as Vat}from"node:crypto";function Zat(e){let t=e.replace(/[.*+?^${}()|[\]\\]/gu,n=>n==="*"?"\0":`\\${n}`);return new RegExp(`^${t.replaceAll("\0",".*")}$`)}function Oye(e,t,n){let r=t??"read_only";return r==="allow_all"?"allow":r==="approve_all"?"ask":n===!0?"allow":n===!1?"ask":Gat.some(i=>Zat(i).test(e))?"allow":"ask"}function fp(e){return e.replace(/Bearer\s+[^\s"']+/giu,"Bearer ***").replace(/(https?:\/\/[^\s"'?]+)\?[^\s"']*/giu,"$1?***").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/gu,"").slice(0,Ks.maxErrorMessageChars)}function $ye(e,t){let n=`mcp__${e}__${t}`,r=n.replace(/[^A-Za-z0-9_-]/gu,"_");if(r===n&&r.length<=Ks.maxPublicNameLength)return r;let i=Kat(e,t),s=Ks.maxPublicNameLength-i.length-1;return`${r.slice(0,s)}_${i}`}function Kat(e,t){return Vat("sha256").update(`${e}\0${t}`).digest("hex").slice(0,12)}function Nye(e){if(!(e==null||typeof e!="object"))try{let t=JSON.parse(JSON.stringify(e));return Kg(t),t}catch{return}}function Xat(e){return Jat.has(e)}function Pye(e){return e.type!=="image"||e.data===void 0||e.mimeType===void 0||!Xat(e.mimeType)||!Yat.test(e.data)?void 0:{data:Uint8Array.from(atob(e.data),n=>n.charCodeAt(0)),mediaType:e.mimeType}}function Dye(e){return e.some(t=>t.type==="image"&&t.data!==void 0)}function CS(e){if(e.isError)return[{type:"text",text:e.content.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(`
|
|
153
153
|
`)||"MCP tool returned an error."}];let t=[],n=[];for(let r of e.content)if(r.type==="text"&&typeof r.text=="string")n.push(r.text);else if(r.type==="resource_link"&&r.uri!==void 0)n.push(`Resource: ${r.name??"unnamed"} (${r.uri})`);else if(r.type==="image"&&r.data!==void 0)n.push(``);else if(r.type==="image")n.push(`[image: ${r.mimeType??"unknown type"}]`);else if(r.type==="audio")n.push("[audio result unsupported on Cloudflare Workers]");else if(r.type==="resource"&&r.resource?.text!==void 0){let i=r.resource.uri??"embedded resource";n.push(`--- ${i} ---
|
|
154
154
|
${r.resource.text}`)}else r.type==="resource"?n.push("[embedded resource: binary content not displayed]"):n.push(`[unsupported MCP content type: ${r.type}]`);return n.length>0&&t.push({type:"text",text:n.join(`
|
|
155
|
-
`)}),t.length>0?t:[{type:"text",text:"(empty MCP result)"}]}var Gat,Jat,Yat,F5=oe(()=>{"use strict";Aa();j5();Gat=["get_*","list_*","read_*","search_*","find_*","fetch_*","describe_*"];o(Zat,"globToRegExp");o(Oye,"evaluateMcpToolPolicy");o(fp,"scrubMcpErrorMessage");o($ye,"publicToolName");o(Kat,"hashSuffix");o(Nye,"supportedOutputSchema");Jat=new Set(["image/png","image/jpeg"]),Yat=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;o(Xat,"isImageMediaType");o(Pye,"decodeImageBlock");o(Dye,"containsImage");o(CS,"mapMcpResultToContentBlocks")});var RW,Mye=oe(()=>{RW={name:"dsh-edge",version:"0.19.0-alpha.2",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.2.0-rc.1"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dev:container":"pnpm run bundle:isolated && node scripts/dev.mjs container","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:container":"pnpm run bundle:isolated && node tests/container.integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.1","jsonc-parser":"^3.3.1",wrangler:"4.129.0"},devDependencies:{"@cfworker/json-schema":"^4.1.1","@cloudflare/computer":"0.3.1","@cloudflare/workers-types":"5.20260904.1","@deepseek-ai/cordis":"4.0.4","@deepseek-ai/cosmokit":"1.8.5","@deepseek-ai/dsh-agent":"0.2.0-rc.1","@deepseek-ai/dsh-agent-loop":"0.2.0-rc.1","@deepseek-ai/dsh-anonymous-user-id":"0.2.0-rc.1","@deepseek-ai/dsh-api-gateway":"0.2.0-rc.1","@deepseek-ai/dsh-api-job-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-remotes":"0.2.0-rc.1","@deepseek-ai/dsh-api-session-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-settings-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-workspace-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-workspace-files":"0.2.0-rc.1","@deepseek-ai/dsh-attachment":"0.2.0-rc.1","@deepseek-ai/dsh-brand":"0.2.0-rc.1","@deepseek-ai/dsh-client-locale":"0.2.0-rc.1","@deepseek-ai/dsh-client-store":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-chat":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-conversation":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-settings":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-settings-general":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-theme":"0.2.0-rc.1","@deepseek-ai/dsh-commands":"0.2.0-rc.1","@deepseek-ai/dsh-compaction":"0.2.0-rc.1","@deepseek-ai/dsh-compaction-basic":"0.2.0-rc.1","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.2.0-rc.1","@deepseek-ai/dsh-credentials":"0.2.0-rc.1","@deepseek-ai/dsh-file-reference":"0.2.0-rc.1","@deepseek-ai/dsh-fs":"0.2.0-rc.1","@deepseek-ai/dsh-goal":"0.2.0-rc.1","@deepseek-ai/dsh-goal-round-driver":"0.2.0-rc.1","@deepseek-ai/dsh-host-directory-picker":"0.2.0-rc.1","@deepseek-ai/dsh-host-plugin-inventory":"0.2.0-rc.1","@deepseek-ai/dsh-invariants":"0.2.0-rc.1","@deepseek-ai/dsh-jobs":"0.2.0-rc.1","@deepseek-ai/dsh-jobs-local":"0.2.0-rc.1","@deepseek-ai/dsh-launch-environment":"0.2.0-rc.1","@deepseek-ai/dsh-llm":"0.2.0-rc.1","@deepseek-ai/dsh-llm-deepseek":"0.2.0-rc.1","@deepseek-ai/dsh-llm-deepseek-api-key":"0.2.0-rc.1","@deepseek-ai/dsh-message-feedback":"0.2.0-rc.1","@deepseek-ai/dsh-output-retention":"0.2.0-rc.1","@deepseek-ai/dsh-plan-mode":"0.2.0-rc.1","@deepseek-ai/dsh-ptc-runtime":"0.2.0-rc.1","@deepseek-ai/dsh-sandbox":"0.2.0-rc.1","@deepseek-ai/dsh-schedule":"0.2.0-rc.1","@deepseek-ai/dsh-scope":"0.2.0-rc.1","@deepseek-ai/dsh-session":"0.2.0-rc.1","@deepseek-ai/dsh-session-format":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-catalog":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v0-to-v1":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v1-to-v2":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v2-to-v3":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v3-to-v4":"0.2.0-rc.1","@deepseek-ai/dsh-session-persistence":"0.2.0-rc.1","@deepseek-ai/dsh-session-projection":"0.2.0-rc.1","@deepseek-ai/dsh-session-projection-cache":"0.2.0-rc.1","@deepseek-ai/dsh-session-query":"0.2.0-rc.1","@deepseek-ai/dsh-session-reference":"0.2.0-rc.1","@deepseek-ai/dsh-session-title":"0.2.0-rc.1","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.2.0-rc.1","@deepseek-ai/dsh-session-title-llm":"0.2.0-rc.1","@deepseek-ai/dsh-settings":"0.2.0-rc.1","@deepseek-ai/dsh-skill":"0.2.0-rc.1","@deepseek-ai/dsh-spill":"0.2.0-rc.1","@deepseek-ai/dsh-spill-policy":"0.2.0-rc.1","@deepseek-ai/dsh-storage":"0.2.0-rc.1","@deepseek-ai/dsh-storage-domain":"0.2.0-rc.1","@deepseek-ai/dsh-subagent":"0.2.0-rc.1","@deepseek-ai/dsh-subagent-in-process-driver":"0.2.0-rc.1","@deepseek-ai/dsh-subagent-spawn-in-process":"0.2.0-rc.1","@deepseek-ai/dsh-system-prompt":"0.2.0-rc.1","@deepseek-ai/dsh-timeout":"0.2.0-rc.1","@deepseek-ai/dsh-token-meter":"0.2.0-rc.1","@deepseek-ai/dsh-tool-ask-user":"0.2.0-rc.1","@deepseek-ai/dsh-tool-call-timeout-policy":"0.2.0-rc.1","@deepseek-ai/dsh-tool-fs":"0.2.0-rc.1","@deepseek-ai/dsh-tool-goal":"0.2.0-rc.1","@deepseek-ai/dsh-tool-jobs":"0.2.0-rc.1","@deepseek-ai/dsh-tool-skill":"0.2.0-rc.1","@deepseek-ai/dsh-tool-subagent":"0.2.0-rc.1","@deepseek-ai/dsh-tool-web":"0.2.0-rc.1","@deepseek-ai/dsh-tool-workflow":"0.2.0-rc.1","@deepseek-ai/dsh-tools":"0.2.0-rc.1","@deepseek-ai/dsh-typert-protocol":"0.2.0-rc.1","@deepseek-ai/dsh-typert-registry":"0.2.0-rc.1","@deepseek-ai/dsh-user-approval":"0.2.0-rc.1","@deepseek-ai/dsh-user-questions":"0.2.0-rc.1","@deepseek-ai/dsh-util-values":"0.2.0-rc.1","@deepseek-ai/dsh-web":"0.2.0-rc.1","@deepseek-ai/dsh-web-fetch-http":"0.2.0-rc.1","@deepseek-ai/dsh-web-search-deepseek":"0.2.0-rc.1","@deepseek-ai/dsh-workflow":"0.2.0-rc.1","@deepseek-ai/dsh-workspace":"0.2.0-rc.1","@deepseek-ai/schemastery":"3.18.4","@mixmark-io/domino":"2.2.0","@modelcontextprotocol/sdk":"1.30.0",acorn:"8.18.0","fast-png":"8.0.0","jpeg-js":"0.4.4","just-bash":"3.4.2",playwright:"^1.49.0",sucrase:"3.35.1",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}}});var P1,Lye,jye,RS=oe(()=>{"use strict";Mye();P1=RW.version,Lye=RW.dshEdge.upstreamVersion,jye=`npx dsh-edge@${P1.includes("-")?"next":"latest"} upgrade`});function rot(e){let t=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/iu.exec(e);if(t!==null)return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(e);if(n!==null){let r=parseInt(n[1],16),i=parseInt(n[2],16);return`${String(r>>8)}.${String(r&255)}.${String(i>>8)}.${String(i&255)}`}}function iot(e){return/^\d+\.\d+\.\d+\.\d+$/u.test(e)||e.includes(":")}function $f(e){let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("MCP server URL must use http: or https: protocol.");let n=t.hostname.toLowerCase(),r=n.endsWith(".")?n.slice(0,-1):n,i=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(!(i==="localhost"||i==="127.0.0.1"||i==="::1")){for(let s of eot)if(i.endsWith(s))throw new Error(`MCP server hostname "${i}" is blocked.`);if(iot(i)){let s=rot(i),a=s??i;for(let l of tot)if(l.test(a))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`);if(s===void 0){for(let l of not)if(l.test(i))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`)}}}}function sot(e){return e?.type==="bearer"&&e.token!==void 0?{Authorization:`Bearer ${e.token}`}:{}}async function Fye(e,t,n){$f(e);let r=new N5(new URL(e),{requestInit:{headers:sot(t),signal:n},fetch:D1}),i=new O5({name:"dsh-edge",version:P1},{capabilities:{},jsonSchemaValidator:aot});return await i.connect(r),{client:i,close:o(async()=>{await i.close().catch(()=>{})},"close")}}async function Uye(e,t,n){let r=AbortSignal.timeout(Ks.probeTimeoutMs),i;try{i=await Fye(t,n,r)}catch(l){throw new Error(fp(l instanceof Error?l.message:String(l)))}let{client:s,close:a}=i;try{let l=[],c=new Set,u=new Set,d;for(let f=0;f<Ks.maxCatalogPages;f++){let g=await s.listTools(d===void 0?void 0:{cursor:d},{signal:r});for(let y of g.tools){if(l.length>=Ks.maxToolsPerServer)break;let v=$ye(e,y.name);if(c.has(v))throw new Error(`Server listed tool "${y.name}" more than once`);c.add(v);let x=y.annotations?.readOnlyHint,S=Nye(y.outputSchema);l.push({name:y.name,publicName:v,description:y.description??"",inputSchema:y.inputSchema??{type:"object"},...S!==void 0?{outputSchema:S}:{},...x!==void 0?{annotations:{readOnlyHint:x}}:{}})}if(l.length>=Ks.maxToolsPerServer||(d=g.nextCursor??void 0,d===void 0))break;if(u.has(d))throw new Error("Server repeated a tools/list continuation cursor");u.add(d)}let p=s.getServerVersion?.(),m=s.getInstructions?.();return{tools:l,serverInfo:p?{name:p.name,version:p.version}:void 0,instructions:typeof m=="string"&&m.length>0?m.slice(0,Ks.maxInstructionsLength):void 0}}finally{await a()}}async function U5(e,t,n,r,i,s){let a=s??Ks.callTimeoutMs,l=i?AbortSignal.any([i,AbortSignal.timeout(a)]):AbortSignal.timeout(a),c;try{c=await Fye(e,r,l)}catch(u){throw new Error(fp(u instanceof Error?u.message:String(u)))}try{let u=await c.client.callTool({name:t,arguments:n},void 0,{signal:l});return{content:u.content??[],structuredContent:u.structuredContent,isError:u.isError===!0}}catch(u){throw new Error(fp(u instanceof Error?u.message:String(u)))}finally{await c.close()}}var eot,tot,not,aot,D1,OS=oe(()=>{"use strict";z1e();Sye();Rye();F5();j5();RS();eot=[".internal",".local",".localhost"],tot=[/^127\./u,/^10\./u,/^172\.(1[6-9]|2\d|3[01])\./u,/^192\.168\./u,/^0\./u,/^169\.254\./u],not=[/^::1$/u,/^fc/iu,/^fd/iu,/^fe[89ab][0-9a-f]:/iu];o(rot,"extractMappedIPv4");o(iot,"isIpAddress");o($f,"assertSafeUrl");o(sot,"buildHeaders");aot=new L5,D1=o(async(e,t)=>{let n=await globalThis.fetch(e,{...t,redirect:"manual"});if(n.status>=300&&n.status<400)throw new Error(`MCP server returned HTTP ${String(n.status)} redirect; redirects are blocked for security.`);return n},"noRedirectFetch");o(Fye,"connectClient");o(Uye,"probe");o(U5,"callTool")});import{Buffer as oot}from"node:buffer";function dot(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&uot.has(e.code)}function Bye(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&cot.has(e.code)}function zye(e,t,n){let r=oot.from(e,"base64");if(e.length===0&&t==="reject"||r.toString("base64")!==e)throw new Qn(n==="INVALID_IMAGE_BASE64"?"Image upload is not canonical base64.":"File upload is not canonical base64.",n);return new Uint8Array(r)}function pot(e){return zye(e,"reject","INVALID_IMAGE_BASE64")}function fot(e){return{data:pot(e.data),mediaType:e.mediaType,...e.name===void 0?{}:{name:e.name}}}async function $S(e,t){return e.saveImages(t.map(fot))}async function hot(e,t){return e.saveFile({data:zye(t.data,"accept","INVALID_FILE_BASE64"),...t.name===void 0?{}:{name:t.name}})}function Wye(e,t,n){let r=Math.min(1,Math.sqrt(n/(e*t)));if(r===1)return{width:e,height:t};if(e>=t){let a=Math.max(1,Math.floor(e*r)),l=Math.max(1,Math.round(a*t/e));for(;a*l>n&&a>1;)a-=1,l=Math.max(1,Math.round(a*t/e));return{width:a,height:l}}let i=Math.max(1,Math.floor(t*r)),s=Math.max(1,Math.round(i*e/t));for(;s*i>n&&i>1;)i-=1,s=Math.max(1,Math.round(i*e/t));return{width:s,height:i}}function OW(e,t,n){return n>=Math.max(e,t)?{width:e,height:t}:e>=t?{width:n,height:Math.max(1,Math.round(n*t/e))}:{width:Math.max(1,Math.round(n*e/t)),height:n}}var qye,lot,cot,uot,Qn,$W,Nf=oe(()=>{Fn();qye=["TOO_MANY_IMAGES","IMAGES_TOO_LARGE","UNSUPPORTED_IMAGE_TYPE","INVALID_IMAGE_BASE64","INVALID_IMAGE","IMAGE_TYPE_MISMATCH","IMAGE_TOO_LARGE","IMAGE_TOO_MANY_PIXELS","IMAGE_DIMENSION_TOO_LARGE"],lot=[...qye,"INVALID_FILE_BASE64","INVALID_ATTACHMENT_REF","ATTACHMENT_CORRUPT","ATTACHMENT_WRITE_FAILED","ATTACHMENT_NOT_FOUND","ATTACHMENT_READ_FAILED","ATTACHMENT_PROJECTION_UNSUPPORTED","ATTACHMENT_FILES_UNSUPPORTED"],cot=new Set(qye),uot=new Set(lot),Qn=class extends Error{static{o(this,"AttachmentError")}code;constructor(e,t,n){super(e,n),this.name="AttachmentError",this.code=t}};o(dot,"isAttachmentError");o(Bye,"isImageAdmissionError");o(zye,"decodeCanonicalBase64");o(pot,"decodeBase64");o(fot,"saveInput");o($S,"admitEncodedImages");o(hot,"admitEncodedFile");o(Wye,"requestImageDimensions");o(OW,"longEdgeDimensions");$W=class extends bt{static{o(this,"AttachmentStore")}constructor(e){super(e,"attachments")}validateImageBatch(e){let{maxImagesPerMessage:t,maxMessageImageBytes:n,mediaTypes:r}=this.imageLimits;if(e.length>t)throw new Qn("Image batch exceeds the configured image-count limit.","TOO_MANY_IMAGES");if(e.reduce((i,s)=>i+s.data.byteLength,0)>n)throw new Qn("Image batch exceeds the configured aggregate image-byte limit.","IMAGES_TOO_LARGE");for(let i of e)if(!r.includes(i.mediaType))throw new Qn(`Image type ${i.mediaType} is not accepted by this deployment.`,"UNSUPPORTED_IMAGE_TYPE")}async saveImages(e){this.validateImageBatch(e);for(let n of e)await this.validateImage(n);let t=[];for(let n of e)t.push(await this.saveImage(n));return t}async admitPromptContent(e){if(e.every(r=>r.type!=="image"))return e.map(r=>r.type==="text"?{type:"text",text:r.text}:{type:"file",attachment:r.attachment});let t=await $S(this,e.filter(r=>r.type==="image")),n=0;return e.map(r=>r.type==="text"?{type:"text",text:r.text}:r.type==="file"?{type:"file",attachment:r.attachment}:{type:"image",attachment:t[n++]})}admitEncodedFile(e){return hot(this,e)}isAttachmentError(e){return dot(e)}imageHostPath(e){}saveFile(e){return Promise.reject(new Qn("The mounted attachment provider cannot store verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}saveFileStream(e){return Promise.reject(new Qn("The mounted attachment provider cannot stream verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}async*readFileStream(e,t){t?.throwIfAborted(),await Promise.reject(new Qn("The mounted attachment provider cannot read verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}fileHostPath(e){}readImageRequest(e,t,n){return n?.throwIfAborted(),Promise.reject(new Qn("The mounted attachment provider cannot derive model-request images.","ATTACHMENT_PROJECTION_UNSUPPORTED"))}}});var B5={};Nn(B5,{buildAuthorizationUrl:()=>kot,discoverEndpoints:()=>wot,exchangeCode:()=>Eot,isTokenExpired:()=>Tot,refreshToken:()=>_ot,registerClient:()=>Sot});function Zye(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("").slice(0,e)}async function xot(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return btoa(String.fromCharCode(...new Uint8Array(n))).replace(/\+/gu,"-").replace(/\//gu,"_").replace(/=/gu,"")}async function wot(e){let t=AbortSignal.timeout(q5),n=new URL(e),r=n.pathname==="/"?"/.well-known/oauth-protected-resource":`/.well-known/oauth-protected-resource${n.pathname}`,i=new URL(r,n.origin);$f(i.href);let s=await D1(i.href,{signal:t});if(!s.ok)throw new Error(`PRM discovery failed: HTTP ${s.status}`);let l=(await s.json()).authorization_servers?.[0];if(typeof l!="string")throw new Error("No authorization server in PRM");let c=new URL(l),u=c.pathname==="/"?"/.well-known/oauth-authorization-server":`/.well-known/oauth-authorization-server${c.pathname}`,d=new URL(u,c.origin);$f(d.href);let p=await D1(d.href,{signal:t});if(!p.ok)throw new Error(`AS metadata failed: HTTP ${p.status}`);let m=await p.json();if(typeof m.authorization_endpoint!="string"||typeof m.token_endpoint!="string")throw new Error("Missing required endpoints in AS metadata");return{authorization:m.authorization_endpoint,token:m.token_endpoint,registration:m.registration_endpoint}}async function Sot(e,t,n){let r=AbortSignal.timeout(q5);$f(e);let i=await D1(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_name:n,redirect_uris:[t],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}),signal:r});if(!i.ok)throw new Error(`DCR failed: HTTP ${i.status}`);let s=await i.json();if(typeof s.client_id!="string")throw new Error("DCR response missing client_id");return{clientId:s.client_id,clientSecret:s.client_secret}}async function kot(e,t,n,r,i){let s=Zye(32),a=Zye(64),l=await xot(a),c=new URL(e.authorization);for(let[u,d]of Object.entries({response_type:"code",client_id:t.clientId,redirect_uri:n,state:s,code_challenge:l,code_challenge_method:"S256",resource:i}))c.searchParams.set(u,d);return{authorizationUrl:c.href,pendingFlow:{state:s,codeVerifier:a,redirectUri:n,serverName:r,serverUrl:i,stagedClient:t,createdAt:Date.now()}}}async function Eot(e,t,n,r,i,s){let a=AbortSignal.timeout(q5),l=new URLSearchParams({grant_type:"authorization_code",code:n,redirect_uri:i,client_id:t.clientId,code_verifier:r});s!==void 0&&l.set("resource",s),t.clientSecret!==void 0&&l.set("client_secret",t.clientSecret),$f(e);let c=await D1(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:l.toString(),signal:a});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return Kye(await c.json())}async function _ot(e,t,n,r){let i=AbortSignal.timeout(q5),s=new URLSearchParams({grant_type:"refresh_token",refresh_token:n,client_id:t.clientId});r!==void 0&&s.set("resource",r),t.clientSecret!==void 0&&s.set("client_secret",t.clientSecret),$f(e);let a=await D1(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:s.toString(),signal:i});if(!a.ok)throw new Error(`Token refresh failed: HTTP ${a.status}`);return Kye(await a.json())}function Kye(e){let t=e;if(typeof t.access_token!="string")throw new Error("Missing access_token");let n=typeof t.expires_in=="number"?t.expires_in:void 0;return{accessToken:t.access_token,refreshToken:typeof t.refresh_token=="string"?t.refresh_token:void 0,expiresAt:n!==void 0?Date.now()+n*1e3:void 0,tokenType:typeof t.token_type=="string"?t.token_type:"Bearer",scope:typeof t.scope=="string"?t.scope:void 0}}function Tot(e){return e.expiresAt===void 0?!1:Date.now()>e.expiresAt-12e4}var q5,z5=oe(()=>{"use strict";OS();q5=1e4;o(Zye,"randomString");o(xot,"sha256Base64Url");o(wot,"discoverEndpoints");o(Sot,"registerClient");o(kot,"buildAuthorizationUrl");o(Eot,"exchangeCode");o(_ot,"refreshToken");o(Kye,"parseTokenResponse");o(Tot,"isTokenExpired")});var er,r0e,H5=oe(()=>{Fn();yr();er=class extends qr{static{o(this,"FsError")}code;constructor(e,t,n){super(e,t,n),this.code=t}},r0e=class extends bt{static{o(this,"FileSystem")}constructor(e){super(e,"fs")}watch(e,t,n){return n.throwIfAborted(),Promise.reject(new er("Filesystem watching is not supported by this provider.","FS_IO_ERROR"))}get sandboxMode(){}processPathFromHostPath(e){}}});function JW(e){return tI.test(e)}function nI(e){return e.invocation.modelInvocable}function Kv(e){return e.invocation.userInvocable}function YW(e){let t=oct(e);return[`<skill_content name="${lct(e.name)}">`,"<skill_resources>",...t,"</skill_resources>","","<skill_instructions>",e.content,"</skill_instructions>","</skill_content>"].join(`
|
|
155
|
+
`)}),t.length>0?t:[{type:"text",text:"(empty MCP result)"}]}var Gat,Jat,Yat,F5=oe(()=>{"use strict";Aa();j5();Gat=["get_*","list_*","read_*","search_*","find_*","fetch_*","describe_*"];o(Zat,"globToRegExp");o(Oye,"evaluateMcpToolPolicy");o(fp,"scrubMcpErrorMessage");o($ye,"publicToolName");o(Kat,"hashSuffix");o(Nye,"supportedOutputSchema");Jat=new Set(["image/png","image/jpeg"]),Yat=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;o(Xat,"isImageMediaType");o(Pye,"decodeImageBlock");o(Dye,"containsImage");o(CS,"mapMcpResultToContentBlocks")});var RW,Mye=oe(()=>{RW={name:"dsh-edge",version:"0.19.0",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.2.0-rc.1"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dev:container":"pnpm run bundle:isolated && node scripts/dev.mjs container","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:container":"pnpm run bundle:isolated && node tests/container.integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.1","jsonc-parser":"^3.3.1",wrangler:"4.129.0"},devDependencies:{"@cfworker/json-schema":"^4.1.1","@cloudflare/computer":"0.3.1","@cloudflare/workers-types":"5.20260904.1","@deepseek-ai/cordis":"4.0.4","@deepseek-ai/cosmokit":"1.8.5","@deepseek-ai/dsh-agent":"0.2.0-rc.1","@deepseek-ai/dsh-agent-loop":"0.2.0-rc.1","@deepseek-ai/dsh-anonymous-user-id":"0.2.0-rc.1","@deepseek-ai/dsh-api-gateway":"0.2.0-rc.1","@deepseek-ai/dsh-api-job-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-remotes":"0.2.0-rc.1","@deepseek-ai/dsh-api-session-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-settings-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-workspace-controller":"0.2.0-rc.1","@deepseek-ai/dsh-api-workspace-files":"0.2.0-rc.1","@deepseek-ai/dsh-attachment":"0.2.0-rc.1","@deepseek-ai/dsh-brand":"0.2.0-rc.1","@deepseek-ai/dsh-client-locale":"0.2.0-rc.1","@deepseek-ai/dsh-client-store":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-chat":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-conversation":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-settings":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-settings-general":"0.2.0-rc.1","@deepseek-ai/dsh-client-ui-theme":"0.2.0-rc.1","@deepseek-ai/dsh-commands":"0.2.0-rc.1","@deepseek-ai/dsh-compaction":"0.2.0-rc.1","@deepseek-ai/dsh-compaction-basic":"0.2.0-rc.1","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.2.0-rc.1","@deepseek-ai/dsh-credentials":"0.2.0-rc.1","@deepseek-ai/dsh-file-reference":"0.2.0-rc.1","@deepseek-ai/dsh-fs":"0.2.0-rc.1","@deepseek-ai/dsh-goal":"0.2.0-rc.1","@deepseek-ai/dsh-goal-round-driver":"0.2.0-rc.1","@deepseek-ai/dsh-host-directory-picker":"0.2.0-rc.1","@deepseek-ai/dsh-host-plugin-inventory":"0.2.0-rc.1","@deepseek-ai/dsh-invariants":"0.2.0-rc.1","@deepseek-ai/dsh-jobs":"0.2.0-rc.1","@deepseek-ai/dsh-jobs-local":"0.2.0-rc.1","@deepseek-ai/dsh-launch-environment":"0.2.0-rc.1","@deepseek-ai/dsh-llm":"0.2.0-rc.1","@deepseek-ai/dsh-llm-deepseek":"0.2.0-rc.1","@deepseek-ai/dsh-llm-deepseek-api-key":"0.2.0-rc.1","@deepseek-ai/dsh-message-feedback":"0.2.0-rc.1","@deepseek-ai/dsh-output-retention":"0.2.0-rc.1","@deepseek-ai/dsh-plan-mode":"0.2.0-rc.1","@deepseek-ai/dsh-ptc-runtime":"0.2.0-rc.1","@deepseek-ai/dsh-sandbox":"0.2.0-rc.1","@deepseek-ai/dsh-schedule":"0.2.0-rc.1","@deepseek-ai/dsh-scope":"0.2.0-rc.1","@deepseek-ai/dsh-session":"0.2.0-rc.1","@deepseek-ai/dsh-session-format":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-catalog":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v0-to-v1":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v1-to-v2":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v2-to-v3":"0.2.0-rc.1","@deepseek-ai/dsh-session-format-v3-to-v4":"0.2.0-rc.1","@deepseek-ai/dsh-session-persistence":"0.2.0-rc.1","@deepseek-ai/dsh-session-projection":"0.2.0-rc.1","@deepseek-ai/dsh-session-projection-cache":"0.2.0-rc.1","@deepseek-ai/dsh-session-query":"0.2.0-rc.1","@deepseek-ai/dsh-session-reference":"0.2.0-rc.1","@deepseek-ai/dsh-session-title":"0.2.0-rc.1","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.2.0-rc.1","@deepseek-ai/dsh-session-title-llm":"0.2.0-rc.1","@deepseek-ai/dsh-settings":"0.2.0-rc.1","@deepseek-ai/dsh-skill":"0.2.0-rc.1","@deepseek-ai/dsh-spill":"0.2.0-rc.1","@deepseek-ai/dsh-spill-policy":"0.2.0-rc.1","@deepseek-ai/dsh-storage":"0.2.0-rc.1","@deepseek-ai/dsh-storage-domain":"0.2.0-rc.1","@deepseek-ai/dsh-subagent":"0.2.0-rc.1","@deepseek-ai/dsh-subagent-in-process-driver":"0.2.0-rc.1","@deepseek-ai/dsh-subagent-spawn-in-process":"0.2.0-rc.1","@deepseek-ai/dsh-system-prompt":"0.2.0-rc.1","@deepseek-ai/dsh-timeout":"0.2.0-rc.1","@deepseek-ai/dsh-token-meter":"0.2.0-rc.1","@deepseek-ai/dsh-tool-ask-user":"0.2.0-rc.1","@deepseek-ai/dsh-tool-call-timeout-policy":"0.2.0-rc.1","@deepseek-ai/dsh-tool-fs":"0.2.0-rc.1","@deepseek-ai/dsh-tool-goal":"0.2.0-rc.1","@deepseek-ai/dsh-tool-jobs":"0.2.0-rc.1","@deepseek-ai/dsh-tool-skill":"0.2.0-rc.1","@deepseek-ai/dsh-tool-subagent":"0.2.0-rc.1","@deepseek-ai/dsh-tool-web":"0.2.0-rc.1","@deepseek-ai/dsh-tool-workflow":"0.2.0-rc.1","@deepseek-ai/dsh-tools":"0.2.0-rc.1","@deepseek-ai/dsh-typert-protocol":"0.2.0-rc.1","@deepseek-ai/dsh-typert-registry":"0.2.0-rc.1","@deepseek-ai/dsh-user-approval":"0.2.0-rc.1","@deepseek-ai/dsh-user-questions":"0.2.0-rc.1","@deepseek-ai/dsh-util-values":"0.2.0-rc.1","@deepseek-ai/dsh-web":"0.2.0-rc.1","@deepseek-ai/dsh-web-fetch-http":"0.2.0-rc.1","@deepseek-ai/dsh-web-search-deepseek":"0.2.0-rc.1","@deepseek-ai/dsh-workflow":"0.2.0-rc.1","@deepseek-ai/dsh-workspace":"0.2.0-rc.1","@deepseek-ai/schemastery":"3.18.4","@mixmark-io/domino":"2.2.0","@modelcontextprotocol/sdk":"1.30.0",acorn:"8.18.0","fast-png":"8.0.0","jpeg-js":"0.4.4","just-bash":"3.4.2",playwright:"^1.49.0",sucrase:"3.35.1",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}}});var P1,Lye,jye,RS=oe(()=>{"use strict";Mye();P1=RW.version,Lye=RW.dshEdge.upstreamVersion,jye=`npx dsh-edge@${P1.includes("-")?"next":"latest"} upgrade`});function rot(e){let t=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/iu.exec(e);if(t!==null)return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(e);if(n!==null){let r=parseInt(n[1],16),i=parseInt(n[2],16);return`${String(r>>8)}.${String(r&255)}.${String(i>>8)}.${String(i&255)}`}}function iot(e){return/^\d+\.\d+\.\d+\.\d+$/u.test(e)||e.includes(":")}function $f(e){let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("MCP server URL must use http: or https: protocol.");let n=t.hostname.toLowerCase(),r=n.endsWith(".")?n.slice(0,-1):n,i=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(!(i==="localhost"||i==="127.0.0.1"||i==="::1")){for(let s of eot)if(i.endsWith(s))throw new Error(`MCP server hostname "${i}" is blocked.`);if(iot(i)){let s=rot(i),a=s??i;for(let l of tot)if(l.test(a))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`);if(s===void 0){for(let l of not)if(l.test(i))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`)}}}}function sot(e){return e?.type==="bearer"&&e.token!==void 0?{Authorization:`Bearer ${e.token}`}:{}}async function Fye(e,t,n){$f(e);let r=new N5(new URL(e),{requestInit:{headers:sot(t),signal:n},fetch:D1}),i=new O5({name:"dsh-edge",version:P1},{capabilities:{},jsonSchemaValidator:aot});return await i.connect(r),{client:i,close:o(async()=>{await i.close().catch(()=>{})},"close")}}async function Uye(e,t,n){let r=AbortSignal.timeout(Ks.probeTimeoutMs),i;try{i=await Fye(t,n,r)}catch(l){throw new Error(fp(l instanceof Error?l.message:String(l)))}let{client:s,close:a}=i;try{let l=[],c=new Set,u=new Set,d;for(let f=0;f<Ks.maxCatalogPages;f++){let g=await s.listTools(d===void 0?void 0:{cursor:d},{signal:r});for(let y of g.tools){if(l.length>=Ks.maxToolsPerServer)break;let v=$ye(e,y.name);if(c.has(v))throw new Error(`Server listed tool "${y.name}" more than once`);c.add(v);let x=y.annotations?.readOnlyHint,S=Nye(y.outputSchema);l.push({name:y.name,publicName:v,description:y.description??"",inputSchema:y.inputSchema??{type:"object"},...S!==void 0?{outputSchema:S}:{},...x!==void 0?{annotations:{readOnlyHint:x}}:{}})}if(l.length>=Ks.maxToolsPerServer||(d=g.nextCursor??void 0,d===void 0))break;if(u.has(d))throw new Error("Server repeated a tools/list continuation cursor");u.add(d)}let p=s.getServerVersion?.(),m=s.getInstructions?.();return{tools:l,serverInfo:p?{name:p.name,version:p.version}:void 0,instructions:typeof m=="string"&&m.length>0?m.slice(0,Ks.maxInstructionsLength):void 0}}finally{await a()}}async function U5(e,t,n,r,i,s){let a=s??Ks.callTimeoutMs,l=i?AbortSignal.any([i,AbortSignal.timeout(a)]):AbortSignal.timeout(a),c;try{c=await Fye(e,r,l)}catch(u){throw new Error(fp(u instanceof Error?u.message:String(u)))}try{let u=await c.client.callTool({name:t,arguments:n},void 0,{signal:l});return{content:u.content??[],structuredContent:u.structuredContent,isError:u.isError===!0}}catch(u){throw new Error(fp(u instanceof Error?u.message:String(u)))}finally{await c.close()}}var eot,tot,not,aot,D1,OS=oe(()=>{"use strict";z1e();Sye();Rye();F5();j5();RS();eot=[".internal",".local",".localhost"],tot=[/^127\./u,/^10\./u,/^172\.(1[6-9]|2\d|3[01])\./u,/^192\.168\./u,/^0\./u,/^169\.254\./u],not=[/^::1$/u,/^fc/iu,/^fd/iu,/^fe[89ab][0-9a-f]:/iu];o(rot,"extractMappedIPv4");o(iot,"isIpAddress");o($f,"assertSafeUrl");o(sot,"buildHeaders");aot=new L5,D1=o(async(e,t)=>{let n=await globalThis.fetch(e,{...t,redirect:"manual"});if(n.status>=300&&n.status<400)throw new Error(`MCP server returned HTTP ${String(n.status)} redirect; redirects are blocked for security.`);return n},"noRedirectFetch");o(Fye,"connectClient");o(Uye,"probe");o(U5,"callTool")});import{Buffer as oot}from"node:buffer";function dot(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&uot.has(e.code)}function Bye(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&cot.has(e.code)}function zye(e,t,n){let r=oot.from(e,"base64");if(e.length===0&&t==="reject"||r.toString("base64")!==e)throw new Qn(n==="INVALID_IMAGE_BASE64"?"Image upload is not canonical base64.":"File upload is not canonical base64.",n);return new Uint8Array(r)}function pot(e){return zye(e,"reject","INVALID_IMAGE_BASE64")}function fot(e){return{data:pot(e.data),mediaType:e.mediaType,...e.name===void 0?{}:{name:e.name}}}async function $S(e,t){return e.saveImages(t.map(fot))}async function hot(e,t){return e.saveFile({data:zye(t.data,"accept","INVALID_FILE_BASE64"),...t.name===void 0?{}:{name:t.name}})}function Wye(e,t,n){let r=Math.min(1,Math.sqrt(n/(e*t)));if(r===1)return{width:e,height:t};if(e>=t){let a=Math.max(1,Math.floor(e*r)),l=Math.max(1,Math.round(a*t/e));for(;a*l>n&&a>1;)a-=1,l=Math.max(1,Math.round(a*t/e));return{width:a,height:l}}let i=Math.max(1,Math.floor(t*r)),s=Math.max(1,Math.round(i*e/t));for(;s*i>n&&i>1;)i-=1,s=Math.max(1,Math.round(i*e/t));return{width:s,height:i}}function OW(e,t,n){return n>=Math.max(e,t)?{width:e,height:t}:e>=t?{width:n,height:Math.max(1,Math.round(n*t/e))}:{width:Math.max(1,Math.round(n*e/t)),height:n}}var qye,lot,cot,uot,Qn,$W,Nf=oe(()=>{Fn();qye=["TOO_MANY_IMAGES","IMAGES_TOO_LARGE","UNSUPPORTED_IMAGE_TYPE","INVALID_IMAGE_BASE64","INVALID_IMAGE","IMAGE_TYPE_MISMATCH","IMAGE_TOO_LARGE","IMAGE_TOO_MANY_PIXELS","IMAGE_DIMENSION_TOO_LARGE"],lot=[...qye,"INVALID_FILE_BASE64","INVALID_ATTACHMENT_REF","ATTACHMENT_CORRUPT","ATTACHMENT_WRITE_FAILED","ATTACHMENT_NOT_FOUND","ATTACHMENT_READ_FAILED","ATTACHMENT_PROJECTION_UNSUPPORTED","ATTACHMENT_FILES_UNSUPPORTED"],cot=new Set(qye),uot=new Set(lot),Qn=class extends Error{static{o(this,"AttachmentError")}code;constructor(e,t,n){super(e,n),this.name="AttachmentError",this.code=t}};o(dot,"isAttachmentError");o(Bye,"isImageAdmissionError");o(zye,"decodeCanonicalBase64");o(pot,"decodeBase64");o(fot,"saveInput");o($S,"admitEncodedImages");o(hot,"admitEncodedFile");o(Wye,"requestImageDimensions");o(OW,"longEdgeDimensions");$W=class extends bt{static{o(this,"AttachmentStore")}constructor(e){super(e,"attachments")}validateImageBatch(e){let{maxImagesPerMessage:t,maxMessageImageBytes:n,mediaTypes:r}=this.imageLimits;if(e.length>t)throw new Qn("Image batch exceeds the configured image-count limit.","TOO_MANY_IMAGES");if(e.reduce((i,s)=>i+s.data.byteLength,0)>n)throw new Qn("Image batch exceeds the configured aggregate image-byte limit.","IMAGES_TOO_LARGE");for(let i of e)if(!r.includes(i.mediaType))throw new Qn(`Image type ${i.mediaType} is not accepted by this deployment.`,"UNSUPPORTED_IMAGE_TYPE")}async saveImages(e){this.validateImageBatch(e);for(let n of e)await this.validateImage(n);let t=[];for(let n of e)t.push(await this.saveImage(n));return t}async admitPromptContent(e){if(e.every(r=>r.type!=="image"))return e.map(r=>r.type==="text"?{type:"text",text:r.text}:{type:"file",attachment:r.attachment});let t=await $S(this,e.filter(r=>r.type==="image")),n=0;return e.map(r=>r.type==="text"?{type:"text",text:r.text}:r.type==="file"?{type:"file",attachment:r.attachment}:{type:"image",attachment:t[n++]})}admitEncodedFile(e){return hot(this,e)}isAttachmentError(e){return dot(e)}imageHostPath(e){}saveFile(e){return Promise.reject(new Qn("The mounted attachment provider cannot store verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}saveFileStream(e){return Promise.reject(new Qn("The mounted attachment provider cannot stream verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}async*readFileStream(e,t){t?.throwIfAborted(),await Promise.reject(new Qn("The mounted attachment provider cannot read verbatim files.","ATTACHMENT_FILES_UNSUPPORTED"))}fileHostPath(e){}readImageRequest(e,t,n){return n?.throwIfAborted(),Promise.reject(new Qn("The mounted attachment provider cannot derive model-request images.","ATTACHMENT_PROJECTION_UNSUPPORTED"))}}});var B5={};Nn(B5,{buildAuthorizationUrl:()=>kot,discoverEndpoints:()=>wot,exchangeCode:()=>Eot,isTokenExpired:()=>Tot,refreshToken:()=>_ot,registerClient:()=>Sot});function Zye(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("").slice(0,e)}async function xot(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return btoa(String.fromCharCode(...new Uint8Array(n))).replace(/\+/gu,"-").replace(/\//gu,"_").replace(/=/gu,"")}async function wot(e){let t=AbortSignal.timeout(q5),n=new URL(e),r=n.pathname==="/"?"/.well-known/oauth-protected-resource":`/.well-known/oauth-protected-resource${n.pathname}`,i=new URL(r,n.origin);$f(i.href);let s=await D1(i.href,{signal:t});if(!s.ok)throw new Error(`PRM discovery failed: HTTP ${s.status}`);let l=(await s.json()).authorization_servers?.[0];if(typeof l!="string")throw new Error("No authorization server in PRM");let c=new URL(l),u=c.pathname==="/"?"/.well-known/oauth-authorization-server":`/.well-known/oauth-authorization-server${c.pathname}`,d=new URL(u,c.origin);$f(d.href);let p=await D1(d.href,{signal:t});if(!p.ok)throw new Error(`AS metadata failed: HTTP ${p.status}`);let m=await p.json();if(typeof m.authorization_endpoint!="string"||typeof m.token_endpoint!="string")throw new Error("Missing required endpoints in AS metadata");return{authorization:m.authorization_endpoint,token:m.token_endpoint,registration:m.registration_endpoint}}async function Sot(e,t,n){let r=AbortSignal.timeout(q5);$f(e);let i=await D1(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_name:n,redirect_uris:[t],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}),signal:r});if(!i.ok)throw new Error(`DCR failed: HTTP ${i.status}`);let s=await i.json();if(typeof s.client_id!="string")throw new Error("DCR response missing client_id");return{clientId:s.client_id,clientSecret:s.client_secret}}async function kot(e,t,n,r,i){let s=Zye(32),a=Zye(64),l=await xot(a),c=new URL(e.authorization);for(let[u,d]of Object.entries({response_type:"code",client_id:t.clientId,redirect_uri:n,state:s,code_challenge:l,code_challenge_method:"S256",resource:i}))c.searchParams.set(u,d);return{authorizationUrl:c.href,pendingFlow:{state:s,codeVerifier:a,redirectUri:n,serverName:r,serverUrl:i,stagedClient:t,createdAt:Date.now()}}}async function Eot(e,t,n,r,i,s){let a=AbortSignal.timeout(q5),l=new URLSearchParams({grant_type:"authorization_code",code:n,redirect_uri:i,client_id:t.clientId,code_verifier:r});s!==void 0&&l.set("resource",s),t.clientSecret!==void 0&&l.set("client_secret",t.clientSecret),$f(e);let c=await D1(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:l.toString(),signal:a});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return Kye(await c.json())}async function _ot(e,t,n,r){let i=AbortSignal.timeout(q5),s=new URLSearchParams({grant_type:"refresh_token",refresh_token:n,client_id:t.clientId});r!==void 0&&s.set("resource",r),t.clientSecret!==void 0&&s.set("client_secret",t.clientSecret),$f(e);let a=await D1(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:s.toString(),signal:i});if(!a.ok)throw new Error(`Token refresh failed: HTTP ${a.status}`);return Kye(await a.json())}function Kye(e){let t=e;if(typeof t.access_token!="string")throw new Error("Missing access_token");let n=typeof t.expires_in=="number"?t.expires_in:void 0;return{accessToken:t.access_token,refreshToken:typeof t.refresh_token=="string"?t.refresh_token:void 0,expiresAt:n!==void 0?Date.now()+n*1e3:void 0,tokenType:typeof t.token_type=="string"?t.token_type:"Bearer",scope:typeof t.scope=="string"?t.scope:void 0}}function Tot(e){return e.expiresAt===void 0?!1:Date.now()>e.expiresAt-12e4}var q5,z5=oe(()=>{"use strict";OS();q5=1e4;o(Zye,"randomString");o(xot,"sha256Base64Url");o(wot,"discoverEndpoints");o(Sot,"registerClient");o(kot,"buildAuthorizationUrl");o(Eot,"exchangeCode");o(_ot,"refreshToken");o(Kye,"parseTokenResponse");o(Tot,"isTokenExpired")});var er,r0e,H5=oe(()=>{Fn();yr();er=class extends qr{static{o(this,"FsError")}code;constructor(e,t,n){super(e,t,n),this.code=t}},r0e=class extends bt{static{o(this,"FileSystem")}constructor(e){super(e,"fs")}watch(e,t,n){return n.throwIfAborted(),Promise.reject(new er("Filesystem watching is not supported by this provider.","FS_IO_ERROR"))}get sandboxMode(){}processPathFromHostPath(e){}}});function JW(e){return tI.test(e)}function nI(e){return e.invocation.modelInvocable}function Kv(e){return e.invocation.userInvocable}function YW(e){let t=oct(e);return[`<skill_content name="${lct(e.name)}">`,"<skill_resources>",...t,"</skill_resources>","","<skill_instructions>",e.content,"</skill_instructions>","</skill_content>"].join(`
|
|
156
156
|
`)}function oct(e){let t=e.resourceBase;if(t===void 0)return[`Resources for this skill are managed by provider "${Zv(e.provider)}".`,"Load referenced resources only as needed."];switch(t.kind){case"directory":return[`Base directory for this skill: ${Zv(t.path)}`,"Resolve relative paths mentioned by this skill against the base directory before using them. Load referenced resources only as needed."];case"url":return[`Base URL for this skill: ${Zv(t.url)}`,"Resolve relative URLs mentioned by this skill against the base URL before using them. Load referenced resources only as needed."];case"opaque":return[`Resources for this skill: ${Zv(t.description)}`,"Load referenced resources only as needed."];default:return mi(t,"SkillResourceBase.kind")}}function lct(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}function Zv(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function uct(e,t){if(Array.isArray(e))return{candidates:e,complete:!0};if(e===null||typeof e!="object")throw E0e(t);let n=e;if(!Array.isArray(n.candidates)||typeof n.complete!="boolean")throw E0e(t);return n}function E0e(e){return new TypeError(`skill provider "${e}" list() must return an array or { candidates, complete } observation`)}function pct(e){return{name:e.name,description:e.description,...e.whenToUse!==void 0?{whenToUse:e.whenToUse}:{},invocation:e.invocation,source:e.source,provider:e.provider,...e.resourceBase!==void 0?{resourceBase:e.resourceBase}:{},rank:act,locator:e,...e.path!==void 0?{path:e.path}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}function fct(e,t){if(typeof e.name!="string")throw new TypeError(`skill provider "${t}" returned a non-string skill name`);if(!tI.test(e.name))throw new Error(`skill provider "${t}" returned invalid skill name "${e.name}"`);if(typeof e.description!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string description`);if(e.description.length===0)throw new Error(`skill provider "${t}" returned skill "${e.name}" without a description`);if(XW(e.invocation,`skill provider "${t}" returned skill "${e.name}"`),e.whenToUse!==void 0&&typeof e.whenToUse!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string whenToUse`);if(typeof e.source!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string source`);if(typeof e.rank!="number"||!Number.isFinite(e.rank))throw new Error(`skill provider "${t}" returned skill "${e.name}" with an invalid rank`);if(typeof e.provider!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string provider`);if(e.provider!==t)throw new Error(`skill provider "${t}" returned skill "${e.name}" for provider "${e.provider}"`);if(e.path!==void 0&&typeof e.path!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string path`)}function hct(e){if(!tI.test(e.name))throw new Error(`invalid skill name "${e.name}"`);if(e.description.length===0)throw new Error(`skill "${e.name}" requires a description`);XW(e.invocation,`runtime skill "${e.name}"`)}function mct(e){let t=e.name,n=e.description,r=e.whenToUse,i=e.invocation,s=e.source,a=e.provider,l=e.content,c=e.path;if(typeof t!="string")throw new TypeError("loaded skill name must be a string");if(!tI.test(t))throw new Error(`loaded skill has invalid name "${t}"`);if(typeof n!="string")throw new TypeError(`loaded skill "${t}" description must be a string`);if(n.length===0)throw new Error(`loaded skill "${t}" requires a description`);if(XW(i,`loaded skill "${t}"`),r!==void 0&&typeof r!="string")throw new TypeError(`loaded skill "${t}" whenToUse must be a string`);if(typeof s!="string")throw new TypeError(`loaded skill "${t}" source must be a string`);if(typeof a!="string")throw new TypeError(`loaded skill "${t}" provider must be a string`);if(typeof l!="string")throw new TypeError(`loaded skill "${t}" content must be a string`);if(c!==void 0&&typeof c!="string")throw new TypeError(`loaded skill "${t}" path must be a string`)}function gct(e){let{name:t,description:n,whenToUse:r,invocation:i,source:s,provider:a,resourceBase:l}=e;return{name:t,...e.path===void 0?{}:{path:e.path},description:n,...r!==void 0?{whenToUse:r}:{},invocation:i,source:s,provider:a,...l!==void 0?{resourceBase:l}:{}}}function XW(e,t){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${t} with a non-object invocation policy`);let n=e;if(typeof n.modelInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.modelInvocable`);if(typeof n.userInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.userInvocable`)}function yct(e,t){return I0e(e.name,t.name)}function I0e(e,t){return e<t?-1:e>t?1:0}function vct(e,t){return e.candidate.rank-t.candidate.rank||e.providerOrder-t.providerOrder||e.localOrder-t.localOrder}function bct(e,t,n=1){if(!Number.isInteger(t)||t<n)throw new Error(`skill: ${e} must be an integer greater than or equal to ${n}`)}function _0e(e,t){return t===void 0?e:(MS(t),new Promise((n,r)=>{let i=o(()=>{t.removeEventListener("abort",s)},"cleanup"),s=o(()=>{i(),r(eI(t.reason))},"onAbort");t.addEventListener("abort",s,{once:!0}),e.then(a=>{i(),n(a)},a=>{i(),r(eI(a))})}))}function MS(e){if(e?.aborted===!0)throw eI(e.reason)}function eI(e){try{if(e instanceof Error)return e}catch{}return new Error(Q5(e))}function Q5(e){try{return String(e)}catch{return"[unrenderable thrown value]"}}var tI,k0e,sct,X5,act,T0e,cct,A0e,dct,Jv=oe(()=>{Fn();Vi();nl();kn();tI=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,k0e=128,sct=2,X5="runtime",act=250,T0e=600;o(JW,"isSkillName");o(nI,"isModelInvocable");o(Kv,"isUserInvocable");o(YW,"renderSkillContent");o(oct,"renderResourceHint");o(lct,"escapeAttr");o(Zv,"escapeText");cct=class{static{o(this,"SkillLayer")}providers;runtime=new Map;constructor(e){this.providers=new Kd(t=>new Error(e===void 0?`a skill provider named "${t}" is already registered`:`a skill provider named "${t}" is already registered in this scope`))}isEmpty(){return this.providers.isEmpty()&&this.runtime.size===0}},A0e=class extends bt{static{o(this,"SkillRegistry")}static Config=U.object({collectCacheMaxEntries:U.number().default(k0e)});collectCacheMaxEntries;layers=new Jd(e=>new cct(e),()=>{this.invalidateCache()});collectCache=new Map;revision=0;nextProviderOrder=0;scopeIds=new WeakMap;nextScopeId=1;constructor(e,t={}){super(e,"skills"),this.collectCacheMaxEntries=t.collectCacheMaxEntries??k0e,bct("collectCacheMaxEntries",this.collectCacheMaxEntries)}registerProvider(e){let t=new AbortController,n,r,i={signal:t.signal,invalidate:o(()=>{let s=n;s!==void 0&&s.layer.providers.get(s.name)?.provider===r&&this.invalidateCache()},"invalidate")};try{r=e(i);let s=r.name;if(s===X5)throw new Error(`"${X5}" is reserved for runtime skill registrations`);let a=this.nextProviderOrder;return this.nextProviderOrder+=1,this.layers.effect(this.ctx,l=>{let c=l.providers.insert(s,{provider:r,order:a});return n={layer:l,name:s},()=>{n=void 0,c(),t.abort(new Error(`skill provider "${s}" disposed`))}},{label:"skills.registerProvider()"})}catch(s){throw t.abort(s),s}}register(e){hct(e);let t=tl(this.ctx),n=t===void 0?this.layers.global:this.layers.peek(t);if(n!==void 0&&n.runtime.has(e.name))return this.ctx.logger.warn(`runtime skill "${e.name}" ignored because it is already registered`),()=>{};let r={...e,invocation:e.invocation??{modelInvocable:!0,userInvocable:!0},provider:e.provider??X5};return this.layers.effect(this.ctx,i=>(i.runtime.set(r.name,r),()=>{i.runtime.delete(r.name)}),{label:"skills.register()"})}async list(e={}){return(await this.snapshot(e)).skills}async snapshot(e={}){let t=await this.collect(e);return{skills:[...t.entries.values()].map(n=>gct(n.candidate)).sort(yct),complete:t.cacheable}}async get(e,t={}){if(!JW(e))return;let n=await this.collect(t);MS(t.signal);let r=n.entries.get(e);if(r===void 0)return;let i=await _0e(r.provider.get(r.candidate,t),t.signal);if(i!==void 0){if(mct(i),i.name!==r.candidate.name){this.invalidateEntry(r);return}return i}}async collect(e){MS(e.signal);let t=1;for(;;){let n=this.revision,r=this.collectCacheKey(e.cwd,aw(e.scope),n),i=this.collectCache.get(r);if(i!==void 0)return{entries:i,cacheable:!0};let s=await this.collectFresh(e);if(MS(e.signal),n!==this.revision){if(t<sct){t+=1;continue}return{entries:s.entries,cacheable:!1}}if(s.cacheable&&(this.collectCache.set(r,s.entries),this.collectCache.size>this.collectCacheMaxEntries)){let a=this.collectCache.keys().next();this.collectCache.delete(a.value)}return s}}async collectFresh(e){let t=[this.layers.global,...this.layers.chainLayers(e.scope)],n=new Map,r=!0;for(let i of t){let s=await this.collectLayer(i,e);s.cacheable||(r=!1);for(let a of s.entries)n.set(a.candidate.name,a)}return{entries:n,cacheable:r}}async collectLayer(e,t){let n=await this.listLayerCandidates(e,t);n.entries.sort(vct);let r=new Set,i=[];for(let s of n.entries){let a=s.candidate;if(r.has(a.name)){this.ctx.logger.warn(`skill "${a.name}" from ${a.source} ignored because a higher-priority skill already exists`);continue}r.add(a.name),i.push(s)}return{entries:i,cacheable:n.cacheable}}async listLayerCandidates(e,t){MS(t.signal);let n=[],r=!0,i=0;for(let s of[...e.runtime.values()].sort((a,l)=>I0e(a.name,l.name)))n.push({candidate:pct(s),provider:dct,providerOrder:-1,localOrder:i,layer:e}),i+=1;for(let{provider:s,order:a}of[...e.providers.values()]){let l=0,c;try{c=await _0e(s.list(t),t.signal)}catch(d){if(t.signal?.aborted===!0)throw eI(t.signal.reason);r=!1,this.ctx.logger.warn(`skill provider "${s.name}" skipped: ${Q5(d)}`)}if(c===void 0)continue;let u=uct(c,s.name);u.complete||(r=!1);for(let d of u.candidates)fct(d,s.name),n.push({candidate:d,provider:s,providerOrder:a,localOrder:l,layer:e}),l+=1}return{entries:n,cacheable:r}}invalidateCache(){this.revision+=1,this.collectCache.clear(),this.notifyChange()}invalidateEntry(e){e.layer.providers.get(e.provider.name)?.provider===e.provider&&this.invalidateCache()}scopeId(e){let t=this.scopeIds.get(e);return t===void 0&&(t=this.nextScopeId,this.nextScopeId+=1,this.scopeIds.set(e,t)),t}collectCacheKey(e,t,n){return JSON.stringify({cwd:e,scopes:t.map(r=>this.scopeId(r)),revision:n})}notifyChange(){for(let e of this.ctx.events.dispatch("emit",["skills/change"]))try{let t=e();Promise.resolve(t).catch(n=>{this.ctx.logger.warn(`skills/change listener rejected: ${Q5(n)}`)})}catch(t){this.ctx.logger.warn(`skills/change listener threw: ${Q5(t)}`)}}};o(uct,"normalizeProviderObservation");o(E0e,"invalidProviderObservation");dct={name:X5,list(){return Promise.resolve([])},get(e){return Promise.resolve(e.locator)}};o(pct,"runtimeCandidate");o(fct,"validateCandidate");o(hct,"validateRuntimeSkill");o(mct,"validateDefinition");o(gct,"toSummary");o(XW,"validateInvocation");o(yct,"compareSkillSummary");o(I0e,"compareCodePoints");o(vct,"compareIndexedCandidates");o(bct,"assertPositiveInteger");o(_0e,"waitWithAbort");o(MS,"throwIfAborted");o(eI,"toError");o(Q5,"errorMessage")});var lu,Xv=oe(()=>{lu=class{static{o(this,"Deque")}buffer=new Array(16);head=0;count=0;get size(){return this.count}pushBack(e){this.ensureCapacity();let t=this.head+this.count;this.buffer[t<this.buffer.length?t:t-this.buffer.length]=e,this.count+=1}pushFront(e){this.ensureCapacity(),this.head=this.head===0?this.buffer.length-1:this.head-1,this.buffer[this.head]=e,this.count+=1}popFront(){if(this.count===0)return;let e=this.buffer[this.head];return this.buffer[this.head]=void 0,this.head+=1,this.head===this.buffer.length&&(this.head=0),this.count-=1,this.compact(),e}clear(){this.buffer=new Array(16),this.head=0,this.count=0}ensureCapacity(){this.count<this.buffer.length||this.resize(this.buffer.length*2)}compact(){if(this.count===0){this.head=0;return}this.buffer.length>16&&this.count<=this.buffer.length/4&&this.resize(Math.max(16,this.buffer.length/2))}resize(e){let t=new Array(e),n=this.head;for(let r=0;r<this.count;r+=1)t[r]=this.buffer[n],n+=1,n===this.buffer.length&&(n=0);this.buffer=t,this.head=0}}});var Df,uve,pH=oe(()=>{Fn();Df=class extends Error{static{o(this,"DirectoryPickerError")}code;path;constructor(e,t,n){super(n),this.code=e,this.path=t,this.name="DirectoryPickerError"}},uve=class extends bt{static{o(this,"DirectoryPicker")}constructor(e){super(e,"directoryPicker")}}});var sbe=ye((Akn,iC)=>{var ibe=ibe||function(e){return Buffer.from(e).toString("base64")};function Oht(e){var t=this,n=Math.round,r=Math.floor,i=new Array(64),s=new Array(64),a=new Array(64),l=new Array(64),c,u,d,p,m=new Array(65535),f=new Array(65535),g=new Array(64),y=new Array(64),v=[],x=0,S=7,k=new Array(64),w=new Array(64),E=new Array(64),I=new Array(256),R=new Array(2048),Z,G=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],q=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],N=[0,1,2,3,4,5,6,7,8,9,10,11],V=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],Q=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],C=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],B=[0,1,2,3,4,5,6,7,8,9,10,11],T=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],A=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function $(ie){for(var De=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],we=0;we<64;we++){var st=r((De[we]*ie+50)/100);st<1?st=1:st>255&&(st=255),i[G[we]]=st}for(var qe=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],Me=0;Me<64;Me++){var ht=r((qe[Me]*ie+50)/100);ht<1?ht=1:ht>255&&(ht=255),s[G[Me]]=ht}for(var tt=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],He=0,pt=0;pt<8;pt++)for(var Ce=0;Ce<8;Ce++)a[He]=1/(i[G[He]]*tt[pt]*tt[Ce]*8),l[He]=1/(s[G[He]]*tt[pt]*tt[Ce]*8),He++}o($,"initQuantTables");function M(ie,De){for(var we=0,st=0,qe=new Array,Me=1;Me<=16;Me++){for(var ht=1;ht<=ie[Me];ht++)qe[De[st]]=[],qe[De[st]][0]=we,qe[De[st]][1]=Me,st++,we++;we*=2}return qe}o(M,"computeHuffmanTbl");function P(){c=M(q,N),u=M(C,B),d=M(V,Q),p=M(T,A)}o(P,"initHuffmanTbl");function H(){for(var ie=1,De=2,we=1;we<=15;we++){for(var st=ie;st<De;st++)f[32767+st]=we,m[32767+st]=[],m[32767+st][1]=we,m[32767+st][0]=st;for(var qe=-(De-1);qe<=-ie;qe++)f[32767+qe]=we,m[32767+qe]=[],m[32767+qe][1]=we,m[32767+qe][0]=De-1+qe;ie<<=1,De<<=1}}o(H,"initCategoryNumber");function Y(){for(var ie=0;ie<256;ie++)R[ie]=19595*ie,R[ie+256>>0]=38470*ie,R[ie+512>>0]=7471*ie+32768,R[ie+768>>0]=-11059*ie,R[ie+1024>>0]=-21709*ie,R[ie+1280>>0]=32768*ie+8421375,R[ie+1536>>0]=-27439*ie,R[ie+1792>>0]=-5329*ie}o(Y,"initRGBYUVTable");function K(ie){for(var De=ie[0],we=ie[1]-1;we>=0;)De&1<<we&&(x|=1<<S),we--,S--,S<0&&(x==255?(j(255),j(0)):j(x),S=7,x=0)}o(K,"writeBits");function j(ie){v.push(ie)}o(j,"writeByte");function ee(ie){j(ie>>8&255),j(ie&255)}o(ee,"writeWord");function ge(ie,De){var we,st,qe,Me,ht,tt,He,pt,Ce=0,xt,Ft=8,ct=64;for(xt=0;xt<Ft;++xt){we=ie[Ce],st=ie[Ce+1],qe=ie[Ce+2],Me=ie[Ce+3],ht=ie[Ce+4],tt=ie[Ce+5],He=ie[Ce+6],pt=ie[Ce+7];var un=we+pt,jt=we-pt,Pt=st+He,ae=st-He,$e=qe+tt,We=qe-tt,rt=Me+ht,Tt=Me-ht,Ze=un+rt,Qt=un-rt,Kt=Pt+$e,dn=Pt-$e;ie[Ce]=Ze+Kt,ie[Ce+4]=Ze-Kt;var Ot=(dn+Qt)*.707106781;ie[Ce+2]=Qt+Ot,ie[Ce+6]=Qt-Ot,Ze=Tt+We,Kt=We+ae,dn=ae+jt;var kr=(Ze-dn)*.382683433,Ir=.5411961*Ze+kr,Bi=1.306562965*dn+kr,hi=Kt*.707106781,nr=jt+hi,zi=jt-hi;ie[Ce+5]=zi+Ir,ie[Ce+3]=zi-Ir,ie[Ce+1]=nr+Bi,ie[Ce+7]=nr-Bi,Ce+=8}for(Ce=0,xt=0;xt<Ft;++xt){we=ie[Ce],st=ie[Ce+8],qe=ie[Ce+16],Me=ie[Ce+24],ht=ie[Ce+32],tt=ie[Ce+40],He=ie[Ce+48],pt=ie[Ce+56];var us=we+pt,Is=we-pt,qs=st+He,Dt=st-He,In=qe+tt,Bs=qe-tt,Ma=Me+ht,ra=Me-ht,ia=us+Ma,pa=us-Ma,La=qs+In,co=qs-In;ie[Ce]=ia+La,ie[Ce+32]=ia-La;var tc=(co+pa)*.707106781;ie[Ce+16]=pa+tc,ie[Ce+48]=pa-tc,ia=ra+Bs,La=Bs+Dt,co=Dt+Is;var ml=(ia-co)*.382683433,Ru=.5411961*ia+ml,Ou=1.306562965*co+ml,$u=La*.707106781,Nu=Is+$u,Hp=Is-$u;ie[Ce+40]=Hp+Ru,ie[Ce+24]=Hp-Ru,ie[Ce+8]=Nu+Ou,ie[Ce+56]=Nu-Ou,Ce++}var Od;for(xt=0;xt<ct;++xt)Od=ie[xt]*De[xt],g[xt]=Od>0?Od+.5|0:Od-.5|0;return g}o(ge,"fDCTQuant");function be(){ee(65504),ee(16),j(74),j(70),j(73),j(70),j(0),j(1),j(1),j(0),ee(1),ee(1),j(0),j(0)}o(be,"writeAPP0");function le(ie){if(ie){ee(65505),ie[0]===69&&ie[1]===120&&ie[2]===105&&ie[3]===102?ee(ie.length+2):(ee(ie.length+5+2),j(69),j(120),j(105),j(102),j(0));for(var De=0;De<ie.length;De++)j(ie[De])}}o(le,"writeAPP1");function Se(ie,De){ee(65472),ee(17),j(8),ee(De),ee(ie),j(3),j(1),j(17),j(0),j(2),j(17),j(1),j(3),j(17),j(1)}o(Se,"writeSOF0");function ke(){ee(65499),ee(132),j(0);for(var ie=0;ie<64;ie++)j(i[ie]);j(1);for(var De=0;De<64;De++)j(s[De])}o(ke,"writeDQT");function ce(){ee(65476),ee(418),j(0);for(var ie=0;ie<16;ie++)j(q[ie+1]);for(var De=0;De<=11;De++)j(N[De]);j(16);for(var we=0;we<16;we++)j(V[we+1]);for(var st=0;st<=161;st++)j(Q[st]);j(1);for(var qe=0;qe<16;qe++)j(C[qe+1]);for(var Me=0;Me<=11;Me++)j(B[Me]);j(17);for(var ht=0;ht<16;ht++)j(T[ht+1]);for(var tt=0;tt<=161;tt++)j(A[tt])}o(ce,"writeDHT");function ue(ie){typeof ie>"u"||ie.constructor!==Array||ie.forEach(De=>{if(typeof De=="string"){ee(65534);var we=De.length;ee(we+2);var st;for(st=0;st<we;st++)j(De.charCodeAt(st))}})}o(ue,"writeCOM");function nt(){ee(65498),ee(12),j(3),j(1),j(0),j(2),j(17),j(3),j(17),j(0),j(63),j(0)}o(nt,"writeSOS");function ze(ie,De,we,st,qe){for(var Me=qe[0],ht=qe[240],tt,He=16,pt=63,Ce=64,xt=ge(ie,De),Ft=0;Ft<Ce;++Ft)y[G[Ft]]=xt[Ft];var ct=y[0]-we;we=y[0],ct==0?K(st[0]):(tt=32767+ct,K(st[f[tt]]),K(m[tt]));for(var un=63;un>0&&y[un]==0;un--);if(un==0)return K(Me),we;for(var jt=1,Pt;jt<=un;){for(var ae=jt;y[jt]==0&&jt<=un;++jt);var $e=jt-ae;if($e>=He){Pt=$e>>4;for(var We=1;We<=Pt;++We)K(ht);$e=$e&15}tt=32767+y[jt],K(qe[($e<<4)+f[tt]]),K(m[tt]),jt++}return un!=pt&&K(Me),we}o(ze,"processDU");function et(){for(var ie=String.fromCharCode,De=0;De<256;De++)I[De]=ie(De)}o(et,"initCharLookupTable"),this.encode=function(ie,De){var we=new Date().getTime();De&&Ae(De),v=new Array,x=0,S=7,ee(65496),be(),ue(ie.comments),le(ie.exifBuffer),ke(),Se(ie.width,ie.height),ce(),nt();var st=0,qe=0,Me=0;x=0,S=7,this.encode.displayName="_encode_";for(var ht=ie.data,tt=ie.width,He=ie.height,pt=tt*4,Ce=tt*3,xt,Ft=0,ct,un,jt,Pt,ae,$e,We,rt;Ft<He;){for(xt=0;xt<pt;){for(Pt=pt*Ft+xt,ae=Pt,$e=-1,We=0,rt=0;rt<64;rt++)We=rt>>3,$e=(rt&7)*4,ae=Pt+We*pt+$e,Ft+We>=He&&(ae-=pt*(Ft+1+We-He)),xt+$e>=pt&&(ae-=xt+$e-pt+4),ct=ht[ae++],un=ht[ae++],jt=ht[ae++],k[rt]=(R[ct]+R[un+256>>0]+R[jt+512>>0]>>16)-128,w[rt]=(R[ct+768>>0]+R[un+1024>>0]+R[jt+1280>>0]>>16)-128,E[rt]=(R[ct+1280>>0]+R[un+1536>>0]+R[jt+1792>>0]>>16)-128;st=ze(k,a,st,c,d),qe=ze(w,l,qe,u,p),Me=ze(E,l,Me,u,p),xt+=32}Ft+=8}if(S>=0){var Tt=[];Tt[1]=S+1,Tt[0]=(1<<S+1)-1,K(Tt)}if(ee(65497),typeof iC>"u")return new Uint8Array(v);return Buffer.from(v);var Ze,Qt};function Ae(ie){if(ie<=0&&(ie=1),ie>100&&(ie=100),Z!=ie){var De=0;ie<50?De=Math.floor(5e3/ie):De=Math.floor(200-ie*2),$(De),Z=ie}}o(Ae,"setQuality");function xe(){var ie=new Date().getTime();e||(e=50),et(),P(),H(),Y(),Ae(e);var De=new Date().getTime()-ie}o(xe,"init"),xe()}o(Oht,"JPEGEncoder");typeof iC<"u"?iC.exports=rbe:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].encode=rbe);function rbe(e,t){typeof t>"u"&&(t=50);var n=new Oht(t),r=n.encode(e,t);return{data:r,width:e.width,height:e.height}}o(rbe,"encode")});var obe=ye((Ckn,kV)=>{var SV=o((function(){"use strict";var t=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),n=4017,r=799,i=3406,s=2276,a=1567,l=3784,c=5793,u=2896;function d(){}o(d,"constructor");function p(S,k){for(var w=0,E=[],I,R,Z=16;Z>0&&!S[Z-1];)Z--;E.push({children:[],index:0});var G=E[0],q;for(I=0;I<Z;I++){for(R=0;R<S[I];R++){for(G=E.pop(),G.children[G.index]=k[w];G.index>0;){if(E.length===0)throw new Error("Could not recreate Huffman Table");G=E.pop()}for(G.index++,E.push(G);E.length<=I;)E.push(q={children:[],index:0}),G.children[G.index]=q.children,G=q;w++}I+1<Z&&(E.push(q={children:[],index:0}),G.children[G.index]=q.children,G=q)}return E[0].children}o(p,"buildHuffmanTable");function m(S,k,w,E,I,R,Z,G,q,N){var V=w.precision,Q=w.samplesPerLine,C=w.scanLines,B=w.mcusPerLine,T=w.progressive,A=w.maxH,$=w.maxV,M=k,P=0,H=0;function Y(){if(H>0)return H--,P>>H&1;if(P=S[k++],P==255){var Ce=S[k++];if(Ce)throw new Error("unexpected marker: "+(P<<8|Ce).toString(16))}return H=7,P>>>7}o(Y,"readBit");function K(Ce){for(var xt=Ce,Ft;(Ft=Y())!==null;){if(xt=xt[Ft],typeof xt=="number")return xt;if(typeof xt!="object")throw new Error("invalid huffman sequence")}return null}o(K,"decodeHuffman");function j(Ce){for(var xt=0;Ce>0;){var Ft=Y();if(Ft===null)return;xt=xt<<1|Ft,Ce--}return xt}o(j,"receive");function ee(Ce){var xt=j(Ce);return xt>=1<<Ce-1?xt:xt+(-1<<Ce)+1}o(ee,"receiveAndExtend");function ge(Ce,xt){var Ft=K(Ce.huffmanTableDC),ct=Ft===0?0:ee(Ft);xt[0]=Ce.pred+=ct;for(var un=1;un<64;){var jt=K(Ce.huffmanTableAC),Pt=jt&15,ae=jt>>4;if(Pt===0){if(ae<15)break;un+=16;continue}un+=ae;var $e=t[un];xt[$e]=ee(Pt),un++}}o(ge,"decodeBaseline");function be(Ce,xt){var Ft=K(Ce.huffmanTableDC),ct=Ft===0?0:ee(Ft)<<q;xt[0]=Ce.pred+=ct}o(be,"decodeDCFirst");function le(Ce,xt){xt[0]|=Y()<<q}o(le,"decodeDCSuccessive");var Se=0;function ke(Ce,xt){if(Se>0){Se--;return}for(var Ft=R,ct=Z;Ft<=ct;){var un=K(Ce.huffmanTableAC),jt=un&15,Pt=un>>4;if(jt===0){if(Pt<15){Se=j(Pt)+(1<<Pt)-1;break}Ft+=16;continue}Ft+=Pt;var ae=t[Ft];xt[ae]=ee(jt)*(1<<q),Ft++}}o(ke,"decodeACFirst");var ce=0,ue;function nt(Ce,xt){for(var Ft=R,ct=Z,un=0;Ft<=ct;){var jt=t[Ft],Pt=xt[jt]<0?-1:1;switch(ce){case 0:var ae=K(Ce.huffmanTableAC),$e=ae&15,un=ae>>4;if($e===0)un<15?(Se=j(un)+(1<<un),ce=4):(un=16,ce=1);else{if($e!==1)throw new Error("invalid ACn encoding");ue=ee($e),ce=un?2:3}continue;case 1:case 2:xt[jt]?xt[jt]+=(Y()<<q)*Pt:(un--,un===0&&(ce=ce==2?3:0));break;case 3:xt[jt]?xt[jt]+=(Y()<<q)*Pt:(xt[jt]=ue<<q,ce=0);break;case 4:xt[jt]&&(xt[jt]+=(Y()<<q)*Pt);break}Ft++}ce===4&&(Se--,Se===0&&(ce=0))}o(nt,"decodeACSuccessive");function ze(Ce,xt,Ft,ct,un){var jt=Ft/B|0,Pt=Ft%B,ae=jt*Ce.v+ct,$e=Pt*Ce.h+un;Ce.blocks[ae]===void 0&&N.tolerantDecoding||xt(Ce,Ce.blocks[ae][$e])}o(ze,"decodeMcu");function et(Ce,xt,Ft){var ct=Ft/Ce.blocksPerLine|0,un=Ft%Ce.blocksPerLine;Ce.blocks[ct]===void 0&&N.tolerantDecoding||xt(Ce,Ce.blocks[ct][un])}o(et,"decodeBlock");var Ae=E.length,xe,ie,De,we,st,qe;T?R===0?qe=G===0?be:le:qe=G===0?ke:nt:qe=ge;var Me=0,ht,tt;Ae==1?tt=E[0].blocksPerLine*E[0].blocksPerColumn:tt=B*w.mcusPerColumn,I||(I=tt);for(var He,pt;Me<tt;){for(ie=0;ie<Ae;ie++)E[ie].pred=0;if(Se=0,Ae==1)for(xe=E[0],st=0;st<I;st++)et(xe,qe,Me),Me++;else for(st=0;st<I;st++){for(ie=0;ie<Ae;ie++)for(xe=E[ie],He=xe.h,pt=xe.v,De=0;De<pt;De++)for(we=0;we<He;we++)ze(xe,qe,Me,De,we);if(Me++,Me===tt)break}if(Me===tt)do{if(S[k]===255&&S[k+1]!==0)break;k+=1}while(k<S.length-2);if(H=0,ht=S[k]<<8|S[k+1],ht<65280)throw new Error("marker was not found");if(ht>=65488&&ht<=65495)k+=2;else break}return k-M}o(m,"decodeScan");function f(S,k){var w=[],E=k.blocksPerLine,I=k.blocksPerColumn,R=E<<3,Z=new Int32Array(64),G=new Uint8Array(64);function q(M,P,H){var Y=k.quantizationTable,K,j,ee,ge,be,le,Se,ke,ce,ue=H,nt;for(nt=0;nt<64;nt++)ue[nt]=M[nt]*Y[nt];for(nt=0;nt<8;++nt){var ze=8*nt;if(ue[1+ze]==0&&ue[2+ze]==0&&ue[3+ze]==0&&ue[4+ze]==0&&ue[5+ze]==0&&ue[6+ze]==0&&ue[7+ze]==0){ce=c*ue[0+ze]+512>>10,ue[0+ze]=ce,ue[1+ze]=ce,ue[2+ze]=ce,ue[3+ze]=ce,ue[4+ze]=ce,ue[5+ze]=ce,ue[6+ze]=ce,ue[7+ze]=ce;continue}K=c*ue[0+ze]+128>>8,j=c*ue[4+ze]+128>>8,ee=ue[2+ze],ge=ue[6+ze],be=u*(ue[1+ze]-ue[7+ze])+128>>8,ke=u*(ue[1+ze]+ue[7+ze])+128>>8,le=ue[3+ze]<<4,Se=ue[5+ze]<<4,ce=K-j+1>>1,K=K+j+1>>1,j=ce,ce=ee*l+ge*a+128>>8,ee=ee*a-ge*l+128>>8,ge=ce,ce=be-Se+1>>1,be=be+Se+1>>1,Se=ce,ce=ke+le+1>>1,le=ke-le+1>>1,ke=ce,ce=K-ge+1>>1,K=K+ge+1>>1,ge=ce,ce=j-ee+1>>1,j=j+ee+1>>1,ee=ce,ce=be*s+ke*i+2048>>12,be=be*i-ke*s+2048>>12,ke=ce,ce=le*r+Se*n+2048>>12,le=le*n-Se*r+2048>>12,Se=ce,ue[0+ze]=K+ke,ue[7+ze]=K-ke,ue[1+ze]=j+Se,ue[6+ze]=j-Se,ue[2+ze]=ee+le,ue[5+ze]=ee-le,ue[3+ze]=ge+be,ue[4+ze]=ge-be}for(nt=0;nt<8;++nt){var et=nt;if(ue[8+et]==0&&ue[16+et]==0&&ue[24+et]==0&&ue[32+et]==0&&ue[40+et]==0&&ue[48+et]==0&&ue[56+et]==0){ce=c*H[nt+0]+8192>>14,ue[0+et]=ce,ue[8+et]=ce,ue[16+et]=ce,ue[24+et]=ce,ue[32+et]=ce,ue[40+et]=ce,ue[48+et]=ce,ue[56+et]=ce;continue}K=c*ue[0+et]+2048>>12,j=c*ue[32+et]+2048>>12,ee=ue[16+et],ge=ue[48+et],be=u*(ue[8+et]-ue[56+et])+2048>>12,ke=u*(ue[8+et]+ue[56+et])+2048>>12,le=ue[24+et],Se=ue[40+et],ce=K-j+1>>1,K=K+j+1>>1,j=ce,ce=ee*l+ge*a+2048>>12,ee=ee*a-ge*l+2048>>12,ge=ce,ce=be-Se+1>>1,be=be+Se+1>>1,Se=ce,ce=ke+le+1>>1,le=ke-le+1>>1,ke=ce,ce=K-ge+1>>1,K=K+ge+1>>1,ge=ce,ce=j-ee+1>>1,j=j+ee+1>>1,ee=ce,ce=be*s+ke*i+2048>>12,be=be*i-ke*s+2048>>12,ke=ce,ce=le*r+Se*n+2048>>12,le=le*n-Se*r+2048>>12,Se=ce,ue[0+et]=K+ke,ue[56+et]=K-ke,ue[8+et]=j+Se,ue[48+et]=j-Se,ue[16+et]=ee+le,ue[40+et]=ee-le,ue[24+et]=ge+be,ue[32+et]=ge-be}for(nt=0;nt<64;++nt){var Ae=128+(ue[nt]+8>>4);P[nt]=Ae<0?0:Ae>255?255:Ae}}o(q,"quantizeAndInverse"),x(R*I*8);for(var N,V,Q=0;Q<I;Q++){var C=Q<<3;for(N=0;N<8;N++)w.push(new Uint8Array(R));for(var B=0;B<E;B++){q(k.blocks[Q][B],G,Z);var T=0,A=B<<3;for(V=0;V<8;V++){var $=w[C+V];for(N=0;N<8;N++)$[A+N]=G[T++]}}}return w}o(f,"buildComponentData");function g(S){return S<0?0:S>255?255:S}o(g,"clampTo8bit"),d.prototype={load:o(function(k){var w=new XMLHttpRequest;w.open("GET",k,!0),w.responseType="arraybuffer",w.onload=(function(){var E=new Uint8Array(w.response||w.mozResponseArrayBuffer);this.parse(E),this.onload&&this.onload()}).bind(this),w.send(null)},"load"),parse:o(function(k){var w=this.opts.maxResolutionInMP*1e3*1e3,E=0,I=k.length;function R(){var ae=k[E]<<8|k[E+1];return E+=2,ae}o(R,"readUint16");function Z(){var ae=R(),$e=k.subarray(E,E+ae-2);return E+=$e.length,$e}o(Z,"readDataBlock");function G(ae){var $e=1,We=1,rt,Tt;for(Tt in ae.components)ae.components.hasOwnProperty(Tt)&&(rt=ae.components[Tt],$e<rt.h&&($e=rt.h),We<rt.v&&(We=rt.v));var Ze=Math.ceil(ae.samplesPerLine/8/$e),Qt=Math.ceil(ae.scanLines/8/We);for(Tt in ae.components)if(ae.components.hasOwnProperty(Tt)){rt=ae.components[Tt];var Kt=Math.ceil(Math.ceil(ae.samplesPerLine/8)*rt.h/$e),dn=Math.ceil(Math.ceil(ae.scanLines/8)*rt.v/We),Ot=Ze*rt.h,kr=Qt*rt.v,Ir=kr*Ot,Bi=[];x(Ir*256);for(var hi=0;hi<kr;hi++){for(var nr=[],zi=0;zi<Ot;zi++)nr.push(new Int32Array(64));Bi.push(nr)}rt.blocksPerLine=Kt,rt.blocksPerColumn=dn,rt.blocks=Bi}ae.maxH=$e,ae.maxV=We,ae.mcusPerLine=Ze,ae.mcusPerColumn=Qt}o(G,"prepareComponents");var q=null,N=null,V=null,Q,C,B=[],T=[],A=[],$=[],M=R(),P=-1;if(this.comments=[],M!=65496)throw new Error("SOI not found");for(M=R();M!=65497;){var H,Y,K;switch(M){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var j=Z();if(M===65534){var ee=String.fromCharCode.apply(null,j);this.comments.push(ee)}M===65504&&j[0]===74&&j[1]===70&&j[2]===73&&j[3]===70&&j[4]===0&&(q={version:{major:j[5],minor:j[6]},densityUnits:j[7],xDensity:j[8]<<8|j[9],yDensity:j[10]<<8|j[11],thumbWidth:j[12],thumbHeight:j[13],thumbData:j.subarray(14,14+3*j[12]*j[13])}),M===65505&&j[0]===69&&j[1]===120&&j[2]===105&&j[3]===102&&j[4]===0&&(this.exifBuffer=j.subarray(5,j.length)),M===65518&&j[0]===65&&j[1]===100&&j[2]===111&&j[3]===98&&j[4]===101&&j[5]===0&&(N={version:j[6],flags0:j[7]<<8|j[8],flags1:j[9]<<8|j[10],transformCode:j[11]});break;case 65499:for(var ge=R(),be=ge+E-2;E<be;){var le=k[E++];x(256);var Se=new Int32Array(64);if(le>>4===0)for(Y=0;Y<64;Y++){var ke=t[Y];Se[ke]=k[E++]}else if(le>>4===1)for(Y=0;Y<64;Y++){var ke=t[Y];Se[ke]=R()}else throw new Error("DQT: invalid table spec");B[le&15]=Se}break;case 65472:case 65473:case 65474:R(),Q={},Q.extended=M===65473,Q.progressive=M===65474,Q.precision=k[E++],Q.scanLines=R(),Q.samplesPerLine=R(),Q.components={},Q.componentsOrder=[];var ce=Q.scanLines*Q.samplesPerLine;if(ce>w){var ue=Math.ceil((ce-w)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${ue}MP`)}var nt=k[E++],ze,et=0,Ae=0;for(H=0;H<nt;H++){ze=k[E];var xe=k[E+1]>>4,ie=k[E+1]&15,De=k[E+2];if(xe<=0||ie<=0)throw new Error("Invalid sampling factor, expected values above 0");Q.componentsOrder.push(ze),Q.components[ze]={h:xe,v:ie,quantizationIdx:De},E+=3}G(Q),T.push(Q);break;case 65476:var we=R();for(H=2;H<we;){var st=k[E++],qe=new Uint8Array(16),Me=0;for(Y=0;Y<16;Y++,E++)Me+=qe[Y]=k[E];x(16+Me);var ht=new Uint8Array(Me);for(Y=0;Y<Me;Y++,E++)ht[Y]=k[E];H+=17+Me,(st>>4===0?$:A)[st&15]=p(qe,ht)}break;case 65501:R(),C=R();break;case 65500:R(),R();break;case 65498:var tt=R(),He=k[E++],pt=[],Ce;for(H=0;H<He;H++){Ce=Q.components[k[E++]];var xt=k[E++];Ce.huffmanTableDC=$[xt>>4],Ce.huffmanTableAC=A[xt&15],pt.push(Ce)}var Ft=k[E++],ct=k[E++],un=k[E++],jt=m(k,E,Q,pt,C,Ft,ct,un>>4,un&15,this.opts);E+=jt;break;case 65535:k[E]!==255&&E--;break;default:if(k[E-3]==255&&k[E-2]>=192&&k[E-2]<=254){E-=3;break}else if(M===224||M==225){if(P!==-1)throw new Error(`first unknown JPEG marker at offset ${P.toString(16)}, second unknown JPEG marker ${M.toString(16)} at offset ${(E-1).toString(16)}`);P=E-1;let ae=R();if(k[E+ae-2]===255){E+=ae-2;break}}throw new Error("unknown JPEG marker "+M.toString(16))}M=R()}if(T.length!=1)throw new Error("only single frame JPEGs supported");for(var H=0;H<T.length;H++){var Pt=T[H].components;for(var Y in Pt)Pt[Y].quantizationTable=B[Pt[Y].quantizationIdx],delete Pt[Y].quantizationIdx}this.width=Q.samplesPerLine,this.height=Q.scanLines,this.jfif=q,this.adobe=N,this.components=[];for(var H=0;H<Q.componentsOrder.length;H++){var Ce=Q.components[Q.componentsOrder[H]];this.components.push({lines:f(Q,Ce),scaleX:Ce.h/Q.maxH,scaleY:Ce.v/Q.maxV})}},"parse"),getData:o(function(k,w){var E=this.width/k,I=this.height/w,R,Z,G,q,N,V,Q,C,B,T,A=0,$,M,P,H,Y,K,j,ee,ge,be,le,Se=k*w*this.components.length;x(Se);var ke=new Uint8Array(Se);switch(this.components.length){case 1:for(R=this.components[0],T=0;T<w;T++)for(N=R.lines[0|T*R.scaleY*I],B=0;B<k;B++)$=N[0|B*R.scaleX*E],ke[A++]=$;break;case 2:for(R=this.components[0],Z=this.components[1],T=0;T<w;T++)for(N=R.lines[0|T*R.scaleY*I],V=Z.lines[0|T*Z.scaleY*I],B=0;B<k;B++)$=N[0|B*R.scaleX*E],ke[A++]=$,$=V[0|B*Z.scaleX*E],ke[A++]=$;break;case 3:for(le=!0,this.adobe&&this.adobe.transformCode?le=!0:typeof this.opts.colorTransform<"u"&&(le=!!this.opts.colorTransform),R=this.components[0],Z=this.components[1],G=this.components[2],T=0;T<w;T++)for(N=R.lines[0|T*R.scaleY*I],V=Z.lines[0|T*Z.scaleY*I],Q=G.lines[0|T*G.scaleY*I],B=0;B<k;B++)le?($=N[0|B*R.scaleX*E],M=V[0|B*Z.scaleX*E],P=Q[0|B*G.scaleX*E],ee=g($+1.402*(P-128)),ge=g($-.3441363*(M-128)-.71413636*(P-128)),be=g($+1.772*(M-128))):(ee=N[0|B*R.scaleX*E],ge=V[0|B*Z.scaleX*E],be=Q[0|B*G.scaleX*E]),ke[A++]=ee,ke[A++]=ge,ke[A++]=be;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(le=!1,this.adobe&&this.adobe.transformCode?le=!0:typeof this.opts.colorTransform<"u"&&(le=!!this.opts.colorTransform),R=this.components[0],Z=this.components[1],G=this.components[2],q=this.components[3],T=0;T<w;T++)for(N=R.lines[0|T*R.scaleY*I],V=Z.lines[0|T*Z.scaleY*I],Q=G.lines[0|T*G.scaleY*I],C=q.lines[0|T*q.scaleY*I],B=0;B<k;B++)le?($=N[0|B*R.scaleX*E],M=V[0|B*Z.scaleX*E],P=Q[0|B*G.scaleX*E],H=C[0|B*q.scaleX*E],Y=255-g($+1.402*(P-128)),K=255-g($-.3441363*(M-128)-.71413636*(P-128)),j=255-g($+1.772*(M-128))):(Y=N[0|B*R.scaleX*E],K=V[0|B*Z.scaleX*E],j=Q[0|B*G.scaleX*E],H=C[0|B*q.scaleX*E]),ke[A++]=255-Y,ke[A++]=255-K,ke[A++]=255-j,ke[A++]=255-H;break;default:throw new Error("Unsupported color mode")}return ke},"getData"),copyToImageData:o(function(k,w){var E=k.width,I=k.height,R=k.data,Z=this.getData(E,I),G=0,q=0,N,V,Q,C,B,T,A,$,M;switch(this.components.length){case 1:for(V=0;V<I;V++)for(N=0;N<E;N++)Q=Z[G++],R[q++]=Q,R[q++]=Q,R[q++]=Q,w&&(R[q++]=255);break;case 3:for(V=0;V<I;V++)for(N=0;N<E;N++)A=Z[G++],$=Z[G++],M=Z[G++],R[q++]=A,R[q++]=$,R[q++]=M,w&&(R[q++]=255);break;case 4:for(V=0;V<I;V++)for(N=0;N<E;N++)B=Z[G++],T=Z[G++],Q=Z[G++],C=Z[G++],A=255-g(B*(1-C/255)+C),$=255-g(T*(1-C/255)+C),M=255-g(Q*(1-C/255)+C),R[q++]=A,R[q++]=$,R[q++]=M,w&&(R[q++]=255);break;default:throw new Error("Unsupported color mode")}},"copyToImageData")};var y=0,v=0;function x(S=0){var k=y+S;if(k>v){var w=Math.ceil((k-v)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${w}MB`)}y=k}return o(x,"requestMemoryAllocation"),d.resetMaxMemoryUsage=function(S){y=0,v=S},d.getBytesAllocated=function(){return y},d.requestMemoryAllocation=x,d}),"jpegImage")();typeof kV<"u"?kV.exports=abe:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].decode=abe);function abe(e,t={}){var n={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512},r={...n,...t},i=new Uint8Array(e),s=new SV;s.opts=r,SV.resetMaxMemoryUsage(r.maxMemoryUsageInMB*1024*1024),s.parse(i);var a=r.formatAsRGBA?4:3,l=s.width*s.height*a;try{SV.requestMemoryAllocation(l);var c={width:s.width,height:s.height,exifBuffer:s.exifBuffer,data:r.useTArray?new Uint8Array(l):Buffer.alloc(l)};s.comments.length>0&&(c.comments=s.comments)}catch(u){throw u instanceof RangeError?new Error("Could not allocate enough memory for the image. Required: "+l):u instanceof ReferenceError&&u.message==="Buffer is not defined"?new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"):u}return s.copyToImageData(c,r.formatAsRGBA),c}o(abe,"decode")});var cbe=ye((Okn,lbe)=>{var $ht=sbe(),Nht=obe();lbe.exports={encode:$ht,decode:Nht}});function Mbe(e,t){let n=0,r=0,s=o(a=>{let l;for(let[c,u]of a.entries()){let d=u;if(u.type==="image"){if(n===t[r]){if(u.offloaded===!0)throw new Error(`image/offload: image index ${n} is already offloaded`);d={...u,offloaded:!0},r+=1}n+=1}d!==u&&(l??=a.slice(0,c)),l?.push(d)}return l??a},"visit")(e.content);if(r!==t.length)throw new Error(`image/offload: image index ${t[r]} does not exist`);return cn({...e,content:s})}var Lbe=oe(()=>{Vi();o(Mbe,"offloadMessageImages")});function jbe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fbe(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0&&!Object.is(e,-0)}var fC,LV=oe(()=>{Lbe();o(jbe,"isRecord");o(Fbe,"isIndex");fC={type:"image/offload",project(e,t){let n=e.data;if(!jbe(n)||Object.keys(n).length!==1||!Array.isArray(n.targets)||n.targets.length===0)throw new Error("image/offload: data must contain a nonempty targets array");let r=new Map,i=new Set(t.nodes);for(let s of n.targets){if(!jbe(s)||Object.keys(s).length!==2||!Fbe(s.seq)||!Array.isArray(s.imageIndexes)||s.imageIndexes.length===0)throw new Error("image/offload: each target must contain a seq and nonempty imageIndexes");let a=s.seq;if(r.has(a))throw new Error(`image/offload: duplicate target seq ${a}`);if(!i.has(a))throw new Error(`image/offload: target seq ${a} is not a current surface node`);let l=t.events[a-t.baseSeq];if(l?.type!=="user/message"&&l?.type!=="tool/result")throw new Error(`image/offload: target seq ${a} must be user/message or tool/result`);let c=-1;for(let d of s.imageIndexes){if(!Fbe(d)||d<=c)throw new Error("image/offload: imageIndexes must be strictly increasing non-negative safe integers");c=d}let u=t.messages.get(a)??(l.type==="user/message"?l.data:l.data.message);r.set(a,Mbe(u,s.imageIndexes))}return r}}});var IC,iwe=oe(()=>{LV();IC=[fC]});async function dwe(e,t,n){let r=n===void 0?void 0:{signal:n},i=await e.open(t,"read",r),s;try{s=await i.read(0,void 0,r)}catch(l){try{await i.close()}catch{}throw l}await i.close();let{events:a}=s;return{eventState:s.eventState,header:i.header,inheritedEventCount:i.inheritedEventCount,events:[...a,...t4(a)]}}function bG(e,t){if(e.id!==t.id||e.createdAt!==t.createdAt||e.cwd!==t.cwd||e.parentSession!==t.parentSession||e.isSeeded!==t.isSeeded||(e.delegationDepth??0)!==(t.delegationDepth??0))throw new wr(`session source headers conflict for session "${e.id}"`,"SESSION_QUERY_SOURCE_CONFLICT")}function CC(e,t,n,r){try{r?.throwIfAborted();let i=n(t);return r?.throwIfAborted(),{sessionId:e,status:"fulfilled",value:i}}catch(i){return r?.aborted&&r.throwIfAborted(),{sessionId:e,status:"rejected",reason:i}}}function xG(e){return{header:e.header,events:e.snapshotEvents()}}function RC(e,t){return e.map(n=>t.get(n))}async function wG(e,t){try{return(await e.list(t===void 0?void 0:{signal:t})).map(n=>n.header)}catch(n){throw t?.aborted&&t.throwIfAborted(),new wr(`session persistence listing failed: ${EG(n)}`,"SESSION_QUERY_PERSISTENCE_FAILED",{cause:n})}}async function swe(e,t,n){try{return await dwe(e,t,n)}catch(r){throw n?.aborted&&n.throwIfAborted(),r instanceof Error&&r.name==="SessionPersistenceCorruptionError"?new wr(`stored session "${t}" is corrupt: ${EG(r)}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:r}):new wr(`failed to read stored session "${t}": ${EG(r)}`,"SESSION_QUERY_PERSISTENCE_FAILED",{cause:r})}}function awe(e){return{header:structuredClone(e.header),inheritedEventCount:e.inheritedEventCount,events:e.snapshotEvents().map(t=>structuredClone(t))}}function dyt(e,t){return t.header.createdAt-e.header.createdAt||e.header.id.localeCompare(t.header.id)}function OC(e){return new wr(`session "${e}" not found`,"SESSION_QUERY_SESSION_NOT_FOUND")}function EG(e){return e instanceof Error?e.message:"unknown error"}function xk(e){if(e?.aborted===!0)throw new wr("session observation was aborted","SESSION_QUERY_ABORTED",{cause:e.reason})}function owe(e,t){return lwe(t,"SessionPersistenceNotFoundError")?_G(e,t):lwe(t,"SessionPersistenceCorruptionError")?new wr(`stored session "${e}" is corrupt: ${t.message}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:t}):new wr(`failed to observe session "${e}": ${$C(t)}`,"SESSION_QUERY_PERSISTENCE_FAILED",{cause:t})}function _G(e,t){return new wr(`session "${e}" not found`,"SESSION_QUERY_SESSION_NOT_FOUND",t===void 0?void 0:{cause:t})}function $C(e){return e instanceof Error?e.message:"unknown error"}function lwe(e,t){return e instanceof Error&&e.name===t}function fyt(e){switch(e.type){case"user/message":return SG(e.data.content);case"assistant/message":return SG(e.data.message.content);case"tool/call":return wk([e.data.name,e.data.arguments]);case"tool/result":return wk([SG(e.data.message.content),e.data.error?.name??"",e.data.error?.code??""]);case"todo/write":return wk(e.data.todos.flatMap(t=>[t.status,t.content]));case"turn/end":return hyt(e.data.reason);case"turn/start":case"step/start":case"step/end":case"assistant/attempt":case"request/header":return"";default:return""}}function hyt(e){switch(e.kind){case"error":return wk(["error",e.error.message]);case"aborted":return"aborted";case"max-tokens":case"interrupted":return e.kind;case"completed":return"";default:return""}}function SG(e){return wk(e.flatMap(myt))}function myt(e){switch(e.type){case"text":return[e.text];case"reasoning":return[];case"tool-call":return[e.name,e.arguments];default:return[]}}function wk(e){return e.map(t=>t.trim()).filter(Boolean).join(`
|
|
157
157
|
`)}function AG(e,t){let n=gyt(t),r=[];for(let i of t){let s=fyt(i);s.length!==0&&r.push({sessionId:e,seq:i.seq,type:i.type,time:i.time,surface:n.get(i.seq)??"log-only",text:s})}return r}function gyt(e){let t;try{t=U9(e,IC)}catch(r){throw new wr(`invalid session surface: ${r instanceof Error?r.message:"unknown error"}`,"SESSION_QUERY_INVALID_SURFACE",{cause:r})}let n=new Map;for(let r of t.nodes)n.set(r,"current");for(let r of t.replacements)for(let i of r.shadowedSeqs)n.set(i,"shadowed");return n}function IG(e,t=[]){let n=t.map(vyt);return e.filter(r=>n.every(i=>i(r)))}function MC(e,t=[]){let n=t.map(byt);return e.filter(r=>n.every(i=>i(r)))}function CG(e){return pwe(e),e.map(t=>{switch(t.kind){case"id":return{kind:t.kind,values:PC(t.kind,t.values)};case"cwd":return{kind:t.kind,values:cwe(t.kind,t.values)};case"created-at":return fwe(t.kind,t);case"parent":return{kind:t.kind,values:cwe(t.kind,t.values)};case"availability":{let n=PC(t.kind,t.values);return FC(t.kind,n,["live","persisted"]),{kind:t.kind,values:n}}default:return jC(t)}})}function LC(e){return pwe(e),e.map(t=>{switch(t.kind){case"seq":case"time":return fwe(t.kind,t);case"type":return{kind:t.kind,values:PC(t.kind,t.values)};case"surface":{let n=PC(t.kind,t.values);return FC(t.kind,n,["current","shadowed","log-only"]),{kind:t.kind,values:n}}case"text":if(typeof t.text!="string")throw _2("text filter text must be a string");return{kind:t.kind,text:t.text};default:return jC(t)}})}function yyt(e){let t=e.trim();if(t.length===0)throw new wr("session text filter must contain non-whitespace text","SESSION_QUERY_INVALID_FILTER");let n=t.split(/\s+/u).map(r=>r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("\\s+");return new RegExp(n,"iu")}function vyt(e){switch(e.kind){case"id":return t=>e.values.includes(t.header.id);case"cwd":return t=>e.values.includes(t.header.cwd??null);case"created-at":{let t=DC(e.kind,e);return n=>TG(n.header.createdAt,t)}case"parent":return t=>e.values.includes(t.header.parentSession??null);case"availability":return FC(e.kind,e.values,["live","persisted"]),t=>e.values.some(n=>n==="live"?t.live:t.persisted);default:return jC(e)}}function byt(e){switch(e.kind){case"seq":{let t=DC(e.kind,e);return n=>TG(n.seq,t)}case"time":{let t=DC(e.kind,e);return n=>TG(n.time,t)}case"type":return t=>e.values.includes(t.type);case"surface":return FC(e.kind,e.values,["current","shadowed","log-only"]),t=>e.values.includes(t.surface);case"text":{let t=yyt(e.text);return n=>t.test(n.text)}default:return jC(e)}}function PC(e,t){if(!hwe(t)||t.some(n=>typeof n!="string"))throw _2(`${e} filter values must be an array of strings`);return[...t]}function pwe(e){if(!Array.isArray(e))throw _2("filters must be an array")}function cwe(e,t){if(!hwe(t)||t.some(n=>n!==null&&typeof n!="string"))throw _2(`${e} filter values must be an array of strings or null`);return[...t]}function fwe(e,t){let n={kind:e,...t.from===void 0?{}:{from:t.from},...t.to===void 0?{}:{to:t.to}};return DC(e,n),n}function jC(e){let t=e.kind;throw _2(`unknown filter kind ${typeof t=="string"?`"${t}"`:"(missing)"}`)}function FC(e,t,n){for(let r of t)if(!n.includes(r))throw new wr(`session ${e} filter contains unknown value "${r}"`,"SESSION_QUERY_INVALID_FILTER")}function DC(e,t){if(t.from!==void 0&&!Number.isFinite(t.from))throw kG(e,"from must be finite");if(t.to!==void 0&&!Number.isFinite(t.to))throw kG(e,"to must be finite");if(t.from!==void 0&&t.to!==void 0&&t.from>t.to)throw kG(e,"from must be less than or equal to to");return t}function TG(e,t){return(t.from===void 0||e>=t.from)&&(t.to===void 0||e<=t.to)}function kG(e,t){return _2(`${e} filter ${t}`)}function _2(e){return new wr(`session ${e}`,"SESSION_QUERY_INVALID_FILTER")}function hwe(e){return Array.isArray(e)}function xyt(e,t){return RG(e,t).records}function wyt(e,t){return RG(e,t).currentSeqs.map(n=>{let r=t[n];if(r===void 0||r.seq!==n||!jh(r))throw new wr(`invalid session surface: current node ${n} is not a surface event`,"SESSION_QUERY_INVALID_SURFACE");return cw(r)})}function Syt(e,t,n){let r=t[n];if(r===void 0||r.seq!==n)throw new wr(`session "${e}" has no event at seq ${n}`,"SESSION_QUERY_EVENT_NOT_FOUND");let i=RG(e,t),s=[],a=i.replacedBy.get(n);for(;a!==void 0;)s.push(a),a=i.replacedBy.get(a);let l=[];for(let d of t)d.seq<=n||uwe(d).includes(n)&&l.push(d.seq);let c=i.records[n],u=i.replacedBy.get(n);return{target:c,...u===void 0?{}:{replacedBy:u},replacementChain:s,replacedEventSeqs:i.replacedEventSeqs.get(n)??[],sourceEventSeqs:[...uwe(r)],derivedEventSeqs:l}}function kyt(e,t){let n=new Map(e.map(p=>[p.header.id,p])),r=n.get(t);if(r===void 0)throw new wr(`session "${t}" not found`,"SESSION_QUERY_SESSION_NOT_FOUND");let i=[],s=new Set([t]),a,l=r.header.parentSession;for(;l!==void 0;){if(s.has(l))throw new wr(`session lineage contains a cycle at "${l}"`,"SESSION_QUERY_INVALID_LINEAGE");s.add(l);let p=n.get(l);if(p===void 0){a=l;break}i.push(p),l=p.header.parentSession}let c=new Map;for(let p of e){let m=p.header.parentSession;if(m===void 0)continue;let f=c.get(m)??[];f.push(p),c.set(m,f)}for(let p of c.values())p.sort((m,f)=>m.header.createdAt-f.header.createdAt||m.header.id.localeCompare(f.header.id));let u=Eyt(c,t),d={target:NC(r),ancestors:i.map(NC),descendants:u};return a!==void 0?{...d,complete:!1,unresolvedParentId:a}:{...d,complete:!0,root:NC(i.at(-1)??r)}}function RG(e,t){let n;try{n=U9(t,IC)}catch(a){throw new wr(`invalid session surface: ${a instanceof Error?a.message:"unknown error"}`,"SESSION_QUERY_INVALID_SURFACE",{cause:a})}let r=new Set(n.nodes),i=new Map,s=new Map;for(let a of n.replacements){let l=a.shadowedSeqs;s.set(a.seq,l);for(let c of l)i.set(c,a.seq)}return{records:t.map(a=>({sessionId:e,seq:a.seq,type:a.type,time:a.time,surface:r.has(a.seq)?"current":i.has(a.seq)?"shadowed":"log-only"})),replacedBy:i,replacedEventSeqs:s,currentSeqs:[...n.nodes]}}function uwe(e){return e.sourceEventSeqs??[]}function Eyt(e,t){let n=[],r=[{sessionId:t,descendants:n}];for(;r.length>0;){let i=r.pop(),s=[];for(let a of e.get(i.sessionId)??[]){let l={session:NC(a),descendants:[]};s.push(l),i.descendants.push(l)}for(let a=s.length-1;a>=0;a-=1){let l=s[a];r.push({sessionId:l.session.header.id,descendants:l.descendants})}}return n}function NC(e){return{...e,header:structuredClone(e.header)}}var wr,uyt,pyt,mwe,OG=oe(()=>{iwe();Fn();_s();im();yr();wr=class extends qr{static{o(this,"SessionQueryError")}constructor(e,t,n){super(e,t,n)}};o(dwe,"readColdSessionLog");o(bG,"assertSessionHeadersCompatible");uyt=class{static{o(this,"SessionCorpus")}_ctx;_persistedReadConcurrency;_persistence;_optionalPersistenceFiber;constructor(e,t){this._ctx=e,this._persistedReadConcurrency=t,this._optionalPersistenceFiber=e.inject(["sessionPersistence"],n=>{let r=n.sessionPersistence;this._persistence=r,n.effect(()=>()=>{this._persistence===r&&(this._persistence=void 0)},"sessionQuery.persistenceBinding")}),e.effect(()=>()=>this._optionalPersistenceFiber.dispose(),"sessionQuery.optionalPersistence")}async listSessions(e){e?.throwIfAborted();let t=this._persistence,n=t===void 0?[]:await wG(t,e);e?.throwIfAborted();let r=new Map;for(let i of n)r.set(i.id,{header:structuredClone(i),live:!1,persisted:!0});for(let i of this._ctx.sessions.list()){let s=r.get(i.id);s!==void 0&&bG(i.header,s.header),r.set(i.id,{header:structuredClone(i.header),live:!0,persisted:s!==void 0})}return[...r.values()].sort(dyt)}async load(e,t){t?.throwIfAborted();let n=this._ctx.sessions.get(e);if(n!==void 0){let c=awe(n);return t?.throwIfAborted(),c}let r=this._persistence;if(r===void 0)throw OC(e);let i=(await wG(r,t)).find(c=>c.id===e);if(t?.throwIfAborted(),i===void 0)throw OC(e);let s=await swe(r,e,t);t?.throwIfAborted();let a=this._ctx.sessions.get(e);if(a!==void 0){let c=awe(a);return t?.throwIfAborted(),c}bG(s.header,i);let l={header:structuredClone(s.header),inheritedEventCount:s.inheritedEventCount,events:s.events.map(c=>structuredClone(c))};return t?.throwIfAborted(),l}async projectMany(e,t,n){let r=[...new Set(e)];n?.throwIfAborted();let i=new Map,s=[];for(let g of r){let y=this._ctx.sessions.get(g);y===void 0?s.push(g):i.set(g,CC(g,xG(y),t,n))}if(s.length===0)return RC(r,i);let a=this._persistence;if(a===void 0){for(let g of s)i.set(g,{sessionId:g,status:"rejected",reason:OC(g)});return RC(r,i)}let l;try{l=await wG(a,n),n?.throwIfAborted()}catch(g){n?.aborted&&n.throwIfAborted();for(let y of s)i.set(y,{sessionId:y,status:"rejected",reason:g});return RC(r,i)}let c=new Map(l.map(g=>[g.id,g])),u=o(async g=>{let y=c.get(g);if(y===void 0){let v=this._ctx.sessions.get(g);i.set(g,v===void 0?{sessionId:g,status:"rejected",reason:OC(g)}:CC(g,xG(v),t,n));return}try{n?.throwIfAborted();let v=await swe(a,g,n);n?.throwIfAborted();let x=this._ctx.sessions.get(g);if(x!==void 0){i.set(g,CC(g,xG(x),t,n));return}bG(v.header,y),i.set(g,CC(g,{header:v.header,events:v.events},t,n))}catch(v){n?.aborted&&n.throwIfAborted(),i.set(g,{sessionId:g,status:"rejected",reason:v})}},"resolvePersisted"),d=0,p=o(async()=>{for(;;){n?.throwIfAborted();let g=d;if(g>=s.length)return;d+=1,await u(s[g])}},"worker"),m=Math.min(this._persistedReadConcurrency,s.length),f=await Promise.allSettled(Array.from({length:m},()=>p()));n?.aborted&&n.throwIfAborted();for(let g of f)if(g.status==="rejected")throw g.reason;return n?.throwIfAborted(),RC(r,i)}};o(CC,"projectSource");o(xG,"sourceLive");o(RC,"orderedResults");o(wG,"listPersisted");o(swe,"inspectPersisted");o(awe,"snapshotLive");o(dyt,"compareSessions");o(OC,"notFound$1");o(EG,"errorMessage$1");pyt=class{static{o(this,"SessionObservationReader")}ctx;cacheCapacity;cache=new Map;constructor(e,t=5){this.ctx=e,this.cacheCapacity=t}async read(e,t={}){let{signal:n,projectionMode:r="all"}=t;for(;;){xk(n);let i=this.ctx.sessions.get(e);if(i!==void 0)return this.live(i,r);let s=this.ctx.get("sessionPersistence");if(s===void 0)throw _G(e);let a=await this.statSource(s,e,n),l=this.ctx.sessions.get(e);if(l!==void 0)return this.live(l,r);let c=this.cachedEntry(s.identity,e,a.revision);if(c===void 0){let d=await this.loadSource(s,e,n);xk(n);let p=this.ctx.sessions.get(e);if(p!==void 0)return this.live(p,r);let m=d.events,f;try{f=this.ctx.sessions.prepare(e,{seed:m,meta:structuredClone(d.header),inheritedEventCount:d.inheritedEventCount,eventState:d.eventState})}catch(g){if(this.ctx.sessions.get(e)!==void 0)continue;throw new wr(`stored session "${e}" is corrupt: ${$C(g)}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:g})}c={persistenceIdentity:s.identity,revision:a.revision,session:f,events:Object.freeze(m),refs:0},this.store(e,c)}let u;try{u=r==="none"?void 0:this.preparedProjections(c)}catch(d){throw new wr(`failed to project session "${e}": ${$C(d)}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:d})}return this.preparedLease(e,c,u)}}async statSource(e,t,n){let r;try{r=await e.stat(t,n===void 0?void 0:{signal:n})}catch(i){throw xk(n),owe(t,i)}if(xk(n),r===void 0)throw _G(t);if(r.header.id!==t)throw new wr(`session persistence returned "${r.header.id}" for "${t}"`,"SESSION_QUERY_SOURCE_CONFLICT");return r}async loadSource(e,t,n){try{return await dwe(e,t,n)}catch(r){throw xk(n),owe(t,r)}}cachedEntry(e,t,n){let r=this.cache.get(t);if(!(r===void 0||r.persistenceIdentity!==e||r.revision!==n))return this.cache.delete(t),this.cache.set(t,r),r}store(e,t){this.cache.delete(e),this.cache.set(e,t),this.evictPastCapacity(t)}evictPastCapacity(e){if(!(this.cache.size<=this.cacheCapacity)){for(let[t,n]of this.cache)if(!(n===e||n.refs>0)&&(this.cache.delete(t),this.cache.size<=this.cacheCapacity))return}}preparedLease(e,t,n){t.refs+=1;let r=o(()=>{let i=!1;return{source:"prepared",header:t.session.header,inheritedEventCount:t.session.inheritedEventCount,events:t.events,cursor:t.events.at(-1)?.seq??-1,revision:t.revision,...n===void 0?{}:{projections:n},retain:o(()=>{if(i)throw new Error(`session observation "${e}" is disposed`);return t.refs+=1,r()},"retain"),[Symbol.dispose]:()=>{i||(i=!0,t.refs-=1,t.refs===0&&this.evictPastCapacity())}}},"lease");return r()}live(e,t){let n=e.seq,r,i;try{i=t==="none"?void 0:this.ctx.get("sessionProjections")?.snapshot(e)}catch(a){throw new wr(`failed to project session "${e.id}": ${$C(a)}`,"SESSION_QUERY_CORRUPT_SESSION",{cause:a})}let s=o(()=>{let a=!1;return{source:"live",header:e.header,inheritedEventCount:e.inheritedEventCount,get events(){return r??=e.snapshotEvents(wn(0),n),r},cursor:n===0?-1:en(n-1),...i===void 0?{}:{projections:i},retain:o(()=>{if(a)throw new Error(`session observation "${e.id}" is disposed`);return s()},"retain"),[Symbol.dispose]:()=>{a=!0}}},"lease");return s()}preparedProjections(e){let t=this.ctx.get("sessionProjections");if(t===void 0)return;let n=this.ctx.get("sessionProjectionCache");return n===void 0?t.hydrate(e.session,{},e.events,wn(0)):n.hydratePrepared(e.session,e.events)}};o(xk,"throwIfObservationAborted");o(owe,"mapPersistenceFailure");o(_G,"notFound");o($C,"errorMessage");o(lwe,"hasErrorName");o(fyt,"extractSessionEventText");o(hyt,"turnEndText");o(SG,"contentText");o(myt,"blockText");o(wk,"joinText");o(AG,"buildSessionEventSearchDocuments");o(gyt,"classifySurface");o(IG,"filterSessionResults");o(MC,"filterSessionEventDocuments");o(CG,"materializeSessionResultFilters");o(LC,"materializeSessionEventResultFilters");o(yyt,"compileSessionTextFilter");o(vyt,"sessionPredicate");o(byt,"eventPredicate");o(PC,"copyStrings");o(pwe,"assertArray");o(cwe,"copyNullableStrings");o(fwe,"copyRange");o(jC,"unknownFilter");o(FC,"assertAllowedValues");o(DC,"validateRange");o(TG,"matchesRange");o(kG,"invalidRange");o(_2,"invalidFilter");o(hwe,"isRuntimeArray");o(xyt,"eventRecords");o(wyt,"currentSurfaceEvents");o(Syt,"traceEvent");o(kyt,"traceSession");o(RG,"analyzeEventLog");o(uwe,"eventSources");o(Eyt,"buildDescendants");o(NC,"cloneRecord");mwe=class extends bt{static{o(this,"SessionQueryEngine")}static inject=["sessions"];_readWindowMax;_corpus;_observations;constructor(e,t={}){if(super(e,"sessionQuery"),this._readWindowMax=t.readWindowMax??50,!Number.isInteger(this._readWindowMax)||this._readWindowMax<0)throw new wr("session-query: readWindowMax must be a non-negative integer","SESSION_QUERY_INVALID_CONFIG");let n=t.persistedReadConcurrency??4;if(!Number.isSafeInteger(n)||n<1)throw new wr("session-query: persistedReadConcurrency must be a positive safe integer","SESSION_QUERY_INVALID_CONFIG");let r=t.preparedSessionCacheSize??5;if(!Number.isSafeInteger(r)||r<1)throw new wr("session-query: preparedSessionCacheSize must be a positive safe integer","SESSION_QUERY_INVALID_CONFIG");this._corpus=new uyt(e,n),this._observations=new pyt(e,r)}observeSession(e,t={}){return this._observations.read(e,t)}listSessions(e){return this._corpus.listSessions(e)}async readSession(e){let t=await this._corpus.load(e);return Hg.create(e,t.events,t.header,t.inheritedEventCount,IC),{session:structuredClone(t.header),inheritedEventCount:t.inheritedEventCount,events:t.events.map(cw)}}async filterSessions(e,t){let n=CG(e);return this._filterSessions(n,t)}async readTitle(e,t){return(await this.readTitleSnapshot(e,t)).title}async readTitleSnapshot(e,t){let n=(await this.readTitleSnapshots([e],t))[0];if(n.status==="rejected")throw n.reason;return n.value}async readTitleSnapshots(e,t){return this._corpus.projectMany(e,n=>{let r=rm(n.events);return{session:structuredClone(n.header),...r===void 0?{}:{title:r}}},t)}async listEvents(e){return xyt(e,(await this._corpus.load(e)).events)}async filterEvents(e,t){let n=LC(t);return this._filterEvents(e,n)}async _filterSessions(e,t){return IG(await this._corpus.listSessions(t),e)}async _filterEvents(e,t){return MC(AG(e,(await this._corpus.load(e)).events),t)}async readSurface(e){let t=await this._corpus.load(e);return{session:structuredClone(t.header),inheritedEventCount:t.inheritedEventCount,capturedThroughSeq:t.events.at(-1)?.seq??null,events:wyt(e,t.events)}}async traceSession(e,t){let n=await this._corpus.listSessions(t);return t?.throwIfAborted(),kyt(n,e)}async traceEvent(e,t){let n=await this._corpus.load(e.sessionId,t);return t?.throwIfAborted(),{session:n.header,...Syt(e.sessionId,n.events,e.seq)}}async readEvent(e,t){let n=this._readWindow("before",e.before),r=this._readWindow("after",e.after),i=e.sessionId,s=e.seq;return this._readEvent(i,s,n,r,t)}async _readEvent(e,t,n,r,i){let s=await this._corpus.load(e,i);i?.throwIfAborted();let a=s.events[t];if(a===void 0||a.seq!==t)throw new wr(`session "${e}" has no event at seq ${t}`,"SESSION_QUERY_EVENT_NOT_FOUND");let l=en(Math.max(0,t-n)),c=en(Math.min(s.events.length-1,t+r)),u=cw(a),d=s.events.slice(l,c+1).map(p=>p===a?u:cw(p));return{session:structuredClone(s.header),inheritedEventCount:s.inheritedEventCount,target:u,events:d,startSeq:l,endSeq:c}}_readWindow(e,t){if(t===void 0)return 0;if(!Number.isInteger(t)||t<0||t>this._readWindowMax)throw new wr(`${e} must be an integer between 0 and ${this._readWindowMax}`,"SESSION_QUERY_INVALID_WINDOW");return t}}});var T2=ye((v6n,Awe)=>{"use strict";Awe.exports=X1;X1.CAPTURING_PHASE=1;X1.AT_TARGET=2;X1.BUBBLING_PHASE=3;function X1(e,t){if(this.type="",this.target=null,this.currentTarget=null,this.eventPhase=X1.AT_TARGET,this.bubbles=!1,this.cancelable=!1,this.isTrusted=!1,this.defaultPrevented=!1,this.timeStamp=Date.now(),this._propagationStopped=!1,this._immediatePropagationStopped=!1,this._initialized=!0,this._dispatching=!1,e&&(this.type=e),t)for(var n in t)this[n]=t[n]}o(X1,"Event");X1.prototype=Object.create(Object.prototype,{constructor:{value:X1},stopPropagation:{value:o(function(){this._propagationStopped=!0},"stopPropagation")},stopImmediatePropagation:{value:o(function(){this._propagationStopped=!0,this._immediatePropagationStopped=!0},"stopImmediatePropagation")},preventDefault:{value:o(function(){this.cancelable&&(this.defaultPrevented=!0)},"preventDefault")},initEvent:{value:o(function(t,n,r){this._initialized=!0,!this._dispatching&&(this._propagationStopped=!1,this._immediatePropagationStopped=!1,this.defaultPrevented=!1,this.isTrusted=!1,this.target=null,this.type=t,this.bubbles=n,this.cancelable=r)},"initEvent")}})});var jG=ye((x6n,Cwe)=>{"use strict";var Iwe=T2();Cwe.exports=LG;function LG(){Iwe.call(this),this.view=null,this.detail=0}o(LG,"UIEvent");LG.prototype=Object.create(Iwe.prototype,{constructor:{value:LG},initUIEvent:{value:o(function(e,t,n,r,i){this.initEvent(e,t,n),this.view=r,this.detail=i},"value")}})});var UG=ye((S6n,Owe)=>{"use strict";var Rwe=jG();Owe.exports=FG;function FG(){Rwe.call(this),this.screenX=this.screenY=this.clientX=this.clientY=0,this.ctrlKey=this.altKey=this.shiftKey=this.metaKey=!1,this.button=0,this.buttons=1,this.relatedTarget=null}o(FG,"MouseEvent");FG.prototype=Object.create(Rwe.prototype,{constructor:{value:FG},initMouseEvent:{value:o(function(e,t,n,r,i,s,a,l,c,u,d,p,m,f,g){switch(this.initEvent(e,t,n,r,i),this.screenX=s,this.screenY=a,this.clientX=l,this.clientY=c,this.ctrlKey=u,this.altKey=d,this.shiftKey=p,this.metaKey=m,this.button=f,f){case 0:this.buttons=1;break;case 1:this.buttons=4;break;case 2:this.buttons=2;break;default:this.buttons=0;break}this.relatedTarget=g},"value")},getModifierState:{value:o(function(e){switch(e){case"Alt":return this.altKey;case"Control":return this.ctrlKey;case"Shift":return this.shiftKey;case"Meta":return this.metaKey;default:return!1}},"value")}})});var HC=ye((E6n,Nwe)=>{"use strict";Nwe.exports=WC;var qyt=1,Byt=3,zyt=4,Wyt=5,Hyt=7,Vyt=8,Gyt=9,Zyt=11,Kyt=12,Jyt=13,Yyt=14,Xyt=15,Qyt=17,e0t=18,t0t=19,n0t=20,r0t=21,i0t=22,s0t=23,a0t=24,o0t=25,l0t=[null,"INDEX_SIZE_ERR",null,"HIERARCHY_REQUEST_ERR","WRONG_DOCUMENT_ERR","INVALID_CHARACTER_ERR",null,"NO_MODIFICATION_ALLOWED_ERR","NOT_FOUND_ERR","NOT_SUPPORTED_ERR","INUSE_ATTRIBUTE_ERR","INVALID_STATE_ERR","SYNTAX_ERR","INVALID_MODIFICATION_ERR","NAMESPACE_ERR","INVALID_ACCESS_ERR",null,"TYPE_MISMATCH_ERR","SECURITY_ERR","NETWORK_ERR","ABORT_ERR","URL_MISMATCH_ERR","QUOTA_EXCEEDED_ERR","TIMEOUT_ERR","INVALID_NODE_TYPE_ERR","DATA_CLONE_ERR"],c0t=[null,"INDEX_SIZE_ERR (1): the index is not in the allowed range",null,"HIERARCHY_REQUEST_ERR (3): the operation would yield an incorrect nodes model","WRONG_DOCUMENT_ERR (4): the object is in the wrong Document, a call to importNode is required","INVALID_CHARACTER_ERR (5): the string contains invalid characters",null,"NO_MODIFICATION_ALLOWED_ERR (7): the object can not be modified","NOT_FOUND_ERR (8): the object can not be found here","NOT_SUPPORTED_ERR (9): this operation is not supported","INUSE_ATTRIBUTE_ERR (10): setAttributeNode called on owned Attribute","INVALID_STATE_ERR (11): the object is in an invalid state","SYNTAX_ERR (12): the string did not match the expected pattern","INVALID_MODIFICATION_ERR (13): the object can not be modified in this way","NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML","INVALID_ACCESS_ERR (15): the object does not support the operation or argument",null,"TYPE_MISMATCH_ERR (17): the type of the object does not match the expected type","SECURITY_ERR (18): the operation is insecure","NETWORK_ERR (19): a network error occurred","ABORT_ERR (20): the user aborted an operation","URL_MISMATCH_ERR (21): the given URL does not match another URL","QUOTA_EXCEEDED_ERR (22): the quota has been exceeded","TIMEOUT_ERR (23): a timeout occurred","INVALID_NODE_TYPE_ERR (24): the supplied node is invalid or has an invalid ancestor for this operation","DATA_CLONE_ERR (25): the object can not be cloned."],$we={INDEX_SIZE_ERR:qyt,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:Byt,WRONG_DOCUMENT_ERR:zyt,INVALID_CHARACTER_ERR:Wyt,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:Hyt,NOT_FOUND_ERR:Vyt,NOT_SUPPORTED_ERR:Gyt,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:Zyt,SYNTAX_ERR:Kyt,INVALID_MODIFICATION_ERR:Jyt,NAMESPACE_ERR:Yyt,INVALID_ACCESS_ERR:Xyt,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:Qyt,SECURITY_ERR:e0t,NETWORK_ERR:t0t,ABORT_ERR:n0t,URL_MISMATCH_ERR:r0t,QUOTA_EXCEEDED_ERR:i0t,TIMEOUT_ERR:s0t,INVALID_NODE_TYPE_ERR:a0t,DATA_CLONE_ERR:o0t};function WC(e){Error.call(this),Error.captureStackTrace(this,this.constructor),this.code=e,this.message=c0t[e],this.name=l0t[e]}o(WC,"DOMException");WC.prototype.__proto__=Error.prototype;for(zC in $we)qG={value:$we[zC]},Object.defineProperty(WC,zC,qG),Object.defineProperty(WC.prototype,zC,qG);var qG,zC});var VC=ye(Pwe=>{Pwe.isApiWritable=!globalThis.__domino_frozen__});var Ps=ye(xi=>{"use strict";var Ns=HC(),Js=Ns,u0t=VC().isApiWritable;xi.NAMESPACE={HTML:"http://www.w3.org/1999/xhtml",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/",MATHML:"http://www.w3.org/1998/Math/MathML",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink"};xi.IndexSizeError=function(){throw new Ns(Js.INDEX_SIZE_ERR)};xi.HierarchyRequestError=function(){throw new Ns(Js.HIERARCHY_REQUEST_ERR)};xi.WrongDocumentError=function(){throw new Ns(Js.WRONG_DOCUMENT_ERR)};xi.InvalidCharacterError=function(){throw new Ns(Js.INVALID_CHARACTER_ERR)};xi.NoModificationAllowedError=function(){throw new Ns(Js.NO_MODIFICATION_ALLOWED_ERR)};xi.NotFoundError=function(){throw new Ns(Js.NOT_FOUND_ERR)};xi.NotSupportedError=function(){throw new Ns(Js.NOT_SUPPORTED_ERR)};xi.InvalidStateError=function(){throw new Ns(Js.INVALID_STATE_ERR)};xi.SyntaxError=function(){throw new Ns(Js.SYNTAX_ERR)};xi.InvalidModificationError=function(){throw new Ns(Js.INVALID_MODIFICATION_ERR)};xi.NamespaceError=function(){throw new Ns(Js.NAMESPACE_ERR)};xi.InvalidAccessError=function(){throw new Ns(Js.INVALID_ACCESS_ERR)};xi.TypeMismatchError=function(){throw new Ns(Js.TYPE_MISMATCH_ERR)};xi.SecurityError=function(){throw new Ns(Js.SECURITY_ERR)};xi.NetworkError=function(){throw new Ns(Js.NETWORK_ERR)};xi.AbortError=function(){throw new Ns(Js.ABORT_ERR)};xi.UrlMismatchError=function(){throw new Ns(Js.URL_MISMATCH_ERR)};xi.QuotaExceededError=function(){throw new Ns(Js.QUOTA_EXCEEDED_ERR)};xi.TimeoutError=function(){throw new Ns(Js.TIMEOUT_ERR)};xi.InvalidNodeTypeError=function(){throw new Ns(Js.INVALID_NODE_TYPE_ERR)};xi.DataCloneError=function(){throw new Ns(Js.DATA_CLONE_ERR)};xi.nyi=function(){throw new Error("NotYetImplemented")};xi.shouldOverride=function(){throw new Error("Abstract function; should be overriding in subclass.")};xi.assert=function(e,t){if(!e)throw new Error("Assertion failed: "+(t||"")+`
|
|
158
158
|
`+new Error().stack)};xi.expose=function(e,t){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],writable:u0t})};xi.merge=function(e,t){for(var n in t)e[n]=t[n]};xi.documentOrder=function(e,t){return 3-(e.compareDocumentPosition(t)&6)};xi.toASCIILowerCase=function(e){return e.replace(/[A-Z]+/g,function(t){return t.toLowerCase()})};xi.toASCIIUpperCase=function(e){return e.replace(/[a-z]+/g,function(t){return t.toUpperCase()})}});var BG=ye((I6n,Mwe)=>{"use strict";var Q1=T2(),d0t=UG(),p0t=Ps();Mwe.exports=Dwe;function Dwe(){}o(Dwe,"EventTarget");Dwe.prototype={addEventListener:o(function(t,n,r){if(n){r===void 0&&(r=!1),this._listeners||(this._listeners=Object.create(null)),this._listeners[t]||(this._listeners[t]=[]);for(var i=this._listeners[t],s=0,a=i.length;s<a;s++){var l=i[s];if(l.listener===n&&l.capture===r)return}var c={listener:n,capture:r};typeof n=="function"&&(c.f=n),i.push(c)}},"addEventListener"),removeEventListener:o(function(t,n,r){if(r===void 0&&(r=!1),this._listeners){var i=this._listeners[t];if(i)for(var s=0,a=i.length;s<a;s++){var l=i[s];if(l.listener===n&&l.capture===r){i.length===1?this._listeners[t]=void 0:i.splice(s,1);return}}}},"removeEventListener"),dispatchEvent:o(function(t){return this._dispatchEvent(t,!1)},"dispatchEvent"),_dispatchEvent:o(function(t,n){typeof n!="boolean"&&(n=!1);function r(u,d){var p=d.type,m=d.eventPhase;if(d.currentTarget=u,m!==Q1.CAPTURING_PHASE&&u._handlers&&u._handlers[p]){var f=u._handlers[p],g;if(typeof f=="function")g=f.call(d.currentTarget,d);else{var y=f.handleEvent;if(typeof y!="function")throw new TypeError("handleEvent property of event handler object isnot a function.");g=y.call(f,d)}d.type==="mouseover"?g===!0&&d.preventDefault():g===!1&&d.preventDefault()}var v=u._listeners&&u._listeners[p];if(v){v=v.slice();for(var x=0,S=v.length;x<S;x++){if(d._immediatePropagationStopped)return;var k=v[x];if(!(m===Q1.CAPTURING_PHASE&&!k.capture||m===Q1.BUBBLING_PHASE&&k.capture))if(k.f)k.f.call(d.currentTarget,d);else{var w=k.listener.handleEvent;if(typeof w!="function")throw new TypeError("handleEvent property of event listener object is not a function.");w.call(k.listener,d)}}}}o(r,"invoke"),(!t._initialized||t._dispatching)&&p0t.InvalidStateError(),t.isTrusted=n,t._dispatching=!0,t.target=this;for(var i=[],s=this.parentNode;s;s=s.parentNode)i.push(s);t.eventPhase=Q1.CAPTURING_PHASE;for(var a=i.length-1;a>=0&&(r(i[a],t),!t._propagationStopped);a--);if(t._propagationStopped||(t.eventPhase=Q1.AT_TARGET,r(this,t)),t.bubbles&&!t._propagationStopped){t.eventPhase=Q1.BUBBLING_PHASE;for(var l=0,c=i.length;l<c&&(r(i[l],t),!t._propagationStopped);l++);}if(t._dispatching=!1,t.eventPhase=Q1.AT_TARGET,t.currentTarget=null,n&&!t.defaultPrevented&&t instanceof d0t)switch(t.type){case"mousedown":this._armed={x:t.clientX,y:t.clientY,t:t.timeStamp};break;case"mouseout":case"mouseover":this._armed=null;break;case"mouseup":this._isClick(t)&&this._doClick(t),this._armed=null;break}return!t.defaultPrevented},"_dispatchEvent"),_isClick:o(function(e){return this._armed!==null&&e.type==="mouseup"&&e.isTrusted&&e.button===0&&e.timeStamp-this._armed.t<1e3&&Math.abs(e.clientX-this._armed.x)<10&&Math.abs(e.clientY-this._armed.Y)<10},"_isClick"),_doClick:o(function(e){if(!this._click_in_progress){this._click_in_progress=!0;for(var t=this;t&&!t._post_click_activation_steps;)t=t.parentNode;t&&t._pre_click_activation_steps&&t._pre_click_activation_steps();var n=this.ownerDocument.createEvent("MouseEvent");n.initMouseEvent("click",!0,!0,this.ownerDocument.defaultView,1,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,null);var r=this._dispatchEvent(n,!0);t&&(r?t._post_click_activation_steps&&t._post_click_activation_steps(n):t._cancelled_activation_steps&&t._cancelled_activation_steps())}},"_doClick"),_setEventHandler:o(function(t,n){this._handlers||(this._handlers=Object.create(null)),this._handlers[t]=n},"_setEventHandler"),_getEventHandler:o(function(t){return this._handlers&&this._handlers[t]||null},"_getEventHandler")}});var zG=ye((R6n,Lwe)=>{"use strict";var zf=Ps(),du=Lwe.exports={valid:o(function(e){return zf.assert(e,"list falsy"),zf.assert(e._previousSibling,"previous falsy"),zf.assert(e._nextSibling,"next falsy"),!0},"valid"),insertBefore:o(function(e,t){zf.assert(du.valid(e)&&du.valid(t));var n=e,r=e._previousSibling,i=t,s=t._previousSibling;n._previousSibling=s,r._nextSibling=i,s._nextSibling=n,i._previousSibling=r,zf.assert(du.valid(e)&&du.valid(t))},"insertBefore"),replace:o(function(e,t){zf.assert(du.valid(e)&&(t===null||du.valid(t))),t!==null&&du.insertBefore(t,e),du.remove(e),zf.assert(du.valid(e)&&(t===null||du.valid(t)))},"replace"),remove:o(function(e){zf.assert(du.valid(e));var t=e._previousSibling;if(t!==e){var n=e._nextSibling;t._nextSibling=n,n._previousSibling=t,e._previousSibling=e._nextSibling=e,zf.assert(du.valid(e))}},"remove")}});var WG=ye(($6n,Hwe)=>{"use strict";Hwe.exports={serializeOne:b0t,\u0275escapeMatchingClosingTag:Bwe,\u0275escapeClosingCommentTag:zwe,\u0275escapeProcessingInstructionContent:Wwe};var qwe=Ps(),ey=qwe.NAMESPACE,jwe={STYLE:!0,SCRIPT:!0,XMP:!0,IFRAME:!0,NOEMBED:!0,NOFRAMES:!0,PLAINTEXT:!0},f0t={area:!0,base:!0,basefont:!0,bgsound:!0,br:!0,col:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},h0t={},Fwe=/[&<>\u00A0]/g,Uwe=/[&"<>\u00A0]/g;function m0t(e){return Fwe.test(e)?e.replace(Fwe,t=>{switch(t){case"&":return"&";case"<":return"<";case">":return">";case"\xA0":return" "}}):e}o(m0t,"escape");function g0t(e){return Uwe.test(e)?e.replace(Uwe,t=>{switch(t){case"<":return"<";case">":return">";case"&":return"&";case'"':return""";case"\xA0":return" "}}):e}o(g0t,"escapeAttr");function y0t(e){var t=e.namespaceURI;return t?t===ey.XML?"xml:"+e.localName:t===ey.XLINK?"xlink:"+e.localName:t===ey.XMLNS?e.localName==="xmlns"?"xmlns":"xmlns:"+e.localName:e.name:e.localName}o(y0t,"attrname");function Bwe(e,t){let n="</"+t;if(!e.toLowerCase().includes(n))return e;let r=[...e],i=e.matchAll(new RegExp(n,"ig"));for(let s of i)r[s.index]="<";return r.join("")}o(Bwe,"escapeMatchingClosingTag");var v0t=/--!?>/;function zwe(e){return v0t.test(e)?e.replace(/(--\!?)>/g,"$1>"):e}o(zwe,"escapeClosingCommentTag");function Wwe(e){return e.includes(">")?e.replaceAll(">",">"):e}o(Wwe,"escapeProcessingInstructionContent");function b0t(e,t){var n="";switch(e.nodeType){case 1:var r=e.namespaceURI,i=r===ey.HTML,s=i||r===ey.SVG||r===ey.MATHML?e.localName:e.tagName;n+="<"+s;for(var a=0,l=e._numattrs;a<l;a++){var c=e._attr(a);n+=" "+y0t(c),c.value!==void 0&&(n+='="'+g0t(c.value)+'"')}if(n+=">",!(i&&f0t[s])){var u=e.serialize();jwe[s.toUpperCase()]&&(u=Bwe(u,s)),i&&h0t[s]&&u.charAt(0)===`
|
|
@@ -5735,7 +5735,7 @@ The web search request used endpoint ${JSON.stringify(e)}. Search endpoint confi
|
|
|
5735
5735
|
.error { padding: .75rem; border-radius: .5rem; background: #461d2b; color: #ffd6df; }
|
|
5736
5736
|
.hint { margin: 1.5rem 0 0; font-size: .875rem; }
|
|
5737
5737
|
code { padding: .1rem .3rem; border-radius: .3rem; background: #0c1222; color: #edf2ff; }
|
|
5738
|
-
`}o(wCe,"pageStyles");RS();var rQ="enabled",iQ=Object.freeze({id:"direct",capabilities:Object.freeze(["bash"]),plan:"free",shell:"just-bash-direct",probe:o(e=>e.LOADER===void 0?"available":"needs-binding","probe")}),NE=Object.freeze({id:"dynamic-worker",capabilities:Object.freeze(["bash","coding"]),plan:"paid",shell:"just-bash-isolated",probe:o(e=>e.LOADER===void 0?"needs-binding":"available","probe")}),sQ=Object.freeze({id:"container",capabilities:Object.freeze(["container"]),plan:"paid",shell:"linux-container",probe:o(e=>e.DSH_EDGE_CONTAINER_RUNTIME===rQ?"available":"needs-binding","probe")}),kPt=Object.freeze([sQ,NE,iQ]);function aQ(e,t=kPt){return t.filter(n=>n.probe(e)==="available")}o(aQ,"availableEdgeRuntimeProviders");function oQ(e){let t=o(r=>e.find(i=>i.capabilities.includes(r)),"first"),n=t("bash");if(n===void 0)throw new Error("No available runtime provider serves the bash layer.");return{bash:n.id,container:t("container")?.id??null}}o(oQ,"resolveEdgeRuntimeSelection");function xO(e){let t=aQ(e),{bash:n,container:r}=oQ(t);return t.find(i=>i.id===(r??n)).shell}o(xO,"resolveEdgeRuntimeShell");function EPt(){return"dsh-edge@0.19.0-alpha.2/isolated"}o(EPt,"resolveEdgeDeploymentId");function PE(e){return{baseURL:LH(e.DEEPSEEK_BASE_URL),maxTokens:UH(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:F1(e.DEEPSEEK_MODEL),reasoningEffort:jH(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:OR(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:FH(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:tg(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}o(PE,"resolveEdgeDeploymentConfig");function _Pt(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}o(_Pt,"edgeDeploymentApiKeyConfigured");function TPt(e){let t=LH(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}o(TPt,"projectedEdgeBaseURL");function lQ(e,t){return{shell:xO(e),storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:EPt(),apiKeyConfigured:_Pt(e),baseURL:TPt(e.DEEPSEEK_BASE_URL),maxTokens:UH(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:F1(e.DEEPSEEK_MODEL),reasoningEffort:jH(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:OR(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:FH(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:tg(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}o(lQ,"resolveEdgeDeploymentProfile");function wO(e){PE(e);let t=lQ(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,...e.CF_VERSION_METADATA===void 0?{}:{workerVersionId:e.CF_VERSION_METADATA.id},version:P1,upstreamVersion:Lye,status:"ready"}}o(wO,"resolveEdgeDeploymentHealth");import{AsyncLocalStorage as XHt}from"node:async_hooks";import{RpcTarget as APt}from"cloudflare:workers";function IPt(e){let{intervalMs:t,ping:n,onFailure:r}=e,i=!1,s=setInterval(()=>{i||n().catch(a=>{i||(i=!0,clearInterval(s),r(a instanceof Error?a:new Error(String(a))))})},t);return()=>{i||(i=!0,clearInterval(s))}}o(IPt,"startHeartbeat");async function CPt(e,t){let n=AbortSignal.timeout(t.timeoutMs),r=await e.fetchPort(t.port,`http://container${t.path}`,{method:"HEAD",signal:n});if(r.body?.cancel(),!r.ok)throw new Error(`computerd health returned ${r.status}`)}o(CPt,"probeComputerdHealth");var RPt="computer.internal",OPt="/health",cQ="/api",$Pt=8080,NPt=3e4,PPt=2e4,DPt=1,MPt=2e3,LPt=250,jPt=2e3;function FPt(e,t){if(t===void 0||e===null)return!1;let n=e.indexOf(" ");if(n===-1||e.slice(0,n).toLowerCase()!=="bearer")return!1;let r=e.slice(n+1).trim();if(r.length!==t.length)return!1;let i=0;for(let s=0;s<t.length;s+=1)i|=r.charCodeAt(s)^t.charCodeAt(s);return i===0}o(FPt,"bearerMatches");var kO=class{static{o(this,"CloudflareContainerBackend")}type="cloudflare-container";id;#e;#t;#r;#n;#i;#s;#o;#l;constructor(e){this.id=e.id??"container-shell",this.#t=e.egress??{mode:"none"},this.#r=this.#t.mode==="http-gateway"?crypto.randomUUID():void 0,this.#e={container:e.container,workspace:e.workspace,containerEnv:e.containerEnv,egressHost:e.egressHost??RPt,containerPort:e.containerPort??$Pt,connectTimeoutMs:e.connectTimeoutMs??NPt,heartbeatIntervalMs:e.heartbeatIntervalMs??PPt,restartAttempts:e.restartAttempts??DPt,healthProbeTimeoutMs:e.healthProbeTimeoutMs??MPt,healthRetryInitialDelayMs:e.healthRetryInitialDelayMs??LPt,healthRetryMaxDelayMs:e.healthRetryMaxDelayMs??jPt}}async connect(){if(this.#l)return this.#l;let e=Date.now()+this.#e.connectTimeoutMs,t=await(await this.#e.container()).getWorkspaceContainer(),n=await t.exitInfo().catch(()=>null),r={PORT:String(this.#e.containerPort),MOUNT_POINT:"/workspace",...this.#e.containerEnv},i,s;try{({runtimeId:i,clientSecret:s}=await t.start({env:r,enableInternet:this.#t.mode==="direct"}))}catch(p){throw new Lo(this.#d("start",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}try{await t.interceptOutboundHttp(this.#e.egressHost,this.#e.workspace),this.#t.mode==="http-gateway"&&this.#r!==void 0&&await t.interceptAllOutboundHttp(this.#e.workspace,this.#r)}catch(p){throw new Lo(this.#d("egress",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}this.#n=s,this.#u(),i=await this.#p(t,r,e,n,i),await this.#f(t,e),await this.#v(t,e,s);let a=await this.#h(e),l=o8(a),c,u=new Promise(p=>{let m=!1,f=o(()=>{m||(m=!0,c?.(),p(),this.#l=void 0)},"onClose");a.addEventListener("close",f,{once:!0}),a.addEventListener("error",f,{once:!0}),l.onRpcBroken(f)});this.#e.heartbeatIntervalMs>0&&(c=IPt({intervalMs:this.#e.heartbeatIntervalMs,ping:o(()=>l.sync.watermarks(),"ping"),onFailure:o(()=>{try{a.close()}catch{}},"onFailure")}));let d={rpc:l,runtimeId:i,closed:u,close:o(async()=>{c?.();try{l[Symbol.dispose]?.()}catch{}try{a.close()}catch{}this.#l=void 0},"close")};return this.#l=d,d}async handleFetch(e){if(this.#t.mode==="http-gateway"&&this.#r!==void 0&&e.headers.get("x-workspace-egress-token")===this.#r){let i=new Headers(e.headers),s=i.get(Lb),a;try{a=new URL(s??"")}catch{return new Response("invalid egress URL",{status:400})}if(a.protocol!=="http:"&&a.protocol!=="https:")return new Response("invalid egress URL",{status:400});i.delete(R_),i.delete(Lb);let l=new Request(e,{headers:i});return this.#t.gateway.fetch(new Request(a,l))}if(new URL(e.url).pathname!==cQ)return new Response("not found",{status:404});if(e.headers.get("upgrade")!=="websocket")return new Response(`${cQ} requires a websocket upgrade`,{status:400});if(!FPt(e.headers.get("authorization"),this.#n))return new Response("unauthorized",{status:401,headers:{"www-authenticate":"Bearer"}});let t=new WebSocketPair,[n,r]=[t[0],t[1]];if(r.accept(),this.#s)this.#s(r);else return r.close(1011,"no pending connect"),new Response("no pending connect",{status:409});return new Response(null,{status:101,webSocket:n})}#u(){this.#i=new Promise((e,t)=>{this.#s=e,this.#o=t}),this.#i.catch(()=>{})}#a(){this.#i=void 0,this.#s=void 0,this.#o=void 0}async#p(e,t,n,r,i){let s=this.#e.restartAttempts+1,a=Math.max(0,n-Date.now()),l=Math.max(250,Math.floor(a/s)),c=0,u=0,d,p=i;for(;c<s;){c++;let m=Math.min(n,Date.now()+l);if(await this.#m(e,m).then(()=>!0,f=>(d=f,!1)))return p;if(c<s)try{({runtimeId:p}=await e.restart({env:t,enableInternet:this.#t.mode==="direct"})),u++}catch(f){throw this.#o?.(f),this.#a(),new Lo(this.#d("restart",{attempt:c,maxAttempts:s,restarts:u,lastError:f}),{cause:f})}}throw this.#o?.(new Error("computerd never became healthy")),this.#a(),new Lo(this.#d("health",{attempt:c,maxAttempts:s,restarts:u,lastError:d,priorExit:r}),d instanceof Error?{cause:d}:void 0)}async#m(e,t){let n=this.#e.healthRetryInitialDelayMs,r;for(;Date.now()<t;)try{await CPt(e,{port:this.#e.containerPort,path:"/health",timeoutMs:Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now()))});return}catch(i){r=i;let s=t-Date.now();if(s<=0)break;await UPt(Math.min(n,s)),n=Math.min(n*2,this.#e.healthRetryMaxDelayMs)}throw r??new Error("computerd health probe timed out")}#d(e,t){let n=t.priorExit?` priorExit=${JSON.stringify(t.priorExit.reason)}`:"";return`CloudflareContainerBackend(${this.id}): connect failed at stage=${e} port=${this.#e.containerPort} attempt=${t.attempt}/${t.maxAttempts} restarts=${t.restarts} timeoutMs=${this.#e.connectTimeoutMs}${n} lastError=${SCe(t.lastError)}`}async#f(e,t){let n;try{let r=await e.fetchPort(this.#e.containerPort,"http://container/api",{signal:AbortSignal.timeout(Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now())))});n=r.status,await r.text().catch(()=>"")}catch{return}if(n!==401)throw this.#o?.(new Error("container is not enforcing RPC_CLIENT_SECRET")),this.#a(),new Lo(`CloudflareContainerBackend(${this.id}) [stage=auth]: container served an unauthenticated request to /api with ${n}, so this workspace would run without authorization. A container or image predating RPC_CLIENT_SECRET has to be recycled.`)}async#v(e,t,n){let r=Math.max(0,t-Date.now()),i;try{i=await e.fetchPort(this.#e.containerPort,"http://container/connect",{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},body:JSON.stringify({base:`http://${this.#e.egressHost}`,health:OPt,api:cQ,healthTimeoutMs:r})})}catch(s){throw this.#o?.(s),this.#a(),new Lo(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect failed: ${SCe(s)}`,{cause:s})}if(!i.ok){let s=await i.text().catch(()=>""),a=new Error(`/connect ${i.status}`);throw this.#o?.(a),this.#a(),new Lo(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect returned ${i.status}: ${s}`,{cause:a})}}async#h(e){let t=this.#i;if(!t)throw new Error("CloudflareContainerBackend: upgrade promise missing");let n=Math.max(0,e-Date.now()),r;try{return await Promise.race([t,new Promise((i,s)=>{r=setTimeout(()=>s(new Lo(`CloudflareContainerBackend(${this.id}) [stage=ws]: /api upgrade did not arrive within ${this.#e.connectTimeoutMs}ms`)),n)})])}finally{r&&clearTimeout(r),this.#a()}}};function UPt(e){return new Promise(t=>setTimeout(t,e))}o(UPt,"sleep");function SCe(e){return e instanceof Error?e.message:String(e)}o(SCe,"describeError");var kCe="computer:container-client-secret",qPt=16;function BPt(){let e=crypto.getRandomValues(new Uint8Array(qPt));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}o(BPt,"generate");var zPt=class{static{o(this,"ContainerClientSecret")}storage;constructor(e){this.storage=e}async ensure(){let e=await this.storage.get(kCe);if(typeof e=="string"&&e.length>0)return e;let t=BPt();return await this.storage.put(kCe,t),t}},ECe="computer:container-launch-record";async function _Ce(e){return{enableInternet:e.enableInternet,envDigest:await HPt(e.env)}}o(_Ce,"launchRecordFor");function WPt(e,t){return e.enableInternet===t.enableInternet&&e.envDigest===t.envDigest}o(WPt,"sameLaunch");async function HPt(e){let t=Object.keys(e).sort().map(r=>`${r.length}:${r}=${e[r]?.length??0}:${e[r]??""}`).join(";"),n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}o(HPt,"digestEnv");var VPt=class{static{o(this,"CurrentContainerLaunchRecord")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(ECe)??null}async set(e){await this.storage.put(ECe,e)}},TCe=new WeakMap;function pQ(e){let t=TCe.get(e);return t===void 0&&(t={exit:null,currentGeneration:0,expectedExitGeneration:null,currentMonitorSettled:null},TCe.set(e,t)),t}o(pQ,"getContainerLifecycle");function SO(e){return pQ(e).exit}o(SO,"containerExitInfo");function ACe(e){return e===void 0?"exited normally":e instanceof Error?e.message:String(e)}o(ACe,"formatExitReason");function ICe(e,t,n){let r=pQ(e);r.currentGeneration+=1;let i=r.currentGeneration;r.exit=null,r.currentMonitorSettled=t.monitor().then(()=>CCe(r,i,void 0,n),s=>CCe(r,i,s,n))}o(ICe,"installContainerMonitor");async function uQ(e,t){let n=pQ(e);n.expectedExitGeneration=n.currentGeneration;let r=n.currentMonitorSettled;await t.destroy(),r&&await r}o(uQ,"destroyContainerExpectingExit");async function CCe(e,t,n,r){if(t!==e.currentGeneration)return;let i=e.expectedExitGeneration===t;i&&(e.expectedExitGeneration=null);let s=ACe(n),a=Date.now();e.exit={reason:s,exitedAt:a},i?console.info({message:"workspace.container.exited",reason:s,exitedAt:a,expected:!0}):console.warn({message:"workspace.container.exited",reason:s,exitedAt:a,expected:!1});try{await r?.()}catch(l){console.error({message:"workspace.container.exit_cleanup_failed",reason:ACe(l),exitedAt:Date.now()})}}o(CCe,"recordExit");var dQ="computer:container-runtime-identity",GPt=class{static{o(this,"CurrentContainerRuntimeIdentity")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(dQ)??null}async markStarted(){let e={id:crypto.randomUUID()};return await this.storage.put(dQ,e),e}async clear(e){(await this.get())?.id===e.id&&await this.storage.delete(dQ)}},ZPt=class extends APt{static{o(this,"WorkspaceContainerAPI")}#e;#t;#r;#n;#i;constructor(e){if(super(),!e.container)throw new Error("WorkspaceContainerAPI: DO is not container-enabled (check wrangler.jsonc)");this.#e=e.container,this.#t=e,this.#r=new GPt(e.storage),this.#n=new zPt(e.storage),this.#i=new VPt(e.storage)}async start(e){let t=SO(this.#t),n=await this.#n.ensure(),r=await _Ce(e);if(t!==null){try{await uQ(this.#t,this.#e)}catch{}return this.#s(e,n,r,"launched")}if(!this.#e.running)return this.#s(e,n,r,"launched");let i=await this.#i.get();if(i===null||!WPt(i,r)){console.warn({message:i===null?"container was started outside WorkspaceContainerAPI; relaunching so the requested environment applies":"running container was launched with a different spec; relaunching",component:"workspace-container",requested:r,actual:i});try{await uQ(this.#t,this.#e)}catch{}return this.#s(e,n,r,"relaunched")}let s=await this.#r.get()??await this.#r.markStarted();return ICe(this.#t,this.#e,()=>this.#r.clear(s)),{runtimeId:s.id,clientSecret:n,outcome:"adopted"}}async restart(e){try{await uQ(this.#t,this.#e)}catch{}let t=await this.#n.ensure();return this.#s(e,t,await _Ce(e),"launched")}async setInactivityTimeout(e){await this.#e.setInactivityTimeout(e)}async#s(e,t,n,r){let i=await this.#r.markStarted();try{this.#e.start({enableInternet:e.enableInternet,env:{...e.env,RPC_CLIENT_SECRET:t}})}catch(s){throw await this.#r.clear(i),s}return await this.#i.set(n),ICe(this.#t,this.#e,()=>this.#r.clear(i)),{runtimeId:i.id,clientSecret:t,outcome:r}}async status(){return{running:this.#e.running,exit:SO(this.#t)}}async exitInfo(){return SO(this.#t)}async interceptAllOutboundHttp(e,t){let n=this.#t.exports.WorkspaceProxy({props:{...e,egressToken:t}});await Promise.all([this.#e.interceptAllOutboundHttp(n),this.#e.interceptOutboundHttps("*",n)])}async interceptOutboundHttp(e,t){let n=this.#t.exports;await this.#e.interceptOutboundHttp(e,n.WorkspaceProxy({props:t}))}fetchPort(e,t,n){let r=SO(this.#t);if(r!==null)throw new Lo(`container exited: ${r.reason}`);return this.#e.getTcpPort(e).fetch(t,n)}port(e){return this.#e.getTcpPort(e)}};function RCe(e){class t extends e{static{o(this,"WithWorkspaceContainer")}getWorkspaceContainer(){return new ZPt(this.ctx)}}return t}o(RCe,"withWorkspaceContainer");var KPt={session:"sessions",skill:"skills",agentPreset:"agentPresets",subagent:"subagents",goal:"goals",event:"events",download:"downloads"};function $Ce(e,t){let n=t.indexOf("."),r=t.indexOf("/"),i=n>=0?n:r;if(i<0)return;let s=t.slice(0,i),a=t.slice(i+1),l=KPt[s]??s,c=e[l];if(c===void 0)return;let u=c[a];return typeof u=="function"?u:void 0}o($Ce,"resolve");function JPt(e,t){return Response.json({type:"server-response",rpcId:e,result:{ok:!1,error:t}})}o(JPt,"errorResponse");async function fQ(e,t,n,r,i){let s=$Ce(e,t);if(s!==void 0)return await s({rpcId:n,payload:r},i)}o(fQ,"callEdgeApi");async function NCe(e,t){let r=new URL(t.url).pathname;if(t.method!=="POST"||!r.startsWith("/api/"))return new Response("not found",{status:404});if(r==="/api/respond")return Response.json({accepted:!1,reason:"not-pending"});let i=r.slice(5);if($Ce(e,i)===void 0)return new Response("not found",{status:404});let s;try{s=await t.json()}catch{return new Response("body is not JSON",{status:400})}let a=typeof s.rpcId=="string"?s.rpcId:"invalid-request",l=s.payload??{};try{let c=await fQ(e,i,a,l,t.signal);return c===void 0?new Response("not found",{status:404}):Response.json({type:"server-response",rpcId:c.rpcId,result:c.result})}catch(c){return JPt(a,{code:"internal",message:String(c),details:{}})}}o(NCe,"dispatchEdgeApi");yr();_s();im();import{DurableObject as QHt}from"cloudflare:workers";var EO=class{constructor(t,n=Date.now,r=2){this.sleepAfterMs=t;this.now=n;this.maxConcurrent=r}sleepAfterMs;now;maxConcurrent;static{o(this,"ContainerActivity")}inFlight=0;lastActivity;stopping;waiters=[];async admit(t){let n=this.now();for(;this.stopping!==void 0||this.inFlight>=this.maxConcurrent;){if(t?.throwIfAborted(),this.stopping!==void 0){await YPt(this.stopping,t);continue}await new Promise((r,i)=>{let s=o(()=>{t?.removeEventListener("abort",a),r()},"wake"),a=o(()=>{let l=this.waiters.indexOf(s);l!==-1&&this.waiters.splice(l,1),i(t.reason)},"abort");this.waiters.push(s),t?.addEventListener("abort",a,{once:!0})})}return t?.aborted===!0&&(this.waiters.shift()?.(),t.throwIfAborted()),{release:this.begin(),queuedMs:this.now()-n}}begin(){this.inFlight+=1,this.lastActivity=this.now();let t=!1;return()=>{t||(t=!0,this.inFlight-=1,this.lastActivity=this.now(),this.waiters.shift()?.())}}async stopIfIdle(t){return this.idle()?await this.stop(t):"busy"}async stopNow(t){return this.inFlight===0?await this.stop(t):"busy"}snapshot(){return{runningCommands:this.inFlight,lastActivityAt:this.lastActivity??null}}async stop(t){if(this.stopping!==void 0)return"busy";let n="stopped",r=t().catch(i=>{n="failed",this.lastActivity=this.now(),console.error("dsh-edge container stop failed.",i)});this.stopping=r;try{await r}finally{this.stopping=void 0}return n}deadline(){return this.inFlight>0?this.now()+this.sleepAfterMs():this.lastActivity===void 0?this.now():this.lastActivity+this.sleepAfterMs()}idle(){return this.inFlight===0&&(this.lastActivity===void 0||this.now()>=this.lastActivity+this.sleepAfterMs())}};function YPt(e,t){return t===void 0?e:new Promise((n,r)=>{let i=o(()=>r(t.reason),"abort");t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",i))})}o(YPt,"untilAborted");import{WorkerEntrypoint as HDn}from"cloudflare:workers";var Uy=vl(PCe(),1);var hQ=o((e,t,n)=>{let r=e instanceof RegExp?DCe(e,n):e,i=t instanceof RegExp?DCe(t,n):t,s=r!==null&&i!=null&&XPt(r,i,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+r.length,s[1]),post:n.slice(s[1]+i.length)}},"balanced"),DCe=o((e,t)=>{let n=t.match(e);return n?n[0]:null},"maybeMatch"),XPt=o((e,t,n)=>{let r,i,s,a,l,c=n.indexOf(e),u=n.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(r=[],s=n.length;d>=0&&!l;){if(d===c)r.push(d),c=n.indexOf(e,d+1);else if(r.length===1){let p=r.pop();p!==void 0&&(l=[p,u])}else i=r.pop(),i!==void 0&&i<s&&(s=i,a=u),u=n.indexOf(t,d+1);d=c<u&&c>=0?c:u}r.length&&a!==void 0&&(l=[s,a])}return l},"range");var MCe="\0SLASH"+Math.random()+"\0",LCe="\0OPEN"+Math.random()+"\0",yQ="\0CLOSE"+Math.random()+"\0",jCe="\0COMMA"+Math.random()+"\0",FCe="\0PERIOD"+Math.random()+"\0",QPt=new RegExp(MCe,"g"),eDt=new RegExp(LCe,"g"),tDt=new RegExp(yQ,"g"),nDt=new RegExp(jCe,"g"),rDt=new RegExp(FCe,"g"),iDt=/\\\\/g,sDt=/\\{/g,aDt=/\\}/g,oDt=/\\,/g,lDt=/\\\./g,cDt=1e5,uDt=4e6;function mQ(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}o(mQ,"numeric");function dDt(e){return e.replace(iDt,MCe).replace(sDt,LCe).replace(aDt,yQ).replace(oDt,jCe).replace(lDt,FCe)}o(dDt,"escapeBraces");function pDt(e){return e.replace(QPt,"\\").replace(eDt,"{").replace(tDt,"}").replace(nDt,",").replace(rDt,".")}o(pDt,"unescapeBraces");function UCe(e){if(!e)return[""];let t=[],n=hQ("{","}",e);if(!n)return e.split(",");let{pre:r,body:i,post:s}=n,a=r.split(",");a[a.length-1]+="{"+i+"}";let l=UCe(s);return s.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),t.push.apply(t,a),t}o(UCe,"parseCommaParts");function qCe(e,t={}){if(!e)return[];let{max:n=cDt,maxLength:r=uDt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),gQ(dDt(e),n,r,!0).map(pDt)}o(qCe,"expand");function fDt(e){return"{"+e+"}"}o(fDt,"embrace");function hDt(e){return/^-?0\d/.test(e)}o(hDt,"isPadded");function mDt(e,t){return e<=t}o(mDt,"lte");function gDt(e,t){return e>=t}o(gDt,"gte");function DE(e,t,n,r,i,s){let a=[],l=0;for(let c=0;c<e.length;c++)for(let u=0;u<n.length;u++){if(a.length>=r)return a;let d=e[c]+t+n[u];if(!(s&&!d)){if(l+d.length>i)return a;a.push(d),l+=d.length}}return a}o(DE,"combine");function yDt(e,t,n,r){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let a=mQ(i[0]),l=mQ(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(mQ(i[2])),1):1,d=mDt;l<a&&(u*=-1,d=gDt);let m=i.some(hDt),f=0;for(let g=a;d(g,l)&&s.length<n;g+=u){let y;if(t)y=String.fromCharCode(g),y==="\\"&&(y="");else if(y=String(g),m){let v=c-y.length;if(v>0){let x=new Array(v+1).join("0");g<0?y="-"+x+y.slice(1):y=x+y}}if(f+y.length>r)break;s.push(y),f+=y.length}return s}o(yDt,"expandSequence");function gQ(e,t,n,r){let i=[""],s=!1,a=!0;for(;;){let l=hQ("{","}",e);if(!l)return DE(i,e,[""],t,n,s);let c=l.pre;if(/\$$/.test(c)){if(i=DE(i,c+"{"+l.body+"}",[""],t,n,s&&!l.post.length),a=!1,!l.post.length)break;e=l.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(l.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(l.body),p=u||d,m=l.body.indexOf(",")>=0;if(!p&&!m){if(l.post.match(/,(?!,).*\}/)){e=l.pre+"{"+l.body+yQ+l.post,r=!0;continue}return DE(i,c+"{"+l.body+"}"+l.post,[""],t,n,s)}a&&(s=r&&!p,a=!1);let f;if(p)f=yDt(l.body,d,t,n);else{let g=UCe(l.body);if(g.length===1&&g[0]!==void 0&&(g=gQ(g[0],t,n,!1).map(fDt),g.length===1)){if(i=DE(i,c+g[0],[""],t,n,s&&!l.post.length),!l.post.length)break;e=l.post;continue}let y=s&&!l.post.length&&!c;for(let x=0;y&&x<i.length;x++)i[x]&&(y=!1);f=[];let v=0;e:for(let x=0;x<g.length;x++){let S=gQ(g[x],t,n,!1);for(let k=0;k<S.length;k++){let w=S[k];if(!(y&&!w)){if(f.length>=t||v+w.length>n)break e;f.push(w),v+=w.length}}}}if(i=DE(i,c,f,t,n,s&&!l.post.length),!l.post.length)break;e=l.post}return i}o(gQ,"expand_");var ME=o(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var vDt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},LE=o(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),bDt=o(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),BCe=o(e=>e.join(""),"rangesToString"),zCe=o((e,t)=>{let n=t;if(e.charAt(n)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=n+1,a=!1,l=!1,c=!1,u=!1,d=n,p="";e:for(;s<e.length;){let y=e.charAt(s);if((y==="!"||y==="^")&&s===n+1){u=!0,s++;continue}if(y==="]"&&a&&!c){d=s+1;break}if(a=!0,y==="\\"&&!c){c=!0,s++;continue}if(y==="["&&!c){for(let[v,[x,S,k]]of Object.entries(vDt))if(e.startsWith(v,s)){if(p)return["$.",!1,e.length-n,!0];s+=v.length,k?i.push(x):r.push(x),l=l||S;continue e}}if(c=!1,p){y>p?r.push(LE(p)+"-"+LE(y)):y===p&&r.push(LE(y)),p="",s++;continue}if(e.startsWith("-]",s+1)){r.push(LE(y+"-")),s+=2;continue}if(e.startsWith("-",s+1)){p=y,s+=2;continue}r.push(LE(y)),s++}if(d<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!u){let y=r[0].length===2?r[0].slice(-1):r[0];return[bDt(y),!1,d-n,!1]}let m="["+(u?"^":"")+BCe(r)+"]",f="["+(u?"":"^")+BCe(i)+"]";return[r.length&&i.length?"("+m+"|"+f+")":r.length?m:f,l,d-n,!0]},"parseClass");var ig=o((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var Jl,xDt=new Set(["!","?","+","*","@"]),vQ=o(e=>xDt.has(e),"isExtglobType"),WCe=o(e=>vQ(e.type),"isExtglobAST"),wDt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),SDt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),kDt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),HCe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),EDt="(?!(?:^|/)\\.\\.?(?:$|/))",TO="(?!\\.)",_Dt=new Set(["[","."]),TDt=new Set(["..","."]),ADt=new Set("().*{}+?[]^$\\!"),IDt=o(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),bQ="[^/]",VCe=bQ+"*?",GCe=bQ+"+?",CDt=0,ky=class{static{o(this,"AST")}type;#e;#t;#r=!1;#n=[];#i;#s;#o;#l=!1;#u;#a;#p=!1;id=++CDt;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#n.length,parts:this.#n}}constructor(t,n,r={}){this.type=t,t&&(this.#t=!0),this.#i=n,this.#e=this.#i?this.#i.#e:this,this.#u=this.#e===this?r:this.#e.#u,this.#o=this.#e===this?[]:this.#e.#o,t==="!"&&!this.#e.#l&&this.#o.push(this),this.#s=this.#i?this.#i.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#n)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#n.map(t=>String(t)).join("|")+")":this.#a=this.#n.map(t=>String(t)).join("")}#m(){if(this!==this.#e)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#o.pop();){if(t.type!=="!")continue;let n=t,r=n.#i;for(;r;){for(let i=n.#s+1;!r.type&&i<r.#n.length;i++)for(let s of t.#n){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#n[i])}n=r,r=n.#i}}return this}push(...t){for(let n of t)if(n!==""){if(typeof n!="string"&&!(n instanceof Jl&&n.#i===this))throw new Error("invalid part: "+n);this.#n.push(n)}}toJSON(){let t=this.type===null?this.#n.slice().map(n=>typeof n=="string"?n:n.toJSON()):[this.type,...this.#n.map(n=>n.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#l&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let n=0;n<this.#s;n++){let r=t.#n[n];if(!(r instanceof Jl&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#n.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let n=new Jl(this.type,t);for(let r of this.#n)n.copyIn(r);return n}static#d(t,n,r,i,s){let a=i.maxExtglobRecursion??2,l=!1,c=!1,u=-1,d=!1;if(n.type===null){let y=r,v="";for(;y<t.length;){let x=t.charAt(y++);if(l||x==="\\"){l=!l,v+=x;continue}if(c){y===u+1?(x==="^"||x==="!")&&(d=!0):x==="]"&&!(y===u+2&&d)&&(c=!1),v+=x;continue}else if(x==="["){c=!0,u=y,d=!1,v+=x;continue}if(!i.noext&&vQ(x)&&t.charAt(y)==="("&&s<=a){n.push(v),v="";let k=new Jl(x,n);y=Jl.#d(t,k,y,i,s+1),n.push(k);continue}v+=x}return n.push(v),y}let p=r+1,m=new Jl(null,n),f=[],g="";for(;p<t.length;){let y=t.charAt(p++);if(l||y==="\\"){l=!l,g+=y;continue}if(c){p===u+1?(y==="^"||y==="!")&&(d=!0):y==="]"&&!(p===u+2&&d)&&(c=!1),g+=y;continue}else if(y==="["){c=!0,u=p,d=!1,g+=y;continue}if(!i.noext&&vQ(y)&&t.charAt(p)==="("&&(s<=a||n&&n.#h(y))){let x=n&&n.#h(y)?0:1;m.push(g),g="";let S=new Jl(y,m);m.push(S),p=Jl.#d(t,S,p,i,s+x);continue}if(y==="|"){m.push(g),g="",f.push(m),m=new Jl(null,n);continue}if(y===")")return g===""&&n.#n.length===0&&(n.#p=!0),m.push(g),g="",n.push(...f,m),p;g+=y}return n.type=null,n.#t=void 0,n.#n=[t.substring(r-1)],p}#f(t){return this.#v(t,SDt)}#v(t,n=wDt){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null)return!1;let r=t.#n[0];return!r||typeof r!="object"||r.type===null?!1:this.#h(r.type,n)}#h(t,n=kDt){return!!n.get(this.type)?.includes(t)}#$(t,n){let r=t.#n[0],i=new Jl(null,r,this.options);i.#n.push(""),r.push(i),this.#b(t,n)}#b(t,n){let r=t.#n[0];this.#n.splice(n,1,...r.#n);for(let i of r.#n)typeof i=="object"&&(i.#i=this);this.#a=void 0}#E(t){return!!HCe.get(this.type)?.has(t)}#_(t){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null||this.#n.length!==1)return!1;let n=t.#n[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type)}#T(t){let n=HCe.get(this.type),r=t.#n[0],i=n?.get(r.type);if(!i)return!1;this.#n=r.#n;for(let s of this.#n)typeof s=="object"&&(s.#i=this);this.type=i,this.#a=void 0,this.#p=!1}static fromGlob(t,n={}){let r=new Jl(null,void 0,n);return Jl.#d(t,r,0,n,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[n,r,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#u.nocase&&!this.#u.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return r;let l=(this.#u.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${n}$`,l),{_src:n,_glob:t})}get options(){return this.#u}toRegExpSource(t){let n=t??!!this.#u.dot;if(this.#e===this&&(this.#c(),this.#m()),!WCe(this)){let c=this.isStart()&&this.isEnd()&&!this.#n.some(f=>typeof f!="string"),u=this.#n.map(f=>{let[g,y,v,x]=typeof f=="string"?Jl.#x(f,this.#t,c):f.toRegExpSource(t);return this.#t=this.#t||v,this.#r=this.#r||x,g}).join(""),d="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&TDt.has(this.#n[0]))){let g=_Dt,y=n&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),v=!n&&!t&&g.has(u.charAt(0));d=y?EDt:v?TO:""}let p="";return this.isEnd()&&this.#e.#l&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[d+u+p,ig(u),this.#t=!!this.#t,this.#r]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#g(n);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#n=[c],u.type=null,u.#t=void 0,[c,ig(this.toString()),!1,!1]}let a=!r||t||n||!TO?"":this.#g(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let l="";if(this.type==="!"&&this.#p)l=(this.isStart()&&!n?TO:"")+GCe;else{let c=this.type==="!"?"))"+(this.isStart()&&!n&&!t?TO:"")+VCe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=i+s+c}return[l,ig(s),this.#t=!!this.#t,this.#r]}#c(){if(WCe(this)){let t=0,n=!1;do{n=!0;for(let r=0;r<this.#n.length;r++){let i=this.#n[r];typeof i=="object"&&(i.#c(),this.#v(i)?(n=!1,this.#b(i,r)):this.#f(i)?(n=!1,this.#$(i,r)):this.#_(i)&&(n=!1,this.#T(i)))}}while(!n&&++t<10)}else for(let t of this.#n)typeof t=="object"&&t.#c();this.#a=void 0}#g(t){return this.#n.map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");let[r,i,s,a]=n.toRegExpSource(t);return this.#r=this.#r||a,r}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|")}static#x(t,n,r=!1){let i=!1,s="",a=!1,l=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(ADt.has(u)?"\\":"")+u;continue}if(u==="*"){if(l)continue;l=!0,s+=r&&/^[*]+$/.test(t)?GCe:VCe,n=!0;continue}else l=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,p,m,f]=zCe(t,c);if(m){s+=d,a=a||p,c+=m-1,n=n||f;continue}}if(u==="?"){s+=bQ,n=!0;continue}s+=IDt(u)}return[s,ig(t),!!n,a]}};Jl=ky;var xQ=o((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Pa=o((e,t,n={})=>(ME(t),!n.nocomment&&t.charAt(0)==="#"?!1:new ub(t,n).match(e)),"minimatch"),RDt=/^\*+([^+@!?*[(]*)$/,ODt=o(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),$Dt=o(e=>t=>t.endsWith(e),"starDotExtTestDot"),NDt=o(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),PDt=o(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),DDt=/^\*+\.\*+$/,MDt=o(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),LDt=o(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),jDt=/^\.\*+$/,FDt=o(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),UDt=/^\*+$/,qDt=o(e=>e.length!==0&&!e.startsWith("."),"starTest"),BDt=o(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),zDt=/^\?+([^+@!?*[(]*)?$/,WDt=o(([e,t=""])=>{let n=JCe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocase"),HDt=o(([e,t=""])=>{let n=YCe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocaseDot"),VDt=o(([e,t=""])=>{let n=YCe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTestDot"),GDt=o(([e,t=""])=>{let n=JCe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTest"),JCe=o(([e])=>{let t=e.length;return n=>n.length===t&&!n.startsWith(".")},"qmarksTestNoExt"),YCe=o(([e])=>{let t=e.length;return n=>n.length===t&&n!=="."&&n!==".."},"qmarksTestNoExtDot"),XCe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ZCe={win32:{sep:"\\"},posix:{sep:"/"}},ZDt=XCe==="win32"?ZCe.win32.sep:ZCe.posix.sep;Pa.sep=ZDt;var No=Symbol("globstar **");Pa.GLOBSTAR=No;var KDt="[^/]",JDt=KDt+"*?",YDt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",XDt="(?:(?!(?:\\/|^)\\.).)*?",QDt=o((e,t={})=>n=>Pa(n,e,t),"filter");Pa.filter=QDt;var bu=o((e,t={})=>Object.assign({},e,t),"ext"),eMt=o(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Pa;let t=Pa;return Object.assign(o((r,i,s={})=>t(r,i,bu(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{o(this,"Minimatch")}constructor(i,s={}){super(i,bu(e,s))}static defaults(i){return t.defaults(bu(e,i)).Minimatch}},AST:class extends t.AST{static{o(this,"AST")}constructor(i,s,a={}){super(i,s,bu(e,a))}static fromGlob(i,s={}){return t.AST.fromGlob(i,bu(e,s))}},unescape:o((r,i={})=>t.unescape(r,bu(e,i)),"unescape"),escape:o((r,i={})=>t.escape(r,bu(e,i)),"escape"),filter:o((r,i={})=>t.filter(r,bu(e,i)),"filter"),defaults:o(r=>t.defaults(bu(e,r)),"defaults"),makeRe:o((r,i={})=>t.makeRe(r,bu(e,i)),"makeRe"),braceExpand:o((r,i={})=>t.braceExpand(r,bu(e,i)),"braceExpand"),match:o((r,i,s={})=>t.match(r,i,bu(e,s)),"match"),sep:t.sep,GLOBSTAR:No})},"defaults");Pa.defaults=eMt;var QCe=o((e,t={})=>(ME(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:qCe(e,{max:t.braceExpandMax})),"braceExpand");Pa.braceExpand=QCe;var tMt=o((e,t={})=>new ub(e,t).makeRe(),"makeRe");Pa.makeRe=tMt;var nMt=o((e,t,n={})=>{let r=new ub(t,n);return e=e.filter(i=>r.match(i)),r.options.nonull&&!e.length&&e.push(t),e},"match");Pa.match=nMt;var KCe=/[?*]|[+@!]\(.*?\)|\[|\]/,rMt=o(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),ub=class{static{o(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,n={}){ME(t),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=t,this.platform=n.platform||XCe,this.isWindows=this.platform==="win32";let r="allowWindowsEscape";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[r]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let n of t)if(typeof n!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,n=this.options;if(!n.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!KCe.test(s[2]))&&!KCe.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let r of t)for(let i=0;i<r.length;i++)r[i]==="**"&&(r[i]="*");let{optimizationLevel:n=1}=this.options;return n>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):n>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(n=>{let r=-1;for(;(r=n.indexOf("**",r+1))!==-1;){let i=r;for(;n[i+1]==="**";)i++;i!==r&&n.splice(r,i-r)}return n})}levelOneOptimize(t){return t.map(n=>(n=n.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),n.length===0?[""]:n))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(n=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(n=!0,t.pop())}let r=0;for(;(r=t.indexOf("..",r+1))!==-1;){let i=t[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(n=!0,t.splice(r-1,2),r-=2)}}while(n);return t.length===0?[""]:t}firstPhasePreProcess(t){let n=!1;do{n=!1;for(let r of t){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let a=i;for(;r[a+1]==="**";)a++;a>i&&r.splice(i+1,a-i);let l=r[i+1],c=r[i+2],u=r[i+3];if(l!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;n=!0,r.splice(i,1);let d=r.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<r.length-1;a++){let l=r[a];a===1&&l===""&&r[0]===""||(l==="."||l==="")&&(n=!0,r.splice(a,1),a--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(n=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let a=r[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){n=!0;let c=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...c),r.length===0&&r.push(""),s-=2}}}}while(n);return t}secondPhasePreProcess(t){for(let n=0;n<t.length-1;n++)for(let r=n+1;r<t.length;r++){let i=this.partsMatch(t[n],t[r],!this.preserveMultipleSlashes);if(i){t[n]=[],t[r]=i;break}}return t.filter(n=>n.length)}partsMatch(t,n,r=!1){let i=0,s=0,a=[],l="";for(;i<t.length&&s<n.length;)if(t[i]===n[s])a.push(l==="b"?n[s]:t[i]),i++,s++;else if(r&&t[i]==="**"&&n[s]===t[i+1])a.push(t[i]),i++;else if(r&&n[s]==="**"&&t[i]===n[s+1])a.push(n[s]),s++;else if(t[i]==="*"&&n[s]&&(this.options.dot||!n[s].startsWith("."))&&n[s]!=="**"){if(l==="b")return!1;l="a",a.push(t[i]),i++,s++}else if(n[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(l==="a")return!1;l="b",a.push(n[s]),i++,s++}else return!1;return t.length===n.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,n=!1,r=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)n=!n,r++;r&&(this.pattern=t.slice(r)),this.negate=n}matchOne(t,n,r=!1){let i=0,s=0;if(this.isWindows){let l=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!l&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),d=!u&&n[0]===""&&n[1]===""&&n[2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3]),p=c?3:l?0:void 0,m=d?3:u?0:void 0;if(typeof p=="number"&&typeof m=="number"){let[f,g]=[t[p],n[m]];f.toLowerCase()===g.toLowerCase()&&(n[m]=f,s=m,i=p)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(t=this.levelTwoFileOptimize(t)),n.includes(No)?this.#e(t,n,r,i,s):this.#r(t,n,r,i,s)}#e(t,n,r,i,s){let a=n.indexOf(No,s),l=n.lastIndexOf(No),[c,u,d]=r?[n.slice(s,a),n.slice(a+1),[]]:[n.slice(s,a),n.slice(a+1,l),n.slice(l+1)];if(c.length){let S=t.slice(i,i+c.length);if(!this.#r(S,c,r,0,0))return!1;i+=c.length,s+=c.length}let p=0;if(d.length){if(d.length+i>t.length)return!1;let S=t.length-d.length;if(this.#r(t,d,r,S,0))p=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(S--,!this.#r(t,d,r,S,0)))return!1;p=d.length+1}}if(!u.length){let S=!!p;for(let k=i;k<t.length-p;k++){let w=String(t[k]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return r||S}let m=[[[],0]],f=m[0],g=0,y=[0];for(let S of u)S===No?(y.push(g),f=[[],0],m.push(f)):(f[0].push(S),g++);let v=m.length-1,x=t.length-p;for(let S of m)S[1]=x-(y[v--]+S[0].length);return!!this.#t(t,m,i,0,r,0,!!p)}#t(t,n,r,i,s,a,l){let c=n[i];if(!c){for(let p=r;p<t.length;p++){l=!0;let m=t[p];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1}return l}let[u,d]=c;for(;r<=d;){if(this.#r(t.slice(0,r+u.length),u,s,r,0)&&a<this.maxGlobstarRecursion){let f=this.#t(t,n,r+u.length,i+1,s,a+1,l);if(f!==!1)return f}let m=t[r];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1;r++}return s||null}#r(t,n,r,i,s){let a,l,c,u;for(a=i,l=s,u=t.length,c=n.length;a<u&&l<c;a++,l++){this.debug("matchOne loop");let d=n[l],p=t[a];if(this.debug(n,d,p),d===!1||d===No)return!1;let m;if(typeof d=="string"?(m=p===d,this.debug("string match",d,p,m)):(m=d.test(p),this.debug("pattern match",d,p,m)),!m)return!1}if(a===u&&l===c)return!0;if(a===u)return r;if(l===c)return a===u-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return QCe(this.pattern,this.options)}parse(t){ME(t);let n=this.options;if(t==="**")return No;if(t==="")return"";let r,i=null;(r=t.match(UDt))?i=n.dot?BDt:qDt:(r=t.match(RDt))?i=(n.nocase?n.dot?PDt:NDt:n.dot?$Dt:ODt)(r[1]):(r=t.match(zDt))?i=(n.nocase?n.dot?HDt:WDt:n.dot?VDt:GDt)(r):(r=t.match(DDt))?i=n.dot?LDt:MDt:(r=t.match(jDt))&&(i=FDt);let s=ky.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let n=this.options,r=n.noglobstar?JDt:n.dot?YDt:XDt,i=new Set(n.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let m of p.flags.split(""))i.add(m);return typeof p=="string"?rMt(p):p===No?No:p._src});u.forEach((p,m)=>{let f=u[m+1],g=u[m-1];p!==No||g===No||(g===void 0?f!==void 0&&f!==No?u[m+1]="(?:\\/|"+r+"\\/)?"+f:u[m]=r:f===void 0?u[m-1]=g+"(?:\\/|\\/"+r+")?":f!==No&&(u[m-1]=g+"(?:\\/|\\/"+r+"\\/)"+f,u[m+1]=No))});let d=u.filter(p=>p!==No);if(this.partial&&d.length>=1){let p=[];for(let m=1;m<=d.length;m++)p.push(d.slice(0,m).join("/"));return"(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[a,l]=t.length>1?["(?:",")"]:["",""];s="^"+a+s+l+"$",this.partial&&(s="^(?:\\/|"+a+s.slice(1,-1)+l+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,n=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&n)return!0;let r=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let a=i[i.length-1];if(!a)for(let l=i.length-2;!a&&l>=0;l--)a=i[l];for(let l of s){let c=i;if(r.matchBase&&l.length===1&&(c=[a]),this.matchOne(c,l,n))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(t){return Pa.defaults(t).Minimatch}};Pa.AST=ky;Pa.Minimatch=ub;Pa.escape=xQ;Pa.unescape=ig;import{gunzipSync as Ajt}from"node:zlib";var jE=class{static{o(this,"Diff")}diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);let s=this.castInput(t,r),a=this.castInput(n,r),l=this.removeEmpty(this.tokenize(s,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(l,c,r,i)}diffWithOptionsObj(t,n,r,i){var s;let a=o(S=>{if(S=this.postProcess(S,r),i){setTimeout(function(){i(S)},0);return}else return S},"done"),l=n.length,c=t.length,u=1,d=l+c;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let p=(s=r.timeout)!==null&&s!==void 0?s:1/0,m=Date.now()+p,f=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(f[0],n,t,0,r);if(f[0].oldPos+1>=c&&g+1>=l)return a(this.buildValues(f[0].lastComponent,n,t));let y=-1/0,v=1/0,x=o(()=>{for(let S=Math.max(y,-u);S<=Math.min(v,u);S+=2){let k,w=f[S-1],E=f[S+1];w&&(f[S-1]=void 0);let I=!1;if(E){let Z=E.oldPos-S;I=E&&0<=Z&&Z<l}let R=w&&w.oldPos+1<c;if(!I&&!R){f[S]=void 0;continue}if(!R||I&&w.oldPos<E.oldPos?k=this.addToPath(E,!0,!1,0,r):k=this.addToPath(w,!1,!0,1,r),g=this.extractCommon(k,n,t,S,r),k.oldPos+1>=c&&g+1>=l)return a(this.buildValues(k.lastComponent,n,t))||!0;f[S]=k,k.oldPos+1>=c&&(v=Math.min(v,S-1)),g+1>=l&&(y=Math.max(y,S+1))}u++},"execEditLength");if(i)o(function S(){setTimeout(function(){if(u>d||Date.now()>m)return i(void 0);x()||S()},0)},"exec")();else for(;u<=d&&Date.now()<=m;){let S=x();if(S)return S}}addToPath(t,n,r,i,s){let a=t.lastComponent;return a&&!s.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,i,s){let a=n.length,l=r.length,c=t.oldPos,u=c-i,d=0;for(;u+1<a&&c+1<l&&this.equals(r[c+1],n[u+1],s);)u++,c++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let a=i.length,l=0,c=0,u=0;for(;l<a;l++){let d=i[l];if(d.removed)d.value=this.join(r.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let p=n.slice(c,c+d.count);p=p.map(function(m,f){let g=r[u+f];return g.length>m.length?g:m}),d.value=this.join(p)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var wQ=class extends jE{static{o(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=sMt}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
|
|
5738
|
+
`}o(wCe,"pageStyles");RS();var rQ="enabled",iQ=Object.freeze({id:"direct",capabilities:Object.freeze(["bash"]),plan:"free",shell:"just-bash-direct",probe:o(e=>e.LOADER===void 0?"available":"needs-binding","probe")}),NE=Object.freeze({id:"dynamic-worker",capabilities:Object.freeze(["bash","coding"]),plan:"paid",shell:"just-bash-isolated",probe:o(e=>e.LOADER===void 0?"needs-binding":"available","probe")}),sQ=Object.freeze({id:"container",capabilities:Object.freeze(["container"]),plan:"paid",shell:"linux-container",probe:o(e=>e.DSH_EDGE_CONTAINER_RUNTIME===rQ?"available":"needs-binding","probe")}),kPt=Object.freeze([sQ,NE,iQ]);function aQ(e,t=kPt){return t.filter(n=>n.probe(e)==="available")}o(aQ,"availableEdgeRuntimeProviders");function oQ(e){let t=o(r=>e.find(i=>i.capabilities.includes(r)),"first"),n=t("bash");if(n===void 0)throw new Error("No available runtime provider serves the bash layer.");return{bash:n.id,container:t("container")?.id??null}}o(oQ,"resolveEdgeRuntimeSelection");function xO(e){let t=aQ(e),{bash:n,container:r}=oQ(t);return t.find(i=>i.id===(r??n)).shell}o(xO,"resolveEdgeRuntimeShell");function EPt(){return"dsh-edge@0.19.0/isolated"}o(EPt,"resolveEdgeDeploymentId");function PE(e){return{baseURL:LH(e.DEEPSEEK_BASE_URL),maxTokens:UH(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:F1(e.DEEPSEEK_MODEL),reasoningEffort:jH(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:OR(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:FH(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:tg(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}o(PE,"resolveEdgeDeploymentConfig");function _Pt(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}o(_Pt,"edgeDeploymentApiKeyConfigured");function TPt(e){let t=LH(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}o(TPt,"projectedEdgeBaseURL");function lQ(e,t){return{shell:xO(e),storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:EPt(),apiKeyConfigured:_Pt(e),baseURL:TPt(e.DEEPSEEK_BASE_URL),maxTokens:UH(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:F1(e.DEEPSEEK_MODEL),reasoningEffort:jH(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:OR(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:FH(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:tg(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}o(lQ,"resolveEdgeDeploymentProfile");function wO(e){PE(e);let t=lQ(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,...e.CF_VERSION_METADATA===void 0?{}:{workerVersionId:e.CF_VERSION_METADATA.id},version:P1,upstreamVersion:Lye,status:"ready"}}o(wO,"resolveEdgeDeploymentHealth");import{AsyncLocalStorage as XHt}from"node:async_hooks";import{RpcTarget as APt}from"cloudflare:workers";function IPt(e){let{intervalMs:t,ping:n,onFailure:r}=e,i=!1,s=setInterval(()=>{i||n().catch(a=>{i||(i=!0,clearInterval(s),r(a instanceof Error?a:new Error(String(a))))})},t);return()=>{i||(i=!0,clearInterval(s))}}o(IPt,"startHeartbeat");async function CPt(e,t){let n=AbortSignal.timeout(t.timeoutMs),r=await e.fetchPort(t.port,`http://container${t.path}`,{method:"HEAD",signal:n});if(r.body?.cancel(),!r.ok)throw new Error(`computerd health returned ${r.status}`)}o(CPt,"probeComputerdHealth");var RPt="computer.internal",OPt="/health",cQ="/api",$Pt=8080,NPt=3e4,PPt=2e4,DPt=1,MPt=2e3,LPt=250,jPt=2e3;function FPt(e,t){if(t===void 0||e===null)return!1;let n=e.indexOf(" ");if(n===-1||e.slice(0,n).toLowerCase()!=="bearer")return!1;let r=e.slice(n+1).trim();if(r.length!==t.length)return!1;let i=0;for(let s=0;s<t.length;s+=1)i|=r.charCodeAt(s)^t.charCodeAt(s);return i===0}o(FPt,"bearerMatches");var kO=class{static{o(this,"CloudflareContainerBackend")}type="cloudflare-container";id;#e;#t;#r;#n;#i;#s;#o;#l;constructor(e){this.id=e.id??"container-shell",this.#t=e.egress??{mode:"none"},this.#r=this.#t.mode==="http-gateway"?crypto.randomUUID():void 0,this.#e={container:e.container,workspace:e.workspace,containerEnv:e.containerEnv,egressHost:e.egressHost??RPt,containerPort:e.containerPort??$Pt,connectTimeoutMs:e.connectTimeoutMs??NPt,heartbeatIntervalMs:e.heartbeatIntervalMs??PPt,restartAttempts:e.restartAttempts??DPt,healthProbeTimeoutMs:e.healthProbeTimeoutMs??MPt,healthRetryInitialDelayMs:e.healthRetryInitialDelayMs??LPt,healthRetryMaxDelayMs:e.healthRetryMaxDelayMs??jPt}}async connect(){if(this.#l)return this.#l;let e=Date.now()+this.#e.connectTimeoutMs,t=await(await this.#e.container()).getWorkspaceContainer(),n=await t.exitInfo().catch(()=>null),r={PORT:String(this.#e.containerPort),MOUNT_POINT:"/workspace",...this.#e.containerEnv},i,s;try{({runtimeId:i,clientSecret:s}=await t.start({env:r,enableInternet:this.#t.mode==="direct"}))}catch(p){throw new Lo(this.#d("start",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}try{await t.interceptOutboundHttp(this.#e.egressHost,this.#e.workspace),this.#t.mode==="http-gateway"&&this.#r!==void 0&&await t.interceptAllOutboundHttp(this.#e.workspace,this.#r)}catch(p){throw new Lo(this.#d("egress",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}this.#n=s,this.#u(),i=await this.#p(t,r,e,n,i),await this.#f(t,e),await this.#v(t,e,s);let a=await this.#h(e),l=o8(a),c,u=new Promise(p=>{let m=!1,f=o(()=>{m||(m=!0,c?.(),p(),this.#l=void 0)},"onClose");a.addEventListener("close",f,{once:!0}),a.addEventListener("error",f,{once:!0}),l.onRpcBroken(f)});this.#e.heartbeatIntervalMs>0&&(c=IPt({intervalMs:this.#e.heartbeatIntervalMs,ping:o(()=>l.sync.watermarks(),"ping"),onFailure:o(()=>{try{a.close()}catch{}},"onFailure")}));let d={rpc:l,runtimeId:i,closed:u,close:o(async()=>{c?.();try{l[Symbol.dispose]?.()}catch{}try{a.close()}catch{}this.#l=void 0},"close")};return this.#l=d,d}async handleFetch(e){if(this.#t.mode==="http-gateway"&&this.#r!==void 0&&e.headers.get("x-workspace-egress-token")===this.#r){let i=new Headers(e.headers),s=i.get(Lb),a;try{a=new URL(s??"")}catch{return new Response("invalid egress URL",{status:400})}if(a.protocol!=="http:"&&a.protocol!=="https:")return new Response("invalid egress URL",{status:400});i.delete(R_),i.delete(Lb);let l=new Request(e,{headers:i});return this.#t.gateway.fetch(new Request(a,l))}if(new URL(e.url).pathname!==cQ)return new Response("not found",{status:404});if(e.headers.get("upgrade")!=="websocket")return new Response(`${cQ} requires a websocket upgrade`,{status:400});if(!FPt(e.headers.get("authorization"),this.#n))return new Response("unauthorized",{status:401,headers:{"www-authenticate":"Bearer"}});let t=new WebSocketPair,[n,r]=[t[0],t[1]];if(r.accept(),this.#s)this.#s(r);else return r.close(1011,"no pending connect"),new Response("no pending connect",{status:409});return new Response(null,{status:101,webSocket:n})}#u(){this.#i=new Promise((e,t)=>{this.#s=e,this.#o=t}),this.#i.catch(()=>{})}#a(){this.#i=void 0,this.#s=void 0,this.#o=void 0}async#p(e,t,n,r,i){let s=this.#e.restartAttempts+1,a=Math.max(0,n-Date.now()),l=Math.max(250,Math.floor(a/s)),c=0,u=0,d,p=i;for(;c<s;){c++;let m=Math.min(n,Date.now()+l);if(await this.#m(e,m).then(()=>!0,f=>(d=f,!1)))return p;if(c<s)try{({runtimeId:p}=await e.restart({env:t,enableInternet:this.#t.mode==="direct"})),u++}catch(f){throw this.#o?.(f),this.#a(),new Lo(this.#d("restart",{attempt:c,maxAttempts:s,restarts:u,lastError:f}),{cause:f})}}throw this.#o?.(new Error("computerd never became healthy")),this.#a(),new Lo(this.#d("health",{attempt:c,maxAttempts:s,restarts:u,lastError:d,priorExit:r}),d instanceof Error?{cause:d}:void 0)}async#m(e,t){let n=this.#e.healthRetryInitialDelayMs,r;for(;Date.now()<t;)try{await CPt(e,{port:this.#e.containerPort,path:"/health",timeoutMs:Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now()))});return}catch(i){r=i;let s=t-Date.now();if(s<=0)break;await UPt(Math.min(n,s)),n=Math.min(n*2,this.#e.healthRetryMaxDelayMs)}throw r??new Error("computerd health probe timed out")}#d(e,t){let n=t.priorExit?` priorExit=${JSON.stringify(t.priorExit.reason)}`:"";return`CloudflareContainerBackend(${this.id}): connect failed at stage=${e} port=${this.#e.containerPort} attempt=${t.attempt}/${t.maxAttempts} restarts=${t.restarts} timeoutMs=${this.#e.connectTimeoutMs}${n} lastError=${SCe(t.lastError)}`}async#f(e,t){let n;try{let r=await e.fetchPort(this.#e.containerPort,"http://container/api",{signal:AbortSignal.timeout(Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now())))});n=r.status,await r.text().catch(()=>"")}catch{return}if(n!==401)throw this.#o?.(new Error("container is not enforcing RPC_CLIENT_SECRET")),this.#a(),new Lo(`CloudflareContainerBackend(${this.id}) [stage=auth]: container served an unauthenticated request to /api with ${n}, so this workspace would run without authorization. A container or image predating RPC_CLIENT_SECRET has to be recycled.`)}async#v(e,t,n){let r=Math.max(0,t-Date.now()),i;try{i=await e.fetchPort(this.#e.containerPort,"http://container/connect",{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},body:JSON.stringify({base:`http://${this.#e.egressHost}`,health:OPt,api:cQ,healthTimeoutMs:r})})}catch(s){throw this.#o?.(s),this.#a(),new Lo(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect failed: ${SCe(s)}`,{cause:s})}if(!i.ok){let s=await i.text().catch(()=>""),a=new Error(`/connect ${i.status}`);throw this.#o?.(a),this.#a(),new Lo(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect returned ${i.status}: ${s}`,{cause:a})}}async#h(e){let t=this.#i;if(!t)throw new Error("CloudflareContainerBackend: upgrade promise missing");let n=Math.max(0,e-Date.now()),r;try{return await Promise.race([t,new Promise((i,s)=>{r=setTimeout(()=>s(new Lo(`CloudflareContainerBackend(${this.id}) [stage=ws]: /api upgrade did not arrive within ${this.#e.connectTimeoutMs}ms`)),n)})])}finally{r&&clearTimeout(r),this.#a()}}};function UPt(e){return new Promise(t=>setTimeout(t,e))}o(UPt,"sleep");function SCe(e){return e instanceof Error?e.message:String(e)}o(SCe,"describeError");var kCe="computer:container-client-secret",qPt=16;function BPt(){let e=crypto.getRandomValues(new Uint8Array(qPt));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}o(BPt,"generate");var zPt=class{static{o(this,"ContainerClientSecret")}storage;constructor(e){this.storage=e}async ensure(){let e=await this.storage.get(kCe);if(typeof e=="string"&&e.length>0)return e;let t=BPt();return await this.storage.put(kCe,t),t}},ECe="computer:container-launch-record";async function _Ce(e){return{enableInternet:e.enableInternet,envDigest:await HPt(e.env)}}o(_Ce,"launchRecordFor");function WPt(e,t){return e.enableInternet===t.enableInternet&&e.envDigest===t.envDigest}o(WPt,"sameLaunch");async function HPt(e){let t=Object.keys(e).sort().map(r=>`${r.length}:${r}=${e[r]?.length??0}:${e[r]??""}`).join(";"),n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}o(HPt,"digestEnv");var VPt=class{static{o(this,"CurrentContainerLaunchRecord")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(ECe)??null}async set(e){await this.storage.put(ECe,e)}},TCe=new WeakMap;function pQ(e){let t=TCe.get(e);return t===void 0&&(t={exit:null,currentGeneration:0,expectedExitGeneration:null,currentMonitorSettled:null},TCe.set(e,t)),t}o(pQ,"getContainerLifecycle");function SO(e){return pQ(e).exit}o(SO,"containerExitInfo");function ACe(e){return e===void 0?"exited normally":e instanceof Error?e.message:String(e)}o(ACe,"formatExitReason");function ICe(e,t,n){let r=pQ(e);r.currentGeneration+=1;let i=r.currentGeneration;r.exit=null,r.currentMonitorSettled=t.monitor().then(()=>CCe(r,i,void 0,n),s=>CCe(r,i,s,n))}o(ICe,"installContainerMonitor");async function uQ(e,t){let n=pQ(e);n.expectedExitGeneration=n.currentGeneration;let r=n.currentMonitorSettled;await t.destroy(),r&&await r}o(uQ,"destroyContainerExpectingExit");async function CCe(e,t,n,r){if(t!==e.currentGeneration)return;let i=e.expectedExitGeneration===t;i&&(e.expectedExitGeneration=null);let s=ACe(n),a=Date.now();e.exit={reason:s,exitedAt:a},i?console.info({message:"workspace.container.exited",reason:s,exitedAt:a,expected:!0}):console.warn({message:"workspace.container.exited",reason:s,exitedAt:a,expected:!1});try{await r?.()}catch(l){console.error({message:"workspace.container.exit_cleanup_failed",reason:ACe(l),exitedAt:Date.now()})}}o(CCe,"recordExit");var dQ="computer:container-runtime-identity",GPt=class{static{o(this,"CurrentContainerRuntimeIdentity")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(dQ)??null}async markStarted(){let e={id:crypto.randomUUID()};return await this.storage.put(dQ,e),e}async clear(e){(await this.get())?.id===e.id&&await this.storage.delete(dQ)}},ZPt=class extends APt{static{o(this,"WorkspaceContainerAPI")}#e;#t;#r;#n;#i;constructor(e){if(super(),!e.container)throw new Error("WorkspaceContainerAPI: DO is not container-enabled (check wrangler.jsonc)");this.#e=e.container,this.#t=e,this.#r=new GPt(e.storage),this.#n=new zPt(e.storage),this.#i=new VPt(e.storage)}async start(e){let t=SO(this.#t),n=await this.#n.ensure(),r=await _Ce(e);if(t!==null){try{await uQ(this.#t,this.#e)}catch{}return this.#s(e,n,r,"launched")}if(!this.#e.running)return this.#s(e,n,r,"launched");let i=await this.#i.get();if(i===null||!WPt(i,r)){console.warn({message:i===null?"container was started outside WorkspaceContainerAPI; relaunching so the requested environment applies":"running container was launched with a different spec; relaunching",component:"workspace-container",requested:r,actual:i});try{await uQ(this.#t,this.#e)}catch{}return this.#s(e,n,r,"relaunched")}let s=await this.#r.get()??await this.#r.markStarted();return ICe(this.#t,this.#e,()=>this.#r.clear(s)),{runtimeId:s.id,clientSecret:n,outcome:"adopted"}}async restart(e){try{await uQ(this.#t,this.#e)}catch{}let t=await this.#n.ensure();return this.#s(e,t,await _Ce(e),"launched")}async setInactivityTimeout(e){await this.#e.setInactivityTimeout(e)}async#s(e,t,n,r){let i=await this.#r.markStarted();try{this.#e.start({enableInternet:e.enableInternet,env:{...e.env,RPC_CLIENT_SECRET:t}})}catch(s){throw await this.#r.clear(i),s}return await this.#i.set(n),ICe(this.#t,this.#e,()=>this.#r.clear(i)),{runtimeId:i.id,clientSecret:t,outcome:r}}async status(){return{running:this.#e.running,exit:SO(this.#t)}}async exitInfo(){return SO(this.#t)}async interceptAllOutboundHttp(e,t){let n=this.#t.exports.WorkspaceProxy({props:{...e,egressToken:t}});await Promise.all([this.#e.interceptAllOutboundHttp(n),this.#e.interceptOutboundHttps("*",n)])}async interceptOutboundHttp(e,t){let n=this.#t.exports;await this.#e.interceptOutboundHttp(e,n.WorkspaceProxy({props:t}))}fetchPort(e,t,n){let r=SO(this.#t);if(r!==null)throw new Lo(`container exited: ${r.reason}`);return this.#e.getTcpPort(e).fetch(t,n)}port(e){return this.#e.getTcpPort(e)}};function RCe(e){class t extends e{static{o(this,"WithWorkspaceContainer")}getWorkspaceContainer(){return new ZPt(this.ctx)}}return t}o(RCe,"withWorkspaceContainer");var KPt={session:"sessions",skill:"skills",agentPreset:"agentPresets",subagent:"subagents",goal:"goals",event:"events",download:"downloads"};function $Ce(e,t){let n=t.indexOf("."),r=t.indexOf("/"),i=n>=0?n:r;if(i<0)return;let s=t.slice(0,i),a=t.slice(i+1),l=KPt[s]??s,c=e[l];if(c===void 0)return;let u=c[a];return typeof u=="function"?u:void 0}o($Ce,"resolve");function JPt(e,t){return Response.json({type:"server-response",rpcId:e,result:{ok:!1,error:t}})}o(JPt,"errorResponse");async function fQ(e,t,n,r,i){let s=$Ce(e,t);if(s!==void 0)return await s({rpcId:n,payload:r},i)}o(fQ,"callEdgeApi");async function NCe(e,t){let r=new URL(t.url).pathname;if(t.method!=="POST"||!r.startsWith("/api/"))return new Response("not found",{status:404});if(r==="/api/respond")return Response.json({accepted:!1,reason:"not-pending"});let i=r.slice(5);if($Ce(e,i)===void 0)return new Response("not found",{status:404});let s;try{s=await t.json()}catch{return new Response("body is not JSON",{status:400})}let a=typeof s.rpcId=="string"?s.rpcId:"invalid-request",l=s.payload??{};try{let c=await fQ(e,i,a,l,t.signal);return c===void 0?new Response("not found",{status:404}):Response.json({type:"server-response",rpcId:c.rpcId,result:c.result})}catch(c){return JPt(a,{code:"internal",message:String(c),details:{}})}}o(NCe,"dispatchEdgeApi");yr();_s();im();import{DurableObject as QHt}from"cloudflare:workers";var EO=class{constructor(t,n=Date.now,r=2){this.sleepAfterMs=t;this.now=n;this.maxConcurrent=r}sleepAfterMs;now;maxConcurrent;static{o(this,"ContainerActivity")}inFlight=0;lastActivity;stopping;waiters=[];async admit(t){let n=this.now();for(;this.stopping!==void 0||this.inFlight>=this.maxConcurrent;){if(t?.throwIfAborted(),this.stopping!==void 0){await YPt(this.stopping,t);continue}await new Promise((r,i)=>{let s=o(()=>{t?.removeEventListener("abort",a),r()},"wake"),a=o(()=>{let l=this.waiters.indexOf(s);l!==-1&&this.waiters.splice(l,1),i(t.reason)},"abort");this.waiters.push(s),t?.addEventListener("abort",a,{once:!0})})}return t?.aborted===!0&&(this.waiters.shift()?.(),t.throwIfAborted()),{release:this.begin(),queuedMs:this.now()-n}}begin(){this.inFlight+=1,this.lastActivity=this.now();let t=!1;return()=>{t||(t=!0,this.inFlight-=1,this.lastActivity=this.now(),this.waiters.shift()?.())}}async stopIfIdle(t){return this.idle()?await this.stop(t):"busy"}async stopNow(t){return this.inFlight===0?await this.stop(t):"busy"}snapshot(){return{runningCommands:this.inFlight,lastActivityAt:this.lastActivity??null}}async stop(t){if(this.stopping!==void 0)return"busy";let n="stopped",r=t().catch(i=>{n="failed",this.lastActivity=this.now(),console.error("dsh-edge container stop failed.",i)});this.stopping=r;try{await r}finally{this.stopping=void 0}return n}deadline(){return this.inFlight>0?this.now()+this.sleepAfterMs():this.lastActivity===void 0?this.now():this.lastActivity+this.sleepAfterMs()}idle(){return this.inFlight===0&&(this.lastActivity===void 0||this.now()>=this.lastActivity+this.sleepAfterMs())}};function YPt(e,t){return t===void 0?e:new Promise((n,r)=>{let i=o(()=>r(t.reason),"abort");t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",i))})}o(YPt,"untilAborted");import{WorkerEntrypoint as HDn}from"cloudflare:workers";var Uy=vl(PCe(),1);var hQ=o((e,t,n)=>{let r=e instanceof RegExp?DCe(e,n):e,i=t instanceof RegExp?DCe(t,n):t,s=r!==null&&i!=null&&XPt(r,i,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+r.length,s[1]),post:n.slice(s[1]+i.length)}},"balanced"),DCe=o((e,t)=>{let n=t.match(e);return n?n[0]:null},"maybeMatch"),XPt=o((e,t,n)=>{let r,i,s,a,l,c=n.indexOf(e),u=n.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(r=[],s=n.length;d>=0&&!l;){if(d===c)r.push(d),c=n.indexOf(e,d+1);else if(r.length===1){let p=r.pop();p!==void 0&&(l=[p,u])}else i=r.pop(),i!==void 0&&i<s&&(s=i,a=u),u=n.indexOf(t,d+1);d=c<u&&c>=0?c:u}r.length&&a!==void 0&&(l=[s,a])}return l},"range");var MCe="\0SLASH"+Math.random()+"\0",LCe="\0OPEN"+Math.random()+"\0",yQ="\0CLOSE"+Math.random()+"\0",jCe="\0COMMA"+Math.random()+"\0",FCe="\0PERIOD"+Math.random()+"\0",QPt=new RegExp(MCe,"g"),eDt=new RegExp(LCe,"g"),tDt=new RegExp(yQ,"g"),nDt=new RegExp(jCe,"g"),rDt=new RegExp(FCe,"g"),iDt=/\\\\/g,sDt=/\\{/g,aDt=/\\}/g,oDt=/\\,/g,lDt=/\\\./g,cDt=1e5,uDt=4e6;function mQ(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}o(mQ,"numeric");function dDt(e){return e.replace(iDt,MCe).replace(sDt,LCe).replace(aDt,yQ).replace(oDt,jCe).replace(lDt,FCe)}o(dDt,"escapeBraces");function pDt(e){return e.replace(QPt,"\\").replace(eDt,"{").replace(tDt,"}").replace(nDt,",").replace(rDt,".")}o(pDt,"unescapeBraces");function UCe(e){if(!e)return[""];let t=[],n=hQ("{","}",e);if(!n)return e.split(",");let{pre:r,body:i,post:s}=n,a=r.split(",");a[a.length-1]+="{"+i+"}";let l=UCe(s);return s.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),t.push.apply(t,a),t}o(UCe,"parseCommaParts");function qCe(e,t={}){if(!e)return[];let{max:n=cDt,maxLength:r=uDt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),gQ(dDt(e),n,r,!0).map(pDt)}o(qCe,"expand");function fDt(e){return"{"+e+"}"}o(fDt,"embrace");function hDt(e){return/^-?0\d/.test(e)}o(hDt,"isPadded");function mDt(e,t){return e<=t}o(mDt,"lte");function gDt(e,t){return e>=t}o(gDt,"gte");function DE(e,t,n,r,i,s){let a=[],l=0;for(let c=0;c<e.length;c++)for(let u=0;u<n.length;u++){if(a.length>=r)return a;let d=e[c]+t+n[u];if(!(s&&!d)){if(l+d.length>i)return a;a.push(d),l+=d.length}}return a}o(DE,"combine");function yDt(e,t,n,r){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let a=mQ(i[0]),l=mQ(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(mQ(i[2])),1):1,d=mDt;l<a&&(u*=-1,d=gDt);let m=i.some(hDt),f=0;for(let g=a;d(g,l)&&s.length<n;g+=u){let y;if(t)y=String.fromCharCode(g),y==="\\"&&(y="");else if(y=String(g),m){let v=c-y.length;if(v>0){let x=new Array(v+1).join("0");g<0?y="-"+x+y.slice(1):y=x+y}}if(f+y.length>r)break;s.push(y),f+=y.length}return s}o(yDt,"expandSequence");function gQ(e,t,n,r){let i=[""],s=!1,a=!0;for(;;){let l=hQ("{","}",e);if(!l)return DE(i,e,[""],t,n,s);let c=l.pre;if(/\$$/.test(c)){if(i=DE(i,c+"{"+l.body+"}",[""],t,n,s&&!l.post.length),a=!1,!l.post.length)break;e=l.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(l.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(l.body),p=u||d,m=l.body.indexOf(",")>=0;if(!p&&!m){if(l.post.match(/,(?!,).*\}/)){e=l.pre+"{"+l.body+yQ+l.post,r=!0;continue}return DE(i,c+"{"+l.body+"}"+l.post,[""],t,n,s)}a&&(s=r&&!p,a=!1);let f;if(p)f=yDt(l.body,d,t,n);else{let g=UCe(l.body);if(g.length===1&&g[0]!==void 0&&(g=gQ(g[0],t,n,!1).map(fDt),g.length===1)){if(i=DE(i,c+g[0],[""],t,n,s&&!l.post.length),!l.post.length)break;e=l.post;continue}let y=s&&!l.post.length&&!c;for(let x=0;y&&x<i.length;x++)i[x]&&(y=!1);f=[];let v=0;e:for(let x=0;x<g.length;x++){let S=gQ(g[x],t,n,!1);for(let k=0;k<S.length;k++){let w=S[k];if(!(y&&!w)){if(f.length>=t||v+w.length>n)break e;f.push(w),v+=w.length}}}}if(i=DE(i,c,f,t,n,s&&!l.post.length),!l.post.length)break;e=l.post}return i}o(gQ,"expand_");var ME=o(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var vDt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},LE=o(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),bDt=o(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),BCe=o(e=>e.join(""),"rangesToString"),zCe=o((e,t)=>{let n=t;if(e.charAt(n)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=n+1,a=!1,l=!1,c=!1,u=!1,d=n,p="";e:for(;s<e.length;){let y=e.charAt(s);if((y==="!"||y==="^")&&s===n+1){u=!0,s++;continue}if(y==="]"&&a&&!c){d=s+1;break}if(a=!0,y==="\\"&&!c){c=!0,s++;continue}if(y==="["&&!c){for(let[v,[x,S,k]]of Object.entries(vDt))if(e.startsWith(v,s)){if(p)return["$.",!1,e.length-n,!0];s+=v.length,k?i.push(x):r.push(x),l=l||S;continue e}}if(c=!1,p){y>p?r.push(LE(p)+"-"+LE(y)):y===p&&r.push(LE(y)),p="",s++;continue}if(e.startsWith("-]",s+1)){r.push(LE(y+"-")),s+=2;continue}if(e.startsWith("-",s+1)){p=y,s+=2;continue}r.push(LE(y)),s++}if(d<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!u){let y=r[0].length===2?r[0].slice(-1):r[0];return[bDt(y),!1,d-n,!1]}let m="["+(u?"^":"")+BCe(r)+"]",f="["+(u?"":"^")+BCe(i)+"]";return[r.length&&i.length?"("+m+"|"+f+")":r.length?m:f,l,d-n,!0]},"parseClass");var ig=o((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var Jl,xDt=new Set(["!","?","+","*","@"]),vQ=o(e=>xDt.has(e),"isExtglobType"),WCe=o(e=>vQ(e.type),"isExtglobAST"),wDt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),SDt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),kDt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),HCe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),EDt="(?!(?:^|/)\\.\\.?(?:$|/))",TO="(?!\\.)",_Dt=new Set(["[","."]),TDt=new Set(["..","."]),ADt=new Set("().*{}+?[]^$\\!"),IDt=o(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),bQ="[^/]",VCe=bQ+"*?",GCe=bQ+"+?",CDt=0,ky=class{static{o(this,"AST")}type;#e;#t;#r=!1;#n=[];#i;#s;#o;#l=!1;#u;#a;#p=!1;id=++CDt;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#n.length,parts:this.#n}}constructor(t,n,r={}){this.type=t,t&&(this.#t=!0),this.#i=n,this.#e=this.#i?this.#i.#e:this,this.#u=this.#e===this?r:this.#e.#u,this.#o=this.#e===this?[]:this.#e.#o,t==="!"&&!this.#e.#l&&this.#o.push(this),this.#s=this.#i?this.#i.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#n)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#n.map(t=>String(t)).join("|")+")":this.#a=this.#n.map(t=>String(t)).join("")}#m(){if(this!==this.#e)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#o.pop();){if(t.type!=="!")continue;let n=t,r=n.#i;for(;r;){for(let i=n.#s+1;!r.type&&i<r.#n.length;i++)for(let s of t.#n){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#n[i])}n=r,r=n.#i}}return this}push(...t){for(let n of t)if(n!==""){if(typeof n!="string"&&!(n instanceof Jl&&n.#i===this))throw new Error("invalid part: "+n);this.#n.push(n)}}toJSON(){let t=this.type===null?this.#n.slice().map(n=>typeof n=="string"?n:n.toJSON()):[this.type,...this.#n.map(n=>n.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#l&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let n=0;n<this.#s;n++){let r=t.#n[n];if(!(r instanceof Jl&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#n.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let n=new Jl(this.type,t);for(let r of this.#n)n.copyIn(r);return n}static#d(t,n,r,i,s){let a=i.maxExtglobRecursion??2,l=!1,c=!1,u=-1,d=!1;if(n.type===null){let y=r,v="";for(;y<t.length;){let x=t.charAt(y++);if(l||x==="\\"){l=!l,v+=x;continue}if(c){y===u+1?(x==="^"||x==="!")&&(d=!0):x==="]"&&!(y===u+2&&d)&&(c=!1),v+=x;continue}else if(x==="["){c=!0,u=y,d=!1,v+=x;continue}if(!i.noext&&vQ(x)&&t.charAt(y)==="("&&s<=a){n.push(v),v="";let k=new Jl(x,n);y=Jl.#d(t,k,y,i,s+1),n.push(k);continue}v+=x}return n.push(v),y}let p=r+1,m=new Jl(null,n),f=[],g="";for(;p<t.length;){let y=t.charAt(p++);if(l||y==="\\"){l=!l,g+=y;continue}if(c){p===u+1?(y==="^"||y==="!")&&(d=!0):y==="]"&&!(p===u+2&&d)&&(c=!1),g+=y;continue}else if(y==="["){c=!0,u=p,d=!1,g+=y;continue}if(!i.noext&&vQ(y)&&t.charAt(p)==="("&&(s<=a||n&&n.#h(y))){let x=n&&n.#h(y)?0:1;m.push(g),g="";let S=new Jl(y,m);m.push(S),p=Jl.#d(t,S,p,i,s+x);continue}if(y==="|"){m.push(g),g="",f.push(m),m=new Jl(null,n);continue}if(y===")")return g===""&&n.#n.length===0&&(n.#p=!0),m.push(g),g="",n.push(...f,m),p;g+=y}return n.type=null,n.#t=void 0,n.#n=[t.substring(r-1)],p}#f(t){return this.#v(t,SDt)}#v(t,n=wDt){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null)return!1;let r=t.#n[0];return!r||typeof r!="object"||r.type===null?!1:this.#h(r.type,n)}#h(t,n=kDt){return!!n.get(this.type)?.includes(t)}#$(t,n){let r=t.#n[0],i=new Jl(null,r,this.options);i.#n.push(""),r.push(i),this.#b(t,n)}#b(t,n){let r=t.#n[0];this.#n.splice(n,1,...r.#n);for(let i of r.#n)typeof i=="object"&&(i.#i=this);this.#a=void 0}#E(t){return!!HCe.get(this.type)?.has(t)}#_(t){if(!t||typeof t!="object"||t.type!==null||t.#n.length!==1||this.type===null||this.#n.length!==1)return!1;let n=t.#n[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type)}#T(t){let n=HCe.get(this.type),r=t.#n[0],i=n?.get(r.type);if(!i)return!1;this.#n=r.#n;for(let s of this.#n)typeof s=="object"&&(s.#i=this);this.type=i,this.#a=void 0,this.#p=!1}static fromGlob(t,n={}){let r=new Jl(null,void 0,n);return Jl.#d(t,r,0,n,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[n,r,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#u.nocase&&!this.#u.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return r;let l=(this.#u.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${n}$`,l),{_src:n,_glob:t})}get options(){return this.#u}toRegExpSource(t){let n=t??!!this.#u.dot;if(this.#e===this&&(this.#c(),this.#m()),!WCe(this)){let c=this.isStart()&&this.isEnd()&&!this.#n.some(f=>typeof f!="string"),u=this.#n.map(f=>{let[g,y,v,x]=typeof f=="string"?Jl.#x(f,this.#t,c):f.toRegExpSource(t);return this.#t=this.#t||v,this.#r=this.#r||x,g}).join(""),d="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&TDt.has(this.#n[0]))){let g=_Dt,y=n&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),v=!n&&!t&&g.has(u.charAt(0));d=y?EDt:v?TO:""}let p="";return this.isEnd()&&this.#e.#l&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[d+u+p,ig(u),this.#t=!!this.#t,this.#r]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#g(n);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#n=[c],u.type=null,u.#t=void 0,[c,ig(this.toString()),!1,!1]}let a=!r||t||n||!TO?"":this.#g(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let l="";if(this.type==="!"&&this.#p)l=(this.isStart()&&!n?TO:"")+GCe;else{let c=this.type==="!"?"))"+(this.isStart()&&!n&&!t?TO:"")+VCe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=i+s+c}return[l,ig(s),this.#t=!!this.#t,this.#r]}#c(){if(WCe(this)){let t=0,n=!1;do{n=!0;for(let r=0;r<this.#n.length;r++){let i=this.#n[r];typeof i=="object"&&(i.#c(),this.#v(i)?(n=!1,this.#b(i,r)):this.#f(i)?(n=!1,this.#$(i,r)):this.#_(i)&&(n=!1,this.#T(i)))}}while(!n&&++t<10)}else for(let t of this.#n)typeof t=="object"&&t.#c();this.#a=void 0}#g(t){return this.#n.map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");let[r,i,s,a]=n.toRegExpSource(t);return this.#r=this.#r||a,r}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|")}static#x(t,n,r=!1){let i=!1,s="",a=!1,l=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(ADt.has(u)?"\\":"")+u;continue}if(u==="*"){if(l)continue;l=!0,s+=r&&/^[*]+$/.test(t)?GCe:VCe,n=!0;continue}else l=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,p,m,f]=zCe(t,c);if(m){s+=d,a=a||p,c+=m-1,n=n||f;continue}}if(u==="?"){s+=bQ,n=!0;continue}s+=IDt(u)}return[s,ig(t),!!n,a]}};Jl=ky;var xQ=o((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Pa=o((e,t,n={})=>(ME(t),!n.nocomment&&t.charAt(0)==="#"?!1:new ub(t,n).match(e)),"minimatch"),RDt=/^\*+([^+@!?*[(]*)$/,ODt=o(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),$Dt=o(e=>t=>t.endsWith(e),"starDotExtTestDot"),NDt=o(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),PDt=o(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),DDt=/^\*+\.\*+$/,MDt=o(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),LDt=o(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),jDt=/^\.\*+$/,FDt=o(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),UDt=/^\*+$/,qDt=o(e=>e.length!==0&&!e.startsWith("."),"starTest"),BDt=o(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),zDt=/^\?+([^+@!?*[(]*)?$/,WDt=o(([e,t=""])=>{let n=JCe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocase"),HDt=o(([e,t=""])=>{let n=YCe([e]);return t?(t=t.toLowerCase(),r=>n(r)&&r.toLowerCase().endsWith(t)):n},"qmarksTestNocaseDot"),VDt=o(([e,t=""])=>{let n=YCe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTestDot"),GDt=o(([e,t=""])=>{let n=JCe([e]);return t?r=>n(r)&&r.endsWith(t):n},"qmarksTest"),JCe=o(([e])=>{let t=e.length;return n=>n.length===t&&!n.startsWith(".")},"qmarksTestNoExt"),YCe=o(([e])=>{let t=e.length;return n=>n.length===t&&n!=="."&&n!==".."},"qmarksTestNoExtDot"),XCe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ZCe={win32:{sep:"\\"},posix:{sep:"/"}},ZDt=XCe==="win32"?ZCe.win32.sep:ZCe.posix.sep;Pa.sep=ZDt;var No=Symbol("globstar **");Pa.GLOBSTAR=No;var KDt="[^/]",JDt=KDt+"*?",YDt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",XDt="(?:(?!(?:\\/|^)\\.).)*?",QDt=o((e,t={})=>n=>Pa(n,e,t),"filter");Pa.filter=QDt;var bu=o((e,t={})=>Object.assign({},e,t),"ext"),eMt=o(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Pa;let t=Pa;return Object.assign(o((r,i,s={})=>t(r,i,bu(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{o(this,"Minimatch")}constructor(i,s={}){super(i,bu(e,s))}static defaults(i){return t.defaults(bu(e,i)).Minimatch}},AST:class extends t.AST{static{o(this,"AST")}constructor(i,s,a={}){super(i,s,bu(e,a))}static fromGlob(i,s={}){return t.AST.fromGlob(i,bu(e,s))}},unescape:o((r,i={})=>t.unescape(r,bu(e,i)),"unescape"),escape:o((r,i={})=>t.escape(r,bu(e,i)),"escape"),filter:o((r,i={})=>t.filter(r,bu(e,i)),"filter"),defaults:o(r=>t.defaults(bu(e,r)),"defaults"),makeRe:o((r,i={})=>t.makeRe(r,bu(e,i)),"makeRe"),braceExpand:o((r,i={})=>t.braceExpand(r,bu(e,i)),"braceExpand"),match:o((r,i,s={})=>t.match(r,i,bu(e,s)),"match"),sep:t.sep,GLOBSTAR:No})},"defaults");Pa.defaults=eMt;var QCe=o((e,t={})=>(ME(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:qCe(e,{max:t.braceExpandMax})),"braceExpand");Pa.braceExpand=QCe;var tMt=o((e,t={})=>new ub(e,t).makeRe(),"makeRe");Pa.makeRe=tMt;var nMt=o((e,t,n={})=>{let r=new ub(t,n);return e=e.filter(i=>r.match(i)),r.options.nonull&&!e.length&&e.push(t),e},"match");Pa.match=nMt;var KCe=/[?*]|[+@!]\(.*?\)|\[|\]/,rMt=o(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),ub=class{static{o(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,n={}){ME(t),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=t,this.platform=n.platform||XCe,this.isWindows=this.platform==="win32";let r="allowWindowsEscape";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[r]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let n of t)if(typeof n!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,n=this.options;if(!n.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!KCe.test(s[2]))&&!KCe.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let r of t)for(let i=0;i<r.length;i++)r[i]==="**"&&(r[i]="*");let{optimizationLevel:n=1}=this.options;return n>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):n>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(n=>{let r=-1;for(;(r=n.indexOf("**",r+1))!==-1;){let i=r;for(;n[i+1]==="**";)i++;i!==r&&n.splice(r,i-r)}return n})}levelOneOptimize(t){return t.map(n=>(n=n.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),n.length===0?[""]:n))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(n=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(n=!0,t.pop())}let r=0;for(;(r=t.indexOf("..",r+1))!==-1;){let i=t[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(n=!0,t.splice(r-1,2),r-=2)}}while(n);return t.length===0?[""]:t}firstPhasePreProcess(t){let n=!1;do{n=!1;for(let r of t){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let a=i;for(;r[a+1]==="**";)a++;a>i&&r.splice(i+1,a-i);let l=r[i+1],c=r[i+2],u=r[i+3];if(l!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;n=!0,r.splice(i,1);let d=r.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<r.length-1;a++){let l=r[a];a===1&&l===""&&r[0]===""||(l==="."||l==="")&&(n=!0,r.splice(a,1),a--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(n=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let a=r[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){n=!0;let c=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...c),r.length===0&&r.push(""),s-=2}}}}while(n);return t}secondPhasePreProcess(t){for(let n=0;n<t.length-1;n++)for(let r=n+1;r<t.length;r++){let i=this.partsMatch(t[n],t[r],!this.preserveMultipleSlashes);if(i){t[n]=[],t[r]=i;break}}return t.filter(n=>n.length)}partsMatch(t,n,r=!1){let i=0,s=0,a=[],l="";for(;i<t.length&&s<n.length;)if(t[i]===n[s])a.push(l==="b"?n[s]:t[i]),i++,s++;else if(r&&t[i]==="**"&&n[s]===t[i+1])a.push(t[i]),i++;else if(r&&n[s]==="**"&&t[i]===n[s+1])a.push(n[s]),s++;else if(t[i]==="*"&&n[s]&&(this.options.dot||!n[s].startsWith("."))&&n[s]!=="**"){if(l==="b")return!1;l="a",a.push(t[i]),i++,s++}else if(n[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(l==="a")return!1;l="b",a.push(n[s]),i++,s++}else return!1;return t.length===n.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,n=!1,r=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)n=!n,r++;r&&(this.pattern=t.slice(r)),this.negate=n}matchOne(t,n,r=!1){let i=0,s=0;if(this.isWindows){let l=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!l&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),d=!u&&n[0]===""&&n[1]===""&&n[2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3]),p=c?3:l?0:void 0,m=d?3:u?0:void 0;if(typeof p=="number"&&typeof m=="number"){let[f,g]=[t[p],n[m]];f.toLowerCase()===g.toLowerCase()&&(n[m]=f,s=m,i=p)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(t=this.levelTwoFileOptimize(t)),n.includes(No)?this.#e(t,n,r,i,s):this.#r(t,n,r,i,s)}#e(t,n,r,i,s){let a=n.indexOf(No,s),l=n.lastIndexOf(No),[c,u,d]=r?[n.slice(s,a),n.slice(a+1),[]]:[n.slice(s,a),n.slice(a+1,l),n.slice(l+1)];if(c.length){let S=t.slice(i,i+c.length);if(!this.#r(S,c,r,0,0))return!1;i+=c.length,s+=c.length}let p=0;if(d.length){if(d.length+i>t.length)return!1;let S=t.length-d.length;if(this.#r(t,d,r,S,0))p=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(S--,!this.#r(t,d,r,S,0)))return!1;p=d.length+1}}if(!u.length){let S=!!p;for(let k=i;k<t.length-p;k++){let w=String(t[k]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return r||S}let m=[[[],0]],f=m[0],g=0,y=[0];for(let S of u)S===No?(y.push(g),f=[[],0],m.push(f)):(f[0].push(S),g++);let v=m.length-1,x=t.length-p;for(let S of m)S[1]=x-(y[v--]+S[0].length);return!!this.#t(t,m,i,0,r,0,!!p)}#t(t,n,r,i,s,a,l){let c=n[i];if(!c){for(let p=r;p<t.length;p++){l=!0;let m=t[p];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1}return l}let[u,d]=c;for(;r<=d;){if(this.#r(t.slice(0,r+u.length),u,s,r,0)&&a<this.maxGlobstarRecursion){let f=this.#t(t,n,r+u.length,i+1,s,a+1,l);if(f!==!1)return f}let m=t[r];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1;r++}return s||null}#r(t,n,r,i,s){let a,l,c,u;for(a=i,l=s,u=t.length,c=n.length;a<u&&l<c;a++,l++){this.debug("matchOne loop");let d=n[l],p=t[a];if(this.debug(n,d,p),d===!1||d===No)return!1;let m;if(typeof d=="string"?(m=p===d,this.debug("string match",d,p,m)):(m=d.test(p),this.debug("pattern match",d,p,m)),!m)return!1}if(a===u&&l===c)return!0;if(a===u)return r;if(l===c)return a===u-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return QCe(this.pattern,this.options)}parse(t){ME(t);let n=this.options;if(t==="**")return No;if(t==="")return"";let r,i=null;(r=t.match(UDt))?i=n.dot?BDt:qDt:(r=t.match(RDt))?i=(n.nocase?n.dot?PDt:NDt:n.dot?$Dt:ODt)(r[1]):(r=t.match(zDt))?i=(n.nocase?n.dot?HDt:WDt:n.dot?VDt:GDt)(r):(r=t.match(DDt))?i=n.dot?LDt:MDt:(r=t.match(jDt))&&(i=FDt);let s=ky.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let n=this.options,r=n.noglobstar?JDt:n.dot?YDt:XDt,i=new Set(n.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let m of p.flags.split(""))i.add(m);return typeof p=="string"?rMt(p):p===No?No:p._src});u.forEach((p,m)=>{let f=u[m+1],g=u[m-1];p!==No||g===No||(g===void 0?f!==void 0&&f!==No?u[m+1]="(?:\\/|"+r+"\\/)?"+f:u[m]=r:f===void 0?u[m-1]=g+"(?:\\/|\\/"+r+")?":f!==No&&(u[m-1]=g+"(?:\\/|\\/"+r+"\\/)"+f,u[m+1]=No))});let d=u.filter(p=>p!==No);if(this.partial&&d.length>=1){let p=[];for(let m=1;m<=d.length;m++)p.push(d.slice(0,m).join("/"));return"(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[a,l]=t.length>1?["(?:",")"]:["",""];s="^"+a+s+l+"$",this.partial&&(s="^(?:\\/|"+a+s.slice(1,-1)+l+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,n=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&n)return!0;let r=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let a=i[i.length-1];if(!a)for(let l=i.length-2;!a&&l>=0;l--)a=i[l];for(let l of s){let c=i;if(r.matchBase&&l.length===1&&(c=[a]),this.matchOne(c,l,n))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(t){return Pa.defaults(t).Minimatch}};Pa.AST=ky;Pa.Minimatch=ub;Pa.escape=xQ;Pa.unescape=ig;import{gunzipSync as Ajt}from"node:zlib";var jE=class{static{o(this,"Diff")}diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);let s=this.castInput(t,r),a=this.castInput(n,r),l=this.removeEmpty(this.tokenize(s,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(l,c,r,i)}diffWithOptionsObj(t,n,r,i){var s;let a=o(S=>{if(S=this.postProcess(S,r),i){setTimeout(function(){i(S)},0);return}else return S},"done"),l=n.length,c=t.length,u=1,d=l+c;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let p=(s=r.timeout)!==null&&s!==void 0?s:1/0,m=Date.now()+p,f=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(f[0],n,t,0,r);if(f[0].oldPos+1>=c&&g+1>=l)return a(this.buildValues(f[0].lastComponent,n,t));let y=-1/0,v=1/0,x=o(()=>{for(let S=Math.max(y,-u);S<=Math.min(v,u);S+=2){let k,w=f[S-1],E=f[S+1];w&&(f[S-1]=void 0);let I=!1;if(E){let Z=E.oldPos-S;I=E&&0<=Z&&Z<l}let R=w&&w.oldPos+1<c;if(!I&&!R){f[S]=void 0;continue}if(!R||I&&w.oldPos<E.oldPos?k=this.addToPath(E,!0,!1,0,r):k=this.addToPath(w,!1,!0,1,r),g=this.extractCommon(k,n,t,S,r),k.oldPos+1>=c&&g+1>=l)return a(this.buildValues(k.lastComponent,n,t))||!0;f[S]=k,k.oldPos+1>=c&&(v=Math.min(v,S-1)),g+1>=l&&(y=Math.max(y,S+1))}u++},"execEditLength");if(i)o(function S(){setTimeout(function(){if(u>d||Date.now()>m)return i(void 0);x()||S()},0)},"exec")();else for(;u<=d&&Date.now()<=m;){let S=x();if(S)return S}}addToPath(t,n,r,i,s){let a=t.lastComponent;return a&&!s.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,i,s){let a=n.length,l=r.length,c=t.oldPos,u=c-i,d=0;for(;u+1<a&&c+1<l&&this.equals(r[c+1],n[u+1],s);)u++,c++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let a=i.length,l=0,c=0,u=0;for(;l<a;l++){let d=i[l];if(d.removed)d.value=this.join(r.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let p=n.slice(c,c+d.count);p=p.map(function(m,f){let g=r[u+f];return g.length>m.length?g:m}),d.value=this.join(p)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var wQ=class extends jE{static{o(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=sMt}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
|
|
5739
5739
|
`))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
|
|
5740
5740
|
`))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
|
|
5741
5741
|
`)&&(t=t.slice(0,-1)),n.endsWith(`
|