@jayyuen66/dsh-scrapling 0.1.17 → 0.2.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.
@@ -1,16 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import{accessSync as e,constants as t,existsSync as n,readFileSync as r,statSync as i}from"node:fs";import{access as a,chmod as o,cp as s,mkdir as c,open as l,readFile as u,readdir as d,rename as f,rm as p,rmdir as m,stat as h,writeFile as ee}from"node:fs/promises";import te from"node:os";import g from"node:path";import{AsyncLocalStorage as ne}from"node:async_hooks";import{createHash as re,randomUUID as ie}from"node:crypto";import{createRequire as ae}from"node:module";import{spawn as oe}from"node:child_process";var se=Object.create,ce=Object.defineProperty,le=Object.getOwnPropertyDescriptor,ue=Object.getOwnPropertyNames,de=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty,pe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),me=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ue(t),a=0,o=i.length,s;a<o;a++)s=i[a],!fe.call(e,s)&&s!==n&&ce(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=le(t,s))||r.enumerable});return e},he=(e,t,n)=>(n=e==null?{}:se(de(e)),me(t||!e||!e.__esModule||!fe.call(e,`default`)?ce(n,`default`,{value:e,enumerable:!0}):n,e));const ge=`scrapling`,_e=[`eager`,`on-demand`],ve=`streamable-http`,ye=`stdio`,be=`DSH_SCRAPLING_MCP_TOKEN`,_=`@deepseek-ai/dsh-mcp-client`,xe=`0.2.3-alpha.2`,Se=Object.freeze([xe,`0.2.2-rc.5`,`0.2.2-rc.1`,`next`]),Ce=[`native`,`mcp`,`official-mcp`],we=new Set(Ce);function Te(e){return we.has(e)}function Ee(e,t){if(!Number.isInteger(e)||e<1||e>65535)throw Error(`MCP port must be an integer in 1..65535, got ${String(e)}`);if(t.trim().length===0)throw Error(`MCP host must not be blank`);if(t.includes(`://`))throw Error(`MCP host must be a bare host, got ${JSON.stringify(t)}`);if(t.startsWith(`[`)&&!t.endsWith(`]`))throw Error(`MCP host has an unterminated bracket, got ${JSON.stringify(t)}`);if(t.includes(`%`))throw Error(`MCP host must percent-encode its zone id as %25 (RFC 6874), got ${JSON.stringify(t)}`);return`http://${t.includes(`:`)&&!t.startsWith(`[`)?`[${t}]`:t}:${String(e)}/mcp`}function De(e=xe){if(!Se.includes(e))throw Error(`unsupported MCP client pin: ${JSON.stringify(e)}`);return`dsh plugin --profile <profile> add ${_}@${e}`}var Oe=class extends Error{code;constructor(e,t){super(t),this.name=`OfficialMcpError`,this.code=e}};function ke(e){if(!g.isAbsolute(e))throw new Oe(`OFFICIAL_MCP_DATA_DIR`,`官方 server 的入口要绝对 dataDir 才能拼:现在给的是 ${JSON.stringify(e)}。相对路径会被宿主按它自己的 cwd 解析,写进 patch 的 command 就不是这个文件了。`);let t=g.join(e,`runtime`,`venv`);return process.platform===`win32`?g.join(t,`Scripts`,`scrapling-mcp.exe`):g.join(t,`bin`,`scrapling-mcp`)}function Ae(e){switch(e){case`"`:return String.raw`\"`;case`\\`:return String.raw`\\`;case`
3
- `:return String.raw`\n`;case`\r`:return String.raw`\r`;case` `:return String.raw`\t`;default:return`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`}}const je=/[\u0000-\u001F\u007F-\u009F\u2028\u2029"\\]/gu;function Me(e){return`"${e.replaceAll(je,e=>Ae(e))}"`}const Ne="official-mcp 直连官方 scrapling-mcp:它的全部工具不经本插件的 URL 守卫与会话闸门(钉住的 scrapling 版本里有 `browser_evaluate` 这类任意 JS 执行),用的是它自己的会话与状态,本插件既不复用也不拦截。";function Pe(e){if(!e.enabled)throw new Oe(`OFFICIAL_MCP_DISABLED`,`official-mcp 未启用:部署配置里把 officialMcpEnabled 设为 true 才会生成接入配置`);if(!e.acceptedRisk)throw new Oe(`RISK_NOT_ACCEPTED`,`${Ne} 确认接受请再跑一次 setup 并带 --accept-risk。`);let t=ke(e.dataDir),n=[],r=ge;return{command:t,args:n,serverName:r,risk:Ne,installCommand:De(`0.2.3-alpha.2`),patch:[`- insert:`,` - id: scrapling-official-mcp`,` name: '${_}'`,` config:`,` serverName: ${r}`,` transport: ${ye}`,` command: ${Me(t)}`,` args: ${JSON.stringify(n)}`,` failOnStartupError: true`,` toolLoading: ${e.toolLoading??`eager`}`,``].join(`
4
- `)}}function Fe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ie=/\r\n|\n|\r/u,Le=/:(?<port>\d+)/u,Re=/[\t ]#.*$/u,ze=/^(?:"(?<double>[^"]*)"|'(?<single>[^']*)')$/u,Be=/^(?:-[\t ]*)?name:(?<value>.*)$/u,Ve=/^(?<key>[\w-]+):[\t ]+(?<value>\S.*)$/u;function He(e,t,n){return e||t===void 0||n<=t}function Ue(e){let t=e.trim(),n=ze.exec(t)?.groups;if(n!==void 0)return n.double??n.single;let r=t.replace(Re,``).trim(),i=ze.exec(r)?.groups,a=i?.double??i?.single;return a===void 0?r.length===0?void 0:r:a}function We(e){return e.split(Ie)}function Ge(e){let t=[],n;for(let r of We(e)){let e=r.length-r.trimStart().length,i=r.slice(e),a=i.startsWith(`-`),o=Ue(Be.exec(i)?.groups?.value??``),s=Ve.exec(i)?.groups;o!==void 0&&He(a,n?.indent,e)?(n={entry:{name:o,config:{}},indent:e},t.push(n.entry)):s?.key!==void 0&&s.value!==void 0&&n!==void 0&&e>n.indent&&(n.entry.config[s.key]=Ue(s.value))}return t}function Ke(e){let{url:t}=e.config,n;if(t!==void 0)try{let{port:e,protocol:r}=new URL(t);e===``?r===`http:`?n=`80`:r===`https:`&&(n=`443`):n=e}catch{n=Le.exec(t)?.groups?.port}return n}function qe(e){return e.config.transport===ye}function Je(e){let t=[];if(e.clientVersionBroken===!0)return t.push({code:`MCP_CLIENT_MANIFEST_BROKEN`,detail:`profile 的 package.json 读不懂(JSON 语法错误或顶层不是对象)——这不是「没装客户端」,先把这份文件修好`}),t;e.mode!==`native`&&e.clientVersion===void 0&&t.push({code:`MCP_CLIENT_MISSING`,detail:`profile 没有 ${_}:跑 ${De()} 装上它`});let n=e.clientVersion;return n!==void 0&&!Se.includes(n)&&t.push({code:`MCP_CLIENT_UNPINNED`,detail:`客户端钉的是 ${e.clientVersion},只接受 ${Se.join(` 或 `)} —— 宿主对不匹配的对端拒绝装载`}),t}function Ye(e,t){let n=[];t.length>1&&n.push({code:`DUPLICATE_SCRAPLING_ENTRY`,detail:`serverName 为 scrapling 的条目有 ${String(t.length)} 条,一个名字只能有一个 server`}),t.some(e=>qe(e))&&t.some(e=>!qe(e))&&n.push({code:`MCP_MODE_CONFLICT`,detail:`本插件的 ${ve} 条目与官方 ${ye} 条目并存;同一时刻只能一种`});let r=e.mode===`official-mcp`,i=t.some(e=>r===qe(e));return e.mode===`native`&&t.length>0?n.push({code:`MCP_MODE_ENTRY_MISMATCH`,detail:`integrationMode=native 却留着 scrapling 的 MCP 条目:模型会同时看到两套工具`}):e.mode!==`native`&&!i&&n.push({code:`MCP_MODE_ENTRY_MISMATCH`,detail:`integrationMode=${e.mode} 需要 ${r?ye:ve} 条目,profile 里没有`}),r&&!e.officialMcpEnabled&&t.some(e=>qe(e))&&n.push({code:`MCP_OFFICIAL_SWITCH_OFF`,detail:`留着官方 stdio 条目但 officialMcpEnabled=false:官方 server 的工具不经本插件守卫,开关要明说`}),n}function Xe(e,t){let n=[...new Set(e.map(e=>Ke(e)).filter(e=>e!==void 0))];if(n.length===0){let n=e.filter(e=>!qe(e));return t!==void 0&&n.length>0?[{code:`MCP_PORT_UNREADABLE`,detail:`给了 --port ${String(t)},但 profile 里 ${String(n.length)} 条 ${ve} 条目都读不出端口(url 为空、写成占位符或被引号/注释截断):端口一致性没法比对,客户端连哪个端口取决于 patch 里那条 url`}]:[]}let r=t===void 0?void 0:String(t);return n.length<2&&(r===void 0||n.includes(r))?[]:[{code:`MCP_PORT_MISMATCH`,detail:`条目里的端口是 ${n.join(`, `)}${r===void 0?``:`,--port 说的是 ${r}`};改过 mcpPort 就要重新应用 patch`}]}function Ze(e){let t=Ge(e.patchText).filter(e=>e.name===`@deepseek-ai/dsh-mcp-client`&&e.config.serverName===`scrapling`);return[...Je(e),...Ye(e,t),...Xe(t,e.expectedPort)]}const Qe=/^(?<indent>[\t ]*)officialMcpEnabled:(?<value>[^\r\n]*)$/gmu,$e=/^(?<indent>[\t ]*)mcpToolLoading:(?<value>[^\r\n]*)$/gmu;function et(e,t){let n,r;for(let i of e.matchAll(t)){
5
- /* v8 ignore next -- 命名组恒存在(`indent` 在模式里是无条件的),`?? ""` 只是类型收窄 */
6
- let e=i.groups?.indent??``;n??=e,e===n&&(r=i.groups?.value)}let i=r?.replace(Re,``).trim(),a=i===void 0?void 0:ze.exec(i)?.groups;return a?.double??a?.single??i}function tt(e){return et(e,Qe)}function nt(e){let t=et(e,$e);if(t===void 0||t===`eager`)return`eager`;if(t===`on-demand`)return t;throw Error(`mcpToolLoading 配置非法:${JSON.stringify(t)};只接受 ${_e.join(` / `)}`)}function rt(e){let t=tt(e);return t===`true`||t===`True`||t===`TRUE`}async function it(e){try{return await u(e,`utf8`)}catch(t){if(Fe(t)&&t.code===`ENOENT`)return``;throw Error(`读不出 ${e}:${String(t)}`,{cause:t})}}function at(e){if(e.trim().length===0)return{broken:!1};let t;try{t=JSON.parse(e)}catch{return{broken:!0}}if(!Fe(t))return{broken:!0};let{dependencies:n}=t,r=Fe(n)?n[_]:void 0;return{version:typeof r==`string`?r:void 0,broken:!1}}async function ot(e){let t=await h(e).catch(()=>null);if(t!==null&&!t.isDirectory())throw Error(`profile 不是目录:${e}`)}async function st(e){await ot(e);let[t,n]=await Promise.all([it(g.join(e,`cordis.patch.yml`)),it(g.join(e,`package.json`))]),r=at(n);return{patchText:t,clientVersion:r.version,clientVersionBroken:r.broken,officialMcpEnabled:rt(t),mcpToolLoading:nt(t)}}function ct(e){return`${e}.patch.yml`}function lt(e){let t=[`- insert:`,` - id: scrapling-mcp`,` name: '${_}'`,` config:`,` serverName: ${ge}`,` transport: ${ve}`,` url: ${Ee(e.port,`127.0.0.1`)}`,` failOnStartupError: false`,` toolLoading: ${e.toolLoading??`eager`}`];return e.withAuth&&t.push(` headers:`,` Authorization: !!js '\`Bearer \${process.env.${be}}\`'`),`${t.join(`
7
- `)}\n`}function ut(){return[`# integrationMode=native:profile 里不留 scrapling 的 MCP 条目。`,`# 留着条目时模型会同时看到原生工具与 mcp__scrapling__* 两套同名不同层的工具。`,`# 这份文本本身不删任何东西:profile 里若已有 name: '${_}' 的条目,`,"# 要手工删掉它再重启宿主,否则 `doctor --mode native` 会按事实报 MCP_MODE_ENTRY_MISMATCH。",``].join(`
8
- `)}const dt=[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`,`deepseek`];function ft(e){return dt.includes(e)}function pt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function mt(e,t=`|`){return e.map(e=>Pt(e)).join(t)}function ht(e,t){return typeof t==`bigint`?t.toString():t}var gt=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function _t(e){return new gt(e)}function vt(e){return e==null}function yt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function bt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function v(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function y(e){return xt(e._zod.def)??e._zod.def.shape}function St(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return v(this,t,e),e},enumerable:!0,configurable:!0})}function Ct(e,t,n){t in e?v(e,t,n):e[t]=n}function b(e,t,n,r){let i=y(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?St(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ct(e,a,r?r(n.value,a):n.value))}}function wt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?St(e,n,()=>t[n]):Ct(e,n,r.value))}}function x(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Tt(e){return JSON.stringify(e)}function Et(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Dt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const kt=/* @__PURE__*/ _t(()=>{if(M.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function At(e){if(Ot(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ot(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function jt(e){return At(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Mt=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function S(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function C(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Pt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ft(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const It={safeint:[-(2**53-1),2**53-1],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Lt={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function Rt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return b(i,e,zt(e,t)),S(e,x(n,{shape:i,checks:[]}))}function zt(e,t){let n=y(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Bt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(zt(e,t)),a={};return b(a,e,Reflect.ownKeys(y(e)).filter(e=>!i.has(e))),S(e,x(n,{shape:a,checks:[]}))}function Vt(e,t){if(!At(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=y(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return S(e,x(e._zod.def,{shape:Ht(e,t)}))}function Ht(e,t){let n={};return b(n,e,Reflect.ownKeys(y(e))),wt(n,t),n}function Ut(e,t){if(!At(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return S(e,x(e._zod.def,{shape:Ht(e,t)}))}function Wt(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return b(n,e,Reflect.ownKeys(y(e))),b(n,t,Reflect.ownKeys(y(t))),S(e,x(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Gt(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(zt(t,n)):void 0,o={};return b(o,t,Reflect.ownKeys(y(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),S(t,x(t._zod.def,{shape:o,checks:[]}))}function Kt(e,t,n){let r=n?new Set(zt(t,n)):void 0,i={};return b(i,t,Reflect.ownKeys(y(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),S(t,x(t._zod.def,{shape:i}))}function w(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function qt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function T(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Jt(e){return typeof e==`string`?e:e?.message}function Yt(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Xt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function E(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Jt(e.inst?._zod.def?.error?.(e))??Jt(a?.(e))??Jt(t?.error?.(e))??Jt(n.customError?.(e))??Jt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const Zt=/[\uD800-\uDBFF]/;function Qt(e){let t=e.length;if(!Zt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function $t(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function en(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function tn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function nn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):on(e,n,r.value)}}function D(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function rn(e,t,n){return D(e,t,n,!1)}/* @__NO_SIDE_EFFECTS__ */
9
- function an(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return D(this,n,r(this))},set(e){D(this,n,e)}})}return t}function on(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:D(this,t,n.bind(this))},set(e){D(this,t,e)}})}function sn(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let cn,O=!1;const ln={configurable:!0,get(){O=!0}};function k(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&cn!==e._zod?cn=void 0:(cn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ln);let e=O;O=!1;try{let r=n(this);return O?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),O||=e,r}catch(n){throw delete this[t],O||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function un(e,t,n,r){let i=sn(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function dn(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var fn;const pn={value:void 0,enumerable:!1};let mn=`captureStackTrace`in Error?Error:null;function hn(e){let t=mn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return mn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}/* @__NO_SIDE_EFFECTS__ */
10
- function A(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){pn.value=new a(r);try{Object.defineProperty(n,"_zod",pn)}finally{pn.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),nn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?hn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var j=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},gn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(fn=globalThis).__zod_globalConfig??(fn.__zod_globalConfig={});const M=globalThis.__zod_globalConfig;function N(e){return e&&Object.assign(M,e),M}function _n(){let e=this._zod;return e.message??=JSON.stringify(e.def,ht,2),e.message}function vn(e){this._zod.message=e}const yn={get:_n,set:vn,enumerable:!0,configurable:!0},bn={value:void 0,enumerable:!1},xn=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),Sn=/* @__PURE__ */ A(`$ZodError`,(e,t)=>{e.name=`$ZodError`,bn.value=t,Object.defineProperty(e,"issues",bn),bn.value=void 0,Object.defineProperty(e,"message",yn);let n=Object.getPrototypeOf(e);xn.has(n)||(xn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function Cn(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function wn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Cn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Tn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function En(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Dn(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${En(e.path)}`);return t.join(`
11
- `)}function On(e,t){return{callee:t?.callee??e,Err:t?.Err}}const kn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new j;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>E(e,o,N())));throw Dt(n,a?.callee??t),n}return s.value};return t},An=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>E(e,o,N())));throw Dt(n,a?.callee??t),n}return s.value};return t},jn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new j;return a.issues.length?Mn(e,a.issues,i):{success:!0,data:a.value}};function Mn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>E(e,n,N()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Nn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Mn(e,a.issues,i):{success:!0,data:a.value}},Pn=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),Fn=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),In=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Pn)return!0;if(r.definite===!0&&n===void 0)return!1}return Ln(e,t,n)});function Ln(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Fn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new j;return a.issues.length===0}const Rn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},zn=e=>{let t=kn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,On(n,a))};return n},Bn=e=>{let t=kn(e),n=(e,r,i,a)=>t(e,r,i,On(n,a));return n},Vn=e=>{let t=An(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,On(n,a))};return n},Hn=e=>{let t=An(e),n=async(e,r,i,a)=>await t(e,r,i,On(n,a));return n},Un=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return jn(e)(t,n,i)},Wn=e=>(t,n,r)=>jn(e)(t,n,r),Gn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Nn(e)(t,n,i)},Kn=e=>async(t,n,r)=>Nn(e)(t,n,r),qn=/^[cC][0-9a-z]{6,}$/,Jn=/^[0-9a-z]+$/,Yn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Xn=/^[0-9a-vA-V]{20}$/,Zn=/^[A-Za-z0-9]{27}$/,Qn=/^[a-zA-Z0-9_-]{21}$/;function $n(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const er=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,tr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,nr=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,rr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function ir(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const ar=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,or=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,sr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ur=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,dr=/^https?$/,fr=/^\+[1-9]\d{6,14}$/,pr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function mr(e){return RegExp(`^${e}$`)}const hr=/*@__PURE__*/ mr(pr);function gr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function _r(e){return RegExp(`^${gr(e)}$`)}function vr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${gr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${gr({precision:e.precision})}`:n;return RegExp(`^${pr}T(?:${r})$`)}const yr=/^[\s\S]{0,}$/,br=/^-?\d+$/,xr=/^-?\d+(?:\.\d+)?$/,Sr=/^[^A-Z]*$/,Cr=/^[^a-z]*$/,P=/*@__PURE__*/ A(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),wr=e=>{let t=e.value;return!vt(t)&&t.length!==void 0},Tr={number:`number`,bigint:`bigint`,object:`date`},Er=/*@__PURE__*/ A(`$ZodCheckLessThan`,(e,t)=>{P.init(e,t);let n=Tr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Tr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dr=/*@__PURE__*/ A(`$ZodCheckGreaterThan`,(e,t)=>{P.init(e,t);let n=Tr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Tr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Or=/*@__PURE__*/ A(`$ZodCheckMultipleOf`,(e,t)=>{P.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):bt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),kr=/*@__PURE__*/ A(`$ZodCheckNumberFormat`,(e,t)=>{P.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=It[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Ar=/*@__PURE__*/ A(`$ZodCheckMaxLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=wr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Qt(r):i)<=t.maximum)return;let a=$t(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),jr=/*@__PURE__*/ A(`$ZodCheckMinLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=wr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Qt(r):i)>=t.minimum)return;let a=$t(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Mr=/*@__PURE__*/ A(`$ZodCheckLengthEquals`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=wr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Qt(r):i;if(a===t.length)return;let o=$t(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Nr=/*@__PURE__*/ A(`$ZodCheckStringFormat`,(e,t)=>{var n,r;P.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Pr=/*@__PURE__*/ A(`$ZodCheckRegex`,(e,t)=>{Nr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fr=/*@__PURE__*/ A(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Sr,Nr.init(e,t)}),Ir=/*@__PURE__*/ A(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Cr,Nr.init(e,t)}),Lr=/*@__PURE__*/ A(`$ZodCheckIncludes`,(e,t)=>{P.init(e,t);let n=Nt(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Rr=/*@__PURE__*/ A(`$ZodCheckStartsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`^${Nt(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),zr=/*@__PURE__*/ A(`$ZodCheckEndsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`.*${Nt(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Br=/*@__PURE__*/ A(`$ZodCheckOverwrite`,(e,t)=>{P.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Vr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ import{accessSync as e,constants as t,existsSync as n,readFileSync as r,statSync as i}from"node:fs";import{access as a,chmod as o,cp as s,mkdir as c,open as l,readFile as u,readdir as d,rename as f,rm as p,rmdir as m,stat as h,writeFile as ee}from"node:fs/promises";import te from"node:os";import g from"node:path";import{AsyncLocalStorage as ne}from"node:async_hooks";import{createHash as re,randomUUID as _}from"node:crypto";import{createRequire as ie}from"node:module";import{spawn as ae}from"node:child_process";var oe=Object.create,se=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,le=Object.getOwnPropertyNames,ue=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty,fe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),pe=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of le(t))!de.call(e,i)&&i!==n&&(r=ce(t,i),se(e,i,{get:r&&r.get&&!r.configurable?r.get:()=>t[i],enumerable:!r||r.enumerable}));return e},me=(e,t,n)=>(n=e==null?{}:oe(ue(e)),pe(t||!e||!e.__esModule||!de.call(e,`default`)?se(n,`default`,{value:e,enumerable:!0}):n,e));function he(e){if(typeof e!=`object`||!e)return!1;try{return!Array.isArray(e)}catch{return!1}}function ge(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`)}const _e=`scrapling`,ve=[`eager`,`on-demand`],ye=`streamable-http`,be=`stdio`,xe=`DSH_SCRAPLING_MCP_TOKEN`,v=`@deepseek-ai/dsh-mcp-client`,Se=`0.2.3-alpha.3`,Ce=Object.freeze([Se,`0.2.2-rc.5`,`0.2.2-rc.1`,`next`]),we=[`native`,`mcp`,`official-mcp`],Te=new Set(we);function Ee(e){return Te.has(e)}function De(e,t){if(!Number.isInteger(e)||e<1||e>65535)throw Error(`MCP port must be an integer in 1..65535, got ${String(e)}`);if(t.trim().length===0)throw Error(`MCP host must not be blank`);if(t.includes(`://`))throw Error(`MCP host must be a bare host, got ${JSON.stringify(t)}`);if(t.startsWith(`[`)&&!t.endsWith(`]`))throw Error(`MCP host has an unterminated bracket, got ${JSON.stringify(t)}`);if(t.includes(`%`))throw Error(`MCP host must percent-encode its zone id as %25 (RFC 6874), got ${JSON.stringify(t)}`);return`http://${t.includes(`:`)&&!t.startsWith(`[`)?`[${t}]`:t}:${String(e)}/mcp`}function Oe(e=Se){if(!Ce.includes(e))throw Error(`unsupported MCP client pin: ${JSON.stringify(e)}`);return`dsh plugin --profile <profile> add ${v}@${e}`}var ke=class extends Error{code;constructor(e,t){super(t),this.name=`OfficialMcpError`,this.code=e}};function Ae(e){if(!g.isAbsolute(e))throw new ke(`OFFICIAL_MCP_DATA_DIR`,`官方 server 的入口要绝对 dataDir 才能拼:现在给的是 ${JSON.stringify(e)}。相对路径会被宿主按它自己的 cwd 解析,写进 patch 的 command 就不是这个文件了。`);let t=g.join(e,`runtime`,`venv`);return process.platform===`win32`?g.join(t,`Scripts`,`scrapling-mcp.exe`):g.join(t,`bin`,`scrapling-mcp`)}function je(e){switch(e){case`"`:return String.raw`\"`;case`\\`:return String.raw`\\`;case`
3
+ `:return String.raw`\n`;case`\r`:return String.raw`\r`;case` `:return String.raw`\t`;default:return`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`}}const Me=/[\u0000-\u001F\u007F-\u009F\u2028\u2029"\\]/gu;function Ne(e){return`"${e.replaceAll(Me,e=>je(e))}"`}const Pe="official-mcp 直连官方 scrapling-mcp:它的全部工具不经本插件的 URL 守卫与会话闸门(钉住的 scrapling 版本里有 `browser_evaluate` 这类任意 JS 执行),用的是它自己的会话与状态,本插件既不复用也不拦截。";function Fe(e){if(!e.enabled)throw new ke(`OFFICIAL_MCP_DISABLED`,`official-mcp 未启用:部署配置里把 officialMcpEnabled 设为 true 才会生成接入配置`);if(!e.acceptedRisk)throw new ke(`RISK_NOT_ACCEPTED`,`${Pe} 确认接受请再跑一次 setup 并带 --accept-risk。`);let t=Ae(e.dataDir),n=[],r=_e;return{command:t,args:n,serverName:r,risk:Pe,installCommand:Oe(`0.2.3-alpha.3`),patch:[`- insert:`,` - id: scrapling-official-mcp`,` name: '${v}'`,` config:`,` serverName: ${r}`,` transport: ${be}`,` command: ${Ne(t)}`,` args: ${JSON.stringify(n)}`,` startupTimeoutMs: 60000`,` failOnStartupError: true`,` toolLoading: ${e.toolLoading??`eager`}`,``].join(`
4
+ `)}}const Ie=/\r\n|\n|\r/u,Le=/:(?<port>\d+)/u,Re=/[\t ]#.*$/u,ze=/^(?:"(?<double>[^"]*)"|'(?<single>[^']*)')$/u,Be=/^(?:-[\t ]*)?name:(?<value>.*)$/u,Ve=/^(?<key>[\w-]+):[\t ]+(?<value>\S.*)$/u;function He(e,t,n){return e||t===void 0||n<=t}function Ue(e){let t=e.trim(),n=ze.exec(t)?.groups;if(n!==void 0)return n.double??n.single;let r=t.replace(Re,``).trim(),i=ze.exec(r)?.groups,a=i?.double??i?.single;return a===void 0?r.length===0?void 0:r:a}function We(e){return e.split(Ie)}function Ge(e){let t=[],n;for(let r of We(e)){let e=r.length-r.trimStart().length,i=r.slice(e),a=i.startsWith(`-`),o=Ue(Be.exec(i)?.groups?.value??``),s=Ve.exec(i)?.groups;o!==void 0&&He(a,n?.indent,e)?(n={entry:{name:o,config:{}},indent:e},t.push(n.entry)):s?.key!==void 0&&s.value!==void 0&&n!==void 0&&e>n.indent&&(n.entry.config[s.key]=Ue(s.value))}return t}function Ke(e){let{url:t}=e.config,n;if(t!==void 0)try{let{port:e,protocol:r}=new URL(t);e===``?r===`http:`?n=`80`:r===`https:`&&(n=`443`):n=e}catch{n=Le.exec(t)?.groups?.port}return n}function qe(e){return e.config.transport===be}function Je(e){let t=[];if(e.clientVersionBroken===!0)return t.push({code:`MCP_CLIENT_MANIFEST_BROKEN`,detail:`profile 的 package.json 读不懂(JSON 语法错误或顶层不是对象)——这不是「没装客户端」,先把这份文件修好`}),t;e.mode!==`native`&&e.clientVersion===void 0&&t.push({code:`MCP_CLIENT_MISSING`,detail:`profile 没有 ${v}:跑 ${Oe()} 装上它`});let n=e.clientVersion;return n!==void 0&&!Ce.includes(n)&&t.push({code:`MCP_CLIENT_UNPINNED`,detail:`客户端钉的是 ${e.clientVersion},只接受 ${Ce.join(` 或 `)} —— 宿主对不匹配的对端拒绝装载`}),t}function Ye(e,t){let n=[];t.length>1&&n.push({code:`DUPLICATE_SCRAPLING_ENTRY`,detail:`serverName 为 scrapling 的条目有 ${String(t.length)} 条,一个名字只能有一个 server`}),t.some(e=>qe(e))&&t.some(e=>!qe(e))&&n.push({code:`MCP_MODE_CONFLICT`,detail:`本插件的 ${ye} 条目与官方 ${be} 条目并存;同一时刻只能一种`});let r=e.mode===`official-mcp`,i=t.some(e=>r===qe(e));return e.mode===`native`&&t.length>0?n.push({code:`MCP_MODE_ENTRY_MISMATCH`,detail:`integrationMode=native 却留着 scrapling 的 MCP 条目:模型会同时看到两套工具`}):e.mode!==`native`&&!i&&n.push({code:`MCP_MODE_ENTRY_MISMATCH`,detail:`integrationMode=${e.mode} 需要 ${r?be:ye} 条目,profile 里没有`}),r&&!e.officialMcpEnabled&&t.some(e=>qe(e))&&n.push({code:`MCP_OFFICIAL_SWITCH_OFF`,detail:`留着官方 stdio 条目但 officialMcpEnabled=false:官方 server 的工具不经本插件守卫,开关要明说`}),n}function Xe(e,t){let n=[...new Set(e.map(e=>Ke(e)).filter(e=>e!==void 0))];if(n.length===0){let n=e.filter(e=>!qe(e));return t!==void 0&&n.length>0?[{code:`MCP_PORT_UNREADABLE`,detail:`给了 --port ${String(t)},但 profile 里 ${String(n.length)} 条 ${ye} 条目都读不出端口(url 为空、写成占位符或被引号/注释截断):端口一致性没法比对,客户端连哪个端口取决于 patch 里那条 url`}]:[]}let r=t===void 0?void 0:String(t);return n.length<2&&(r===void 0||n.includes(r))?[]:[{code:`MCP_PORT_MISMATCH`,detail:`条目里的端口是 ${n.join(`, `)}${r===void 0?``:`,--port 说的是 ${r}`};改过 mcpPort 就要重新应用 patch`}]}function Ze(e){let t=Ge(e.patchText).filter(e=>e.name===`@deepseek-ai/dsh-mcp-client`&&e.config.serverName===`scrapling`);return[...Je(e),...Ye(e,t),...Xe(t,e.expectedPort)]}const Qe=/^(?<indent>[\t ]*)officialMcpEnabled:(?<value>[^\r\n]*)$/gmu,$e=/^(?<indent>[\t ]*)mcpToolLoading:(?<value>[^\r\n]*)$/gmu;function et(e,t){let n,r;for(let i of e.matchAll(t)){let e=i.groups?.indent??``;n??=e,e===n&&(r=i.groups?.value)}let i=r?.replace(Re,``).trim(),a=i===void 0?void 0:ze.exec(i)?.groups;return a?.double??a?.single??i}function tt(e){return et(e,Qe)}function nt(e){let t=et(e,$e);if(t===void 0||t===`eager`)return`eager`;if(t===`on-demand`)return t;throw Error(`mcpToolLoading 配置非法:${JSON.stringify(t)};只接受 ${ve.join(` / `)}`)}function rt(e){let t=tt(e);return t===`true`||t===`True`||t===`TRUE`}async function it(e){try{return await u(e,`utf8`)}catch(t){if(he(t)&&t.code===`ENOENT`)return``;throw Error(`读不出 ${e}:${String(t)}`,{cause:t})}}function at(e){if(e.trim().length===0)return{broken:!1};let t;try{t=JSON.parse(e)}catch{return{broken:!0}}if(!he(t))return{broken:!0};let{dependencies:n}=t,r=he(n)?n[v]:void 0;return{version:typeof r==`string`?r:void 0,broken:!1}}async function ot(e){let t=await h(e).catch(()=>null);if(t!==null&&!t.isDirectory())throw Error(`profile 不是目录:${e}`)}async function st(e){await ot(e);let[t,n]=await Promise.all([it(g.join(e,`cordis.patch.yml`)),it(g.join(e,`package.json`))]),r=at(n);return{patchText:t,clientVersion:r.version,clientVersionBroken:r.broken,officialMcpEnabled:rt(t),mcpToolLoading:nt(t)}}function ct(e){return`${e}.patch.yml`}function lt(e){let t=[`- insert:`,` - id: scrapling-mcp`,` name: '${v}'`,` config:`,` serverName: ${_e}`,` transport: ${ye}`,` url: ${De(e.port,`127.0.0.1`)}`,` failOnStartupError: false`,` toolLoading: ${e.toolLoading??`eager`}`];return e.withAuth&&t.push(` headers:`,` Authorization: !!js '\`Bearer \${process.env.${xe}}\`'`),`${t.join(`
5
+ `)}\n`}function ut(){return[`# integrationMode=native:profile 里不留 scrapling 的 MCP 条目。`,`# 留着条目时模型会同时看到原生工具与 mcp__scrapling__* 两套同名不同层的工具。`,`# 这份文本本身不删任何东西:profile 里若已有 name: '${v}' 的条目,`,"# 要手工删掉它再重启宿主,否则 `doctor --mode native` 会按事实报 MCP_MODE_ENTRY_MISMATCH。",``].join(`
6
+ `)}const dt=[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`,`deepseek`];function ft(e){return dt.includes(e)}function pt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function mt(e,t=`|`){return e.map(e=>Mt(e)).join(t)}function ht(e,t){return typeof t==`bigint`?t.toString():t}var gt=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function _t(e){return new gt(e)}function vt(e){return e==null}function yt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function bt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function y(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function b(e){return xt(e._zod.def)??e._zod.def.shape}function St(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return y(this,t,e),e},enumerable:!0,configurable:!0})}function Ct(e,t,n){t in e?y(e,t,n):e[t]=n}function x(e,t,n,r){let i=b(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?St(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ct(e,a,r?r(n.value,a):n.value))}}function wt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?St(e,n,()=>t[n]):Ct(e,n,r.value))}}function S(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Tt(e){return JSON.stringify(e)}function Et(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Dt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const kt=_t(()=>{if(F.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function C(e){if(Ot(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ot(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function At(e){return C(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const jt=new Set([`string`,`number`,`symbol`]);function w(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function T(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function E(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Mt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Nt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const Pt={safeint:[-(2**53-1),2**53-1],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ft={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function It(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return x(i,e,Lt(e,t)),T(e,S(n,{shape:i,checks:[]}))}function Lt(e,t){let n=b(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Rt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Lt(e,t)),a={};return x(a,e,Reflect.ownKeys(b(e)).filter(e=>!i.has(e))),T(e,S(n,{shape:a,checks:[]}))}function zt(e,t){if(!C(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=b(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return T(e,S(e._zod.def,{shape:Bt(e,t)}))}function Bt(e,t){let n={};return x(n,e,Reflect.ownKeys(b(e))),wt(n,t),n}function Vt(e,t){if(!C(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return T(e,S(e._zod.def,{shape:Bt(e,t)}))}function Ht(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return x(n,e,Reflect.ownKeys(b(e))),x(n,t,Reflect.ownKeys(b(t))),T(e,S(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ut(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Lt(t,n)):void 0,o={};return x(o,t,Reflect.ownKeys(b(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),T(t,S(t._zod.def,{shape:o,checks:[]}))}function Wt(e,t,n){let r=n?new Set(Lt(t,n)):void 0,i={};return x(i,t,Reflect.ownKeys(b(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),T(t,S(t._zod.def,{shape:i}))}function D(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Gt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function O(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Kt(e){return typeof e==`string`?e:e?.message}function qt(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Jt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function k(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Kt(e.inst?._zod.def?.error?.(e))??Kt(a?.(e))??Kt(t?.error?.(e))??Kt(n.customError?.(e))??Kt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const Yt=/[\uD800-\uDBFF]/;function Xt(e){let t=e.length;if(!Yt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Zt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Qt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function $t(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function en(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):rn(e,n,r.value)}}function A(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function tn(e,t,n){return A(e,t,n,!1)}function nn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return A(this,n,r(this))},set(e){A(this,n,e)}})}return t}function rn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:A(this,t,n.bind(this))},set(e){A(this,t,e)}})}function an(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let on,j=!1;const sn={configurable:!0,get(){j=!0}};function M(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&on!==e._zod?on=void 0:(on=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,sn);let e=j;j=!1;try{let r=n(this);return j?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),j||=e,r}catch(n){throw delete this[t],j||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function cn(e,t,n,r){let i=an(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function ln(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var un;const dn={value:void 0,enumerable:!1};let fn=`captureStackTrace`in Error?Error:null;function pn(e){let t=fn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return fn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function N(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){dn.value=new a(r);try{Object.defineProperty(n,"_zod",dn)}finally{dn.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),en(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?pn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var P=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},mn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(un=globalThis).__zod_globalConfig??(un.__zod_globalConfig={});const F=globalThis.__zod_globalConfig;function I(e){return e&&Object.assign(F,e),F}function hn(){let e=this._zod;return e.message??=JSON.stringify(e.def,ht,2),e.message}function gn(e){this._zod.message=e}const _n={get:hn,set:gn,enumerable:!0,configurable:!0},vn={value:void 0,enumerable:!1},yn=new WeakSet([Object.prototype,Error.prototype]),bn=N(`$ZodError`,(e,t)=>{e.name=`$ZodError`,vn.value=t,Object.defineProperty(e,"issues",vn),vn.value=void 0,Object.defineProperty(e,"message",_n);let n=Object.getPrototypeOf(e);yn.has(n)||(yn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function xn(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Sn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?xn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Cn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function wn(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Tn(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${wn(e.path)}`);return t.join(`
7
+ `)}function En(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Dn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new P;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>k(e,o,I())));throw Dt(n,a?.callee??t),n}return s.value};return t},On=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>k(e,o,I())));throw Dt(n,a?.callee??t),n}return s.value};return t},kn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new P;return a.issues.length?An(e,a.issues,i):{success:!0,data:a.value}};function An(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>k(e,n,I()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const jn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?An(e,a.issues,i):{success:!0,data:a.value}},Mn=Symbol.for(`zod.compile.invalid`),Nn=Symbol.for(`zod.compile.fallback`),Pn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Mn)return!0;if(r.definite===!0&&n===void 0)return!1}return Fn(e,t,n)});function Fn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Nn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new P;return a.issues.length===0}const In=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Ln=e=>{let t=Dn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,En(n,a))};return n},Rn=e=>{let t=Dn(e),n=(e,r,i,a)=>t(e,r,i,En(n,a));return n},zn=e=>{let t=On(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,En(n,a))};return n},Bn=e=>{let t=On(e),n=async(e,r,i,a)=>await t(e,r,i,En(n,a));return n},Vn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return kn(e)(t,n,i)},Hn=e=>(t,n,r)=>kn(e)(t,n,r),Un=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return jn(e)(t,n,i)},Wn=e=>async(t,n,r)=>jn(e)(t,n,r),Gn=/^[cC][0-9a-z]{6,}$/,Kn=/^[0-9a-z]+$/,qn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Jn=/^[0-9a-vA-V]{20}$/,Yn=/^[A-Za-z0-9]{27}$/,Xn=/^[a-zA-Z0-9_-]{21}$/;function Zn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Qn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$n=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,er=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function nr(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const rr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ir=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ar=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,or=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,sr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,cr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,lr=/^https?$/,ur=/^\+[1-9]\d{6,14}$/,dr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function fr(e){return RegExp(`^${e}$`)}const pr=fr(dr);function mr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hr(e){return RegExp(`^${mr(e)}$`)}function gr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${mr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${mr({precision:e.precision})}`:n;return RegExp(`^${dr}T(?:${r})$`)}const _r=/^[\s\S]{0,}$/,vr=/^-?\d+$/,yr=/^-?\d+(?:\.\d+)?$/,br=/^[^A-Z]*$/,xr=/^[^a-z]*$/,L=N(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Sr=e=>{let t=e.value;return!vt(t)&&t.length!==void 0},Cr={number:`number`,bigint:`bigint`,object:`date`},wr=N(`$ZodCheckLessThan`,(e,t)=>{L.init(e,t);let n=Cr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Cr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Tr=N(`$ZodCheckGreaterThan`,(e,t)=>{L.init(e,t);let n=Cr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Cr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Er=N(`$ZodCheckMultipleOf`,(e,t)=>{L.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):bt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Dr=N(`$ZodCheckNumberFormat`,(e,t)=>{L.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Pt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Or=N(`$ZodCheckMaxLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=Sr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Xt(r):i)<=t.maximum)return;let a=Zt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kr=N(`$ZodCheckMinLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=Sr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Xt(r):i)>=t.minimum)return;let a=Zt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ar=N(`$ZodCheckLengthEquals`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=Sr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Xt(r):i;if(a===t.length)return;let o=Zt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),jr=N(`$ZodCheckStringFormat`,(e,t)=>{var n,r;L.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Mr=N(`$ZodCheckRegex`,(e,t)=>{jr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Nr=N(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=br,jr.init(e,t)}),Pr=N(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=xr,jr.init(e,t)}),Fr=N(`$ZodCheckIncludes`,(e,t)=>{L.init(e,t);let n=w(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ir=N(`$ZodCheckStartsWith`,(e,t)=>{L.init(e,t);let n=RegExp(`^${w(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Lr=N(`$ZodCheckEndsWith`,(e,t)=>{L.init(e,t);let n=RegExp(`.*${w(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Rr=N(`$ZodCheckOverwrite`,(e,t)=>{L.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var zr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
12
8
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
13
- `)}\n};`)(...Object.values(this.closed))}};const Hr={major:4,minor:6,patch:7},F=/*@__PURE__*/ A(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Hr;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=w(t),a;for(let o of n){if(o._zod.def.when){if(qt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new j;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Xt(t.issues,n,e),i||=w(t,n))});else{if(t.issues.length===n)continue;Xt(t.issues,n,e),i||=w(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(w(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new j;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new j;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return rn(this,`~standard`,Gr(this))},set"~standard"(e){D(this,`~standard`,e)}}),Ur=(e,t)=>e.issues.length?{issues:e.issues.map(e=>E(e,t,N()))}:{value:e.value};async function Wr(e,t){let n={async:!0};return Ur(await e._zod.run({value:t,issues:[]},n),n)}function Gr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Ur(r,n)}catch{}return Wr(e,t)},vendor:`zod`,version:1}}const Kr=/*@__PURE__*/ A(`$ZodString`,(e,t)=>{F.init(e,t),e._zod.pattern=t.pattern??yr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),I=/*@__PURE__*/ A(`$ZodStringFormat`,(e,t)=>{Nr.init(e,t),Kr.init(e,t)}),qr=/*@__PURE__*/ A(`$ZodGUID`,(e,t)=>{t.pattern??=tr,I.init(e,t)}),Jr=/*@__PURE__*/ A(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=nr(e)}else t.pattern??=nr();I.init(e,t)}),Yr=/*@__PURE__*/ A(`$ZodEmail`,(e,t)=>{t.pattern??=rr,I.init(e,t)});function Xr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Zr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Xr(e)||2:Qr(e,t)}function Qr(e,t){if(!t.normalize&&t.protocol?.source===dr.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const $r=/[\t\n\r]/g;function ei(e){return e.replace($r,``)}function ti(e,t){return t.lastIndex=0,t.test(e.hostname)}function ni(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const ri=/*@__PURE__*/ A(`$ZodURL`,(e,t)=>{I.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Zr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=ei(r);return}t.hostname&&!ti(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!ni(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:ei(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ii=/*@__PURE__*/ A(`$ZodEmoji`,(e,t)=>{t.pattern??=ir(),I.init(e,t)}),ai=/*@__PURE__*/ A(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Qn:$n(t.length),I.init(e,t)}),oi=/*@__PURE__*/ A(`$ZodCUID`,(e,t)=>{t.pattern??=qn,I.init(e,t)}),si=/*@__PURE__*/ A(`$ZodCUID2`,(e,t)=>{t.pattern??=Jn,I.init(e,t)}),ci=/*@__PURE__*/ A(`$ZodULID`,(e,t)=>{t.pattern??=Yn,I.init(e,t)}),li=/*@__PURE__*/ A(`$ZodXID`,(e,t)=>{t.pattern??=Xn,I.init(e,t)}),ui=/*@__PURE__*/ A(`$ZodKSUID`,(e,t)=>{t.pattern??=Zn,I.init(e,t)}),di=/*@__PURE__*/ A(`$ZodISODateTime`,(e,t)=>{t.pattern??=vr(t),I.init(e,t)}),fi=/*@__PURE__*/ A(`$ZodISODate`,(e,t)=>{t.pattern??=hr,I.init(e,t)}),pi=/*@__PURE__*/ A(`$ZodISOTime`,(e,t)=>{t.pattern??=_r(t),I.init(e,t)}),mi=/*@__PURE__*/ A(`$ZodISODuration`,(e,t)=>{t.pattern??=er,I.init(e,t)}),hi=/*@__PURE__*/ A(`$ZodIPv4`,(e,t)=>{t.pattern??=ar,I.init(e,t)}),gi=/^[0-9a-fA-F:.]+$/;function _i(e){return gi.test(e)?Xr(`http://[${e}]`):!1}const vi=/*@__PURE__*/ A(`$ZodIPv6`,(e,t)=>{t.pattern??=or,I.init(e,t),e._zod.check=n=>{_i(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),yi=/*@__PURE__*/ A(`$ZodCIDRv4`,(e,t)=>{t.pattern??=sr,I.init(e,t)});function bi(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:_i(n)}const xi=/*@__PURE__*/ A(`$ZodCIDRv6`,(e,t)=>{t.pattern??=cr,I.init(e,t),e._zod.check=n=>{bi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Si(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Ci=/^[0-9a-zA-Z+/]*={0,2}$/,wi=/*@__PURE__*/ A(`$ZodBase64`,(e,t)=>{t.pattern??=Ci,I.init(e,t),e._zod.check=n=>{Si(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ti=/^[A-Za-z0-9_-]*$/;function Ei(e){if(!Ti.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Si(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Di=/*@__PURE__*/ A(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ti,I.init(e,t),e._zod.check=n=>{Ei(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Oi=/*@__PURE__*/ A(`$ZodE164`,(e,t)=>{t.pattern??=fr,I.init(e,t)});function ki(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Ai=/*@__PURE__*/ A(`$ZodJWT`,(e,t)=>{I.init(e,t),e._zod.check=n=>{ki(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ji=/*@__PURE__*/ A(`$ZodNumber`,(e,t)=>{F.init(e,t),e._zod.pattern=xr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Mi=/*@__PURE__*/ A(`$ZodNumberFormat`,(e,t)=>{kr.init(e,t),ji.init(e,t)}),Ni=/*@__PURE__*/ A(`$ZodUnknown`,(e,t)=>{F.init(e,t),e._zod.parse=e=>e}),Pi=/*@__PURE__*/ A(`$ZodNever`,(e,t)=>{F.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Fi(e,t){let n=Yt(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Yt(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Xt(n.issues,t,e),n}}return i(n,a)}}const Ii=e=>Array.isArray(e)?e.length:-1;function Li(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}const Ri=/*@__PURE__*/ A(`$ZodArray`,(e,t)=>{F.init(e,t);let n=M.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Li(t,r,e)));else if(Li(c,r,e),s&&c.issues.length!==0&&w(c))break}return o.length?Promise.all(o).then(()=>r):r},Fi(e,Ii)});function zi(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...T(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const Bi=[];function Vi(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Bi,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Ft(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Hi(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(w(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>zi(e,n,i,t,d,f))):zi(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Ui=/*@__PURE__*/ A(`$ZodObject`,(e,t)=>{F.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=_t(()=>Vi(t));k(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||v(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Ot,o=t.catchall,s,c=M.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(w(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>zi(n,t,e,r,a,o))):zi(s,t,e,r,a,o)}return o?Hi(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Wi=/*@__PURE__*/ A(`$ZodObjectJIT`,(e,t)=>{Ui.init(e,t);let n=e._zod.parse,r=_t(()=>Vi(t)),i=M.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Vr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
9
+ `)}\n};`)(...Object.values(this.closed))}};const Br={major:4,minor:6,patch:7},R=N(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Br;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=D(t),a;for(let o of n){if(o._zod.def.when){if(Gt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new P;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Jt(t.issues,n,e),i||=D(t,n))});else{if(t.issues.length===n)continue;Jt(t.issues,n,e),i||=D(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(D(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new P;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new P;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return tn(this,`~standard`,Ur(this))},set"~standard"(e){A(this,`~standard`,e)}}),Vr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>k(e,t,I()))}:{value:e.value};async function Hr(e,t){let n={async:!0};return Vr(await e._zod.run({value:t,issues:[]},n),n)}function Ur(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Vr(r,n)}catch{}return Hr(e,t)},vendor:`zod`,version:1}}const Wr=N(`$ZodString`,(e,t)=>{R.init(e,t),e._zod.pattern=t.pattern??_r,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),z=N(`$ZodStringFormat`,(e,t)=>{jr.init(e,t),Wr.init(e,t)}),Gr=N(`$ZodGUID`,(e,t)=>{t.pattern??=$n,z.init(e,t)}),Kr=N(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=er(e)}else t.pattern??=er();z.init(e,t)}),qr=N(`$ZodEmail`,(e,t)=>{t.pattern??=tr,z.init(e,t)});function Jr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Yr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Jr(e)||2:Xr(e,t)}function Xr(e,t){if(!t.normalize&&t.protocol?.source===lr.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const Zr=/[\t\n\r]/g;function Qr(e){return e.replace(Zr,``)}function $r(e,t){return t.lastIndex=0,t.test(e.hostname)}function ei(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const ti=N(`$ZodURL`,(e,t)=>{z.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Yr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Qr(r);return}t.hostname&&!$r(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!ei(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Qr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ni=N(`$ZodEmoji`,(e,t)=>{t.pattern??=nr(),z.init(e,t)}),ri=N(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Xn:Zn(t.length),z.init(e,t)}),ii=N(`$ZodCUID`,(e,t)=>{t.pattern??=Gn,z.init(e,t)}),ai=N(`$ZodCUID2`,(e,t)=>{t.pattern??=Kn,z.init(e,t)}),oi=N(`$ZodULID`,(e,t)=>{t.pattern??=qn,z.init(e,t)}),si=N(`$ZodXID`,(e,t)=>{t.pattern??=Jn,z.init(e,t)}),ci=N(`$ZodKSUID`,(e,t)=>{t.pattern??=Yn,z.init(e,t)}),li=N(`$ZodISODateTime`,(e,t)=>{t.pattern??=gr(t),z.init(e,t)}),ui=N(`$ZodISODate`,(e,t)=>{t.pattern??=pr,z.init(e,t)}),di=N(`$ZodISOTime`,(e,t)=>{t.pattern??=hr(t),z.init(e,t)}),fi=N(`$ZodISODuration`,(e,t)=>{t.pattern??=Qn,z.init(e,t)}),pi=N(`$ZodIPv4`,(e,t)=>{t.pattern??=rr,z.init(e,t)}),mi=/^[0-9a-fA-F:.]+$/;function hi(e){return mi.test(e)?Jr(`http://[${e}]`):!1}const gi=N(`$ZodIPv6`,(e,t)=>{t.pattern??=ir,z.init(e,t),e._zod.check=n=>{hi(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),_i=N(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ar,z.init(e,t)});function vi(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:hi(n)}const yi=N(`$ZodCIDRv6`,(e,t)=>{t.pattern??=or,z.init(e,t),e._zod.check=n=>{vi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function bi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const xi=/^[0-9a-zA-Z+/]*={0,2}$/,Si=N(`$ZodBase64`,(e,t)=>{t.pattern??=xi,z.init(e,t),e._zod.check=n=>{bi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ci=/^[A-Za-z0-9_-]*$/;function wi(e){if(!Ci.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return bi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Ti=N(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ci,z.init(e,t),e._zod.check=n=>{wi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ei=N(`$ZodE164`,(e,t)=>{t.pattern??=ur,z.init(e,t)});function Di(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Oi=N(`$ZodJWT`,(e,t)=>{z.init(e,t),e._zod.check=n=>{Di(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ki=N(`$ZodNumber`,(e,t)=>{R.init(e,t),e._zod.pattern=yr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ai=N(`$ZodNumberFormat`,(e,t)=>{Dr.init(e,t),ki.init(e,t)}),ji=N(`$ZodUnknown`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),Mi=N(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ni(e,t){let n=qt(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of qt(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Jt(n.issues,t,e),n}}return i(n,a)}}const Pi=e=>Array.isArray(e)?e.length:-1;function Fi(e,t,n){e.issues.length&&t.issues.push(...O(n,e.issues)),t.value[n]=e.value}const Ii=N(`$ZodArray`,(e,t)=>{R.init(e,t);let n=F.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Fi(t,r,e)));else if(Fi(c,r,e),s&&c.issues.length!==0&&D(c))break}return o.length?Promise.all(o).then(()=>r):r},Ni(e,Pi)});function Li(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...O(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const Ri=[];function zi(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Ri,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Nt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Bi(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(D(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Li(e,n,i,t,d,f))):Li(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Vi=N(`$ZodObject`,(e,t)=>{R.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=_t(()=>zi(t));M(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||y(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Ot,o=t.catchall,s,c=F.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(D(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Li(n,t,e,r,a,o))):Li(s,t,e,r,a,o)}return o?Bi(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Hi=N(`$ZodObjectJIT`,(e,t)=>{Vi.init(e,t);let n=e._zod.parse,r=_t(()=>zi(t)),i=F.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new zr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
14
10
  let ${e}_ab = false;
15
11
  for (let i = 0; i < ${e}.issues.length; i++) {
16
12
  const iss = ${e}.issues[i];
@@ -60,66 +56,9 @@ function A(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=
60
56
  newResult[${r}] = ${n}.value;
61
57
  }
62
58
 
63
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ot,c=!M.jitless,l=c&&kt.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Hi([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Gi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!w(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>E(e,r,N())))}),t)}const Ki=/*@__PURE__*/ A(`$ZodUnion`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),k(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),k(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),k(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>yt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Gi(t,r,e,i)):Gi(o,r,e,i)}}),qi=/*@__PURE__*/ A(`$ZodIntersection`,(e,t)=>{F.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Yi(e,t,n)):Yi(e,i,a)}});function Ji(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(At(e)&&At(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ji(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=Ji(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yi(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ji(t.value,n.value);if(!c.valid){if(w(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Xi=/*@__PURE__*/ A(`$ZodRecord`,(e,t)=>{F.init(e,t);let n=M.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!At(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>E(e,i,N())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...T(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...T(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&xr.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>E(e,i,N())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...T(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...T(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Zi=/*@__PURE__*/ A(`$ZodEnum`,(e,t)=>{F.init(e,t);let n=pt(t.entries),r=new Set(n);e._zod.values=r,k(e,`pattern`,e=>{let t=pt(e.def.entries).filter(e=>Mt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Nt(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Qi=/*@__PURE__*/ A(`$ZodLiteral`,(e,t)=>{F.init(e,t);let n=new Set(t.values);e._zod.values=n,k(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Nt(e):e?Nt(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),$i=/*@__PURE__*/ A(`$ZodTransform`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,M.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new gn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new j;return n.value=i,n}});function ea(e,t){return e.value=t.issues.length?void 0:t.value,e}const ta=/*@__PURE__*/ A(`$ZodOptional`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,k(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),k(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${yt(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>ea(e,t)):ea(e,r)}return t.innerType._zod.run(e,n)}}),na=/*@__PURE__*/ A(`$ZodExactOptional`,(e,t)=>{ta.init(e,t),k(e,`values`,e=>e.def.innerType._zod.values),k(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ra=/*@__PURE__*/ A(`$ZodNullable`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.innerType._zod.optin),k(e,`optout`,e=>e.def.innerType._zod.optout),k(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${yt(t.source)}|null)$`):void 0}),k(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ia=/*@__PURE__*/ A(`$ZodDefault`,(e,t)=>{F.init(e,t),e._zod.optin=`defaulted`,k(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>aa(e,t)):aa(r,t)}});function aa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const oa=/*@__PURE__*/ A(`$ZodPrefault`,(e,t)=>{F.init(e,t),e._zod.optin=`defaulted`,k(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),sa=/*@__PURE__*/ A(`$ZodNonOptional`,(e,t)=>{F.init(e,t),k(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ca(t,e)):ca(i,e)}});function ca(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function la(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>E(e,r,N()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const ua=/*@__PURE__*/ A(`$ZodCatch`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),k(e,`optout`,e=>e.def.innerType._zod.optout),k(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>la(e,r,t,n)):la(e,r,t,n)}}),da=/*@__PURE__*/ A(`$ZodPipe`,(e,t)=>{F.init(e,t),k(e,`values`,e=>e.def.in._zod.values),k(e,`optin`,e=>e.def.in._zod.optin),k(e,`optout`,e=>e.def.out._zod.optout),k(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>fa(e,t.in,n)):fa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>fa(e,t.out,n)):fa(r,t.out,n)}});function fa(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const pa=/*@__PURE__*/ A(`$ZodReadonly`,(e,t)=>{F.init(e,t),k(e,`propValues`,e=>e.def.innerType._zod.propValues),k(e,`values`,e=>e.def.innerType._zod.values),k(e,`optin`,e=>e.def.innerType?._zod?.optin),k(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ma):ma(r)}});function ma(e){return e.memo||(e.value=Object.freeze(e.value)),e}const ha=/*@__PURE__*/ A(`$ZodCustom`,(e,t)=>{P.init(e,t),F.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ga(t,n,r,e));ga(i,n,r,e)}});function ga(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(tn(e))}}var _a=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const va=`~memo`,ya=[];function ba(e){return typeof e==`object`&&!!e}function xa(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const Sa=/*@__PURE__*/ new WeakMap;function Ca(e,t,n){let r=Sa.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=Ca(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?Ca(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=xt(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Ca(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),wa(e,i)}function wa(e,t){return t!==1&&Sa.set(e,t===2),t}function Ta(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let Ea;const Da=[],Oa={alloc(e,t,n){let r=Ea;if(!r)return n;Ea=void 0;let i={value:n,issues:null};return r.set(t.value,i),Da.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Aa(n,e.value))throw new _a;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Ca(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!ba(l))return t(s,c);let u=c[va];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[va]=u);let d;i===c?d=a:(d=Ta(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...xa(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;Ea=d;let p=Da.length,m=t(s,c);Ea=void 0;let h=Da.length>p?Da.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?xa(e.issues):ya),e)):(h&&(h.issues=m.issues.length?xa(m.issues):ya),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ka(){return Oa}function Aa(e,t){let n=e[va]?.backEdges;return n!==void 0&&ba(t)&&n.has(t)}const ja=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(en(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Pt(e.values[0])}`:`Invalid option: expected one of ${mt(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${mt(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Ma(){return{localeError:ja()}}var Na,Pa=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Fa(){return new Pa}(Na=globalThis).__zod_globalRegistry??(Na.__zod_globalRegistry=Fa());const Ia=globalThis.__zod_globalRegistry;function La(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
64
- function Ra(e,t){return new e(La({type:`string`,...C(t)}))}// @__NO_SIDE_EFFECTS__
65
- function za(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
66
- function Ba(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
67
- function Va(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
68
- function Ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...C(t)})}// @__NO_SIDE_EFFECTS__
69
- function Ua(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...C(t)})}// @__NO_SIDE_EFFECTS__
70
- function Wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...C(t)})}// @__NO_SIDE_EFFECTS__
71
- function Ga(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
72
- function Ka(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
73
- function qa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
74
- function Ja(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
75
- function Ya(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
76
- function Xa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
77
- function Za(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
78
- function Qa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
79
- function $a(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
80
- function eo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
81
- function to(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
82
- function no(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
83
- function ro(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
84
- function io(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
85
- function ao(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
86
- function oo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...C(t)})}// @__NO_SIDE_EFFECTS__
87
- function so(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...C(t)})}// @__NO_SIDE_EFFECTS__
88
- function co(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...C(t)})}// @__NO_SIDE_EFFECTS__
89
- function lo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...C(t)})}// @__NO_SIDE_EFFECTS__
90
- function uo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...C(t)})}// @__NO_SIDE_EFFECTS__
91
- function fo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...C(t)})}// @__NO_SIDE_EFFECTS__
92
- function po(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
93
- function mo(e,t){return new e({type:`never`,...C(t)})}// @__NO_SIDE_EFFECTS__
94
- function ho(e,t){return new Er({check:`less_than`,...C(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
95
- function go(e,t){return new Er({check:`less_than`,...C(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
96
- function _o(e,t){return new Dr({check:`greater_than`,...C(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
97
- function vo(e,t){return new Dr({check:`greater_than`,...C(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
98
- function yo(e,t){return new Or({check:`multiple_of`,...C(t),value:e})}// @__NO_SIDE_EFFECTS__
99
- function bo(e,t){return new Ar({check:`max_length`,...C(t),maximum:e})}// @__NO_SIDE_EFFECTS__
100
- function xo(e,t){return new jr({check:`min_length`,...C(t),minimum:e})}// @__NO_SIDE_EFFECTS__
101
- function So(e,t){return new Mr({check:`length_equals`,...C(t),length:e})}// @__NO_SIDE_EFFECTS__
102
- function Co(e,t){return new Pr({check:`string_format`,format:`regex`,...C(t),pattern:e})}// @__NO_SIDE_EFFECTS__
103
- function wo(e){return new Fr({check:`string_format`,format:`lowercase`,...C(e)})}// @__NO_SIDE_EFFECTS__
104
- function To(e){return new Ir({check:`string_format`,format:`uppercase`,...C(e)})}// @__NO_SIDE_EFFECTS__
105
- function Eo(e,t){return new Lr({check:`string_format`,format:`includes`,...C(t),includes:e})}// @__NO_SIDE_EFFECTS__
106
- function Do(e,t){return new Rr({check:`string_format`,format:`starts_with`,...C(t),prefix:e})}// @__NO_SIDE_EFFECTS__
107
- function Oo(e,t){return new zr({check:`string_format`,format:`ends_with`,...C(t),suffix:e})}// @__NO_SIDE_EFFECTS__
108
- function L(e){return new Br({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
109
- function ko(e){return/* @__PURE__ */ L(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
110
- function Ao(){return/* @__PURE__ */ L(e=>e.trim())}// @__NO_SIDE_EFFECTS__
111
- function jo(){return/* @__PURE__ */ L(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
112
- function Mo(){return/* @__PURE__ */ L(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
113
- function No(){return/* @__PURE__ */ L(e=>Et(e))}// @__NO_SIDE_EFFECTS__
114
- function Po(e,t,n){return new e({type:`array`,element:t,...C(n)})}// @__NO_SIDE_EFFECTS__
115
- function Fo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...C(n)})}// @__NO_SIDE_EFFECTS__
116
- function Io(e,t){let n=/* @__PURE__ */ Lo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(tn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(tn(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
117
- function Lo(e,t){let n=new P({check:`custom`,...C(t)});return n._zod.check=e,n}function Ro(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&v(e,t,n[t]);return e}function zo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ia,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function R(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function z(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,z(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ro(o.schema,c),t.io===`input`&&B(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Bo(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Vo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Bo(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Bo(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
59
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ot,c=!F.jitless,l=c&&kt.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Bi([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ui(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!D(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>k(e,r,I())))}),t)}const Wi=N(`$ZodUnion`,(e,t)=>{R.init(e,t),M(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),M(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),M(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),M(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>yt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ui(t,r,e,i)):Ui(o,r,e,i)}}),Gi=N(`$ZodIntersection`,(e,t)=>{R.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>qi(e,t,n)):qi(e,i,a)}});function Ki(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(C(e)&&C(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ki(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=Ki(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function qi(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ki(t.value,n.value);if(!c.valid){if(D(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Ji=N(`$ZodRecord`,(e,t)=>{R.init(e,t);let n=F.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!C(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>k(e,i,I())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...O(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...O(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&yr.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>k(e,i,I())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...O(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...O(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Yi=N(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=pt(t.entries),r=new Set(n);e._zod.values=r,M(e,`pattern`,e=>{let t=pt(e.def.entries).filter(e=>jt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>w(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Xi=N(`$ZodLiteral`,(e,t)=>{R.init(e,t);let n=new Set(t.values);e._zod.values=n,M(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?w(e):e?w(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Zi=N(`$ZodTransform`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,F.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new mn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new P;return n.value=i,n}});function Qi(e,t){return e.value=t.issues.length?void 0:t.value,e}const $i=N(`$ZodOptional`,(e,t)=>{R.init(e,t),M(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,M(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),M(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${yt(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Qi(e,t)):Qi(e,r)}return t.innerType._zod.run(e,n)}}),ea=N(`$ZodExactOptional`,(e,t)=>{$i.init(e,t),M(e,`values`,e=>e.def.innerType._zod.values),M(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ta=N(`$ZodNullable`,(e,t)=>{R.init(e,t),M(e,`optin`,e=>e.def.innerType._zod.optin),M(e,`optout`,e=>e.def.innerType._zod.optout),M(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${yt(t.source)}|null)$`):void 0}),M(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),na=N(`$ZodDefault`,(e,t)=>{R.init(e,t),e._zod.optin=`defaulted`,M(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ra(e,t)):ra(r,t)}});function ra(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ia=N(`$ZodPrefault`,(e,t)=>{R.init(e,t),e._zod.optin=`defaulted`,M(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),aa=N(`$ZodNonOptional`,(e,t)=>{R.init(e,t),M(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>oa(t,e)):oa(i,e)}});function oa(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function sa(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>k(e,r,I()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const ca=N(`$ZodCatch`,(e,t)=>{R.init(e,t),M(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),M(e,`optout`,e=>e.def.innerType._zod.optout),M(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>sa(e,r,t,n)):sa(e,r,t,n)}}),la=N(`$ZodPipe`,(e,t)=>{R.init(e,t),M(e,`values`,e=>e.def.in._zod.values),M(e,`optin`,e=>e.def.in._zod.optin),M(e,`optout`,e=>e.def.out._zod.optout),M(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ua(e,t.in,n)):ua(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ua(e,t.out,n)):ua(r,t.out,n)}});function ua(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const da=N(`$ZodReadonly`,(e,t)=>{R.init(e,t),M(e,`propValues`,e=>e.def.innerType._zod.propValues),M(e,`values`,e=>e.def.innerType._zod.values),M(e,`optin`,e=>e.def.innerType?._zod?.optin),M(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(fa):fa(r)}});function fa(e){return e.memo||(e.value=Object.freeze(e.value)),e}const pa=N(`$ZodCustom`,(e,t)=>{L.init(e,t),R.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ma(t,n,r,e));ma(i,n,r,e)}});function ma(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push($t(e))}}var ha=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const ga=`~memo`,_a=[];function va(e){return typeof e==`object`&&!!e}function ya(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const ba=new WeakMap;function xa(e,t,n){let r=ba.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=xa(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?xa(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=xt(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?xa(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Sa(e,i)}function Sa(e,t){return t!==1&&ba.set(e,t===2),t}function Ca(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let wa;const Ta=[],Ea={alloc(e,t,n){let r=wa;if(!r)return n;wa=void 0;let i={value:n,issues:null};return r.set(t.value,i),Ta.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Oa(n,e.value))throw new ha;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=xa(e,new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!va(l))return t(s,c);let u=c[ga];u||(u={buckets:new WeakMap,backEdges:void 0},c[ga]=u);let d;i===c?d=a:(d=Ca(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ya(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;wa=d;let p=Ta.length,m=t(s,c);wa=void 0;let h=Ta.length>p?Ta.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ya(e.issues):_a),e)):(h&&(h.issues=m.issues.length?ya(m.issues):_a),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Da(){return Ea}function Oa(e,t){let n=e[ga]?.backEdges;return n!==void 0&&va(t)&&n.has(t)}const ka=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Qt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Mt(e.values[0])}`:`Invalid option: expected one of ${mt(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${mt(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Aa(){return{localeError:ka()}}var ja,Ma=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Na(){return new Ma}(ja=globalThis).__zod_globalRegistry??(ja.__zod_globalRegistry=Na());const Pa=globalThis.__zod_globalRegistry;function Fa(e){return e.checks&&=[...e.checks],e}function Ia(e,t){return new e(Fa({type:`string`,...E(t)}))}function La(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...E(t)})}function Ra(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...E(t)})}function za(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...E(t)})}function Ba(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...E(t)})}function Va(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...E(t)})}function Ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...E(t)})}function Ua(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...E(t)})}function Wa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...E(t)})}function Ga(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...E(t)})}function Ka(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...E(t)})}function qa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...E(t)})}function Ja(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...E(t)})}function Ya(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...E(t)})}function Xa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...E(t)})}function Za(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...E(t)})}function Qa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...E(t)})}function $a(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...E(t)})}function eo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...E(t)})}function to(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...E(t)})}function no(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...E(t)})}function ro(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...E(t)})}function io(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...E(t)})}function ao(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...E(t)})}function oo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...E(t)})}function so(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...E(t)})}function co(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...E(t)})}function lo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...E(t)})}function uo(e){return new e({type:`unknown`})}function fo(e,t){return new e({type:`never`,...E(t)})}function po(e,t){return new wr({check:`less_than`,...E(t),value:e,inclusive:!1})}function mo(e,t){return new wr({check:`less_than`,...E(t),value:e,inclusive:!0})}function ho(e,t){return new Tr({check:`greater_than`,...E(t),value:e,inclusive:!1})}function go(e,t){return new Tr({check:`greater_than`,...E(t),value:e,inclusive:!0})}function _o(e,t){return new Er({check:`multiple_of`,...E(t),value:e})}function vo(e,t){return new Or({check:`max_length`,...E(t),maximum:e})}function yo(e,t){return new kr({check:`min_length`,...E(t),minimum:e})}function bo(e,t){return new Ar({check:`length_equals`,...E(t),length:e})}function xo(e,t){return new Mr({check:`string_format`,format:`regex`,...E(t),pattern:e})}function So(e){return new Nr({check:`string_format`,format:`lowercase`,...E(e)})}function Co(e){return new Pr({check:`string_format`,format:`uppercase`,...E(e)})}function wo(e,t){return new Fr({check:`string_format`,format:`includes`,...E(t),includes:e})}function To(e,t){return new Ir({check:`string_format`,format:`starts_with`,...E(t),prefix:e})}function Eo(e,t){return new Lr({check:`string_format`,format:`ends_with`,...E(t),suffix:e})}function Do(e){return new Rr({check:`overwrite`,tx:e})}function Oo(e){return Do(t=>t.normalize(e))}function ko(){return Do(e=>e.trim())}function Ao(){return Do(e=>e.toLowerCase())}function jo(){return Do(e=>e.toUpperCase())}function Mo(){return Do(e=>Et(e))}function No(e,t,n){return new e({type:`array`,element:t,...E(n)})}function Po(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...E(n)})}function Fo(e,t){let n=Io(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push($t(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push($t(r))}},e(t.value,t)),t);return n}function Io(e,t){let n=new L({check:`custom`,...E(t)});return n._zod.check=e,n}function Lo(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&y(e,t,n[t]);return e}function Ro(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Pa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function B(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function V(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,V(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Lo(o.schema,c),t.io===`input`&&H(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function zo(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Bo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${zo(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+zo(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
118
60
 
119
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ho(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Ho(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Uo=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Wo=[`oneOf`,`anyOf`];function Go(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ko(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Uo.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Go(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}v(n,r,e.length===1?e[0]:Ko(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Go(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function qo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Uo)if(t in e)return;let n=t.filter(e=>Wo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ko(t);else{let e=n[0],i=Wo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ko([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ro(e,r))}function Jo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ro(i,s),Ro(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Ho(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])qo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Ro(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,v(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Xo(t,`input`,e.processors),output:Xo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function B(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return B(r.element,n);if(r.type===`set`)return B(r.valueType,n);if(r.type===`lazy`)return B(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return B(r.innerType,n);if(r.type===`intersection`)return B(r.left,n)||B(r.right,n);if(r.type===`record`||r.type===`map`)return B(r.keyType,n)||B(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:B(r.in,n)||B(r.out,n);if(r.type===`object`){for(let e in r.shape)if(B(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(B(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(B(e,n))return!0;return!!(r.rest&&B(r.rest,n))}return!1}const Yo=(e,t={})=>n=>{let r=zo({...n,processors:t});return z(e,r),Vo(r,e),Jo(r,e)},Xo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=zo({...i??{},target:a,io:t,processors:n});return z(e,o),Vo(o,e),Jo(o,e)},V=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},H=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Zo=(e,t)=>{V(e,`minimum`,t),H(e,`maximum`,t)},Qo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},$o=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},es=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},ts=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},ns=(e,t)=>V(e,`minimum`,t.minimum),rs=(e,t)=>H(e,`maximum`,t.maximum),is=e=>(t,n)=>{ts(t,n.format);let[r,i]=e[n.format];V(t,`minimum`,r),H(t,`maximum`,i)},as={greater_than:(e,t)=>V(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>H(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Qo(e,t.value),number_format:is(It),bigint_format:is(Lt),min_length:ns,max_length:rs,length_equals:(e,t)=>Zo(e,t.length),min_size:ns,max_size:rs,size_equals:(e,t)=>Zo(e,t.size),string_format:(e,t)=>{ts(e,t.format),t.pattern&&$o(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>es(e,t.mime)};function U(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)as[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&V(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&V(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&H(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&H(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Qo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&es(t,i.mime);for(let e of i.patterns??[])$o(t,e);return t}const os={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ss=/* @__PURE__ */ new Map([[Ci,lr],[Ti,ur]]),cs=e=>ss.get(e)??e,ls=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=U(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=os[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(cs);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},us=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=U(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):R(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},ds=(e,t,n,r)=>{n.not={}},fs=(e,t,n,r)=>{let i=pt(e._zod.def.entries);i.length===0?n.not={}:(i.every(e=>typeof e==`number`)&&(n.type=`number`),i.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=i)},ps=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(R(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(R(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},ms=(e,t,n,r)=>{R(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},hs=(e,t,n,r)=>{R(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},gs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=U(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=z(a.element,t,{...r,path:[...r.path,`items`]})};function _s(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?_s(t.out):t.type===`catch`?_s(t.innerType):e._zod.optin}const vs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&R(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)v(i.properties,e,z(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?_s(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=z(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ys=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>z(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},bs=(e,t,n,r)=>{let i=e._zod.def,a=z(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=z(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function xs(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=xs(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>xs(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?xr:br).source)),p}const Ss=/* @__PURE__ */ new WeakMap;function Cs(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of Ss.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=xs(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const ws=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=U(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=z(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)v(i.patternProperties,cs(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=z(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Ss.get(t);n||(n=[],Ss.set(t,n),t.deferred.push(()=>Cs(t))),n.push(e)}i.additionalProperties=z(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&_s(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Ts=(e,t,n,r)=>{let i=e._zod.def,a=z(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Es=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ds=Symbol();function Os(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(R(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ds):JSON.parse(o)}const ks=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Os(i.defaultValue,e,t,n,r);o!==Ds&&(n.default=o)},As=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Os(i.defaultValue,e,t,n,r);o!==Ds&&(n._prefault=o)},js=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{R(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Ms=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;z(o,t,r);let s=t.seen.get(e);s.ref=o},Ns=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ps=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Fs=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function Is(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const W=/*@__PURE__*/ A(`ZodError`,(e,t)=>{Sn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Fs.has(n)||(Fs.add(n),Is(n,`format`,e=>t=>Tn(e,t)),Is(n,`flatten`,e=>t=>wn(e,t)),Is(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ht,2)}),Is(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ht,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ls=/* @__PURE__ */ kn(W),Rs=/* @__PURE__ */ An(W),zs=/* @__PURE__ */ jn(W),Bs=/* @__PURE__ */ Nn(W),Vs=/* @__PURE__ */ zn(W),Hs=/* @__PURE__ */ Bn(W),Us=/* @__PURE__ */ Vn(W),Ws=/* @__PURE__ */ Hn(W),Gs=/* @__PURE__ */ Un(W),Ks=/* @__PURE__ */ Wn(W),qs=/* @__PURE__ */ Gn(W),Js=/* @__PURE__ */ Kn(W);function Ys(){M.localeError||N(Ma())}function Xs(){M.memoizer||N({memoizer:ka()})}const G=/*@__PURE__*/ A(`ZodType`,(e,t)=>(Ys(),F.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(x(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return S(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(dl(e,t))},superRefine(e,t){return this.check(fl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ L(e))},optional(){return qc(this)},exactOptional(){return Yc(this)},nullable(){return Zc(this)},nullish(){return qc(Zc(this))},nonoptional(e){return rl(this,e)},array(){return jc(this)},or(e){return Fc([this,e])},and(e){return Lc(this,e)},transform(e){return sl(this,Gc(e))},default(e){return $c(this,e)},prefault(e){return tl(this,e)},catch(e){return al(this,e)},pipe(e){return sl(this,e)},readonly(){return ll(this)},describe(e){let t=this.clone();return Ia.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ia.get(this);let t=this.clone();return Ia.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return rn(this,`~standard`,{...Gr(this),jsonSchema:{input:Xo(this,`input`),output:Xo(this,`output`)}})},set"~standard"(e){D(this,`~standard`,e)},parse:function e(t,n){return Ls(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Rs(this,t,n,{callee:e})},safeParse(e,t){return zs(this,e,t)},async safeParseAsync(e,t){return Bs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){D(this,`spa`,e)},validate(e,t){return In(this,e,t)},validateAsync(e,t){return Rn(this,e,t)},encode:function e(t,n){return Vs(this,t,n,{callee:e})},decode:function e(t,n){return Hs(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Us(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ws(this,t,n,{callee:e})},safeEncode(e,t){return Gs(this,e,t)},safeDecode(e,t){return Ks(this,e,t)},async safeEncodeAsync(e,t){return qs(this,e,t)},async safeDecodeAsync(e,t){return Js(this,e,t)},toJSONSchema(e){return Yo(this,{})(e)},get description(){return Ia.get(this)?.description},get _def(){return this._zod.def}}),Zs=/*@__PURE__*/ A(`_ZodString`,(e,t)=>{Kr.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r)},/*@__PURE__*/ an({format:e=>U(e).format??null,minLength:e=>U(e).minimum??null,maxLength:e=>U(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Co(...e))},includes(...e){return this.check(/* @__PURE__ */ Eo(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Do(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Oo(...e))},min(...e){return this.check(/* @__PURE__ */ xo(...e))},max(...e){return this.check(/* @__PURE__ */ bo(...e))},length(...e){return this.check(/* @__PURE__ */ So(...e))},nonempty(...e){return this.check(/* @__PURE__ */ xo(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ wo(e))},uppercase(e){return this.check(/* @__PURE__ */ To(e))},trim(){return this.check(/* @__PURE__ */ Ao())},normalize(...e){return this.check(/* @__PURE__ */ ko(...e))},toLowerCase(){return this.check(/* @__PURE__ */ jo())},toUpperCase(){return this.check(/* @__PURE__ */ Mo())},slugify(){return this.check(/* @__PURE__ */ No())}})),Qs=/*@__PURE__*/ A(`ZodString`,(e,t)=>{Kr.init(e,t),Zs.init(e,t)},{email(e){return this.check(/* @__PURE__ */ za(rc,e))},url(e){return this.check(/* @__PURE__ */ Ga(oc,e))},jwt(e){return this.check(/* @__PURE__ */ oo(Sc,e))},emoji(e){return this.check(/* @__PURE__ */ Ka(cc,e))},guid(e){return this.check(/* @__PURE__ */ Ba(ic,e))},uuid(e){return this.check(/* @__PURE__ */ Va(ac,e))},uuidv4(e){return this.check(/* @__PURE__ */ Ha(ac,e))},uuidv6(e){return this.check(/* @__PURE__ */ Ua(ac,e))},uuidv7(e){return this.check(/* @__PURE__ */ Wa(ac,e))},nanoid(e){return this.check(/* @__PURE__ */ qa(lc,e))},cuid(e){return this.check(/* @__PURE__ */ Ja(uc,e))},cuid2(e){return this.check(/* @__PURE__ */ Ya(dc,e))},ulid(e){return this.check(/* @__PURE__ */ Xa(fc,e))},base64(e){return this.check(/* @__PURE__ */ ro(yc,e))},base64url(e){return this.check(/* @__PURE__ */ io(bc,e))},xid(e){return this.check(/* @__PURE__ */ Za(pc,e))},ksuid(e){return this.check(/* @__PURE__ */ Qa(mc,e))},ipv4(e){return this.check(/* @__PURE__ */ $a(hc,e))},ipv6(e){return this.check(/* @__PURE__ */ eo(gc,e))},cidrv4(e){return this.check(/* @__PURE__ */ to(_c,e))},cidrv6(e){return this.check(/* @__PURE__ */ no(vc,e))},e164(e){return this.check(/* @__PURE__ */ ao(xc,e))},datetime(e){return this.check(/* @__PURE__ */ so($s,e))},date(e){return this.check(/* @__PURE__ */ co(ec,e))},time(e){return this.check(/* @__PURE__ */ lo(tc,e))},duration(e){return this.check(/* @__PURE__ */ uo(nc,e))}});function K(e){return/* @__PURE__ */ Ra(Qs,e)}const q=/*@__PURE__*/ A(`ZodStringFormat`,(e,t)=>{I.init(e,t),Zs.init(e,t)}),$s=/*@__PURE__*/ A(`ZodISODateTime`,(e,t)=>{di.init(e,t),q.init(e,t)}),ec=/*@__PURE__*/ A(`ZodISODate`,(e,t)=>{fi.init(e,t),q.init(e,t)}),tc=/*@__PURE__*/ A(`ZodISOTime`,(e,t)=>{pi.init(e,t),q.init(e,t)}),nc=/*@__PURE__*/ A(`ZodISODuration`,(e,t)=>{mi.init(e,t),q.init(e,t)}),rc=/*@__PURE__*/ A(`ZodEmail`,(e,t)=>{Yr.init(e,t),q.init(e,t)}),ic=/*@__PURE__*/ A(`ZodGUID`,(e,t)=>{qr.init(e,t),q.init(e,t)}),ac=/*@__PURE__*/ A(`ZodUUID`,(e,t)=>{Jr.init(e,t),q.init(e,t)}),oc=/*@__PURE__*/ A(`ZodURL`,(e,t)=>{ri.init(e,t),q.init(e,t)});function sc(e){return/* @__PURE__ */ Ga(oc,e)}const cc=/*@__PURE__*/ A(`ZodEmoji`,(e,t)=>{ii.init(e,t),q.init(e,t)}),lc=/*@__PURE__*/ A(`ZodNanoID`,(e,t)=>{ai.init(e,t),q.init(e,t)}),uc=/*@__PURE__*/ A(`ZodCUID`,(e,t)=>{oi.init(e,t),q.init(e,t)}),dc=/*@__PURE__*/ A(`ZodCUID2`,(e,t)=>{si.init(e,t),q.init(e,t)}),fc=/*@__PURE__*/ A(`ZodULID`,(e,t)=>{ci.init(e,t),q.init(e,t)}),pc=/*@__PURE__*/ A(`ZodXID`,(e,t)=>{li.init(e,t),q.init(e,t)}),mc=/*@__PURE__*/ A(`ZodKSUID`,(e,t)=>{ui.init(e,t),q.init(e,t)}),hc=/*@__PURE__*/ A(`ZodIPv4`,(e,t)=>{hi.init(e,t),q.init(e,t)}),gc=/*@__PURE__*/ A(`ZodIPv6`,(e,t)=>{vi.init(e,t),q.init(e,t)}),_c=/*@__PURE__*/ A(`ZodCIDRv4`,(e,t)=>{yi.init(e,t),q.init(e,t)}),vc=/*@__PURE__*/ A(`ZodCIDRv6`,(e,t)=>{xi.init(e,t),q.init(e,t)}),yc=/*@__PURE__*/ A(`ZodBase64`,(e,t)=>{wi.init(e,t),q.init(e,t)}),bc=/*@__PURE__*/ A(`ZodBase64URL`,(e,t)=>{Di.init(e,t),q.init(e,t)}),xc=/*@__PURE__*/ A(`ZodE164`,(e,t)=>{Oi.init(e,t),q.init(e,t)}),Sc=/*@__PURE__*/ A(`ZodJWT`,(e,t)=>{Ai.init(e,t),q.init(e,t)}),Cc=/*@__PURE__*/ A(`ZodNumber`,(e,t)=>{ji.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ an({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=U(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=U(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=U(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>U(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ _o(e,t))},gte(e,t){return this.check(/* @__PURE__ */ vo(e,t))},min(e,t){return this.check(/* @__PURE__ */ vo(e,t))},lt(e,t){return this.check(/* @__PURE__ */ ho(e,t))},lte(e,t){return this.check(/* @__PURE__ */ go(e,t))},max(e,t){return this.check(/* @__PURE__ */ go(e,t))},int(e){return this.check(Tc(e))},safe(e){return this.check(Tc(e))},positive(e){return this.check(/* @__PURE__ */ _o(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ vo(0,e))},negative(e){return this.check(/* @__PURE__ */ ho(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ go(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ yo(e,t))},step(e,t){return this.check(/* @__PURE__ */ yo(e,t))},finite(){return this}})),wc=/*@__PURE__*/ A(`ZodNumberFormat`,(e,t)=>{Mi.init(e,t),Cc.init(e,t)});function Tc(e){return/* @__PURE__ */ fo(wc,e)}const Ec=/*@__PURE__*/ A(`ZodUnknown`,(e,t)=>{Ni.init(e,t),G.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Dc(){return/* @__PURE__ */ po(Ec)}const Oc=/*@__PURE__*/ A(`ZodNever`,(e,t)=>{Pi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r)});function kc(e){return/* @__PURE__ */ mo(Oc,e)}const Ac=/*@__PURE__*/ A(`ZodArray`,(e,t)=>{Xs(),Ri.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ xo(e,t))},nonempty(e){return this.check(/* @__PURE__ */ xo(1,e))},max(e,t){return this.check(/* @__PURE__ */ bo(e,t))},length(e,t){return this.check(/* @__PURE__ */ So(e,t))},unwrap(){return this.element}});function jc(e,t){return/* @__PURE__ */ Po(Ac,e,t)}const Mc=/*@__PURE__*/ A(`ZodObject`,(e,t)=>{Xs(),Wi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),un(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Vc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(x(this._zod.def,{catchall:e}))},passthrough(){return this.clone(x(this._zod.def,{catchall:Dc()}))},loose(){return this.clone(x(this._zod.def,{catchall:Dc()}))},strict(){return this.clone(x(this._zod.def,{catchall:kc()}))},strip(){return this.clone(x(this._zod.def,{catchall:void 0}))},extend(e){return Vt(this,e)},safeExtend(e){return Ut(this,e)},merge(e){return Wt(this,e)},pick(e){return Rt(this,e)},omit(e){return Bt(this,e)},partial(...e){return Gt(Kc,this,e[0])},exactPartial(...e){return Gt(Jc,this,e[0],`exactPartial`)},required(...e){return Kt(nl,this,e[0])}});function Nc(e,t){let n={type:`object`,shape:e??{},...C(t)};return new Mc(n)}const Pc=/*@__PURE__*/ A(`ZodUnion`,(e,t)=>{Ki.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.options=t.options});function Fc(e,t){return new Pc({type:`union`,options:e,...C(t)})}const Ic=/*@__PURE__*/ A(`ZodIntersection`,(e,t)=>{qi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function Lc(e,t){return new Ic({type:`intersection`,left:e,right:t})}const Rc=/*@__PURE__*/ A(`ZodRecord`,(e,t)=>{Xs(),Xi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function zc(e,t,n){return!t||!t._zod?new Rc({type:`record`,keyType:K(),valueType:e,...C(t)}):new Rc({type:`record`,keyType:e,valueType:t,...C(n)})}const Bc=/*@__PURE__*/ A(`ZodEnum`,(e,t)=>{Zi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Bc({...t,checks:[],...C(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Bc({...t,checks:[],...C(r),entries:i})}});function Vc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Bc({type:`enum`,entries:n,...C(t)})}const Hc=/*@__PURE__*/ A(`ZodLiteral`,(e,t)=>{Qi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Uc(e,t){return new Hc({type:`literal`,values:Array.isArray(e)?e:[e],...C(t)})}const Wc=/*@__PURE__*/ A(`ZodTransform`,(e,t)=>{Xs(),$i.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new gn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(tn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(tn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Gc(e){return new Wc({type:`transform`,transform:e})}const Kc=/*@__PURE__*/ A(`ZodOptional`,(e,t)=>{ta.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qc(e){return new Kc({type:`optional`,innerType:e})}const Jc=/*@__PURE__*/ A(`ZodExactOptional`,(e,t)=>{na.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`optional`,innerType:e})}const Xc=/*@__PURE__*/ A(`ZodNullable`,(e,t)=>{ra.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`nullable`,innerType:e})}const Qc=/*@__PURE__*/ A(`ZodDefault`,(e,t)=>{ia.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $c(e,t){return new Qc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():jt(t)}})}const el=/*@__PURE__*/ A(`ZodPrefault`,(e,t)=>{oa.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tl(e,t){return new el({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():jt(t)}})}const nl=/*@__PURE__*/ A(`ZodNonOptional`,(e,t)=>{sa.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rl(e,t){return new nl({type:`nonoptional`,innerType:e,...C(t)})}const il=/*@__PURE__*/ A(`ZodCatch`,(e,t)=>{ua.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function al(e,t){return new il({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:dn(t)})}const ol=/*@__PURE__*/ A(`ZodPipe`,(e,t)=>{da.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r),e.in=t.in,e.out=t.out});function sl(e,t){return new ol({type:`pipe`,in:e,out:t})}const cl=/*@__PURE__*/ A(`ZodReadonly`,(e,t)=>{pa.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ll(e){return new cl({type:`readonly`,innerType:e})}const ul=/*@__PURE__*/ A(`ZodCustom`,(e,t)=>{ha.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r)});function dl(e,t={}){return/* @__PURE__ */ Fo(ul,e,t)}function fl(e,t){return/* @__PURE__ */ Io(e,t)}const pl=/^[0-9a-f]{64}$/u,ml=Nc({darwinArm64:Nc({platform:Uc(`darwin`),arch:Uc(`arm64`),pythonVersion:K().regex(/^\d+\.\d+\.\d+$/u,`pythonVersion 必须是三段数字的版本号`),release:K(),url:sc({protocol:/^https$/u}).describe(`托管资产只允许 https 下载:http/file 会让安装器去取明文或本机文件`),sha256:K().regex(pl,`sha256 必须是 64 位小写十六进制`),sizeBytes:Tc().positive()}),documents:Nc({requirements:Uc(`py/documents-requirements.txt`),distribution:Uc(`pypdf`),version:K().regex(/^\d+\.\d+\.\d+$/u,`version 必须是三段数字的版本号`),sha256:K().regex(pl,`sha256 必须是 64 位小写十六进制`)}),unsupported:zc(K(),K())}),hl=n(g.join(import.meta.dirname,`runtime-manifest.json`))?import.meta.dirname:g.resolve(import.meta.dirname,`..`);function gl(e){let t;try{t=JSON.parse(e)}catch(e){throw Error(`runtime-manifest.json is invalid: ${String(e)}`,{cause:e})}let n=ml.safeParse(t);if(!n.success)throw Error(`runtime-manifest.json is invalid: ${Dn(n.error)}`);return n.data}let _l;const vl=/^version\s*=\s*(?<version>\S+)\s*$/mu;function yl(){return g.join(hl,`runtime-manifest.json`)}function bl(e=yl()){try{return r(e,`utf8`)}catch(t){throw Error(`runtime-manifest.json is unreadable: ${e}`,{cause:t})}}function xl(){return _l??=gl(bl()),_l}const J={get darwinArm64(){return xl().darwinArm64},get documents(){return xl().documents},get unsupported(){return xl().unsupported}};function Sl(e){return g.join(e,`runtime`,`python`,J.darwinArm64.pythonVersion,`bin`,`python3`)}function Cl(e){let t=g.join(e,`runtime`,`venv`);return process.platform===`win32`?g.join(t,`Scripts`,`python.exe`):g.join(t,`bin`,`python3`)}function Y(n){try{return i(n).isFile()?(e(n,t.X_OK),!0):!1}catch{return!1}}function wl(e){return process.platform===`win32`?g.join(e,`_env`,`.venv`,`Scripts`,`python.exe`):g.join(e,`_env`,`.venv`,`bin`,`python`)}function Tl(e){let t=g.join(e,`runtime`,`venv`,`pyvenv.cfg`),n;try{n=r(t,`utf8`)}catch{n=void 0}return(n===void 0?null:vl.exec(n))?.groups?.version}function El(){let e;try{e=J.unsupported[`${process.platform}-${process.arch}`]}catch{
120
- /* v8 ignore next 2 -- 清单读不到才走到这条兜底:正常装配里它必须存在,要在用例里造出来
121
- 得清掉模块级缓存,代价与「这条兜底不吞异常」的收益不成比例 */
122
- e=void 0}return e}function Dl(e){let t=e.pythonBin.trim();if(t.length>0)return{pythonPath:t,via:`configured`,version:`unknown`};if(process.platform===`darwin`&&process.arch===`arm64`&&e.dataDir.length>0){let t=Cl(e.dataDir);if(Y(t))return{pythonPath:t,via:`managed-venv`,version:Tl(e.dataDir)??J.darwinArm64.pythonVersion};let n=Sl(e.dataDir);if(Y(n))return{pythonPath:n,via:`managed`,version:J.darwinArm64.pythonVersion}}let n=e.repoRoot.length>0?wl(e.repoRoot):``;if(n.length>0&&Y(n))return{pythonPath:n,via:`repo`,version:`unknown`};let r=process.platform===`win32`?`python`:`python3`,i=El();return i===void 0?{pythonPath:r,via:`path`,version:`unknown`}:{pythonPath:r,via:`path`,version:`unknown`,assetNote:i}}var Ol=/* @__PURE__ */ he((/* @__PURE__ */ pe(((e,t,n)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=/* @__PURE__ */ RegExp(`^0[0-7]+$`,`i`),a=/* @__PURE__ */ RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>0xffffffff||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t=0;for(;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>0xffffff||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(n)})))(),1);const kl=/(?<scheme>[a-z][a-z0-9+.!-]*:\/\/)[^\s/?#]*@/giu;function Al(e){return e.toByteArray().reduce((e,t)=>e*256+t,0)}Al(Ol.default.IPv4.parse(`198.18.0.0`)),Al(Ol.default.IPv4.parse(`198.19.255.255`)),Al(Ol.default.IPv4.parse(`100.64.0.0`)),Al(Ol.default.IPv4.parse(`100.127.255.255`));function jl(e){let t=e.trimStart(),n=e.slice(0,e.length-t.length),r=t.replaceAll(kl,`$<scheme>***@`);if(r!==t)return`${n}${r}`;let i=t.indexOf(`@`),a=t.startsWith(`//`)?2:0;return i>a&&!t.slice(a,i).includes(`/`)?`${n}${t.slice(0,a)}***@${t.slice(i+1)}`:e}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ml=`state.json`,Nl=/No matching distribution|Could not find a version/iu,Pl=/Network|Temporary failure|Connection|timed out/iu;function Fl(e){return jl(e)}function Il(){return process.platform===`darwin`&&process.arch===`arm64`}const Ll=/* @__PURE__ */ new Set([`Chromium`,`chrome`,`chrome.exe`,`Google Chrome for Testing`]);var Z=class extends Error{code;constructor(e,t,n){super(t,n),this.name=`InstallError`,this.code=e}};function Rl(e){return X(e)&&typeof e.code==`string`?e.code:void 0}const zl=65536,Bl=`
123
- [installer] 输出过长,后续内容已丢弃`;function Vl(e,t){if(e.endsWith(Bl))return e;let n=e+t;return n.length>zl?`${n.slice(0,zl)}${Bl}`:n}async function Hl(e,t={}){let n=t.timeoutMs??18e5;return new Promise(r=>{let i=oe(e[0]??``,e.slice(1),{env:{...process.env,...t.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=``,o=``,s=!1,c={},l=e=>{s||(s=!0,clearTimeout(c.timer),r(e))};c.timer=setTimeout(()=>{i.kill(`SIGKILL`),l({code:null,stdout:a,stderr:`${o}\n[installer] ${String(n)}ms 内没有结束,已终止`})},n),i.stdout.on(`data`,e=>{a=Vl(a,e.toString(`utf8`))}),i.stderr.on(`data`,e=>{o=Vl(o,e.toString(`utf8`))}),i.on(`error`,e=>{l({code:null,stdout:a,stderr:`${o}${String(e)}`})}),i.on(`close`,e=>{l({code:e,stdout:a,stderr:o})})})}function Ul(e){return async t=>{let n=g.join(te.tmpdir(),`dsh-scrapling-dl-${ie()}`),r=await e([`curl`,`--fail`,`--location`,`--silent`,`--show-error`,`--connect-timeout`,`20`,`--max-time`,`900`,`--output`,n,t]);if(r.code===0)try{return new Uint8Array(await u(n))}finally{await p(n,{force:!0})}if(await p(n,{force:!0}),r.code!==null)throw new Z(`INSTALL_NETWORK`,`curl failed for ${jl(t)}: ${Fl(r.stderr).slice(0,400)}`);let i=await fetch(t,{signal:AbortSignal.timeout(9e5)});if(!i.ok)throw new Z(`INSTALL_NETWORK`,`${jl(t)} answered HTTP ${i.status}`);return new Uint8Array(await i.arrayBuffer())}}const Wl={download:Ul(Hl),extract:async(e,t)=>{let n=await Hl([`tar`,`-xzf`,e,`-C`,t]);if(n.code!==0)throw new Z(`INSTALL_FAILED`,`tar failed: ${Fl(n.stderr).slice(0,400)}`)},spawn:Hl};async function Gl(e){try{return await a(e,t.F_OK),!0}catch{return!1}}function Kl(e=ae(import.meta.url)){let t;try{t=e(`fs-native-extensions`)}catch{t=void 0}if(X(t)){let e=t.tryLock,n=t.unlock;if(typeof e==`function`&&typeof n==`function`)return{tryLock:n=>!!e.call(t,n),unlock:e=>{n.call(t,e)}}}return null}const ql=Kl();function Jl(e,t=ql){if(t===null)throw new Z(`INSTALL_LOCK_UNREADABLE`,`fs-native-extensions is not loadable`);try{return t.tryLock(e)}catch(e){throw new Z(`INSTALL_LOCK_UNREADABLE`,`cannot lock install fd: ${String(e)}`)}}async function Yl(e,t=ql){let n;try{n=await l(e,`a+`)}catch(t){throw new Z(`INSTALL_LOCK_UNREADABLE`,`cannot open install lock ${e}: ${String(t)}`)}let r;try{r=Jl(n.fd,t)}catch(e){throw await n.close(),e}if(!r)throw await n.close(),new Z(`INSTALL_BUSY`,`another install holds ${e}`);return{release:async()=>{try{t?.unlock(n.fd)}catch{}await n.close()}}}async function Xl(e){let t=g.join(e,`runtime`);return await c(t,{recursive:!0}),process.platform!==`win32`&&await o(t,448),t}const Zl=new ne;async function Ql(e,t){let n=g.join(e,`runtime`),r=g.join(n,`install.lock`),i=g.resolve(r),a=Zl.getStore();if(a?.has(i)===!0)return t();await Xl(e);let o=await Yl(r),s=/* @__PURE__ */ new Set([...a??[],i]);try{return await Zl.run(s,t)}finally{await o.release()}}async function $l(e,t){if(!URL.canParse(t))throw new Z(`INSTALL_OFFLINE_ASSETS`,`manifest archive URL is not parseable: ${t}`);let n=g.basename(new URL(t).pathname),r;try{r=decodeURIComponent(n)}catch{throw new Z(`INSTALL_OFFLINE_ASSETS`,`manifest archive name has invalid percent-encoding: ${n}`)}let i=n===r?[n]:[r,n],a=(await Promise.all(i.map(async t=>({name:t,bytes:await u(g.join(e,t)).catch(()=>null)})))).find(e=>e.bytes!==null)?.bytes;if(a==null)throw new Z(`INSTALL_OFFLINE_ASSETS`,`offline python archive missing under ${e}: expected ${i.join(` or `)}`);return new Uint8Array(a)}async function eu(e,t,n,r){return Ql(t,async()=>{let i=g.join(t,`runtime`,`.tmp`,ie());await c(i,{recursive:!0});let a=g.join(i,`python.tar.gz`);try{let o=r===void 0?await n.download(e.url):await $l(r,e.url),l=re(`sha256`).update(o).digest(`hex`);if(l!==e.sha256)throw new Z(`INSTALL_HASH_MISMATCH`,`python archive hash ${l} does not match ${e.sha256}`);await ee(a,o);let u=g.join(i,`extract`);await c(u,{recursive:!0}),await n.extract(a,u);let d=g.join(u,`python`),m=Y(g.join(d,`bin`,`python3`))?d:u;if(e.pythonVersion!==J.darwinArm64.pythonVersion)throw new Z(`INSTALL_FAILED`,`python asset version ${e.pythonVersion} is not the manifest version ${J.darwinArm64.pythonVersion}`);let h=g.dirname(g.dirname(Sl(t)));await c(g.dirname(h),{recursive:!0});let te=`${h}.new-${ie()}`;try{await s(m,te,{recursive:!0,dereference:!0}),await p(h,{recursive:!0,force:!0}),await f(te,h)}catch(e){throw await p(te,{recursive:!0,force:!0}),e}let ne=Sl(t);if(!Y(ne))throw new Z(`INSTALL_FAILED`,`python archive did not contain bin/python3`);return{pythonPath:ne,version:J.darwinArm64.pythonVersion}}finally{await p(i,{recursive:!0,force:!0}),await m(g.join(t,`runtime`,`.tmp`)).catch(()=>null)}})}async function tu(e){let t=g.join(e,`runtime`,Ml),n;try{n=await u(t,`utf8`)}catch(e){if(Rl(e)===`ENOENT`)return{packs:{}};throw new Z(`INSTALL_STATE_CORRUPT`,`cannot read ${t}: ${String(e)}; delete it and install again`,{cause:e})}let r;try{r=JSON.parse(n)}catch(e){throw new Z(`INSTALL_STATE_CORRUPT`,`${t} is not valid JSON; delete it and install again`,{cause:e})}if(!X(r))throw new Z(`INSTALL_STATE_CORRUPT`,`${t} does not hold a JSON object; delete it and install again`);return r}async function nu(e,t){let n=await Xl(e),r=g.join(n,Ml),i=`${r}.${ie()}.tmp`;try{await ee(i,JSON.stringify(t,null,2),`utf8`),await f(i,r)}finally{try{await p(i,{force:!0})}catch{}}}async function ru(e,t,n,r=e=>u(e,`utf8`)){let i=g.join(e,`bin`),a=`#!${t}/`,o=(await d(i,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isFile()).map(e=>g.join(i,e.name));await Promise.all(o.map(async e=>{let t=await r(e).catch(()=>``),i=t.indexOf(`
124
- `),o=i===-1?t:t.slice(0,i);if(!o.startsWith(a))return;let s=i===-1?``:t.slice(i);await ee(e,`#!${n}/${o.slice(a.length)}${s}`,`utf8`)}))}async function iu(e,t){let n=!1;if(t){try{await p(e.venv,{recursive:!0,force:!0})}catch{}try{await f(e.previousVenv,e.venv)}catch{n=!0}}if(!n)try{await p(e.previousVenv,{recursive:!0,force:!0})}catch{}try{await p(e.staging,{recursive:!0,force:!0})}catch{}}async function au(e){let{io:t}=e;await Ql(e.dataDir,async()=>{let n=await Xl(e.dataDir),r=g.join(n,`venv`),i=g.join(n,`.tmp`,`venv-${ie()}`),a=g.join(n,`.tmp`,`venv-previous-${ie()}`),o=[g.join(e.repoRoot,`py`,`runtime-requirements.txt`)];if(e.documents===!0){let t=g.join(e.repoRoot,J.documents.requirements),n=await u(t),r=re(`sha256`).update(n).digest(`hex`);if(r!==J.documents.sha256)throw new Z(`INSTALL_HASH_MISMATCH`,`documents requirements hash ${r} does not match ${J.documents.sha256}`);o.push(t)}let s=!1,c=!1;try{let n=await t.spawn([e.pythonPath,`-m`,`venv`,i]);if(n.code!==0)throw new Z(`INSTALL_FAILED`,`venv failed: ${Fl(n.stderr).slice(0,400)}`);let l=g.join(i,`bin`,`python3`),u=e.assets===void 0?[]:[`--no-index`,`--find-links`,g.join(e.assets,`wheels`)],d=await t.spawn([l,`-m`,`pip`,`install`,`--only-binary=:all:`,`--require-hashes`,...o.flatMap(e=>[`-r`,e]),...u],{env:{PIP_DISABLE_PIP_VERSION_CHECK:`1`}});if(d.code!==0){let e=`${d.stdout}\n${d.stderr}`;throw Nl.test(e)?new Z(`INSTALL_NO_WHEEL`,`a dependency has no wheel for this platform`):Pl.test(e)?new Z(`INSTALL_NETWORK`,`pip could not reach the package index`):new Z(`INSTALL_FAILED`,`pip failed: ${Fl(d.stderr).slice(0,400)}`)}await ru(i,i,r);try{await Gl(r)&&(await f(r,a),s=!0),await f(i,r)}catch(e){throw new Z(`INSTALL_FAILED`,`cannot replace ${r}: ${String(e)}`,{cause:e})}let p=await tu(e.dataDir),m={...X(p.packs)?p.packs:{},core:`ready`,...e.markDocuments===!0?{documents:`ready`}:{}};await nu(e.dataDir,{...p,packs:m,python:e.pythonPath}),c=!0}finally{await iu({venv:r,previousVenv:a,staging:i},s&&!c)}})}async function ou(e){try{return(await d(e,{recursive:!0})).some(e=>Ll.has(g.basename(e)))}catch{return!1}}async function su(e){return ou(g.join(e,`runtime`,`browsers`))}async function cu(e){let t=`${J.documents.distribution}-${J.documents.version}.dist-info`;try{return(await d(g.join(e,`runtime`,`venv`),{recursive:!0})).some(e=>g.basename(e)===t)}catch{return!1}}async function lu(e){let{io:t}=e;return Ql(e.dataDir,async()=>{let n=g.join(e.dataDir,`runtime`,`browsers`);await c(n,{recursive:!0});let r=await t.spawn([e.pythonPath,`-m`,`patchright`,`install`,`chromium`],{env:{PLAYWRIGHT_BROWSERS_PATH:n}});if(r.code!==0)throw new Z(`INSTALL_BROWSER_FAILED`,`chromium install failed: ${Fl(r.stderr).slice(0,400)}`);if(!await ou(n))throw new Z(`INSTALL_BROWSER_FAILED`,`no chromium executable found under ${n}`);let i=await tu(e.dataDir),a={...X(i.packs)?i.packs:{},browser:`ready`};return await nu(e.dataDir,{...i,packs:a,browsersPath:n}),{browsersPath:n}})}function uu(e,t){return e===`ready`?t?`ready`:`corrupt`:`missing`}async function du(e,t){if(!Il())return{core:`blocked`,browser:`blocked`,search:`blocked`,media:`blocked`,documents:`blocked`,"adaptive-redis":`blocked`,mcp:`blocked`};let n=(await tu(e)).packs,r=X(n)?n:{},i=uu(r.core,Y(Cl(e))),a={core:i,browser:uu(r.browser,await su(e)),search:i,media:i,documents:uu(r.documents,i===`ready`&&await cu(e)),"adaptive-redis":i,mcp:i};return t!==void 0&&(a[t]=`installing`),a}function fu(e){if(e?.aborted===!0)throw new Z(`INSTALL_CANCELLED`,`install cancelled`)}async function pu(e,t,n,r,i){let a=Sl(e);return Y(a)?a:(fu(n),(await eu(r,e,t,i)).pythonPath)}async function mu(e,t){if(!Il())throw new Z(`INSTALL_PACK_BLOCKED`,`runtime packs are verified on macOS arm64 only; this host is ${process.platform}/${process.arch}`);let{dataDir:n,repoRoot:r,io:i,signal:a,onProgress:o,assets:s}=t,c=t.asset??J.darwinArm64;if(s!==void 0&&!await Gl(g.join(s,`wheels`)))throw new Z(`INSTALL_OFFLINE_ASSETS`,`offline wheelhouse missing: ${g.join(s,`wheels`)}`);fu(a),o?.(`installing ${e}`);let l=await pu(n,i,a,c,s);fu(a),o?.(`installing core packages into ${l}`);let u=await tu(n),d=X(u.packs)?u.packs:{};await au({pythonPath:l,dataDir:n,repoRoot:r,io:i,documents:e===`documents`||d.documents===`ready`,markDocuments:e===`documents`,...s===void 0?{}:{assets:s}}),fu(a),e===`browser`&&(o?.(`installing full chromium`),await lu({pythonPath:Cl(n),dataDir:n,io:i}),fu(a)),o?.(`${e} ready`)}const hu=mu;async function gu(e,t){await Ql(t.dataDir,async()=>{let n=g.join(t.dataDir,`runtime`),r=e===`browser`?`browsers`:`venv`;await p(g.join(n,r),{recursive:!0,force:!0}),t.purge&&(await Promise.all([``,`-wal`,`-shm`].map(e=>p(g.join(t.dataDir,`elements_storage.db${e}`),{force:!0}))),await p(g.join(t.dataDir,`downloads`),{recursive:!0,force:!0}));let i=await tu(t.dataDir);if(!X(i.packs))return;let a={...i.packs};Reflect.deleteProperty(a,e),await nu(t.dataDir,{...i,packs:a})})}const _u=[`core`,`browser`,`search`,`media`,`documents`,`adaptive-redis`,`mcp`];new Set(_u);const vu=/\r\n|\n|\r/u,yu=/[\t ]#.*$/u,bu=_u,xu=new Set(bu),Su=/* @__PURE__ */ new Set([`setup`,`doctor`]),Cu=/* @__PURE__ */ new Set([`status`,`apply`,`repair`,`purge`,`dry-run`,`with-auth`,`accept-risk`]),wu=/* @__PURE__ */ new Set([`port`,`mode`,`profile`,`offline`,`uninstall`,`feature`]);function Tu(){let e=process.env.DSH_SCRAPLING_DATA_DIR;return e===void 0||e===``?g.join(te.homedir(),`.dsh-scrapling`):g.resolve(e)}function Eu(e){return xu.has(e)}function Du(e,t){if(!e.startsWith(`--`))return{kind:`invalid`};let n=e.slice(2);return Cu.has(n)?{kind:`boolean`,name:n}:!wu.has(n)||t===void 0||t.startsWith(`--`)?{kind:`invalid`}:{kind:`value`,name:n,value:t}}function Ou(e){let[t,...n]=e;if(t===void 0||!Su.has(t))return null;let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Set;for(let[e,t]of n.entries())if(!i.has(e)){let a=Du(t,n[e+1]);if(a.kind===`invalid`)return null;r.set(a.name,a.kind!==`value`||a.value),a.kind===`value`&&i.add(e+1)}return{command:t,flags:r}}function ku(e){return{io:Wl,dataDir:Tu(),repoRoot:g.resolve(import.meta.dirname,`..`),log:e=>{console.info(e)},installPackFn:mu,repairPackFn:hu,uninstallPackFn:gu,...e}}function Q(e,t){let n=e.get(t);return typeof n==`string`?n:void 0}function Au(e){let t=Q(e,`port`);if(t===void 0)return{invalid:!1};let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535?{port:n,invalid:!1}:{invalid:!0}}function ju(e){let t=Q(e,`mode`);return t===void 0||!Te(t)?null:t}function Mu(e,t,n){let r=typeof n==`string`?JSON.stringify(n):`(缺省)`;return`--${e} 要写 ${t.join(` / `)} 之一;现在给的是 ${r}`}function Nu(e){return Mu(`mode`,Ce,e.get(`mode`))}function Pu(e,t){return Mu(e,bu,t.get(e))}function Fu(e){return e.has(`apply`)&&!e.has(`dry-run`)}function Iu(e,t){return e.has(`dry-run`)&&e.has(`apply`)?`dry-run:--dry-run 压过 --apply,${t.suppressed}`:t.missingApply}function Lu(e){if(e.mode===`native`)return{text:ut(),note:`native 模式不留 dsh-mcp-client 条目:原生工具已经在宿主名册里,再端一份就是两套。`,install:``};if(e.mode===`mcp`){let t=e.withAuth?`Authorization 在宿主装载时从宿主进程环境的 ${be} 求值:变量缺席会写成 "Bearer undefined",加鉴权前先确认宿主环境里已设置它。`:``;return{text:lt({port:e.port,withAuth:e.withAuth,toolLoading:e.toolLoading}),note:`mcp 模式起的是本插件的 server,URL 里的端口要与部署项 mcpPort 同值(当前按 ${String(e.port)} 生成)。${t}`,install:De()}}let t=Pe({dataDir:e.dataDir,enabled:e.enabled,acceptedRisk:e.acceptRisk,toolLoading:e.toolLoading});return{text:t.patch,note:t.risk,install:t.installCommand}}async function Ru(e,t){await c(g.dirname(e),{recursive:!0}),await ee(e,t,`utf8`)}async function zu(e,t){let r=ju(e);if(r===null)return t.log(Nu(e)),2;let i=Au(e);if(i.invalid)return t.log(`--port 要写 1 到 65535 之间的整数;现在给的是 ${String(Q(e,`port`))}`),2;let a=i.port??39217,o=Q(e,`profile`),s=o===void 0?void 0:await st(o),c=Lu({mode:r,port:a,withAuth:e.has(`with-auth`),acceptRisk:e.has(`accept-risk`),dataDir:t.dataDir,enabled:s?.officialMcpEnabled===!0,toolLoading:s?.mcpToolLoading??`eager`});t.log(c.text),t.log(c.note),c.install!==``&&(t.log(`客户端没装就先跑:${c.install}`),t.log(`只接受 ${Se.join(` 或 `)}:npm 的 latest 比宿主线旧,宿主拒绝装载不匹配的对端。`));let l=g.join(t.dataDir,`mcp`,ct(r));if(r===`official-mcp`){let e=ke(t.dataDir);n(e)||t.log(`${e} 现在还不存在:先跑 setup --feature mcp --apply 把官方 server 装进托管 venv;在那之前这条条目连不上(failOnStartupError: true 会让宿主把这条报成红)。`)}return Fu(e)?(await Ru(l,c.text),t.log(`wrote ${l}`),t.log(`profile 不会被这条命令改写:把这段并进 <profile>/cordis.patch.yml,再重启宿主。`),0):(t.log(Iu(e,{suppressed:`只打印条目,不写 ${l}`,missingApply:`dry-run; add --apply to write ${l}`})),0)}function Bu(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`)}function Vu(e){let t=e.trim(),n=t.charAt(0);if(n===`"`||n===`'`){let e=t.indexOf(n,1);if(e>0)return t.slice(1,e)}return t.replace(yu,``).trim()}function $(e,t){let n=RegExp(`^[\\t ]*(?:-[\\t ]+)?${Bu(t)}:(?<value>[^\\r\\n]*)$`,`u`);return e.split(vu).filter(e=>!e.trimStart().startsWith(`#`)).map(e=>Vu(n.exec(e)?.groups?.value??``)).filter(e=>e!==``).at(-1)}function Hu(e,t){return $(e,t)!==void 0}function Uu(e,t){let n=$(e,t);return n===`true`||n===`True`||n===`TRUE`}function Wu(e){return!e.includes(`/`)&&!e.includes(`\\`)?{value:e,relative:!1}:{value:g.resolve(e),relative:!g.isAbsolute(e)}}async function Gu(e){let t=Q(e,`profile`);if(t===void 0)return{profile:{path:null,pythonBin:null,dataDir:null,note:`未读 profile:runtime 只按 CLI 自身的解析链(pythonBin 配置 → 托管 venv → 裸托管解释器 → 仓内 _env/.venv → PATH python3);要看部署配置解析出的解释器就加 --profile <目录>`},pythonBin:``};let n=await st(t),r=$(n.patchText,`pythonBin`)??``,i=$(n.patchText,`dataDir`)??``,a=Wu(r),o=Wu(i),s=a.value,c=[...r===``?[`profile 里没有 scrapling 的 pythonBin:runtime 回落到 CLI 自身的解析链(托管 venv → 裸托管解释器 → 仓内 _env/.venv → PATH python3)`]:[],...a.relative||o.relative?[`profile 里的 pythonBin / dataDir 写的是相对路径:CLI 已按自己进程的 cwd 展开,而宿主按它自己的 cwd 展开,两处可能不是同一个目录;改写成绝对路径才没有这层歧义`]:[]];return{profile:{path:t,pythonBin:r===``?null:r,dataDir:i===``?null:i,...c.length===0?{}:{note:c.join(`;`)}},pythonBin:s,...i===``?{}:{dataDirOverride:o.value}}}async function Ku(e,t){let{profile:n,pythonBin:r,dataDirOverride:i}=await Gu(e),a=i??t.dataDir,o=Dl({pythonBin:r,dataDir:a,repoRoot:t.repoRoot}),s=await tu(a),c=await du(a);return t.log(JSON.stringify({dataDir:a,profile:n,runtime:o,packs:c,state:s},null,2)),0}const qu={tavily:`tavilyApiKey`,brave:`braveApiKey`,serper:`serperApiKey`,searxng:`searxngEndpoint`};function Ju(e){return e===void 0||ft(e)?[]:[{code:`SEARCH_BACKEND_INVALID`,detail:`searchBackend=${e} 不是本包实现的后端:可写的取值是 ${dt.join(` / `)},删掉这一行即回到 auto。`}]}function Yu(e){let t=`searchProvider 已指向 scrapling,但能力包没装好:web_search 会报 WEB_PROVIDER_CONFIGURED_UNAVAILABLE。`;return e===`blocked`?`${t}原因是这台机器不在安装器支持的范围内(只验过 macOS arm64),所以 core 被标成 blocked —— 这不是「没装」,重跑安装计划在那台机器上也修不好。修复:把 profile 里 - id: scrapling 的 pythonBin 指到一个装好 scrapling 的解释器,或把 searchProvider 从 scrapling 改回宿主自己的 provider。`:`${t}修复:dsh-scrapling setup --feature core --apply。`}function Xu(e,t){let n=$(e,`searchProvider`),r=$(e,`searchBackend`),i=r??`auto`,a=Uu(e,`searchPublicFallback`),o=Hu(e,`tavilyApiKey`),s=Hu(e,`searxngEndpoint`),c=i===`auto`&&!o&&!s&&!a,l=i===`auto`?void 0:qu[i],u=l!==void 0&&!Hu(e,l),d=n===`scrapling`,f=[],p=[];return n===void 0&&f.push(`SEARCH_PROVIDER_NOT_CONFIGURED 部署配置里还没写 searchProvider: scrapling:内置 web_search 仍走宿主自己选的 provider(base 层默认 deepseek-official),本插件的 search provider 只是备选。要接管它,给 <profile>/cordis.patch.yml 里 - id: web 的 config 加一行 searchProvider: scrapling,再重启宿主。`),c&&!d&&f.push(`SEARCH_BACKEND_MISSING 搜索后端未配置(预期行为):searchBackend=auto 但没配 tavilyApiKey、也没设 searxngEndpoint,且 searchPublicFallback=false,所以本插件的 search provider 不可用。修复:配 tavilyApiKey、设 searxngEndpoint,或显式把 searchPublicFallback 设为 true(会把查询词发给公共引擎)。`),u&&!d&&f.push(`SEARCH_AUTH searchBackend=${i} 但 ${l} 没配:查询会报 SEARCH_AUTH。修复:配 ${l},或换一个后端。`),p.push(...Ju(r)),d&&t!==`ready`&&p.push({code:`WEB_PROVIDER_CONFIGURED_UNAVAILABLE`,detail:Yu(t)}),d&&c&&p.push({code:`WEB_PROVIDER_CONFIGURED_UNAVAILABLE`,detail:`searchProvider 已指向 scrapling,但搜索后端不可用(没配 key/SearXNG,且 searchPublicFallback=false):web_search 会报 WEB_PROVIDER_CONFIGURED_UNAVAILABLE。修复:配 tavilyApiKey、设 searxngEndpoint,或显式打开 searchPublicFallback。`}),d&&u&&p.push({code:`SEARCH_AUTH`,detail:`searchBackend=${i} 但 ${l} 没配:provider 会注册成功,而每次查询都会报 SEARCH_AUTH。修复:配 ${l},或换一个后端。`}),{hints:f,findings:p}}async function Zu(e,t){let n=ju(e);if(n===null)return t.log(Nu(e)),2;let r=Q(e,`profile`);if(r===void 0)return t.log(`doctor 要 --profile <目录>:判据来自那份 profile 自己写下的 cordis.patch.yml。`),2;let i=Au(e);if(i.invalid)return t.log(`--port 要写 1 到 65535 之间的整数;现在给的是 ${String(Q(e,`port`))}`),2;let a=await st(r),o=await du($(a.patchText,`dataDir`)??t.dataDir),s=Ze({mode:n,expectedPort:i.port,...a}),c=Xu(a.patchText,o.core);for(let e of c.hints)t.log(e);for(let e of s)t.log(`${e.code} ${e.detail}`);for(let e of c.findings)t.log(`${e.code} ${e.detail}`);let l=s.length+c.findings.length;return l===0?(t.log(`${r} 与 integrationMode=${n} 一致。`),0):(t.log(s.length>0?`${String(l)} 处不一致:改完重跑 setup --mode ${n} --apply,并把条目并进 profile 后重启宿主。`:`${String(l)} 处搜索配置不一致:按上面逐条的修复动作改 ${r} 里 web 条目的 config,重启宿主生效。`),1)}async function Qu(e,t){let n=e.get(`uninstall`);if(typeof n!=`string`||!Eu(n))return t.log(Pu(`uninstall`,e)),2;let r=e.has(`purge`);return t.log(`uninstall ${n}${r?` (and purge user data)`:``} from ${g.join(t.dataDir,`runtime`)}`),Fu(e)?(await Ql(t.dataDir,async()=>{await t.uninstallPackFn(n,{dataDir:t.dataDir,purge:r})}),t.log(`uninstalled ${n}${r?` (purged data)`:``}`),0):(t.log(Iu(e,{suppressed:`只打印计划,不删任何 runtime 文件`,missingApply:`dry-run; add --apply to uninstall`})),0)}function $u(e,t){let n=J.darwinArm64,r=g.join(t.repoRoot,`py`,`runtime-requirements.txt`);return[`python ${n.pythonVersion}(清单声明 ${String(n.sizeBytes)} 字节,sha256 前 12 位 ${n.sha256.slice(0,12)})`,e===`browser`?`core venv 依赖:${r},再装一份完整 Chromium(patchright)`:`core venv 依赖:${r}`,...e===`documents`?[`documents 依赖:${g.join(t.repoRoot,J.documents.requirements)}`]:[],`落地位置:${g.join(t.dataDir,`runtime`)}(Python 在 runtime/python/,wheel 在 runtime/venv/)`].join(`
125
- `)}async function ed(e,t,n,r){await(n?t.repairPackFn:t.installPackFn)(e,{dataDir:t.dataDir,repoRoot:t.repoRoot,io:t.io,onProgress:t.log,...r===void 0?{}:{assets:r}})}async function td(e,t){let n=e.get(`feature`);if(typeof n!=`string`||!Eu(n))return t.log(Pu(`feature`,e)),2;let r=Q(e,`offline`);return r===``?(t.log(`--offline 要给一个资产目录`),2):(t.log($u(n,t)),r!==void 0&&t.log(`离线资产目录:${r}`),Fu(e)?(await ed(n,t,e.has(`repair`),r),t.log(`installed ${n}`),0):(t.log(Iu(e,{suppressed:`只打印计划,不下载也不写 runtime`,missingApply:`dry-run; add --apply to install`})),0))}function nd(e,t){return t.log(e instanceof Z||e instanceof Oe?`${e.code}: ${e.message}`:`command failed: ${String(e)}`),1}async function rd(e,t={}){let n=ku(t),r=Ou(e);if(r===null)return n.log(`用法:dsh-scrapling setup [--feature <core|browser|search|media|adaptive-redis|mcp>] [--mode <native|mcp|official-mcp>] [--profile <目录>] [--port <1-65535>] [--offline <资产目录>] [--apply] [--dry-run] [--repair] [--status] [--with-auth] [--accept-risk] [--uninstall <core|browser|search|media|adaptive-redis|mcp> [--purge]];dsh-scrapling doctor --mode <native|mcp|official-mcp> --profile <目录>;--apply 才落地,--dry-run(缺省)只打印计划,两者同时给时 --dry-run 胜。`),2;let{flags:i}=r;try{return r.command===`doctor`?await Zu(i,n):i.has(`status`)?await Ku(i,n):i.has(`mode`)?await zu(i,n):i.has(`uninstall`)?await Qu(i,n):await td(i,n)}catch(e){return nd(e,n)}}try{process.exitCode=await rd(process.argv.slice(2))}catch(e){console.error(`command failed: ${String(e)}`),process.exitCode=1}export{};
61
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Vo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Vo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Ho=new Set([`type`,`properties`,`required`,`additionalProperties`]),Uo=[`oneOf`,`anyOf`];function Wo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Go(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ho.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Wo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}y(n,r,e.length===1?e[0]:Go(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Wo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Ko(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ho)if(t in e)return;let n=t.filter(e=>Uo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Go(t);else{let e=n[0],i=Uo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Go([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Lo(e,r))}function qo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Lo(i,s),Lo(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Vo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Ko(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Lo(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,y(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Yo(t,`input`,e.processors),output:Yo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function H(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return H(r.element,n);if(r.type===`set`)return H(r.valueType,n);if(r.type===`lazy`)return H(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return H(r.innerType,n);if(r.type===`intersection`)return H(r.left,n)||H(r.right,n);if(r.type===`record`||r.type===`map`)return H(r.keyType,n)||H(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:H(r.in,n)||H(r.out,n);if(r.type===`object`){for(let e in r.shape)if(H(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(H(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(H(e,n))return!0;return!!(r.rest&&H(r.rest,n))}return!1}const Jo=(e,t={})=>n=>{let r=Ro({...n,processors:t});return V(e,r),Bo(r,e),qo(r,e)},Yo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ro({...i??{},target:a,io:t,processors:n});return V(e,o),Bo(o,e),qo(o,e)},Xo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Zo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Qo=(e,t)=>{Xo(e,`minimum`,t),Zo(e,`maximum`,t)},$o=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},es=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},ts=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},ns=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},rs=(e,t)=>Xo(e,`minimum`,t.minimum),is=(e,t)=>Zo(e,`maximum`,t.maximum),as=e=>(t,n)=>{ns(t,n.format);let[r,i]=e[n.format];Xo(t,`minimum`,r),Zo(t,`maximum`,i)},os={greater_than:(e,t)=>Xo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Zo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>$o(e,t.value),number_format:as(Pt),bigint_format:as(Ft),min_length:rs,max_length:is,length_equals:(e,t)=>Qo(e,t.length),min_size:rs,max_size:is,size_equals:(e,t)=>Qo(e,t.size),string_format:(e,t)=>{ns(e,t.format),t.pattern&&es(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>ts(e,t.mime)};function U(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)os[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Xo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Xo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Zo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Zo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&$o(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&ts(t,i.mime);for(let e of i.patterns??[])es(t,e);return t}const ss={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},cs=new Map([[xi,sr],[Ci,cr]]),ls=e=>cs.get(e)??e,us=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=U(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ss[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ls);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ds=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=U(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):B(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},fs=(e,t,n,r)=>{n.not={}},ps=(e,t,n,r)=>{let i=pt(e._zod.def.entries);i.length===0?n.not={}:(i.every(e=>typeof e==`number`)&&(n.type=`number`),i.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=i)},ms=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(B(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(B(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},hs=(e,t,n,r)=>{B(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},gs=(e,t,n,r)=>{B(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},_s=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=U(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=V(a.element,t,{...r,path:[...r.path,`items`]})};function vs(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?vs(t.out):t.type===`catch`?vs(t.innerType):e._zod.optin}const ys=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&B(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)y(i.properties,e,V(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?vs(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=V(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},bs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>V(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},xs=(e,t,n,r)=>{let i=e._zod.def,a=V(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=V(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Ss(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Ss(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Ss(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?yr:vr).source)),p}const Cs=new WeakMap;function ws(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Cs.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Ss(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const Ts=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=U(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=V(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)y(i.patternProperties,ls(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=V(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Cs.get(t);n||(n=[],Cs.set(t,n),t.deferred.push(()=>ws(t))),n.push(e)}i.additionalProperties=V(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&vs(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Es=(e,t,n,r)=>{let i=e._zod.def,a=V(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ds=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Os=Symbol();function ks(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(B(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Os):JSON.parse(o)}const As=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=ks(i.defaultValue,e,t,n,r);o!==Os&&(n.default=o)},js=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=ks(i.defaultValue,e,t,n,r);o!==Os&&(n._prefault=o)},Ms=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{B(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Ns=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;V(o,t,r);let s=t.seen.get(e);s.ref=o},Ps=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Fs=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Is=new WeakSet([Object.prototype,Error.prototype]);function Ls(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const W=N(`ZodError`,(e,t)=>{bn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Is.has(n)||(Is.add(n),Ls(n,`format`,e=>t=>Cn(e,t)),Ls(n,`flatten`,e=>t=>Sn(e,t)),Ls(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ht,2)}),Ls(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ht,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Rs=Dn(W),zs=On(W),Bs=kn(W),Vs=jn(W),Hs=Ln(W),Us=Rn(W),Ws=zn(W),Gs=Bn(W),Ks=Vn(W),qs=Hn(W),Js=Un(W),Ys=Wn(W);function Xs(){F.localeError||I(Aa())}function Zs(){F.memoizer||I({memoizer:Da()})}const G=N(`ZodType`,(e,t)=>(Xs(),R.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(S(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return T(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(fl(e,t))},superRefine(e,t){return this.check(pl(e,t))},overwrite(e){return this.check(Do(e))},optional(){return Jc(this)},exactOptional(){return Xc(this)},nullable(){return Qc(this)},nullish(){return Jc(Qc(this))},nonoptional(e){return il(this,e)},array(){return Mc(this)},or(e){return Ic([this,e])},and(e){return Rc(this,e)},transform(e){return cl(this,Kc(e))},default(e){return el(this,e)},prefault(e){return nl(this,e)},catch(e){return ol(this,e)},pipe(e){return cl(this,e)},readonly(){return ul(this)},describe(e){let t=this.clone();return Pa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Pa.get(this);let t=this.clone();return Pa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return tn(this,`~standard`,{...Ur(this),jsonSchema:{input:Yo(this,`input`),output:Yo(this,`output`)}})},set"~standard"(e){A(this,`~standard`,e)},parse:function e(t,n){return Rs(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await zs(this,t,n,{callee:e})},safeParse(e,t){return Bs(this,e,t)},async safeParseAsync(e,t){return Vs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){A(this,`spa`,e)},validate(e,t){return Pn(this,e,t)},validateAsync(e,t){return In(this,e,t)},encode:function e(t,n){return Hs(this,t,n,{callee:e})},decode:function e(t,n){return Us(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ws(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Gs(this,t,n,{callee:e})},safeEncode(e,t){return Ks(this,e,t)},safeDecode(e,t){return qs(this,e,t)},async safeEncodeAsync(e,t){return Js(this,e,t)},async safeDecodeAsync(e,t){return Ys(this,e,t)},toJSONSchema(e){return Jo(this,{})(e)},get description(){return Pa.get(this)?.description},get _def(){return this._zod.def}}),Qs=N(`_ZodString`,(e,t)=>{Wr.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r)},nn({format:e=>U(e).format??null,minLength:e=>U(e).minimum??null,maxLength:e=>U(e).maximum??null},{regex(...e){return this.check(xo(...e))},includes(...e){return this.check(wo(...e))},startsWith(...e){return this.check(To(...e))},endsWith(...e){return this.check(Eo(...e))},min(...e){return this.check(yo(...e))},max(...e){return this.check(vo(...e))},length(...e){return this.check(bo(...e))},nonempty(...e){return this.check(yo(1,...e))},lowercase(e){return this.check(So(e))},uppercase(e){return this.check(Co(e))},trim(){return this.check(ko())},normalize(...e){return this.check(Oo(...e))},toLowerCase(){return this.check(Ao())},toUpperCase(){return this.check(jo())},slugify(){return this.check(Mo())}})),$s=N(`ZodString`,(e,t)=>{Wr.init(e,t),Qs.init(e,t)},{email(e){return this.check(La(ic,e))},url(e){return this.check(Ua(sc,e))},jwt(e){return this.check(io(Cc,e))},emoji(e){return this.check(Wa(lc,e))},guid(e){return this.check(Ra(ac,e))},uuid(e){return this.check(za(oc,e))},uuidv4(e){return this.check(Ba(oc,e))},uuidv6(e){return this.check(Va(oc,e))},uuidv7(e){return this.check(Ha(oc,e))},nanoid(e){return this.check(Ga(uc,e))},cuid(e){return this.check(Ka(dc,e))},cuid2(e){return this.check(qa(fc,e))},ulid(e){return this.check(Ja(pc,e))},base64(e){return this.check(to(bc,e))},base64url(e){return this.check(no(xc,e))},xid(e){return this.check(Ya(mc,e))},ksuid(e){return this.check(Xa(hc,e))},ipv4(e){return this.check(Za(gc,e))},ipv6(e){return this.check(Qa(_c,e))},cidrv4(e){return this.check($a(vc,e))},cidrv6(e){return this.check(eo(yc,e))},e164(e){return this.check(ro(Sc,e))},datetime(e){return this.check(ao(ec,e))},date(e){return this.check(oo(tc,e))},time(e){return this.check(so(nc,e))},duration(e){return this.check(co(rc,e))}});function K(e){return Ia($s,e)}const q=N(`ZodStringFormat`,(e,t)=>{z.init(e,t),Qs.init(e,t)}),ec=N(`ZodISODateTime`,(e,t)=>{li.init(e,t),q.init(e,t)}),tc=N(`ZodISODate`,(e,t)=>{ui.init(e,t),q.init(e,t)}),nc=N(`ZodISOTime`,(e,t)=>{di.init(e,t),q.init(e,t)}),rc=N(`ZodISODuration`,(e,t)=>{fi.init(e,t),q.init(e,t)}),ic=N(`ZodEmail`,(e,t)=>{qr.init(e,t),q.init(e,t)}),ac=N(`ZodGUID`,(e,t)=>{Gr.init(e,t),q.init(e,t)}),oc=N(`ZodUUID`,(e,t)=>{Kr.init(e,t),q.init(e,t)}),sc=N(`ZodURL`,(e,t)=>{ti.init(e,t),q.init(e,t)});function cc(e){return Ua(sc,e)}const lc=N(`ZodEmoji`,(e,t)=>{ni.init(e,t),q.init(e,t)}),uc=N(`ZodNanoID`,(e,t)=>{ri.init(e,t),q.init(e,t)}),dc=N(`ZodCUID`,(e,t)=>{ii.init(e,t),q.init(e,t)}),fc=N(`ZodCUID2`,(e,t)=>{ai.init(e,t),q.init(e,t)}),pc=N(`ZodULID`,(e,t)=>{oi.init(e,t),q.init(e,t)}),mc=N(`ZodXID`,(e,t)=>{si.init(e,t),q.init(e,t)}),hc=N(`ZodKSUID`,(e,t)=>{ci.init(e,t),q.init(e,t)}),gc=N(`ZodIPv4`,(e,t)=>{pi.init(e,t),q.init(e,t)}),_c=N(`ZodIPv6`,(e,t)=>{gi.init(e,t),q.init(e,t)}),vc=N(`ZodCIDRv4`,(e,t)=>{_i.init(e,t),q.init(e,t)}),yc=N(`ZodCIDRv6`,(e,t)=>{yi.init(e,t),q.init(e,t)}),bc=N(`ZodBase64`,(e,t)=>{Si.init(e,t),q.init(e,t)}),xc=N(`ZodBase64URL`,(e,t)=>{Ti.init(e,t),q.init(e,t)}),Sc=N(`ZodE164`,(e,t)=>{Ei.init(e,t),q.init(e,t)}),Cc=N(`ZodJWT`,(e,t)=>{Oi.init(e,t),q.init(e,t)}),wc=N(`ZodNumber`,(e,t)=>{ki.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.isFinite=!0},nn({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=U(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=U(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=U(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>U(e).format??null},{gt(e,t){return this.check(ho(e,t))},gte(e,t){return this.check(go(e,t))},min(e,t){return this.check(go(e,t))},lt(e,t){return this.check(po(e,t))},lte(e,t){return this.check(mo(e,t))},max(e,t){return this.check(mo(e,t))},int(e){return this.check(Ec(e))},safe(e){return this.check(Ec(e))},positive(e){return this.check(ho(0,e))},nonnegative(e){return this.check(go(0,e))},negative(e){return this.check(po(0,e))},nonpositive(e){return this.check(mo(0,e))},multipleOf(e,t){return this.check(_o(e,t))},step(e,t){return this.check(_o(e,t))},finite(){return this}})),Tc=N(`ZodNumberFormat`,(e,t)=>{Ai.init(e,t),wc.init(e,t)});function Ec(e){return lo(Tc,e)}const Dc=N(`ZodUnknown`,(e,t)=>{ji.init(e,t),G.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Oc(){return uo(Dc)}const kc=N(`ZodNever`,(e,t)=>{Mi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r)});function Ac(e){return fo(kc,e)}const jc=N(`ZodArray`,(e,t)=>{Zs(),Ii.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.element=t.element},{min(e,t){return this.check(yo(e,t))},nonempty(e){return this.check(yo(1,e))},max(e,t){return this.check(vo(e,t))},length(e,t){return this.check(bo(e,t))},unwrap(){return this.element}});function Mc(e,t){return No(jc,e,t)}const Nc=N(`ZodObject`,(e,t)=>{Zs(),Hi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),cn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Hc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(S(this._zod.def,{catchall:e}))},passthrough(){return this.clone(S(this._zod.def,{catchall:Oc()}))},loose(){return this.clone(S(this._zod.def,{catchall:Oc()}))},strict(){return this.clone(S(this._zod.def,{catchall:Ac()}))},strip(){return this.clone(S(this._zod.def,{catchall:void 0}))},extend(e){return zt(this,e)},safeExtend(e){return Vt(this,e)},merge(e){return Ht(this,e)},pick(e){return It(this,e)},omit(e){return Rt(this,e)},partial(...e){return Ut(qc,this,e[0])},exactPartial(...e){return Ut(Yc,this,e[0],`exactPartial`)},required(...e){return Wt(rl,this,e[0])}});function Pc(e,t){let n={type:`object`,shape:e??{},...E(t)};return new Nc(n)}const Fc=N(`ZodUnion`,(e,t)=>{Wi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.options=t.options});function Ic(e,t){return new Fc({type:`union`,options:e,...E(t)})}const Lc=N(`ZodIntersection`,(e,t)=>{Gi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Rc(e,t){return new Lc({type:`intersection`,left:e,right:t})}const zc=N(`ZodRecord`,(e,t)=>{Zs(),Ji.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Bc(e,t,n){return!t||!t._zod?new zc({type:`record`,keyType:K(),valueType:e,...E(t)}):new zc({type:`record`,keyType:e,valueType:t,...E(n)})}const Vc=N(`ZodEnum`,(e,t)=>{Yi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Vc({...t,checks:[],...E(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Vc({...t,checks:[],...E(r),entries:i})}});function Hc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Vc({type:`enum`,entries:n,...E(t)})}const Uc=N(`ZodLiteral`,(e,t)=>{Xi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Wc(e,t){return new Uc({type:`literal`,values:Array.isArray(e)?e:[e],...E(t)})}const Gc=N(`ZodTransform`,(e,t)=>{Zs(),Zi.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new mn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push($t(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push($t(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Kc(e){return new Gc({type:`transform`,transform:e})}const qc=N(`ZodOptional`,(e,t)=>{$i.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e){return new qc({type:`optional`,innerType:e})}const Yc=N(`ZodExactOptional`,(e,t)=>{ea.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e){return new Yc({type:`optional`,innerType:e})}const Zc=N(`ZodNullable`,(e,t)=>{ta.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`nullable`,innerType:e})}const $c=N(`ZodDefault`,(e,t)=>{na.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function el(e,t){return new $c({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():At(t)}})}const tl=N(`ZodPrefault`,(e,t)=>{ia.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nl(e,t){return new tl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():At(t)}})}const rl=N(`ZodNonOptional`,(e,t)=>{aa.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function il(e,t){return new rl({type:`nonoptional`,innerType:e,...E(t)})}const al=N(`ZodCatch`,(e,t)=>{ca.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ol(e,t){return new al({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:ln(t)})}const sl=N(`ZodPipe`,(e,t)=>{la.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r),e.in=t.in,e.out=t.out});function cl(e,t){return new sl({type:`pipe`,in:e,out:t})}const ll=N(`ZodReadonly`,(e,t)=>{da.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ul(e){return new ll({type:`readonly`,innerType:e})}const dl=N(`ZodCustom`,(e,t)=>{pa.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)});function fl(e,t={}){return Po(dl,e,t)}function pl(e,t){return Fo(e,t)}const ml=/^[0-9a-f]{64}$/u,hl=Pc({darwinArm64:Pc({platform:Wc(`darwin`),arch:Wc(`arm64`),pythonVersion:K().regex(/^\d+\.\d+\.\d+$/u,`pythonVersion 必须是三段数字的版本号`),release:K(),url:cc({protocol:/^https$/u}).describe(`托管资产只允许 https 下载:http/file 会让安装器去取明文或本机文件`),sha256:K().regex(ml,`sha256 必须是 64 位小写十六进制`),sizeBytes:Ec().positive()}),documents:Pc({requirements:Wc(`py/documents-requirements.txt`),distribution:Wc(`pypdf`),version:K().regex(/^\d+\.\d+\.\d+$/u,`version 必须是三段数字的版本号`),sha256:K().regex(ml,`sha256 必须是 64 位小写十六进制`)}),unsupported:Bc(K(),K())}),gl=n(g.join(import.meta.dirname,`runtime-manifest.json`))?import.meta.dirname:g.resolve(import.meta.dirname,`..`);function _l(e){let t;try{t=JSON.parse(e)}catch(e){throw Error(`runtime-manifest.json is invalid: ${String(e)}`,{cause:e})}let n=hl.safeParse(t);if(!n.success)throw Error(`runtime-manifest.json is invalid: ${Tn(n.error)}`);return n.data}let vl;const yl=/^version\s*=\s*(?<version>\S+)\s*$/mu;function bl(){return g.join(gl,`runtime-manifest.json`)}function xl(e=bl()){try{return r(e,`utf8`)}catch(t){throw Error(`runtime-manifest.json is unreadable: ${e}`,{cause:t})}}function Sl(){return vl??=_l(xl()),vl}const J={get darwinArm64(){return Sl().darwinArm64},get documents(){return Sl().documents},get unsupported(){return Sl().unsupported}};function Cl(e){return g.join(e,`runtime`,`python`,J.darwinArm64.pythonVersion,`bin`,`python3`)}function wl(e){let t=g.join(e,`runtime`,`venv`);return process.platform===`win32`?g.join(t,`Scripts`,`python.exe`):g.join(t,`bin`,`python3`)}function Y(n){try{return i(n).isFile()?(e(n,t.X_OK),!0):!1}catch{return!1}}function Tl(e){return process.platform===`win32`?g.join(e,`_env`,`.venv`,`Scripts`,`python.exe`):g.join(e,`_env`,`.venv`,`bin`,`python`)}function El(e){let t=g.join(e,`runtime`,`venv`,`pyvenv.cfg`),n;try{n=r(t,`utf8`)}catch{n=void 0}return(n===void 0?null:yl.exec(n))?.groups?.version}function Dl(){let e;try{e=J.unsupported[`${process.platform}-${process.arch}`]}catch{e=void 0}return e}function Ol(e){let t=e.pythonBin.trim();if(t.length>0)return{pythonPath:t,via:`configured`,version:`unknown`};if(process.platform===`darwin`&&process.arch===`arm64`&&e.dataDir.length>0){let t=wl(e.dataDir);if(Y(t))return{pythonPath:t,via:`managed-venv`,version:El(e.dataDir)??J.darwinArm64.pythonVersion};let n=Cl(e.dataDir);if(Y(n))return{pythonPath:n,via:`managed`,version:J.darwinArm64.pythonVersion}}let n=e.repoRoot.length>0?Tl(e.repoRoot):``;if(n.length>0&&Y(n))return{pythonPath:n,via:`repo`,version:`unknown`};let r=process.platform===`win32`?`python`:`python3`,i=Dl();return i===void 0?{pythonPath:r,via:`path`,version:`unknown`}:{pythonPath:r,via:`path`,version:`unknown`,assetNote:i}}var kl=me(fe(((e,t,n)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>0xffffffff||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t=0;for(;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>0xffffff||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(n)}))(),1);const Al=/(?<scheme>[a-z][a-z0-9+.!-]*:\/\/)[^\s/?#]*@/giu;function jl(e){return e.toByteArray().reduce((e,t)=>e*256+t,0)}jl(kl.default.IPv4.parse(`198.18.0.0`)),jl(kl.default.IPv4.parse(`198.19.255.255`)),jl(kl.default.IPv4.parse(`100.64.0.0`)),jl(kl.default.IPv4.parse(`100.127.255.255`));function Ml(e){let t=e.trimStart(),n=e.slice(0,e.length-t.length),r=t.replaceAll(Al,`$<scheme>***@`);if(r!==t)return`${n}${r}`;let i=t.indexOf(`@`),a=t.startsWith(`//`)?2:0;return i>a&&!t.slice(a,i).includes(`/`)?`${n}${t.slice(0,a)}***@${t.slice(i+1)}`:e}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Nl=`state.json`,Pl=/No matching distribution|Could not find a version/iu,Fl=/Network|Temporary failure|Connection|timed out/iu;function Il(e){return Ml(e)}function Ll(){return process.platform===`darwin`&&process.arch===`arm64`}const Rl=new Set([`Chromium`,`chrome`,`chrome.exe`,`Google Chrome for Testing`]);var Z=class extends Error{code;constructor(e,t,n){super(t,n),this.name=`InstallError`,this.code=e}};function zl(e){return X(e)&&typeof e.code==`string`?e.code:void 0}const Bl=65536,Vl=`
62
+ [installer] 输出过长,后续内容已丢弃`;function Hl(e,t){if(e.endsWith(Vl))return e;let n=e+t;return n.length>Bl?`${n.slice(0,Bl)}${Vl}`:n}async function Ul(e,t={}){let n=t.timeoutMs??18e5;return new Promise(r=>{let i=ae(e[0]??``,e.slice(1),{env:{...process.env,...t.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=``,o=``,s=!1,c={},l=e=>{s||(s=!0,clearTimeout(c.timer),r(e))};c.timer=setTimeout(()=>{i.kill(`SIGKILL`),l({code:null,stdout:a,stderr:`${o}\n[installer] ${String(n)}ms 内没有结束,已终止`})},n),i.stdout.on(`data`,e=>{a=Hl(a,e.toString(`utf8`))}),i.stderr.on(`data`,e=>{o=Hl(o,e.toString(`utf8`))}),i.on(`error`,e=>{l({code:null,stdout:a,stderr:`${o}${String(e)}`})}),i.on(`close`,e=>{l({code:e,stdout:a,stderr:o})})})}function Wl(e){return async t=>{let n=g.join(te.tmpdir(),`dsh-scrapling-dl-${_()}`),r=await e([`curl`,`--fail`,`--location`,`--silent`,`--show-error`,`--connect-timeout`,`20`,`--max-time`,`900`,`--output`,n,t]);if(r.code===0)try{return new Uint8Array(await u(n))}finally{await p(n,{force:!0})}if(await p(n,{force:!0}),r.code!==null)throw new Z(`INSTALL_NETWORK`,`curl failed for ${Ml(t)}: ${Il(r.stderr).slice(0,400)}`);let i=await fetch(t,{signal:AbortSignal.timeout(9e5)});if(!i.ok)throw new Z(`INSTALL_NETWORK`,`${Ml(t)} answered HTTP ${i.status}`);return new Uint8Array(await i.arrayBuffer())}}const Gl={download:Wl(Ul),extract:async(e,t)=>{let n=await Ul([`tar`,`-xzf`,e,`-C`,t]);if(n.code!==0)throw new Z(`INSTALL_FAILED`,`tar failed: ${Il(n.stderr).slice(0,400)}`)},spawn:Ul};async function Kl(e){try{return await a(e,t.F_OK),!0}catch{return!1}}function ql(e=ie(import.meta.url)){let t;try{t=e(`fs-native-extensions`)}catch{t=void 0}if(X(t)){let e=t.tryLock,n=t.unlock;if(typeof e==`function`&&typeof n==`function`)return{tryLock:n=>!!e.call(t,n),unlock:e=>{n.call(t,e)}}}return null}const Jl=ql();function Yl(e,t=Jl){if(t===null)throw new Z(`INSTALL_LOCK_UNREADABLE`,`fs-native-extensions is not loadable`);try{return t.tryLock(e)}catch(e){throw new Z(`INSTALL_LOCK_UNREADABLE`,`cannot lock install fd: ${String(e)}`)}}async function Xl(e,t=Jl){let n;try{n=await l(e,`a+`)}catch(t){throw new Z(`INSTALL_LOCK_UNREADABLE`,`cannot open install lock ${e}: ${String(t)}`)}let r;try{r=Yl(n.fd,t)}catch(e){throw await n.close(),e}if(!r)throw await n.close(),new Z(`INSTALL_BUSY`,`another install holds ${e}`);return{release:async()=>{try{t?.unlock(n.fd)}catch{}await n.close()}}}async function Zl(e){let t=g.join(e,`runtime`);return await c(t,{recursive:!0}),process.platform!==`win32`&&await o(t,448),t}const Ql=new ne;async function $l(e,t){let n=g.join(e,`runtime`),r=g.join(n,`install.lock`),i=g.resolve(r),a=Ql.getStore();if(a?.has(i)===!0)return t();await Zl(e);let o=await Xl(r),s=new Set([...a??[],i]);try{return await Ql.run(s,t)}finally{await o.release()}}async function eu(e,t){if(!URL.canParse(t))throw new Z(`INSTALL_OFFLINE_ASSETS`,`manifest archive URL is not parseable: ${t}`);let n=g.basename(new URL(t).pathname),r;try{r=decodeURIComponent(n)}catch{throw new Z(`INSTALL_OFFLINE_ASSETS`,`manifest archive name has invalid percent-encoding: ${n}`)}let i=n===r?[n]:[r,n],a=(await Promise.all(i.map(async t=>({name:t,bytes:await u(g.join(e,t)).catch(()=>null)})))).find(e=>e.bytes!==null)?.bytes;if(a==null)throw new Z(`INSTALL_OFFLINE_ASSETS`,`offline python archive missing under ${e}: expected ${i.join(` or `)}`);return new Uint8Array(a)}async function tu(e,t,n,r){return $l(t,async()=>{let i=g.join(t,`runtime`,`.tmp`,_());await c(i,{recursive:!0});let a=g.join(i,`python.tar.gz`);try{let o=r===void 0?await n.download(e.url):await eu(r,e.url),l=re(`sha256`).update(o).digest(`hex`);if(l!==e.sha256)throw new Z(`INSTALL_HASH_MISMATCH`,`python archive hash ${l} does not match ${e.sha256}`);await ee(a,o);let u=g.join(i,`extract`);await c(u,{recursive:!0}),await n.extract(a,u);let d=g.join(u,`python`),m=Y(g.join(d,`bin`,`python3`))?d:u;if(e.pythonVersion!==J.darwinArm64.pythonVersion)throw new Z(`INSTALL_FAILED`,`python asset version ${e.pythonVersion} is not the manifest version ${J.darwinArm64.pythonVersion}`);let h=g.dirname(g.dirname(Cl(t)));await c(g.dirname(h),{recursive:!0});let te=`${h}.new-${_()}`;try{await s(m,te,{recursive:!0,dereference:!0}),await p(h,{recursive:!0,force:!0}),await f(te,h)}catch(e){throw await p(te,{recursive:!0,force:!0}),e}let ne=Cl(t);if(!Y(ne))throw new Z(`INSTALL_FAILED`,`python archive did not contain bin/python3`);return{pythonPath:ne,version:J.darwinArm64.pythonVersion}}finally{await p(i,{recursive:!0,force:!0}),await m(g.join(t,`runtime`,`.tmp`)).catch(()=>null)}})}async function nu(e){let t=g.join(e,`runtime`,Nl),n;try{n=await u(t,`utf8`)}catch(e){if(zl(e)===`ENOENT`)return{packs:{}};throw new Z(`INSTALL_STATE_CORRUPT`,`cannot read ${t}: ${String(e)}; delete it and install again`,{cause:e})}let r;try{r=JSON.parse(n)}catch(e){throw new Z(`INSTALL_STATE_CORRUPT`,`${t} is not valid JSON; delete it and install again`,{cause:e})}if(!X(r))throw new Z(`INSTALL_STATE_CORRUPT`,`${t} does not hold a JSON object; delete it and install again`);return r}async function ru(e,t){let n=await Zl(e),r=g.join(n,Nl),i=`${r}.${_()}.tmp`;try{await ee(i,JSON.stringify(t,null,2),`utf8`),await f(i,r)}finally{try{await p(i,{force:!0})}catch{}}}async function iu(e,t,n,r=e=>u(e,`utf8`)){let i=g.join(e,`bin`),a=`#!${t}/`,o=(await d(i,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isFile()).map(e=>g.join(i,e.name));await Promise.all(o.map(async e=>{let t=await r(e).catch(()=>``),i=t.indexOf(`
63
+ `),o=i===-1?t:t.slice(0,i);if(!o.startsWith(a))return;let s=i===-1?``:t.slice(i);await ee(e,`#!${n}/${o.slice(a.length)}${s}`,`utf8`)}))}async function au(e,t){let n=!1;if(t){try{await p(e.venv,{recursive:!0,force:!0})}catch{}try{await f(e.previousVenv,e.venv)}catch{n=!0}}if(!n)try{await p(e.previousVenv,{recursive:!0,force:!0})}catch{}try{await p(e.staging,{recursive:!0,force:!0})}catch{}}async function ou(e){let{io:t}=e;await $l(e.dataDir,async()=>{let n=await Zl(e.dataDir),r=g.join(n,`venv`),i=g.join(n,`.tmp`,`venv-${_()}`),a=g.join(n,`.tmp`,`venv-previous-${_()}`),o=[g.join(e.repoRoot,`py`,`runtime-requirements.txt`)];if(e.documents===!0){let t=g.join(e.repoRoot,J.documents.requirements),n=await u(t),r=re(`sha256`).update(n).digest(`hex`);if(r!==J.documents.sha256)throw new Z(`INSTALL_HASH_MISMATCH`,`documents requirements hash ${r} does not match ${J.documents.sha256}`);o.push(t)}let s=!1,c=!1;try{let n=await t.spawn([e.pythonPath,`-m`,`venv`,i]);if(n.code!==0)throw new Z(`INSTALL_FAILED`,`venv failed: ${Il(n.stderr).slice(0,400)}`);let l=g.join(i,`bin`,`python3`),u=e.assets===void 0?[]:[`--no-index`,`--find-links`,g.join(e.assets,`wheels`)],d=await t.spawn([l,`-m`,`pip`,`install`,`--only-binary=:all:`,`--require-hashes`,...o.flatMap(e=>[`-r`,e]),...u],{env:{PIP_DISABLE_PIP_VERSION_CHECK:`1`}});if(d.code!==0){let e=`${d.stdout}\n${d.stderr}`;throw Pl.test(e)?new Z(`INSTALL_NO_WHEEL`,`a dependency has no wheel for this platform`):Fl.test(e)?new Z(`INSTALL_NETWORK`,`pip could not reach the package index`):new Z(`INSTALL_FAILED`,`pip failed: ${Il(d.stderr).slice(0,400)}`)}await iu(i,i,r);try{await Kl(r)&&(await f(r,a),s=!0),await f(i,r)}catch(e){throw new Z(`INSTALL_FAILED`,`cannot replace ${r}: ${String(e)}`,{cause:e})}let p=await nu(e.dataDir),m={...X(p.packs)?p.packs:{},core:`ready`,...e.markDocuments===!0?{documents:`ready`}:{}};await ru(e.dataDir,{...p,packs:m,python:e.pythonPath}),c=!0}finally{await au({venv:r,previousVenv:a,staging:i},s&&!c)}})}async function su(e){try{return(await d(e,{recursive:!0})).some(e=>Rl.has(g.basename(e)))}catch{return!1}}async function cu(e){return su(g.join(e,`runtime`,`browsers`))}async function lu(e){let t=`${J.documents.distribution}-${J.documents.version}.dist-info`;try{return(await d(g.join(e,`runtime`,`venv`),{recursive:!0})).some(e=>g.basename(e)===t)}catch{return!1}}async function uu(e){let{io:t}=e;return $l(e.dataDir,async()=>{let n=g.join(e.dataDir,`runtime`,`browsers`);await c(n,{recursive:!0});let r=await t.spawn([e.pythonPath,`-m`,`patchright`,`install`,`chromium`],{env:{PLAYWRIGHT_BROWSERS_PATH:n}});if(r.code!==0)throw new Z(`INSTALL_BROWSER_FAILED`,`chromium install failed: ${Il(r.stderr).slice(0,400)}`);if(!await su(n))throw new Z(`INSTALL_BROWSER_FAILED`,`no chromium executable found under ${n}`);let i=await nu(e.dataDir),a={...X(i.packs)?i.packs:{},browser:`ready`};return await ru(e.dataDir,{...i,packs:a,browsersPath:n}),{browsersPath:n}})}function du(e,t){return e===`ready`?t?`ready`:`corrupt`:`missing`}async function fu(e,t){if(!Ll())return{core:`blocked`,browser:`blocked`,search:`blocked`,media:`blocked`,documents:`blocked`,"adaptive-redis":`blocked`,mcp:`blocked`};let n=(await nu(e)).packs,r=X(n)?n:{},i=du(r.core,Y(wl(e))),a={core:i,browser:du(r.browser,await cu(e)),search:i,media:i,documents:du(r.documents,i===`ready`&&await lu(e)),"adaptive-redis":i,mcp:i};return t!==void 0&&(a[t]=`installing`),a}function pu(e){if(e?.aborted===!0)throw new Z(`INSTALL_CANCELLED`,`install cancelled`)}async function mu(e,t,n,r,i){let a=Cl(e);return Y(a)?a:(pu(n),(await tu(r,e,t,i)).pythonPath)}async function hu(e,t){if(!Ll())throw new Z(`INSTALL_PACK_BLOCKED`,`runtime packs are verified on macOS arm64 only; this host is ${process.platform}/${process.arch}`);let{dataDir:n,repoRoot:r,io:i,signal:a,onProgress:o,assets:s}=t,c=t.asset??J.darwinArm64;if(s!==void 0&&!await Kl(g.join(s,`wheels`)))throw new Z(`INSTALL_OFFLINE_ASSETS`,`offline wheelhouse missing: ${g.join(s,`wheels`)}`);pu(a),o?.(`installing ${e}`);let l=await mu(n,i,a,c,s);pu(a),o?.(`installing core packages into ${l}`);let u=await nu(n),d=X(u.packs)?u.packs:{};await ou({pythonPath:l,dataDir:n,repoRoot:r,io:i,documents:e===`documents`||d.documents===`ready`,markDocuments:e===`documents`,...s===void 0?{}:{assets:s}}),pu(a),e===`browser`&&(o?.(`installing full chromium`),await uu({pythonPath:wl(n),dataDir:n,io:i}),pu(a)),o?.(`${e} ready`)}const gu=hu;async function _u(e,t){await $l(t.dataDir,async()=>{let n=g.join(t.dataDir,`runtime`),r=e===`browser`?`browsers`:`venv`;await p(g.join(n,r),{recursive:!0,force:!0}),t.purge&&(await Promise.all([``,`-wal`,`-shm`].map(e=>p(g.join(t.dataDir,`elements_storage.db${e}`),{force:!0}))),await p(g.join(t.dataDir,`downloads`),{recursive:!0,force:!0}));let i=await nu(t.dataDir);if(!X(i.packs))return;let a={...i.packs};Reflect.deleteProperty(a,e),await ru(t.dataDir,{...i,packs:a})})}const vu=[`core`,`browser`,`search`,`media`,`documents`,`adaptive-redis`,`mcp`];new Set(vu);const yu=/\r\n|\n|\r/u,bu=/[\t ]#.*$/u,xu=vu,Su=new Set(xu),Cu=new Set([`setup`,`doctor`]),wu=new Set([`status`,`apply`,`repair`,`purge`,`dry-run`,`with-auth`,`accept-risk`]),Tu=new Set([`port`,`mode`,`profile`,`offline`,`uninstall`,`feature`]);function Eu(){let e=process.env.DSH_SCRAPLING_DATA_DIR;return e===void 0||e===``?g.join(te.homedir(),`.dsh-scrapling`):g.resolve(e)}function Du(e){return Su.has(e)}function Ou(e,t){if(!e.startsWith(`--`))return{kind:`invalid`};let n=e.slice(2);return wu.has(n)?{kind:`boolean`,name:n}:!Tu.has(n)||t===void 0||t.startsWith(`--`)?{kind:`invalid`}:{kind:`value`,name:n,value:t}}function ku(e){let[t,...n]=e;if(t===void 0||!Cu.has(t))return null;let r=new Map,i=new Set;for(let[e,t]of n.entries())if(!i.has(e)){let a=Ou(t,n[e+1]);if(a.kind===`invalid`)return null;r.set(a.name,a.kind!==`value`||a.value),a.kind===`value`&&i.add(e+1)}return{command:t,flags:r}}function Au(e){return{io:Gl,dataDir:Eu(),repoRoot:g.resolve(import.meta.dirname,`..`),log:e=>{console.info(e)},installPackFn:hu,repairPackFn:gu,uninstallPackFn:_u,...e}}function Q(e,t){let n=e.get(t);return typeof n==`string`?n:void 0}function ju(e){let t=Q(e,`port`);if(t===void 0)return{invalid:!1};let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535?{port:n,invalid:!1}:{invalid:!0}}function Mu(e){let t=Q(e,`mode`);return t===void 0||!Ee(t)?null:t}function Nu(e,t,n){let r=typeof n==`string`?JSON.stringify(n):`(缺省)`;return`--${e} 要写 ${t.join(` / `)} 之一;现在给的是 ${r}`}function Pu(e){return Nu(`mode`,we,e.get(`mode`))}function Fu(e,t){return Nu(e,xu,t.get(e))}function Iu(e){return e.has(`apply`)&&!e.has(`dry-run`)}function Lu(e,t){return e.has(`dry-run`)&&e.has(`apply`)?`dry-run:--dry-run 压过 --apply,${t.suppressed}`:t.missingApply}function Ru(e){if(e.mode===`native`)return{text:ut(),note:`native 模式不留 dsh-mcp-client 条目:原生工具已经在宿主名册里,再端一份就是两套。`,install:``};if(e.mode===`mcp`){let t=e.withAuth?`Authorization 在宿主装载时从宿主进程环境的 ${xe} 求值:变量缺席会写成 "Bearer undefined",加鉴权前先确认宿主环境里已设置它。`:``;return{text:lt({port:e.port,withAuth:e.withAuth,toolLoading:e.toolLoading}),note:`mcp 模式起的是本插件的 server,URL 里的端口要与部署项 mcpPort 同值(当前按 ${String(e.port)} 生成)。${t}`,install:Oe()}}let t=Fe({dataDir:e.dataDir,enabled:e.enabled,acceptedRisk:e.acceptRisk,toolLoading:e.toolLoading});return{text:t.patch,note:t.risk,install:t.installCommand}}async function zu(e,t){await c(g.dirname(e),{recursive:!0}),await ee(e,t,`utf8`)}async function Bu(e,t){let r=Mu(e);if(r===null)return t.log(Pu(e)),2;let i=ju(e);if(i.invalid)return t.log(`--port 要写 1 到 65535 之间的整数;现在给的是 ${String(Q(e,`port`))}`),2;let a=i.port??39217,o=Q(e,`profile`),s=o===void 0?void 0:await st(o),c=Ru({mode:r,port:a,withAuth:e.has(`with-auth`),acceptRisk:e.has(`accept-risk`),dataDir:t.dataDir,enabled:s?.officialMcpEnabled===!0,toolLoading:s?.mcpToolLoading??`eager`});t.log(c.text),t.log(c.note),c.install!==``&&(t.log(`客户端没装就先跑:${c.install}`),t.log(`只接受 ${Ce.join(` 或 `)}:npm 的 latest 比宿主线旧,宿主拒绝装载不匹配的对端。`));let l=g.join(t.dataDir,`mcp`,ct(r));if(r===`official-mcp`){let e=Ae(t.dataDir);n(e)||t.log(`${e} 现在还不存在:先跑 setup --feature mcp --apply 把官方 server 装进托管 venv;在那之前这条条目连不上(failOnStartupError: true 会让宿主把这条报成红)。`)}return Iu(e)?(await zu(l,c.text),t.log(`wrote ${l}`),t.log(`profile 不会被这条命令改写:把这段并进 <profile>/cordis.patch.yml,再重启宿主。`),0):(t.log(Lu(e,{suppressed:`只打印条目,不写 ${l}`,missingApply:`dry-run; add --apply to write ${l}`})),0)}function Vu(e){let t=e.trim(),n=t.charAt(0);if(n===`"`||n===`'`){let e=t.indexOf(n,1);if(e>0)return t.slice(1,e)}return t.replace(bu,``).trim()}function $(e,t){let n=RegExp(`^[\\t ]*(?:-[\\t ]+)?${ge(t)}:(?<value>[^\\r\\n]*)$`,`u`);return e.split(yu).filter(e=>!e.trimStart().startsWith(`#`)).map(e=>Vu(n.exec(e)?.groups?.value??``)).filter(e=>e!==``).at(-1)}function Hu(e,t){return $(e,t)!==void 0}function Uu(e,t){let n=$(e,t);return n===`true`||n===`True`||n===`TRUE`}function Wu(e){return!e.includes(`/`)&&!e.includes(`\\`)?{value:e,relative:!1}:{value:g.resolve(e),relative:!g.isAbsolute(e)}}async function Gu(e){let t=Q(e,`profile`);if(t===void 0)return{profile:{path:null,pythonBin:null,dataDir:null,note:`未读 profile:runtime 只按 CLI 自身的解析链(pythonBin 配置 → 托管 venv → 裸托管解释器 → 仓内 _env/.venv → PATH python3);要看部署配置解析出的解释器就加 --profile <目录>`},pythonBin:``};let n=await st(t),r=$(n.patchText,`pythonBin`)??``,i=$(n.patchText,`dataDir`)??``,a=Wu(r),o=Wu(i),s=a.value,c=[...r===``?[`profile 里没有 scrapling 的 pythonBin:runtime 回落到 CLI 自身的解析链(托管 venv → 裸托管解释器 → 仓内 _env/.venv → PATH python3)`]:[],...a.relative||o.relative?[`profile 里的 pythonBin / dataDir 写的是相对路径:CLI 已按自己进程的 cwd 展开,而宿主按它自己的 cwd 展开,两处可能不是同一个目录;改写成绝对路径才没有这层歧义`]:[]];return{profile:{path:t,pythonBin:r===``?null:r,dataDir:i===``?null:i,...c.length===0?{}:{note:c.join(`;`)}},pythonBin:s,...i===``?{}:{dataDirOverride:o.value}}}async function Ku(e,t){let{profile:n,pythonBin:r,dataDirOverride:i}=await Gu(e),a=i??t.dataDir,o=Ol({pythonBin:r,dataDir:a,repoRoot:t.repoRoot}),s=await nu(a),c=await fu(a);return t.log(JSON.stringify({dataDir:a,profile:n,runtime:o,packs:c,state:s},null,2)),0}const qu={tavily:`tavilyApiKey`,brave:`braveApiKey`,serper:`serperApiKey`,searxng:`searxngEndpoint`};function Ju(e){return e===void 0||ft(e)?[]:[{code:`SEARCH_BACKEND_INVALID`,detail:`searchBackend=${e} 不是本包实现的后端:可写的取值是 ${dt.join(` / `)},删掉这一行即回到 auto。`}]}function Yu(e){let t=`searchProvider 已指向 scrapling,但能力包没装好:web_search 会报 WEB_PROVIDER_CONFIGURED_UNAVAILABLE。`;return e===`blocked`?`${t}原因是这台机器不在安装器支持的范围内(只验过 macOS arm64),所以 core 被标成 blocked —— 这不是「没装」,重跑安装计划在那台机器上也修不好。修复:把 profile 里 - id: scrapling 的 pythonBin 指到一个装好 scrapling 的解释器,或把 searchProvider 从 scrapling 改回宿主自己的 provider。`:`${t}修复:dsh-scrapling setup --feature core --apply。`}function Xu(e,t){let n=$(e,`searchProvider`),r=$(e,`searchBackend`),i=r??`auto`,a=Uu(e,`searchPublicFallback`),o=Hu(e,`tavilyApiKey`),s=Hu(e,`searxngEndpoint`),c=i===`auto`&&!o&&!s&&!a,l=i===`auto`?void 0:qu[i],u=l!==void 0&&!Hu(e,l),d=n===`scrapling`,f=[],p=[];return n===void 0&&f.push(`SEARCH_PROVIDER_NOT_CONFIGURED 部署配置里还没写 searchProvider: scrapling:内置 web_search 仍走宿主自己选的 provider(base 层默认 deepseek-official),本插件的 search provider 只是备选。要接管它,给 <profile>/cordis.patch.yml 里 - id: web 的 config 加一行 searchProvider: scrapling,再重启宿主。`),c&&!d&&f.push(`SEARCH_BACKEND_MISSING 搜索后端未配置(预期行为):searchBackend=auto 但没配 tavilyApiKey、也没设 searxngEndpoint,且 searchPublicFallback=false,所以本插件的 search provider 不可用。修复:配 tavilyApiKey、设 searxngEndpoint,或显式把 searchPublicFallback 设为 true(会把查询词发给公共引擎)。`),u&&!d&&f.push(`SEARCH_AUTH searchBackend=${i} 但 ${l} 没配:查询会报 SEARCH_AUTH。修复:配 ${l},或换一个后端。`),p.push(...Ju(r)),d&&t!==`ready`&&p.push({code:`WEB_PROVIDER_CONFIGURED_UNAVAILABLE`,detail:Yu(t)}),d&&c&&p.push({code:`WEB_PROVIDER_CONFIGURED_UNAVAILABLE`,detail:`searchProvider 已指向 scrapling,但搜索后端不可用(没配 key/SearXNG,且 searchPublicFallback=false):web_search 会报 WEB_PROVIDER_CONFIGURED_UNAVAILABLE。修复:配 tavilyApiKey、设 searxngEndpoint,或显式打开 searchPublicFallback。`}),d&&u&&p.push({code:`SEARCH_AUTH`,detail:`searchBackend=${i} 但 ${l} 没配:provider 会注册成功,而每次查询都会报 SEARCH_AUTH。修复:配 ${l},或换一个后端。`}),{hints:f,findings:p}}async function Zu(e,t){let n=Mu(e);if(n===null)return t.log(Pu(e)),2;let r=Q(e,`profile`);if(r===void 0)return t.log(`doctor 要 --profile <目录>:判据来自那份 profile 自己写下的 cordis.patch.yml。`),2;let i=ju(e);if(i.invalid)return t.log(`--port 要写 1 到 65535 之间的整数;现在给的是 ${String(Q(e,`port`))}`),2;let a=await st(r),o=await fu($(a.patchText,`dataDir`)??t.dataDir),s=Ze({mode:n,expectedPort:i.port,...a}),c=Xu(a.patchText,o.core);for(let e of c.hints)t.log(e);for(let e of s)t.log(`${e.code} ${e.detail}`);for(let e of c.findings)t.log(`${e.code} ${e.detail}`);let l=s.length+c.findings.length;return l===0?(t.log(`${r} 与 integrationMode=${n} 一致。`),0):(t.log(s.length>0?`${String(l)} 处不一致:改完重跑 setup --mode ${n} --apply,并把条目并进 profile 后重启宿主。`:`${String(l)} 处搜索配置不一致:按上面逐条的修复动作改 ${r} 里 web 条目的 config,重启宿主生效。`),1)}async function Qu(e,t){let n=e.get(`uninstall`);if(typeof n!=`string`||!Du(n))return t.log(Fu(`uninstall`,e)),2;let r=e.has(`purge`);return t.log(`uninstall ${n}${r?` (and purge user data)`:``} from ${g.join(t.dataDir,`runtime`)}`),Iu(e)?(await $l(t.dataDir,async()=>{await t.uninstallPackFn(n,{dataDir:t.dataDir,purge:r})}),t.log(`uninstalled ${n}${r?` (purged data)`:``}`),0):(t.log(Lu(e,{suppressed:`只打印计划,不删任何 runtime 文件`,missingApply:`dry-run; add --apply to uninstall`})),0)}function $u(e,t){let n=J.darwinArm64,r=g.join(t.repoRoot,`py`,`runtime-requirements.txt`);return[`python ${n.pythonVersion}(清单声明 ${String(n.sizeBytes)} 字节,sha256 前 12 位 ${n.sha256.slice(0,12)})`,e===`browser`?`core venv 依赖:${r},再装一份完整 Chromium(patchright)`:`core venv 依赖:${r}`,...e===`documents`?[`documents 依赖:${g.join(t.repoRoot,J.documents.requirements)}`]:[],`落地位置:${g.join(t.dataDir,`runtime`)}(Python 在 runtime/python/,wheel 在 runtime/venv/)`].join(`
64
+ `)}async function ed(e,t,n,r){await(n?t.repairPackFn:t.installPackFn)(e,{dataDir:t.dataDir,repoRoot:t.repoRoot,io:t.io,onProgress:t.log,...r===void 0?{}:{assets:r}})}async function td(e,t){let n=e.get(`feature`);if(typeof n!=`string`||!Du(n))return t.log(Fu(`feature`,e)),2;let r=Q(e,`offline`);return r===``?(t.log(`--offline 要给一个资产目录`),2):(t.log($u(n,t)),r!==void 0&&t.log(`离线资产目录:${r}`),Iu(e)?(await ed(n,t,e.has(`repair`),r),t.log(`installed ${n}`),0):(t.log(Lu(e,{suppressed:`只打印计划,不下载也不写 runtime`,missingApply:`dry-run; add --apply to install`})),0))}function nd(e,t){return t.log(e instanceof Z||e instanceof ke?`${e.code}: ${e.message}`:`command failed: ${String(e)}`),1}async function rd(e,t={}){let n=Au(t),r=ku(e);if(r===null)return n.log(`用法:dsh-scrapling setup [--feature <core|browser|search|media|documents|adaptive-redis|mcp>] [--mode <native|mcp|official-mcp>] [--profile <目录>] [--port <1-65535>] [--offline <资产目录>] [--apply] [--dry-run] [--repair] [--status] [--with-auth] [--accept-risk] [--uninstall <core|browser|search|media|documents|adaptive-redis|mcp> [--purge]];dsh-scrapling doctor --mode <native|mcp|official-mcp> --profile <目录>;--apply 才落地,--dry-run(缺省)只打印计划,两者同时给时 --dry-run 胜。`),2;let{flags:i}=r;try{return r.command===`doctor`?await Zu(i,n):i.has(`status`)?await Ku(i,n):i.has(`mode`)?await Bu(i,n):i.has(`uninstall`)?await Qu(i,n):await td(i,n)}catch(e){return nd(e,n)}}try{process.exitCode=await rd(process.argv.slice(2))}catch(e){console.error(`command failed: ${String(e)}`),process.exitCode=1}export{};