@jayyuen66/dsh-scrapling 0.1.14 → 0.1.15

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,16 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";import{accessSync as t,constants as n,existsSync as r,readFileSync as i,statSync as a}from"node:fs";import{access as o,chmod as s,cp as c,mkdir as l,open as u,readFile as d,readdir as f,rename as p,rm as m,rmdir as h,stat as ee,writeFile as te}from"node:fs/promises";import ne from"node:os";import g from"node:path";import{AsyncLocalStorage as re}from"node:async_hooks";import{createHash as ie,randomUUID as _}from"node:crypto";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(var i=le(t),a=0,o=i.length,s;a<o;a++)s=i[a],!de.call(e,s)&&s!==n&&se(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ce(t,s))||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));const he=`scrapling`,ge=`streamable-http`,_e=`stdio`,ve=`DSH_SCRAPLING_MCP_TOKEN`,v=`@deepseek-ai/dsh-mcp-client`,ye=`0.2.2-rc.2`,be=Object.freeze([ye,`0.2.2-rc.1`,`next`]),xe=[`native`,`mcp`,`official-mcp`],Se=new Set(xe);function Ce(e){return Se.has(e)}function we(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 Te(e=ye){if(!be.includes(e))throw Error(`unsupported MCP client pin: ${JSON.stringify(e)}`);return`dsh plugin --profile <profile> add ${v}@${e}`}var Ee=class extends Error{code;constructor(e,t){super(t),this.name=`OfficialMcpError`,this.code=e}};function De(e){if(!g.isAbsolute(e))throw new Ee(`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 Oe(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 ke=/[\u0000-\u001F\u007F-\u009F\u2028\u2029"\\]/gu;function Ae(e){return`"${e.replaceAll(ke,e=>Oe(e))}"`}const je="official-mcp 直连官方 scrapling-mcp:它的全部工具不经本插件的 URL 守卫与会话闸门(钉住的 scrapling 版本里有 `browser_evaluate` 这类任意 JS 执行),用的是它自己的会话与状态,本插件既不复用也不拦截。";function Me(e){if(!e.enabled)throw new Ee(`OFFICIAL_MCP_DISABLED`,`official-mcp 未启用:部署配置里把 officialMcpEnabled 设为 true 才会生成接入配置`);if(!e.acceptedRisk)throw new Ee(`RISK_NOT_ACCEPTED`,`${je} 确认接受请再跑一次 setup 并带 --accept-risk。`);let t=De(e.dataDir),n=[],r=he;return{command:t,args:n,serverName:r,risk:je,installCommand:Te(`0.2.2-rc.2`),patch:[`- insert:`,` - id: scrapling-official-mcp`,` name: '${v}'`,` config:`,` serverName: ${r}`,` transport: ${_e}`,` command: ${Ae(t)}`,` args: ${JSON.stringify(n)}`,` failOnStartupError: true`,``].join(`
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(var i=le(t),a=0,o=i.length,s;a<o;a++)s=i[a],!de.call(e,s)&&s!==n&&se(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ce(t,s))||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));const he=`scrapling`,ge=`streamable-http`,_e=`stdio`,ve=`DSH_SCRAPLING_MCP_TOKEN`,v=`@deepseek-ai/dsh-mcp-client`,ye=`0.2.2-rc.5`,be=Object.freeze([ye,`0.2.2-rc.1`,`next`]),xe=[`native`,`mcp`,`official-mcp`],Se=new Set(xe);function Ce(e){return Se.has(e)}function we(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 Te(e=ye){if(!be.includes(e))throw Error(`unsupported MCP client pin: ${JSON.stringify(e)}`);return`dsh plugin --profile <profile> add ${v}@${e}`}var Ee=class extends Error{code;constructor(e,t){super(t),this.name=`OfficialMcpError`,this.code=e}};function De(e){if(!g.isAbsolute(e))throw new Ee(`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 Oe(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 ke=/[\u0000-\u001F\u007F-\u009F\u2028\u2029"\\]/gu;function Ae(e){return`"${e.replaceAll(ke,e=>Oe(e))}"`}const je="official-mcp 直连官方 scrapling-mcp:它的全部工具不经本插件的 URL 守卫与会话闸门(钉住的 scrapling 版本里有 `browser_evaluate` 这类任意 JS 执行),用的是它自己的会话与状态,本插件既不复用也不拦截。";function Me(e){if(!e.enabled)throw new Ee(`OFFICIAL_MCP_DISABLED`,`official-mcp 未启用:部署配置里把 officialMcpEnabled 设为 true 才会生成接入配置`);if(!e.acceptedRisk)throw new Ee(`RISK_NOT_ACCEPTED`,`${je} 确认接受请再跑一次 setup 并带 --accept-risk。`);let t=De(e.dataDir),n=[],r=he;return{command:t,args:n,serverName:r,risk:je,installCommand:Te(`0.2.2-rc.5`),patch:[`- insert:`,` - id: scrapling-official-mcp`,` name: '${v}'`,` config:`,` serverName: ${r}`,` transport: ${_e}`,` command: ${Ae(t)}`,` args: ${JSON.stringify(n)}`,` failOnStartupError: true`,``].join(`
4
4
  `)}}function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Pe=/\r\n|\n|\r/u,Fe=/:(?<port>\d+)/u,Ie=/[\t ]#.*$/u,Le=/^(?:"(?<double>[^"]*)"|'(?<single>[^']*)')$/u,Re=/^(?:-[\t ]*)?name:(?<value>.*)$/u,ze=/^(?<key>[\w-]+):[\t ]+(?<value>\S.*)$/u;function Be(e,t,n){return e||t===void 0||n<=t}function Ve(e){let t=e.trim(),n=Le.exec(t)?.groups;if(n!==void 0)return n.double??n.single;let r=t.replace(Ie,``).trim(),i=Le.exec(r)?.groups,a=i?.double??i?.single;return a===void 0?r.length===0?void 0:r:a}function He(e){return e.split(Pe)}function Ue(e){let t=[],n;for(let r of He(e)){let e=r.length-r.trimStart().length,i=r.slice(e),a=i.startsWith(`-`),o=Ve(Re.exec(i)?.groups?.value??``),s=ze.exec(i)?.groups;o!==void 0&&Be(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]=Ve(s.value))}return t}function We(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=Fe.exec(t)?.groups?.port}return n}function Ge(e){return e.config.transport===_e}function Ke(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}:跑 ${Te()} 装上它`});let n=e.clientVersion;return n!==void 0&&!be.includes(n)&&t.push({code:`MCP_CLIENT_UNPINNED`,detail:`客户端钉的是 ${e.clientVersion},只接受 ${be.join(` 或 `)} —— 宿主对不匹配的对端拒绝装载`}),t}function qe(e,t){let n=[];t.length>1&&n.push({code:`DUPLICATE_SCRAPLING_ENTRY`,detail:`serverName 为 scrapling 的条目有 ${String(t.length)} 条,一个名字只能有一个 server`}),t.some(e=>Ge(e))&&t.some(e=>!Ge(e))&&n.push({code:`MCP_MODE_CONFLICT`,detail:`本插件的 ${ge} 条目与官方 ${_e} 条目并存;同一时刻只能一种`});let r=e.mode===`official-mcp`,i=t.some(e=>r===Ge(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?_e:ge} 条目,profile 里没有`}),r&&!e.officialMcpEnabled&&t.some(e=>Ge(e))&&n.push({code:`MCP_OFFICIAL_SWITCH_OFF`,detail:`留着官方 stdio 条目但 officialMcpEnabled=false:官方 server 的工具不经本插件守卫,开关要明说`}),n}function Je(e,t){let n=[...new Set(e.map(e=>We(e)).filter(e=>e!==void 0))];if(n.length===0){let n=e.filter(e=>!Ge(e));return t!==void 0&&n.length>0?[{code:`MCP_PORT_UNREADABLE`,detail:`给了 --port ${String(t)},但 profile 里 ${String(n.length)} 条 ${ge} 条目都读不出端口(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 Ye(e){let t=Ue(e.patchText).filter(e=>e.name===`@deepseek-ai/dsh-mcp-client`&&e.config.serverName===`scrapling`);return[...Ke(e),...qe(e,t),...Je(t,e.expectedPort)]}const Xe=/^(?<indent>[\t ]*)officialMcpEnabled:(?<value>[^\r\n]*)$/gmu;function Ze(e){let t,n;for(let r of e.matchAll(Xe)){
5
5
  /* v8 ignore next -- 命名组恒存在(`indent` 在模式里是无条件的),`?? ""` 只是类型收窄 */
6
- let e=r.groups?.indent??``;t??=e,e===t&&(n=r.groups?.value)}let r=n?.replace(Ie,``).trim(),i=r===void 0?void 0:Le.exec(r)?.groups;return i?.double??i?.single??r}function Qe(e){let t=Ze(e);return t===`true`||t===`True`||t===`TRUE`}async function $e(e){try{return await d(e,`utf8`)}catch(t){if(Ne(t)&&t.code===`ENOENT`)return``;throw Error(`读不出 ${e}:${String(t)}`,{cause:t})}}function et(e){if(e.trim().length===0)return{broken:!1};let t;try{t=JSON.parse(e)}catch{return{broken:!0}}if(!Ne(t))return{broken:!0};let{dependencies:n}=t,r=Ne(n)?n[v]:void 0;return{version:typeof r==`string`?r:void 0,broken:!1}}async function tt(e){let t=await ee(e).catch(()=>null);if(t!==null&&!t.isDirectory())throw Error(`profile 不是目录:${e}`)}async function nt(e){await tt(e);let[t,n]=await Promise.all([$e(g.join(e,`cordis.patch.yml`)),$e(g.join(e,`package.json`))]),r=et(n);return{patchText:t,clientVersion:r.version,clientVersionBroken:r.broken,officialMcpEnabled:Qe(t)}}function rt(e){return`${e}.patch.yml`}function it(e){let t=[`- insert:`,` - id: scrapling-mcp`,` name: '${v}'`,` config:`,` serverName: ${he}`,` transport: ${ge}`,` url: ${we(e.port,`127.0.0.1`)}`,` failOnStartupError: false`];return e.withAuth&&t.push(` headers:`,` Authorization: !!js '\`Bearer \${process.env.${ve}}\`'`),`${t.join(`
6
+ let e=r.groups?.indent??``;t??=e,e===t&&(n=r.groups?.value)}let r=n?.replace(Ie,``).trim(),i=r===void 0?void 0:Le.exec(r)?.groups;return i?.double??i?.single??r}function Qe(e){let t=Ze(e);return t===`true`||t===`True`||t===`TRUE`}async function $e(e){try{return await u(e,`utf8`)}catch(t){if(Ne(t)&&t.code===`ENOENT`)return``;throw Error(`读不出 ${e}:${String(t)}`,{cause:t})}}function et(e){if(e.trim().length===0)return{broken:!1};let t;try{t=JSON.parse(e)}catch{return{broken:!0}}if(!Ne(t))return{broken:!0};let{dependencies:n}=t,r=Ne(n)?n[v]:void 0;return{version:typeof r==`string`?r:void 0,broken:!1}}async function tt(e){let t=await h(e).catch(()=>null);if(t!==null&&!t.isDirectory())throw Error(`profile 不是目录:${e}`)}async function nt(e){await tt(e);let[t,n]=await Promise.all([$e(g.join(e,`cordis.patch.yml`)),$e(g.join(e,`package.json`))]),r=et(n);return{patchText:t,clientVersion:r.version,clientVersionBroken:r.broken,officialMcpEnabled:Qe(t)}}function rt(e){return`${e}.patch.yml`}function it(e){let t=[`- insert:`,` - id: scrapling-mcp`,` name: '${v}'`,` config:`,` serverName: ${he}`,` transport: ${ge}`,` url: ${we(e.port,`127.0.0.1`)}`,` failOnStartupError: false`];return e.withAuth&&t.push(` headers:`,` Authorization: !!js '\`Bearer \${process.env.${ve}}\`'`),`${t.join(`
7
7
  `)}\n`}function at(){return[`# integrationMode=native:profile 里不留 scrapling 的 MCP 条目。`,`# 留着条目时模型会同时看到原生工具与 mcp__scrapling__* 两套同名不同层的工具。`,`# 这份文本本身不删任何东西:profile 里若已有 name: '${v}' 的条目,`,"# 要手工删掉它再重启宿主,否则 `doctor --mode native` 会按事实报 MCP_MODE_ENTRY_MISMATCH。",``].join(`
8
- `)}const ot=[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`];function st(e){return ot.includes(e)}function ct(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 lt(e,t=`|`){return e.map(e=>Dt(e)).join(t)}function ut(e,t){return typeof t==`bigint`?t.toString():t}var dt=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 ft(e){return new dt(e)}function pt(e){return e==null}function mt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ht(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 gt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function b(e){return gt(e._zod.def)??e._zod.def.shape}function _t(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return y(this,t,e),e},enumerable:!0,configurable:!0})}function vt(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?_t(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):vt(e,a,r?r(n.value,a):n.value))}}function yt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?_t(e,n,()=>t[n]):vt(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 bt(e){return JSON.stringify(e)}function xt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const St=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ct(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const wt=/* @__PURE__*/ ft(()=>{if(F.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function C(e){if(Ct(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ct(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Tt(e){return C(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Et=/* @__PURE__*/ 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 Dt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ot(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const kt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},At={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function jt(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,Mt(e,t)),T(e,S(n,{shape:i,checks:[]}))}function Mt(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 Nt(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(Mt(e,t)),a={};return x(a,e,Reflect.ownKeys(b(e)).filter(e=>!i.has(e))),T(e,S(n,{shape:a,checks:[]}))}function Pt(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:Ft(e,t)}))}function Ft(e,t){let n={};return x(n,e,Reflect.ownKeys(b(e))),yt(n,t),n}function It(e,t){if(!C(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return T(e,S(e._zod.def,{shape:Ft(e,t)}))}function Lt(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 Rt(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(Mt(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 zt(e,t,n){let r=n?new Set(Mt(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 Bt(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 Vt(e){return typeof e==`string`?e:e?.message}function Ht(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 Ut(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:Vt(e.inst?._zod.def?.error?.(e))??Vt(a?.(e))??Vt(t?.error?.(e))??Vt(n.customError?.(e))??Vt(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 Wt=/[\uD800-\uDBFF]/;function Gt(e){let t=e.length;if(!Wt.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 Kt(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 Jt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Yt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Qt(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 Xt(e,t,n){return A(e,t,n,!1)}/* @__NO_SIDE_EFFECTS__ */
9
- function Zt(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 Qt(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 $t(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let en,j=!1;const tn={configurable:!0,get(){j=!0}};function M(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&en!==e._zod?en=void 0:(en=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,tn);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 nn(e,t,n,r){let i=$t(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 rn(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var an;const on={value:void 0,enumerable:!1};let sn=`captureStackTrace`in Error?Error:null;function cn(e){let t=sn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return sn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}/* @__NO_SIDE_EFFECTS__ */
10
- function N(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){on.value=new a(r);try{Object.defineProperty(n,"_zod",on)}finally{on.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),Yt(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?cn(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.`)}},ln=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(an=globalThis).__zod_globalConfig??(an.__zod_globalConfig={});const F=globalThis.__zod_globalConfig;function I(e){return e&&Object.assign(F,e),F}function un(){let e=this._zod;return e.message??=JSON.stringify(e.def,ut,2),e.message}function dn(e){this._zod.message=e}const fn={get:un,set:dn,enumerable:!0,configurable:!0},pn={value:void 0,enumerable:!1},mn=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),hn=/* @__PURE__ */ N(`$ZodError`,(e,t)=>{e.name=`$ZodError`,pn.value=t,Object.defineProperty(e,"issues",pn),pn.value=void 0,Object.defineProperty(e,"message",fn);let n=Object.getPrototypeOf(e);mn.has(n)||(mn.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 gn(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 _n(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?gn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function vn(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 yn(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 bn(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 ${yn(e.path)}`);return t.join(`
11
- `)}function xn(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Sn=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 St(n,a?.callee??t),n}return s.value};return t},Cn=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 St(n,a?.callee??t),n}return s.value};return t},wn=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?Tn(e,a.issues,i):{success:!0,data:a.value}};function Tn(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 En=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?Tn(e,a.issues,i):{success:!0,data:a.value}},Dn=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),On=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),kn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Dn)return!0;if(r.definite===!0&&n===void 0)return!1}return An(e,t,n)});function An(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[On]=!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 jn=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},Mn=e=>{let t=Sn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,xn(n,a))};return n},Nn=e=>{let t=Sn(e),n=(e,r,i,a)=>t(e,r,i,xn(n,a));return n},Pn=e=>{let t=Cn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,xn(n,a))};return n},Fn=e=>{let t=Cn(e),n=async(e,r,i,a)=>await t(e,r,i,xn(n,a));return n},In=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return wn(e)(t,n,i)},Ln=e=>(t,n,r)=>wn(e)(t,n,r),Rn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return En(e)(t,n,i)},zn=e=>async(t,n,r)=>En(e)(t,n,r),Bn=/^[cC][0-9a-z]{6,}$/,Vn=/^[0-9a-z]+$/,Hn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Un=/^[0-9a-vA-V]{20}$/,Wn=/^[A-Za-z0-9]{27}$/,Gn=/^[a-zA-Z0-9_-]{21}$/;function Kn(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)?)?)$/,Jn=/^([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})$/,Yn=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)$/,Xn=/^(?:[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 Zn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const Qn=/^(?:(?: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])$/,$n=/^(([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}|:))$/,er=/^((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])$/,tr=/^(([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])$/,nr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ir=/^https?$/,ar=/^\+[1-9]\d{6,14}$/,or=`(?:(?:\\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 sr(e){return RegExp(`^${e}$`)}const cr=/*@__PURE__*/ sr(or);function lr(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 ur(e){return RegExp(`^${lr(e)}$`)}function dr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${lr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${lr({precision:e.precision})}`:n;return RegExp(`^${or}T(?:${r})$`)}const fr=/^[\s\S]{0,}$/,pr=/^-?\d+$/,mr=/^-?\d+(?:\.\d+)?$/,hr=/^[^A-Z]*$/,gr=/^[^a-z]*$/,L=/*@__PURE__*/ N(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),_r=e=>{let t=e.value;return!pt(t)&&t.length!==void 0},vr={number:`number`,bigint:`bigint`,object:`date`},yr=/*@__PURE__*/ N(`$ZodCheckLessThan`,(e,t)=>{L.init(e,t);let n=vr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:vr[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})}}),br=/*@__PURE__*/ N(`$ZodCheckGreaterThan`,(e,t)=>{L.init(e,t);let n=vr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:vr[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})}}),xr=/*@__PURE__*/ 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):ht(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})}}),Sr=/*@__PURE__*/ 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]=kt[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})}}),Cr=/*@__PURE__*/ N(`$ZodCheckMaxLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=_r),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Gt(r):i)<=t.maximum)return;let a=Kt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wr=/*@__PURE__*/ N(`$ZodCheckMinLength`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=_r),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Gt(r):i)>=t.minimum)return;let a=Kt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Tr=/*@__PURE__*/ N(`$ZodCheckLengthEquals`,(e,t)=>{var n;L.init(e,t),(n=e._zod.def).when??(n.when=_r),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Gt(r):i;if(a===t.length)return;let o=Kt(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})}}),Er=/*@__PURE__*/ 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=()=>{})}),Dr=/*@__PURE__*/ N(`$ZodCheckRegex`,(e,t)=>{Er.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})}}),Or=/*@__PURE__*/ N(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=hr,Er.init(e,t)}),kr=/*@__PURE__*/ N(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=gr,Er.init(e,t)}),Ar=/*@__PURE__*/ 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})}}),jr=/*@__PURE__*/ 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})}}),Mr=/*@__PURE__*/ 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})}}),Nr=/*@__PURE__*/ N(`$ZodCheckOverwrite`,(e,t)=>{L.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Pr=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(`
8
+ `)}const ot=[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`];function st(e){return ot.includes(e)}function ct(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 lt(e,t=`|`){return e.map(e=>Dt(e)).join(t)}function ut(e,t){return typeof t==`bigint`?t.toString():t}var dt=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 ft(e){return new dt(e)}function pt(e){return e==null}function mt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ht(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 gt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function b(e){return gt(e._zod.def)??e._zod.def.shape}function _t(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return y(this,t,e),e},enumerable:!0,configurable:!0})}function vt(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?_t(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):vt(e,a,r?r(n.value,a):n.value))}}function yt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?_t(e,n,()=>t[n]):vt(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 bt(e){return JSON.stringify(e)}function xt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const St=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ct(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const wt=/* @__PURE__*/ ft(()=>{if(P.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function C(e){if(Ct(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ct(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Tt(e){return C(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Et=/* @__PURE__*/ 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 Dt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ot(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const kt={safeint:[-(2**53-1),2**53-1],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},At={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function jt(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,Mt(e,t)),T(e,S(n,{shape:i,checks:[]}))}function Mt(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 Nt(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(Mt(e,t)),a={};return x(a,e,Reflect.ownKeys(b(e)).filter(e=>!i.has(e))),T(e,S(n,{shape:a,checks:[]}))}function Pt(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:Ft(e,t)}))}function Ft(e,t){let n={};return x(n,e,Reflect.ownKeys(b(e))),yt(n,t),n}function It(e,t){if(!C(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return T(e,S(e._zod.def,{shape:Ft(e,t)}))}function Lt(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 Rt(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(Mt(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 zt(e,t,n){let r=n?new Set(Mt(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 Bt(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 Vt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ht(e){return typeof e==`string`?e:e?.message}function Ut(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 Wt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function O(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:Ht(e.inst?._zod.def?.error?.(e))??Ht(a?.(e))??Ht(t?.error?.(e))??Ht(n.customError?.(e))??Ht(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 Gt=/[\uD800-\uDBFF]/;function Kt(e){let t=e.length;if(!Gt.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 qt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Jt(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 Yt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Xt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):$t(e,n,r.value)}}function k(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Zt(e,t,n){return k(e,t,n,!1)}/* @__NO_SIDE_EFFECTS__ */
9
+ function Qt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return k(this,n,r(this))},set(e){k(this,n,e)}})}return t}function $t(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:k(this,t,n.bind(this))},set(e){k(this,t,e)}})}function en(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let tn,A=!1;const nn={configurable:!0,get(){A=!0}};function j(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&tn!==e._zod?tn=void 0:(tn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,nn);let e=A;A=!1;try{let r=n(this);return A?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),A||=e,r}catch(n){throw delete this[t],A||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function rn(e,t,n,r){let i=en(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 an(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var on;const sn={value:void 0,enumerable:!1};let cn=`captureStackTrace`in Error?Error:null;function ln(e){let t=cn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return cn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}/* @__NO_SIDE_EFFECTS__ */
10
+ function M(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){sn.value=new a(r);try{Object.defineProperty(n,"_zod",sn)}finally{sn.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),Xt(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?ln(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 N=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},un=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(on=globalThis).__zod_globalConfig??(on.__zod_globalConfig={});const P=globalThis.__zod_globalConfig;function F(e){return e&&Object.assign(P,e),P}function dn(){let e=this._zod;return e.message??=JSON.stringify(e.def,ut,2),e.message}function fn(e){this._zod.message=e}const pn={get:dn,set:fn,enumerable:!0,configurable:!0},mn={value:void 0,enumerable:!1},hn=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),gn=/* @__PURE__ */ M(`$ZodError`,(e,t)=>{e.name=`$ZodError`,mn.value=t,Object.defineProperty(e,"issues",mn),mn.value=void 0,Object.defineProperty(e,"message",pn);let n=Object.getPrototypeOf(e);hn.has(n)||(hn.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 _n(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 vn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?_n(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function yn(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 bn(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 xn(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 ${bn(e.path)}`);return t.join(`
11
+ `)}function Sn(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Cn=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 N;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>O(e,o,F())));throw St(n,a?.callee??t),n}return s.value};return t},wn=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=>O(e,o,F())));throw St(n,a?.callee??t),n}return s.value};return t},Tn=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 N;return a.issues.length?En(e,a.issues,i):{success:!0,data:a.value}};function En(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>O(e,n,F()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Dn=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?En(e,a.issues,i):{success:!0,data:a.value}},On=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),kn=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),An=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==On)return!0;if(r.definite===!0&&n===void 0)return!1}return jn(e,t,n)});function jn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[kn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new N;return a.issues.length===0}const Mn=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},Nn=e=>{let t=Cn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Sn(n,a))};return n},Pn=e=>{let t=Cn(e),n=(e,r,i,a)=>t(e,r,i,Sn(n,a));return n},Fn=e=>{let t=wn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Sn(n,a))};return n},In=e=>{let t=wn(e),n=async(e,r,i,a)=>await t(e,r,i,Sn(n,a));return n},Ln=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Tn(e)(t,n,i)},Rn=e=>(t,n,r)=>Tn(e)(t,n,r),zn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Dn(e)(t,n,i)},Bn=e=>async(t,n,r)=>Dn(e)(t,n,r),Vn=/^[cC][0-9a-z]{6,}$/,Hn=/^[0-9a-z]+$/,Un=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Wn=/^[0-9a-vA-V]{20}$/,Gn=/^[A-Za-z0-9]{27}$/,Kn=/^[a-zA-Z0-9_-]{21}$/;function qn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Jn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Yn=/^([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})$/,Xn=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)$/,Zn=/^(?:[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 Qn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const $n=/^(?:(?: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])$/,er=/^(([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}|:))$/,tr=/^((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])$/,nr=/^(([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])$/,rr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ir=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ar=/^https?$/,or=/^\+[1-9]\d{6,14}$/,sr=`(?:(?:\\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 cr(e){return RegExp(`^${e}$`)}const lr=/*@__PURE__*/ cr(sr);function ur(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 dr(e){return RegExp(`^${ur(e)}$`)}function fr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${ur({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${ur({precision:e.precision})}`:n;return RegExp(`^${sr}T(?:${r})$`)}const pr=/^[\s\S]{0,}$/,mr=/^-?\d+$/,hr=/^-?\d+(?:\.\d+)?$/,gr=/^[^A-Z]*$/,_r=/^[^a-z]*$/,I=/*@__PURE__*/ M(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),vr=e=>{let t=e.value;return!pt(t)&&t.length!==void 0},yr={number:`number`,bigint:`bigint`,object:`date`},br=/*@__PURE__*/ M(`$ZodCheckLessThan`,(e,t)=>{I.init(e,t);let n=yr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:yr[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})}}),xr=/*@__PURE__*/ M(`$ZodCheckGreaterThan`,(e,t)=>{I.init(e,t);let n=yr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:yr[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})}}),Sr=/*@__PURE__*/ M(`$ZodCheckMultipleOf`,(e,t)=>{I.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):ht(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})}}),Cr=/*@__PURE__*/ M(`$ZodCheckNumberFormat`,(e,t)=>{I.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=kt[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})}}),wr=/*@__PURE__*/ M(`$ZodCheckMaxLength`,(e,t)=>{var n;I.init(e,t),(n=e._zod.def).when??(n.when=vr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Kt(r):i)<=t.maximum)return;let a=qt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Tr=/*@__PURE__*/ M(`$ZodCheckMinLength`,(e,t)=>{var n;I.init(e,t),(n=e._zod.def).when??(n.when=vr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Kt(r):i)>=t.minimum)return;let a=qt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Er=/*@__PURE__*/ M(`$ZodCheckLengthEquals`,(e,t)=>{var n;I.init(e,t),(n=e._zod.def).when??(n.when=vr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Kt(r):i;if(a===t.length)return;let o=qt(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})}}),Dr=/*@__PURE__*/ M(`$ZodCheckStringFormat`,(e,t)=>{var n,r;I.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=()=>{})}),Or=/*@__PURE__*/ M(`$ZodCheckRegex`,(e,t)=>{Dr.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})}}),kr=/*@__PURE__*/ M(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=gr,Dr.init(e,t)}),Ar=/*@__PURE__*/ M(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=_r,Dr.init(e,t)}),jr=/*@__PURE__*/ M(`$ZodCheckIncludes`,(e,t)=>{I.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})}}),Mr=/*@__PURE__*/ M(`$ZodCheckStartsWith`,(e,t)=>{I.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})}}),Nr=/*@__PURE__*/ M(`$ZodCheckEndsWith`,(e,t)=>{I.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})}}),Pr=/*@__PURE__*/ M(`$ZodCheckOverwrite`,(e,t)=>{I.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Fr=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
12
  `).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 Fr={major:4,minor:6,patch:7},R=/*@__PURE__*/ N(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Fr;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(Bt(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&&(Ut(t.issues,n,e),i||=D(t,n))});else{if(t.issues.length===n)continue;Ut(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 Xt(this,`~standard`,Rr(this))},set"~standard"(e){A(this,`~standard`,e)}}),Ir=(e,t)=>e.issues.length?{issues:e.issues.map(e=>k(e,t,I()))}:{value:e.value};async function Lr(e,t){let n={async:!0};return Ir(await e._zod.run({value:t,issues:[]},n),n)}function Rr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Ir(r,n)}catch{}return Lr(e,t)},vendor:`zod`,version:1}}const zr=/*@__PURE__*/ N(`$ZodString`,(e,t)=>{R.init(e,t),e._zod.pattern=t.pattern??fr,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=/*@__PURE__*/ N(`$ZodStringFormat`,(e,t)=>{Er.init(e,t),zr.init(e,t)}),Br=/*@__PURE__*/ N(`$ZodGUID`,(e,t)=>{t.pattern??=Jn,z.init(e,t)}),Vr=/*@__PURE__*/ 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??=Yn(e)}else t.pattern??=Yn();z.init(e,t)}),Hr=/*@__PURE__*/ N(`$ZodEmail`,(e,t)=>{t.pattern??=Xn,z.init(e,t)});function Ur(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Wr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Ur(e)||2:Gr(e,t)}function Gr(e,t){if(!t.normalize&&t.protocol?.source===ir.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 Kr=/[\t\n\r]/g;function qr(e){return e.replace(Kr,``)}function Jr(e,t){return t.lastIndex=0,t.test(e.hostname)}function Yr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const Xr=/*@__PURE__*/ N(`$ZodURL`,(e,t)=>{z.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Wr(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&&!Jr(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&&!Yr(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})}}}),Zr=/*@__PURE__*/ N(`$ZodEmoji`,(e,t)=>{t.pattern??=Zn(),z.init(e,t)}),Qr=/*@__PURE__*/ 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?Gn:Kn(t.length),z.init(e,t)}),$r=/*@__PURE__*/ N(`$ZodCUID`,(e,t)=>{t.pattern??=Bn,z.init(e,t)}),ei=/*@__PURE__*/ N(`$ZodCUID2`,(e,t)=>{t.pattern??=Vn,z.init(e,t)}),ti=/*@__PURE__*/ N(`$ZodULID`,(e,t)=>{t.pattern??=Hn,z.init(e,t)}),ni=/*@__PURE__*/ N(`$ZodXID`,(e,t)=>{t.pattern??=Un,z.init(e,t)}),ri=/*@__PURE__*/ N(`$ZodKSUID`,(e,t)=>{t.pattern??=Wn,z.init(e,t)}),ii=/*@__PURE__*/ N(`$ZodISODateTime`,(e,t)=>{t.pattern??=dr(t),z.init(e,t)}),ai=/*@__PURE__*/ N(`$ZodISODate`,(e,t)=>{t.pattern??=cr,z.init(e,t)}),oi=/*@__PURE__*/ N(`$ZodISOTime`,(e,t)=>{t.pattern??=ur(t),z.init(e,t)}),si=/*@__PURE__*/ N(`$ZodISODuration`,(e,t)=>{t.pattern??=qn,z.init(e,t)}),ci=/*@__PURE__*/ N(`$ZodIPv4`,(e,t)=>{t.pattern??=Qn,z.init(e,t)}),li=/^[0-9a-fA-F:.]+$/;function ui(e){return li.test(e)?Ur(`http://[${e}]`):!1}const di=/*@__PURE__*/ N(`$ZodIPv6`,(e,t)=>{t.pattern??=$n,z.init(e,t),e._zod.check=n=>{ui(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),fi=/*@__PURE__*/ N(`$ZodCIDRv4`,(e,t)=>{t.pattern??=er,z.init(e,t)});function pi(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:ui(n)}const mi=/*@__PURE__*/ N(`$ZodCIDRv6`,(e,t)=>{t.pattern??=tr,z.init(e,t),e._zod.check=n=>{pi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function hi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const gi=/^[0-9a-zA-Z+/]*={0,2}$/,_i=/*@__PURE__*/ N(`$ZodBase64`,(e,t)=>{t.pattern??=gi,z.init(e,t),e._zod.check=n=>{hi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),vi=/^[A-Za-z0-9_-]*$/;function yi(e){if(!vi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return hi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const bi=/*@__PURE__*/ N(`$ZodBase64URL`,(e,t)=>{t.pattern??=vi,z.init(e,t),e._zod.check=n=>{yi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),xi=/*@__PURE__*/ N(`$ZodE164`,(e,t)=>{t.pattern??=ar,z.init(e,t)});function Si(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 Ci=/*@__PURE__*/ N(`$ZodJWT`,(e,t)=>{z.init(e,t),e._zod.check=n=>{Si(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),wi=/*@__PURE__*/ N(`$ZodNumber`,(e,t)=>{R.init(e,t),e._zod.pattern=mr,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}}),Ti=/*@__PURE__*/ N(`$ZodNumberFormat`,(e,t)=>{Sr.init(e,t),wi.init(e,t)}),Ei=/*@__PURE__*/ N(`$ZodUnknown`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),Di=/*@__PURE__*/ 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 Oi(e,t){let n=Ht(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 Ht(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,Ut(n.issues,t,e),n}}return i(n,a)}}const ki=e=>Array.isArray(e)?e.length:-1;function Ai(e,t,n){e.issues.length&&t.issues.push(...O(n,e.issues)),t.value[n]=e.value}const ji=/*@__PURE__*/ 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=>Ai(t,r,e)));else if(Ai(c,r,e),s&&c.issues.length!==0&&D(c))break}return o.length?Promise.all(o).then(()=>r):r},Oi(e,ki)});function Mi(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 Ni=[];function Pi(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Ni,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=Ot(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Fi(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=>Mi(e,n,i,t,d,f))):Mi(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 Ii=/*@__PURE__*/ 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=ft(()=>Pi(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,/* @__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=Ct,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=>Mi(n,t,e,r,a,o))):Mi(s,t,e,r,a,o)}return o?Fi(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Li=/*@__PURE__*/ N(`$ZodObjectJIT`,(e,t)=>{Ii.init(e,t);let n=e._zod.parse,r=ft(()=>Pi(t)),i=F.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Pr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
13
+ `)}\n};`)(...Object.values(this.closed))}};const Ir={major:4,minor:6,patch:7},L=/*@__PURE__*/ M(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ir;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(Bt(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 N;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Wt(t.issues,n,e),i||=D(t,n))});else{if(t.issues.length===n)continue;Wt(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 N;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 N;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Zt(this,`~standard`,zr(this))},set"~standard"(e){k(this,`~standard`,e)}}),Lr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>O(e,t,F()))}:{value:e.value};async function Rr(e,t){let n={async:!0};return Lr(await e._zod.run({value:t,issues:[]},n),n)}function zr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Lr(r,n)}catch{}return Rr(e,t)},vendor:`zod`,version:1}}const Br=/*@__PURE__*/ M(`$ZodString`,(e,t)=>{L.init(e,t),e._zod.pattern=t.pattern??pr,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}}),R=/*@__PURE__*/ M(`$ZodStringFormat`,(e,t)=>{Dr.init(e,t),Br.init(e,t)}),Vr=/*@__PURE__*/ M(`$ZodGUID`,(e,t)=>{t.pattern??=Yn,R.init(e,t)}),Hr=/*@__PURE__*/ M(`$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??=Xn(e)}else t.pattern??=Xn();R.init(e,t)}),Ur=/*@__PURE__*/ M(`$ZodEmail`,(e,t)=>{t.pattern??=Zn,R.init(e,t)});function Wr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Gr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Wr(e)||2:Kr(e,t)}function Kr(e,t){if(!t.normalize&&t.protocol?.source===ar.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 qr=/[\t\n\r]/g;function Jr(e){return e.replace(qr,``)}function Yr(e,t){return t.lastIndex=0,t.test(e.hostname)}function Xr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const Zr=/*@__PURE__*/ M(`$ZodURL`,(e,t)=>{R.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Gr(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=Jr(r);return}t.hostname&&!Yr(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&&!Xr(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:Jr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Qr=/*@__PURE__*/ M(`$ZodEmoji`,(e,t)=>{t.pattern??=Qn(),R.init(e,t)}),$r=/*@__PURE__*/ M(`$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?Kn:qn(t.length),R.init(e,t)}),ei=/*@__PURE__*/ M(`$ZodCUID`,(e,t)=>{t.pattern??=Vn,R.init(e,t)}),ti=/*@__PURE__*/ M(`$ZodCUID2`,(e,t)=>{t.pattern??=Hn,R.init(e,t)}),ni=/*@__PURE__*/ M(`$ZodULID`,(e,t)=>{t.pattern??=Un,R.init(e,t)}),ri=/*@__PURE__*/ M(`$ZodXID`,(e,t)=>{t.pattern??=Wn,R.init(e,t)}),ii=/*@__PURE__*/ M(`$ZodKSUID`,(e,t)=>{t.pattern??=Gn,R.init(e,t)}),ai=/*@__PURE__*/ M(`$ZodISODateTime`,(e,t)=>{t.pattern??=fr(t),R.init(e,t)}),oi=/*@__PURE__*/ M(`$ZodISODate`,(e,t)=>{t.pattern??=lr,R.init(e,t)}),si=/*@__PURE__*/ M(`$ZodISOTime`,(e,t)=>{t.pattern??=dr(t),R.init(e,t)}),ci=/*@__PURE__*/ M(`$ZodISODuration`,(e,t)=>{t.pattern??=Jn,R.init(e,t)}),li=/*@__PURE__*/ M(`$ZodIPv4`,(e,t)=>{t.pattern??=$n,R.init(e,t)}),ui=/^[0-9a-fA-F:.]+$/;function di(e){return ui.test(e)?Wr(`http://[${e}]`):!1}const fi=/*@__PURE__*/ M(`$ZodIPv6`,(e,t)=>{t.pattern??=er,R.init(e,t),e._zod.check=n=>{di(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),pi=/*@__PURE__*/ M(`$ZodCIDRv4`,(e,t)=>{t.pattern??=tr,R.init(e,t)});function mi(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:di(n)}const hi=/*@__PURE__*/ M(`$ZodCIDRv6`,(e,t)=>{t.pattern??=nr,R.init(e,t),e._zod.check=n=>{mi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function gi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const _i=/^[0-9a-zA-Z+/]*={0,2}$/,vi=/*@__PURE__*/ M(`$ZodBase64`,(e,t)=>{t.pattern??=_i,R.init(e,t),e._zod.check=n=>{gi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),yi=/^[A-Za-z0-9_-]*$/;function bi(e){if(!yi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return gi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const xi=/*@__PURE__*/ M(`$ZodBase64URL`,(e,t)=>{t.pattern??=yi,R.init(e,t),e._zod.check=n=>{bi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Si=/*@__PURE__*/ M(`$ZodE164`,(e,t)=>{t.pattern??=or,R.init(e,t)});function Ci(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 wi=/*@__PURE__*/ M(`$ZodJWT`,(e,t)=>{R.init(e,t),e._zod.check=n=>{Ci(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ti=/*@__PURE__*/ M(`$ZodNumber`,(e,t)=>{L.init(e,t),e._zod.pattern=hr,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}}),Ei=/*@__PURE__*/ M(`$ZodNumberFormat`,(e,t)=>{Cr.init(e,t),Ti.init(e,t)}),Di=/*@__PURE__*/ M(`$ZodUnknown`,(e,t)=>{L.init(e,t),e._zod.parse=e=>e}),Oi=/*@__PURE__*/ M(`$ZodNever`,(e,t)=>{L.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ki(e,t){let n=Ut(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 Ut(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,Wt(n.issues,t,e),n}}return i(n,a)}}const Ai=e=>Array.isArray(e)?e.length:-1;function ji(e,t,n){e.issues.length&&t.issues.push(...Vt(n,e.issues)),t.value[n]=e.value}const Mi=/*@__PURE__*/ M(`$ZodArray`,(e,t)=>{L.init(e,t);let n=P.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=>ji(t,r,e)));else if(ji(c,r,e),s&&c.issues.length!==0&&D(c))break}return o.length?Promise.all(o).then(()=>r):r},ki(e,Ai)});function Ni(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(...Vt(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 Pi=[];function Fi(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Pi,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=Ot(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Ii(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=>Ni(e,n,i,t,d,f))):Ni(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 Li=/*@__PURE__*/ M(`$ZodObject`,(e,t)=>{L.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=ft(()=>Fi(t));j(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,/* @__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=Ct,o=t.catchall,s,c=P.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=>Ni(n,t,e,r,a,o))):Ni(s,t,e,r,a,o)}return o?Ii(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Ri=/*@__PURE__*/ M(`$ZodObjectJIT`,(e,t)=>{Li.init(e,t);let n=e._zod.parse,r=ft(()=>Fi(t)),i=P.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Fr([`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
14
  let ${e}_ab = false;
15
15
  for (let i = 0; i < ${e}.issues.length; i++) {
16
16
  const iss = ${e}.issues[i];
@@ -60,66 +60,66 @@ function N(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=
60
60
  newResult[${r}] = ${n}.value;
61
61
  }
62
62
 
63
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ct,c=!F.jitless,l=c&&wt.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?Fi([],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 Ri(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 zi=/*@__PURE__*/ 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=>mt(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=>Ri(t,r,e,i)):Ri(o,r,e,i)}}),Bi=/*@__PURE__*/ 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])=>Hi(e,t,n)):Hi(e,i,a)}});function Vi(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=Vi(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=e[r],a=t[r],o=Vi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Hi(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=Vi(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 Ui=/*@__PURE__*/ 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=/* @__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=>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`&&mr.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}}),Wi=/*@__PURE__*/ N(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=ct(t.entries),r=new Set(n);e._zod.values=r,M(e,`pattern`,e=>{let t=ct(e.def.entries).filter(e=>Et.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}}),Gi=/*@__PURE__*/ 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}}),Ki=/*@__PURE__*/ 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 ln(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 Ji=/*@__PURE__*/ 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?/* @__PURE__ */ new Set([...t,void 0]):void 0}),M(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${mt(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)}}),Yi=/*@__PURE__*/ N(`$ZodExactOptional`,(e,t)=>{Ji.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)}),Xi=/*@__PURE__*/ 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(`^(${mt(t.source)}|null)$`):void 0}),M(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)}),Zi=/*@__PURE__*/ 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=>Qi(e,t)):Qi(r,t)}});function Qi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $i=/*@__PURE__*/ 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))}),ea=/*@__PURE__*/ 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=>ta(t,e)):ta(i,e)}});function ta(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 na(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 ra=/*@__PURE__*/ 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=>na(e,r,t,n)):na(e,r,t,n)}}),ia=/*@__PURE__*/ 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=>aa(e,t.in,n)):aa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>aa(e,t.out,n)):aa(r,t.out,n)}});function aa(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 oa=/*@__PURE__*/ 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(sa):sa(r)}});function sa(e){return e.memo||(e.value=Object.freeze(e.value)),e}const ca=/*@__PURE__*/ 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=>la(t,n,r,e));la(i,n,r,e)}});function la(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(Jt(e))}}var ua=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const da=`~memo`,fa=[];function pa(e){return typeof e==`object`&&!!e}function ma(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const ha=/*@__PURE__*/ new WeakMap;function ga(e,t,n){let r=ha.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=ga(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?ga(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=gt(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?ga(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),_a(e,i)}function _a(e,t){return t!==1&&ha.set(e,t===2),t}function va(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let ya;const ba=[],xa={alloc(e,t,n){let r=ya;if(!r)return n;ya=void 0;let i={value:n,issues:null};return r.set(t.value,i),ba.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`&&Ca(n,e.value))throw new ua;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=ga(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(!pa(l))return t(s,c);let u=c[da];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[da]=u);let d;i===c?d=a:(d=va(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(...ma(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;ya=d;let p=ba.length,m=t(s,c);ya=void 0;let h=ba.length>p?ba.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ma(e.issues):fa),e)):(h&&(h.issues=m.issues.length?ma(m.issues):fa),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Sa(){return xa}function Ca(e,t){let n=e[da]?.backEdges;return n!==void 0&&pa(t)&&n.has(t)}const wa=()=>{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 ${Dt(e.values[0])}`:`Invalid option: expected one of ${lt(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`:``}: ${lt(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 Ta(){return{localeError:wa()}}var Ea,Da=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 Oa(){return new Da}(Ea=globalThis).__zod_globalRegistry??(Ea.__zod_globalRegistry=Oa());const ka=globalThis.__zod_globalRegistry;function Aa(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
64
- function ja(e,t){return new e(Aa({type:`string`,...E(t)}))}// @__NO_SIDE_EFFECTS__
65
- function Ma(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
66
- function Na(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
67
- function Pa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
68
- function Fa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...E(t)})}// @__NO_SIDE_EFFECTS__
69
- function Ia(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...E(t)})}// @__NO_SIDE_EFFECTS__
70
- function La(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...E(t)})}// @__NO_SIDE_EFFECTS__
71
- function Ra(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
72
- function za(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
73
- function Ba(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
74
- function Va(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
75
- function Ha(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
76
- function Ua(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
77
- function Wa(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
78
- function Ga(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
79
- function Ka(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
80
- function qa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
81
- function Ja(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
82
- function Ya(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
83
- function Xa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
84
- function Za(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
85
- function Qa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
86
- function $a(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
87
- function eo(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...E(t)})}// @__NO_SIDE_EFFECTS__
88
- function to(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...E(t)})}// @__NO_SIDE_EFFECTS__
89
- function no(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...E(t)})}// @__NO_SIDE_EFFECTS__
90
- function ro(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...E(t)})}// @__NO_SIDE_EFFECTS__
91
- function io(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...E(t)})}// @__NO_SIDE_EFFECTS__
92
- function ao(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
93
- function oo(e,t){return new e({type:`never`,...E(t)})}// @__NO_SIDE_EFFECTS__
94
- function so(e,t){return new yr({check:`less_than`,...E(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
95
- function co(e,t){return new yr({check:`less_than`,...E(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
96
- function lo(e,t){return new br({check:`greater_than`,...E(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
97
- function uo(e,t){return new br({check:`greater_than`,...E(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
98
- function fo(e,t){return new xr({check:`multiple_of`,...E(t),value:e})}// @__NO_SIDE_EFFECTS__
99
- function po(e,t){return new Cr({check:`max_length`,...E(t),maximum:e})}// @__NO_SIDE_EFFECTS__
100
- function mo(e,t){return new wr({check:`min_length`,...E(t),minimum:e})}// @__NO_SIDE_EFFECTS__
101
- function ho(e,t){return new Tr({check:`length_equals`,...E(t),length:e})}// @__NO_SIDE_EFFECTS__
102
- function go(e,t){return new Dr({check:`string_format`,format:`regex`,...E(t),pattern:e})}// @__NO_SIDE_EFFECTS__
103
- function _o(e){return new Or({check:`string_format`,format:`lowercase`,...E(e)})}// @__NO_SIDE_EFFECTS__
104
- function vo(e){return new kr({check:`string_format`,format:`uppercase`,...E(e)})}// @__NO_SIDE_EFFECTS__
105
- function yo(e,t){return new Ar({check:`string_format`,format:`includes`,...E(t),includes:e})}// @__NO_SIDE_EFFECTS__
106
- function bo(e,t){return new jr({check:`string_format`,format:`starts_with`,...E(t),prefix:e})}// @__NO_SIDE_EFFECTS__
107
- function xo(e,t){return new Mr({check:`string_format`,format:`ends_with`,...E(t),suffix:e})}// @__NO_SIDE_EFFECTS__
108
- function B(e){return new Nr({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
109
- function So(e){return/* @__PURE__ */ B(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
110
- function Co(){return/* @__PURE__ */ B(e=>e.trim())}// @__NO_SIDE_EFFECTS__
111
- function wo(){return/* @__PURE__ */ B(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
112
- function To(){return/* @__PURE__ */ B(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
113
- function Eo(){return/* @__PURE__ */ B(e=>xt(e))}// @__NO_SIDE_EFFECTS__
114
- function Do(e,t,n){return new e({type:`array`,element:t,...E(n)})}// @__NO_SIDE_EFFECTS__
115
- function Oo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...E(n)})}// @__NO_SIDE_EFFECTS__
116
- function ko(e,t){let n=/* @__PURE__ */ Ao(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Jt(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(Jt(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
117
- function Ao(e,t){let n=new L({check:`custom`,...E(t)});return n._zod.check=e,n}function jo(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 Mo(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??ka,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 V(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 H(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,H(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&jo(o.schema,c),t.io===`input`&&U(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 No(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Po(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}/${No(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+No(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>
63
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ct,c=!P.jitless,l=c&&wt.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?Ii([],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 zi(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=>O(e,r,F())))}),t)}const Bi=/*@__PURE__*/ M(`$ZodUnion`,(e,t)=>{L.init(e,t),j(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),j(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(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)))}),j(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=>mt(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=>zi(t,r,e,i)):zi(o,r,e,i)}}),Vi=/*@__PURE__*/ M(`$ZodIntersection`,(e,t)=>{L.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])=>Ui(e,t,n)):Ui(e,i,a)}});function Hi(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=Hi(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=Hi(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 Ui(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=Hi(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 Wi=/*@__PURE__*/ M(`$ZodRecord`,(e,t)=>{L.init(e,t);let n=P.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=/* @__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=>O(e,i,F())),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(...Vt(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Vt(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`&&hr.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=>O(e,i,F())),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(...Vt(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Vt(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}}),Gi=/*@__PURE__*/ M(`$ZodEnum`,(e,t)=>{L.init(e,t);let n=ct(t.entries),r=new Set(n);e._zod.values=r,j(e,`pattern`,e=>{let t=ct(e.def.entries).filter(e=>Et.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}}),Ki=/*@__PURE__*/ M(`$ZodLiteral`,(e,t)=>{L.init(e,t);let n=new Set(t.values);e._zod.values=n,j(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}}),qi=/*@__PURE__*/ M(`$ZodTransform`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,P.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new un(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 N;return n.value=i,n}});function Ji(e,t){return e.value=t.issues.length?void 0:t.value,e}const Yi=/*@__PURE__*/ M(`$ZodOptional`,(e,t)=>{L.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,j(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${mt(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=>Ji(e,t)):Ji(e,r)}return t.innerType._zod.run(e,n)}}),Xi=/*@__PURE__*/ M(`$ZodExactOptional`,(e,t)=>{Yi.init(e,t),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Zi=/*@__PURE__*/ M(`$ZodNullable`,(e,t)=>{L.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin),j(e,`optout`,e=>e.def.innerType._zod.optout),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${mt(t.source)}|null)$`):void 0}),j(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)}),Qi=/*@__PURE__*/ M(`$ZodDefault`,(e,t)=>{L.init(e,t),e._zod.optin=`defaulted`,j(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=>$i(e,t)):$i(r,t)}});function $i(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ea=/*@__PURE__*/ M(`$ZodPrefault`,(e,t)=>{L.init(e,t),e._zod.optin=`defaulted`,j(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))}),ta=/*@__PURE__*/ M(`$ZodNonOptional`,(e,t)=>{L.init(e,t),j(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=>na(t,e)):na(i,e)}});function na(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 ra(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>O(e,r,F()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const ia=/*@__PURE__*/ M(`$ZodCatch`,(e,t)=>{L.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),j(e,`optout`,e=>e.def.innerType._zod.optout),j(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=>ra(e,r,t,n)):ra(e,r,t,n)}}),aa=/*@__PURE__*/ M(`$ZodPipe`,(e,t)=>{L.init(e,t),j(e,`values`,e=>e.def.in._zod.values),j(e,`optin`,e=>e.def.in._zod.optin),j(e,`optout`,e=>e.def.out._zod.optout),j(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=>oa(e,t.in,n)):oa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>oa(e,t.out,n)):oa(r,t.out,n)}});function oa(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 sa=/*@__PURE__*/ M(`$ZodReadonly`,(e,t)=>{L.init(e,t),j(e,`propValues`,e=>e.def.innerType._zod.propValues),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`optin`,e=>e.def.innerType?._zod?.optin),j(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(ca):ca(r)}});function ca(e){return e.memo||(e.value=Object.freeze(e.value)),e}const la=/*@__PURE__*/ M(`$ZodCustom`,(e,t)=>{I.init(e,t),L.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=>ua(t,n,r,e));ua(i,n,r,e)}});function ua(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(Yt(e))}}var da=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const fa=`~memo`,pa=[];function ma(e){return typeof e==`object`&&!!e}function ha(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const ga=/*@__PURE__*/ new WeakMap;function _a(e,t,n){let r=ga.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=_a(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?_a(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=gt(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?_a(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),va(e,i)}function va(e,t){return t!==1&&ga.set(e,t===2),t}function ya(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let ba;const xa=[],Sa={alloc(e,t,n){let r=ba;if(!r)return n;ba=void 0;let i={value:n,issues:null};return r.set(t.value,i),xa.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`&&wa(n,e.value))throw new da;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=_a(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(!ma(l))return t(s,c);let u=c[fa];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[fa]=u);let d;i===c?d=a:(d=ya(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(...ha(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;ba=d;let p=xa.length,m=t(s,c);ba=void 0;let h=xa.length>p?xa.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ha(e.issues):pa),e)):(h&&(h.issues=m.issues.length?ha(m.issues):pa),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Ca(){return Sa}function wa(e,t){let n=e[fa]?.backEdges;return n!==void 0&&ma(t)&&n.has(t)}const Ta=()=>{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(Jt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Dt(e.values[0])}`:`Invalid option: expected one of ${lt(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`:``}: ${lt(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 Ea(){return{localeError:Ta()}}var Da,Oa=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 ka(){return new Oa}(Da=globalThis).__zod_globalRegistry??(Da.__zod_globalRegistry=ka());const Aa=globalThis.__zod_globalRegistry;function ja(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
64
+ function Ma(e,t){return new e(ja({type:`string`,...E(t)}))}// @__NO_SIDE_EFFECTS__
65
+ function Na(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
66
+ function Pa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
67
+ function Fa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
68
+ function Ia(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...E(t)})}// @__NO_SIDE_EFFECTS__
69
+ function La(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...E(t)})}// @__NO_SIDE_EFFECTS__
70
+ function Ra(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...E(t)})}// @__NO_SIDE_EFFECTS__
71
+ function za(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
72
+ function Ba(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
73
+ function Va(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
74
+ function Ha(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
75
+ function Ua(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
76
+ function Wa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
77
+ function Ga(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
78
+ function Ka(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
79
+ function qa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
80
+ function Ja(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
81
+ function Ya(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
82
+ function Xa(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
83
+ function Za(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
84
+ function Qa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
85
+ function $a(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
86
+ function eo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...E(t)})}// @__NO_SIDE_EFFECTS__
87
+ function to(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...E(t)})}// @__NO_SIDE_EFFECTS__
88
+ function no(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...E(t)})}// @__NO_SIDE_EFFECTS__
89
+ function ro(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...E(t)})}// @__NO_SIDE_EFFECTS__
90
+ function io(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...E(t)})}// @__NO_SIDE_EFFECTS__
91
+ function ao(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...E(t)})}// @__NO_SIDE_EFFECTS__
92
+ function oo(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
93
+ function so(e,t){return new e({type:`never`,...E(t)})}// @__NO_SIDE_EFFECTS__
94
+ function co(e,t){return new br({check:`less_than`,...E(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
95
+ function lo(e,t){return new br({check:`less_than`,...E(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
96
+ function uo(e,t){return new xr({check:`greater_than`,...E(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
97
+ function fo(e,t){return new xr({check:`greater_than`,...E(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
98
+ function po(e,t){return new Sr({check:`multiple_of`,...E(t),value:e})}// @__NO_SIDE_EFFECTS__
99
+ function mo(e,t){return new wr({check:`max_length`,...E(t),maximum:e})}// @__NO_SIDE_EFFECTS__
100
+ function ho(e,t){return new Tr({check:`min_length`,...E(t),minimum:e})}// @__NO_SIDE_EFFECTS__
101
+ function go(e,t){return new Er({check:`length_equals`,...E(t),length:e})}// @__NO_SIDE_EFFECTS__
102
+ function _o(e,t){return new Or({check:`string_format`,format:`regex`,...E(t),pattern:e})}// @__NO_SIDE_EFFECTS__
103
+ function vo(e){return new kr({check:`string_format`,format:`lowercase`,...E(e)})}// @__NO_SIDE_EFFECTS__
104
+ function yo(e){return new Ar({check:`string_format`,format:`uppercase`,...E(e)})}// @__NO_SIDE_EFFECTS__
105
+ function bo(e,t){return new jr({check:`string_format`,format:`includes`,...E(t),includes:e})}// @__NO_SIDE_EFFECTS__
106
+ function xo(e,t){return new Mr({check:`string_format`,format:`starts_with`,...E(t),prefix:e})}// @__NO_SIDE_EFFECTS__
107
+ function So(e,t){return new Nr({check:`string_format`,format:`ends_with`,...E(t),suffix:e})}// @__NO_SIDE_EFFECTS__
108
+ function z(e){return new Pr({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
109
+ function Co(e){return/* @__PURE__ */ z(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
110
+ function wo(){return/* @__PURE__ */ z(e=>e.trim())}// @__NO_SIDE_EFFECTS__
111
+ function To(){return/* @__PURE__ */ z(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
112
+ function Eo(){return/* @__PURE__ */ z(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
113
+ function Do(){return/* @__PURE__ */ z(e=>xt(e))}// @__NO_SIDE_EFFECTS__
114
+ function Oo(e,t,n){return new e({type:`array`,element:t,...E(n)})}// @__NO_SIDE_EFFECTS__
115
+ function ko(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...E(n)})}// @__NO_SIDE_EFFECTS__
116
+ function Ao(e,t){let n=/* @__PURE__ */ jo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Yt(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(Yt(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
117
+ function jo(e,t){let n=new I({check:`custom`,...E(t)});return n._zod.check=e,n}function Mo(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 No(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??Aa,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 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&&Mo(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 Po(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Fo(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}/${Po(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+Po(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
118
 
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 Fo(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;Fo(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 Io=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Lo=[`oneOf`,`anyOf`];function Ro(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function zo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Io.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]??Ro(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}y(n,r,e.length===1?e[0]:zo(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=Ro(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 Bo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Io)if(t in e)return;let n=t.filter(e=>Lo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=zo(t);else{let e=n[0],i=Lo.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=>zo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,jo(e,r))}function Vo(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)):jo(i,s),jo(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())Fo(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)??[])Bo(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)}jo(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:Uo(t,`input`,e.processors),output:Uo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function U(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 U(r.element,n);if(r.type===`set`)return U(r.valueType,n);if(r.type===`lazy`)return U(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 U(r.innerType,n);if(r.type===`intersection`)return U(r.left,n)||U(r.right,n);if(r.type===`record`||r.type===`map`)return U(r.keyType,n)||U(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:U(r.in,n)||U(r.out,n);if(r.type===`object`){for(let e in r.shape)if(U(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(U(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(U(e,n))return!0;return!!(r.rest&&U(r.rest,n))}return!1}const Ho=(e,t={})=>n=>{let r=Mo({...n,processors:t});return H(e,r),Po(r,e),Vo(r,e)},Uo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Mo({...i??{},target:a,io:t,processors:n});return H(e,o),Po(o,e),Vo(o,e)},Wo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Go=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ko=(e,t)=>{Wo(e,`minimum`,t),Go(e,`maximum`,t)},qo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Jo=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Yo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Xo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Zo=(e,t)=>Wo(e,`minimum`,t.minimum),Qo=(e,t)=>Go(e,`maximum`,t.maximum),$o=e=>(t,n)=>{Xo(t,n.format);let[r,i]=e[n.format];Wo(t,`minimum`,r),Go(t,`maximum`,i)},es={greater_than:(e,t)=>Wo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Go(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>qo(e,t.value),number_format:$o(kt),bigint_format:$o(At),min_length:Zo,max_length:Qo,length_equals:(e,t)=>Ko(e,t.length),min_size:Zo,max_size:Qo,size_equals:(e,t)=>Ko(e,t.size),string_format:(e,t)=>{Xo(e,t.format),t.pattern&&Jo(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)=>Yo(e,t.mime)};function W(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)es[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Wo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Wo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Go(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Go(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&&Yo(t,i.mime);for(let e of i.patterns??[])Jo(t,e);return t}const ts={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ns=/* @__PURE__ */ new Map([[gi,nr],[vi,rr]]),rs=e=>ns.get(e)??e,is=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=W(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ts[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(rs);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}))])}},as=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=W(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)):V(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}))])}},os=(e,t,n,r)=>{n.not={}},ss=(e,t,n,r)=>{let i=e._zod.def,a=ct(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},cs=(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(V(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(V(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}},ls=(e,t,n,r)=>{V(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},us=(e,t,n,r)=>{V(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ds=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=W(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=H(a.element,t,{...r,path:[...r.path,`items`]})};function fs(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?fs(t.out):t.type===`catch`?fs(t.innerType):e._zod.optin}const ps=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&V(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,H(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`?fs(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=H(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ms=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>H(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},hs=(e,t,n,r)=>{let i=e._zod.def,a=H(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=H(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 gs(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=gs(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=>gs(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`)?mr:pr).source)),p}const _s=/* @__PURE__ */ new WeakMap;function vs(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 _s.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=gs(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 ys=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=W(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=H(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)y(i.patternProperties,rs(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=H(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=_s.get(t);n||(n=[],_s.set(t,n),t.deferred.push(()=>vs(t))),n.push(e)}i.additionalProperties=H(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&fs(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))}},bs=(e,t,n,r)=>{let i=e._zod.def,a=H(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`}]},xs=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ss=Symbol();function Cs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(V(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ss):JSON.parse(o)}const ws=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Cs(i.defaultValue,e,t,n,r);o!==Ss&&(n.default=o)},Ts=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Cs(i.defaultValue,e,t,n,r);o!==Ss&&(n._prefault=o)},Es=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{V(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Ds=(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;H(o,t,r);let s=t.seen.get(e);s.ref=o},Os=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ks=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},As=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function js(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 G=/*@__PURE__*/ N(`ZodError`,(e,t)=>{hn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);As.has(n)||(As.add(n),js(n,`format`,e=>t=>vn(e,t)),js(n,`flatten`,e=>t=>_n(e,t)),js(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ut,2)}),js(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ut,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ms=/* @__PURE__ */ Sn(G),Ns=/* @__PURE__ */ Cn(G),Ps=/* @__PURE__ */ wn(G),Fs=/* @__PURE__ */ En(G),Is=/* @__PURE__ */ Mn(G),Ls=/* @__PURE__ */ Nn(G),Rs=/* @__PURE__ */ Pn(G),zs=/* @__PURE__ */ Fn(G),Bs=/* @__PURE__ */ In(G),Vs=/* @__PURE__ */ Ln(G),Hs=/* @__PURE__ */ Rn(G),Us=/* @__PURE__ */ zn(G);function Ws(){F.localeError||I(Ta())}function Gs(){F.memoizer||I({memoizer:Sa()})}const K=/*@__PURE__*/ N(`ZodType`,(e,t)=>(Ws(),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(sl(e,t))},superRefine(e,t){return this.check(cl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ B(e))},optional(){return Uc(this)},exactOptional(){return Gc(this)},nullable(){return qc(this)},nullish(){return Uc(qc(this))},nonoptional(e){return $c(this,e)},array(){return Dc(this)},or(e){return jc([this,e])},and(e){return Nc(this,e)},transform(e){return rl(this,Vc(e))},default(e){return Yc(this,e)},prefault(e){return Zc(this,e)},catch(e){return tl(this,e)},pipe(e){return rl(this,e)},readonly(){return al(this)},describe(e){let t=this.clone();return ka.add(t,{description:e}),t},meta(...e){if(e.length===0)return ka.get(this);let t=this.clone();return ka.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 Xt(this,`~standard`,{...Rr(this),jsonSchema:{input:Uo(this,`input`),output:Uo(this,`output`)}})},set"~standard"(e){A(this,`~standard`,e)},parse:function e(t,n){return Ms(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ns(this,t,n,{callee:e})},safeParse(e,t){return Ps(this,e,t)},async safeParseAsync(e,t){return Fs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){A(this,`spa`,e)},validate(e,t){return kn(this,e,t)},validateAsync(e,t){return jn(this,e,t)},encode:function e(t,n){return Is(this,t,n,{callee:e})},decode:function e(t,n){return Ls(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Rs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await zs(this,t,n,{callee:e})},safeEncode(e,t){return Bs(this,e,t)},safeDecode(e,t){return Vs(this,e,t)},async safeEncodeAsync(e,t){return Hs(this,e,t)},async safeDecodeAsync(e,t){return Us(this,e,t)},toJSONSchema(e){return Ho(this,{})(e)},get description(){return ka.get(this)?.description},get _def(){return this._zod.def}}),Ks=/*@__PURE__*/ N(`_ZodString`,(e,t)=>{zr.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)},/*@__PURE__*/ Zt({format:e=>W(e).format??null,minLength:e=>W(e).minimum??null,maxLength:e=>W(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ go(...e))},includes(...e){return this.check(/* @__PURE__ */ yo(...e))},startsWith(...e){return this.check(/* @__PURE__ */ bo(...e))},endsWith(...e){return this.check(/* @__PURE__ */ xo(...e))},min(...e){return this.check(/* @__PURE__ */ mo(...e))},max(...e){return this.check(/* @__PURE__ */ po(...e))},length(...e){return this.check(/* @__PURE__ */ ho(...e))},nonempty(...e){return this.check(/* @__PURE__ */ mo(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ _o(e))},uppercase(e){return this.check(/* @__PURE__ */ vo(e))},trim(){return this.check(/* @__PURE__ */ Co())},normalize(...e){return this.check(/* @__PURE__ */ So(...e))},toLowerCase(){return this.check(/* @__PURE__ */ wo())},toUpperCase(){return this.check(/* @__PURE__ */ To())},slugify(){return this.check(/* @__PURE__ */ Eo())}})),qs=/*@__PURE__*/ N(`ZodString`,(e,t)=>{zr.init(e,t),Ks.init(e,t)},{email(e){return this.check(/* @__PURE__ */ Ma($s,e))},url(e){return this.check(/* @__PURE__ */ Ra(nc,e))},jwt(e){return this.check(/* @__PURE__ */ $a(vc,e))},emoji(e){return this.check(/* @__PURE__ */ za(ic,e))},guid(e){return this.check(/* @__PURE__ */ Na(ec,e))},uuid(e){return this.check(/* @__PURE__ */ Pa(tc,e))},uuidv4(e){return this.check(/* @__PURE__ */ Fa(tc,e))},uuidv6(e){return this.check(/* @__PURE__ */ Ia(tc,e))},uuidv7(e){return this.check(/* @__PURE__ */ La(tc,e))},nanoid(e){return this.check(/* @__PURE__ */ Ba(ac,e))},cuid(e){return this.check(/* @__PURE__ */ Va(oc,e))},cuid2(e){return this.check(/* @__PURE__ */ Ha(sc,e))},ulid(e){return this.check(/* @__PURE__ */ Ua(cc,e))},base64(e){return this.check(/* @__PURE__ */ Xa(hc,e))},base64url(e){return this.check(/* @__PURE__ */ Za(gc,e))},xid(e){return this.check(/* @__PURE__ */ Wa(lc,e))},ksuid(e){return this.check(/* @__PURE__ */ Ga(uc,e))},ipv4(e){return this.check(/* @__PURE__ */ Ka(dc,e))},ipv6(e){return this.check(/* @__PURE__ */ qa(fc,e))},cidrv4(e){return this.check(/* @__PURE__ */ Ja(pc,e))},cidrv6(e){return this.check(/* @__PURE__ */ Ya(mc,e))},e164(e){return this.check(/* @__PURE__ */ Qa(_c,e))},datetime(e){return this.check(/* @__PURE__ */ eo(Ys,e))},date(e){return this.check(/* @__PURE__ */ to(Xs,e))},time(e){return this.check(/* @__PURE__ */ no(Zs,e))},duration(e){return this.check(/* @__PURE__ */ ro(Qs,e))}});function Js(e){return/* @__PURE__ */ ja(qs,e)}const q=/*@__PURE__*/ N(`ZodStringFormat`,(e,t)=>{z.init(e,t),Ks.init(e,t)}),Ys=/*@__PURE__*/ N(`ZodISODateTime`,(e,t)=>{ii.init(e,t),q.init(e,t)}),Xs=/*@__PURE__*/ N(`ZodISODate`,(e,t)=>{ai.init(e,t),q.init(e,t)}),Zs=/*@__PURE__*/ N(`ZodISOTime`,(e,t)=>{oi.init(e,t),q.init(e,t)}),Qs=/*@__PURE__*/ N(`ZodISODuration`,(e,t)=>{si.init(e,t),q.init(e,t)}),$s=/*@__PURE__*/ N(`ZodEmail`,(e,t)=>{Hr.init(e,t),q.init(e,t)}),ec=/*@__PURE__*/ N(`ZodGUID`,(e,t)=>{Br.init(e,t),q.init(e,t)}),tc=/*@__PURE__*/ N(`ZodUUID`,(e,t)=>{Vr.init(e,t),q.init(e,t)}),nc=/*@__PURE__*/ N(`ZodURL`,(e,t)=>{Xr.init(e,t),q.init(e,t)});function rc(e){return/* @__PURE__ */ Ra(nc,e)}const ic=/*@__PURE__*/ N(`ZodEmoji`,(e,t)=>{Zr.init(e,t),q.init(e,t)}),ac=/*@__PURE__*/ N(`ZodNanoID`,(e,t)=>{Qr.init(e,t),q.init(e,t)}),oc=/*@__PURE__*/ N(`ZodCUID`,(e,t)=>{$r.init(e,t),q.init(e,t)}),sc=/*@__PURE__*/ N(`ZodCUID2`,(e,t)=>{ei.init(e,t),q.init(e,t)}),cc=/*@__PURE__*/ N(`ZodULID`,(e,t)=>{ti.init(e,t),q.init(e,t)}),lc=/*@__PURE__*/ N(`ZodXID`,(e,t)=>{ni.init(e,t),q.init(e,t)}),uc=/*@__PURE__*/ N(`ZodKSUID`,(e,t)=>{ri.init(e,t),q.init(e,t)}),dc=/*@__PURE__*/ N(`ZodIPv4`,(e,t)=>{ci.init(e,t),q.init(e,t)}),fc=/*@__PURE__*/ N(`ZodIPv6`,(e,t)=>{di.init(e,t),q.init(e,t)}),pc=/*@__PURE__*/ N(`ZodCIDRv4`,(e,t)=>{fi.init(e,t),q.init(e,t)}),mc=/*@__PURE__*/ N(`ZodCIDRv6`,(e,t)=>{mi.init(e,t),q.init(e,t)}),hc=/*@__PURE__*/ N(`ZodBase64`,(e,t)=>{_i.init(e,t),q.init(e,t)}),gc=/*@__PURE__*/ N(`ZodBase64URL`,(e,t)=>{bi.init(e,t),q.init(e,t)}),_c=/*@__PURE__*/ N(`ZodE164`,(e,t)=>{xi.init(e,t),q.init(e,t)}),vc=/*@__PURE__*/ N(`ZodJWT`,(e,t)=>{Ci.init(e,t),q.init(e,t)}),yc=/*@__PURE__*/ N(`ZodNumber`,(e,t)=>{wi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Zt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=W(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=W(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=W(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>W(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ lo(e,t))},gte(e,t){return this.check(/* @__PURE__ */ uo(e,t))},min(e,t){return this.check(/* @__PURE__ */ uo(e,t))},lt(e,t){return this.check(/* @__PURE__ */ so(e,t))},lte(e,t){return this.check(/* @__PURE__ */ co(e,t))},max(e,t){return this.check(/* @__PURE__ */ co(e,t))},int(e){return this.check(xc(e))},safe(e){return this.check(xc(e))},positive(e){return this.check(/* @__PURE__ */ lo(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ uo(0,e))},negative(e){return this.check(/* @__PURE__ */ so(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ co(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ fo(e,t))},step(e,t){return this.check(/* @__PURE__ */ fo(e,t))},finite(){return this}})),bc=/*@__PURE__*/ N(`ZodNumberFormat`,(e,t)=>{Ti.init(e,t),yc.init(e,t)});function xc(e){return/* @__PURE__ */ io(bc,e)}const Sc=/*@__PURE__*/ N(`ZodUnknown`,(e,t)=>{Ei.init(e,t),K.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Cc(){return/* @__PURE__ */ ao(Sc)}const wc=/*@__PURE__*/ N(`ZodNever`,(e,t)=>{Di.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Tc(e){return/* @__PURE__ */ oo(wc,e)}const Ec=/*@__PURE__*/ N(`ZodArray`,(e,t)=>{Gs(),ji.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ mo(e,t))},nonempty(e){return this.check(/* @__PURE__ */ mo(1,e))},max(e,t){return this.check(/* @__PURE__ */ po(e,t))},length(e,t){return this.check(/* @__PURE__ */ ho(e,t))},unwrap(){return this.element}});function Dc(e,t){return/* @__PURE__ */ Do(Ec,e,t)}const Oc=/*@__PURE__*/ N(`ZodObject`,(e,t)=>{Gs(),Li.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),nn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Lc(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:Cc()}))},loose(){return this.clone(S(this._zod.def,{catchall:Cc()}))},strict(){return this.clone(S(this._zod.def,{catchall:Tc()}))},strip(){return this.clone(S(this._zod.def,{catchall:void 0}))},extend(e){return Pt(this,e)},safeExtend(e){return It(this,e)},merge(e){return Lt(this,e)},pick(e){return jt(this,e)},omit(e){return Nt(this,e)},partial(...e){return Rt(Hc,this,e[0])},exactPartial(...e){return Rt(Wc,this,e[0],`exactPartial`)},required(...e){return zt(Qc,this,e[0])}});function kc(e,t){let n={type:`object`,shape:e??{},...E(t)};return new Oc(n)}const Ac=/*@__PURE__*/ N(`ZodUnion`,(e,t)=>{zi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.options=t.options});function jc(e,t){return new Ac({type:`union`,options:e,...E(t)})}const Mc=/*@__PURE__*/ N(`ZodIntersection`,(e,t)=>{Bi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)});function Nc(e,t){return new Mc({type:`intersection`,left:e,right:t})}const Pc=/*@__PURE__*/ N(`ZodRecord`,(e,t)=>{Gs(),Ui.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Fc(e,t,n){return!t||!t._zod?new Pc({type:`record`,keyType:Js(),valueType:e,...E(t)}):new Pc({type:`record`,keyType:e,valueType:t,...E(n)})}const Ic=/*@__PURE__*/ N(`ZodEnum`,(e,t)=>{Wi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(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 Ic({...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 Ic({...t,checks:[],...E(r),entries:i})}});function Lc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ic({type:`enum`,entries:n,...E(t)})}const Rc=/*@__PURE__*/ N(`ZodLiteral`,(e,t)=>{Gi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(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 zc(e,t){return new Rc({type:`literal`,values:Array.isArray(e)?e:[e],...E(t)})}const Bc=/*@__PURE__*/ N(`ZodTransform`,(e,t)=>{Gs(),Ki.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ln(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Jt(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(Jt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Vc(e){return new Bc({type:`transform`,transform:e})}const Hc=/*@__PURE__*/ N(`ZodOptional`,(e,t)=>{Ji.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e){return new Hc({type:`optional`,innerType:e})}const Wc=/*@__PURE__*/ N(`ZodExactOptional`,(e,t)=>{Yi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e){return new Wc({type:`optional`,innerType:e})}const Kc=/*@__PURE__*/ N(`ZodNullable`,(e,t)=>{Xi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qc(e){return new Kc({type:`nullable`,innerType:e})}const Jc=/*@__PURE__*/ N(`ZodDefault`,(e,t)=>{Zi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yc(e,t){return new Jc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tt(t)}})}const Xc=/*@__PURE__*/ N(`ZodPrefault`,(e,t)=>{$i.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e,t){return new Xc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tt(t)}})}const Qc=/*@__PURE__*/ N(`ZodNonOptional`,(e,t)=>{ea.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e,t){return new Qc({type:`nonoptional`,innerType:e,...E(t)})}const el=/*@__PURE__*/ N(`ZodCatch`,(e,t)=>{ra.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function tl(e,t){return new el({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:rn(t)})}const nl=/*@__PURE__*/ N(`ZodPipe`,(e,t)=>{ia.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.in=t.in,e.out=t.out});function rl(e,t){return new nl({type:`pipe`,in:e,out:t})}const il=/*@__PURE__*/ N(`ZodReadonly`,(e,t)=>{oa.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e){return new il({type:`readonly`,innerType:e})}const ol=/*@__PURE__*/ N(`ZodCustom`,(e,t)=>{ca.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r)});function sl(e,t={}){return/* @__PURE__ */ Oo(ol,e,t)}function cl(e,t){return/* @__PURE__ */ ko(e,t)}const ll=kc({darwinArm64:kc({platform:zc(`darwin`),arch:zc(`arm64`),pythonVersion:Js().regex(/^\d+\.\d+\.\d+$/u,`pythonVersion 必须是三段数字的版本号`),release:Js(),url:rc({protocol:/^https$/u}).describe(`托管资产只允许 https 下载:http/file 会让安装器去取明文或本机文件`),sha256:Js().regex(/^[0-9a-f]{64}$/u,`sha256 必须是 64 位小写十六进制`),sizeBytes:xc().positive()}),unsupported:Fc(Js(),Js())}),ul=r(g.join(import.meta.dirname,`runtime-manifest.json`))?import.meta.dirname:g.resolve(import.meta.dirname,`..`);function dl(e){let t;try{t=JSON.parse(e)}catch(e){throw Error(`runtime-manifest.json is invalid: ${String(e)}`,{cause:e})}let n=ll.safeParse(t);if(!n.success)throw Error(`runtime-manifest.json is invalid: ${bn(n.error)}`);return n.data}let fl;const pl=/^version\s*=\s*(?<version>\S+)\s*$/mu;function ml(){return g.join(ul,`runtime-manifest.json`)}function hl(e=ml()){try{return i(e,`utf8`)}catch(t){throw Error(`runtime-manifest.json is unreadable: ${e}`,{cause:t})}}function gl(){return fl??=dl(hl()),fl}const J={get darwinArm64(){return gl().darwinArm64},get unsupported(){return gl().unsupported}};function _l(e){return g.join(e,`runtime`,`python`,J.darwinArm64.pythonVersion,`bin`,`python3`)}function vl(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(e){try{return a(e).isFile()?(t(e,n.X_OK),!0):!1}catch{return!1}}function yl(e){return process.platform===`win32`?g.join(e,`_env`,`.venv`,`Scripts`,`python.exe`):g.join(e,`_env`,`.venv`,`bin`,`python`)}function bl(e){let t=g.join(e,`runtime`,`venv`,`pyvenv.cfg`),n;try{n=i(t,`utf8`)}catch{n=void 0}return(n===void 0?null:pl.exec(n))?.groups?.version}function xl(){let e;try{e=J.unsupported[`${process.platform}-${process.arch}`]}catch{
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 Io(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;Io(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 Lo=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Ro=[`oneOf`,`anyOf`];function zo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Bo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Lo.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]??zo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}y(n,r,e.length===1?e[0]:Bo(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=zo(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 Vo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Lo)if(t in e)return;let n=t.filter(e=>Ro.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Bo(t);else{let e=n[0],i=Ro.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=>Bo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Mo(e,r))}function Ho(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)):Mo(i,s),Mo(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())Io(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)??[])Vo(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)}Mo(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:Wo(t,`input`,e.processors),output:Wo(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:/* @__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 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 Uo=(e,t={})=>n=>{let r=No({...n,processors:t});return V(e,r),Fo(r,e),Ho(r,e)},Wo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=No({...i??{},target:a,io:t,processors:n});return V(e,o),Fo(o,e),Ho(o,e)},U=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Go=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ko=(e,t)=>{U(e,`minimum`,t),Go(e,`maximum`,t)},qo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Jo=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Yo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Xo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Zo=(e,t)=>U(e,`minimum`,t.minimum),Qo=(e,t)=>Go(e,`maximum`,t.maximum),$o=e=>(t,n)=>{Xo(t,n.format);let[r,i]=e[n.format];U(t,`minimum`,r),Go(t,`maximum`,i)},es={greater_than:(e,t)=>U(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Go(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>qo(e,t.value),number_format:$o(kt),bigint_format:$o(At),min_length:Zo,max_length:Qo,length_equals:(e,t)=>Ko(e,t.length),min_size:Zo,max_size:Qo,size_equals:(e,t)=>Ko(e,t.size),string_format:(e,t)=>{Xo(e,t.format),t.pattern&&Jo(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)=>Yo(e,t.mime)};function W(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)es[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&U(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&U(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Go(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Go(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&&Yo(t,i.mime);for(let e of i.patterns??[])Jo(t,e);return t}const ts={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ns=/* @__PURE__ */ new Map([[_i,rr],[yi,ir]]),rs=e=>ns.get(e)??e,is=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=W(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ts[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(rs);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}))])}},as=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=W(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)):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}))])}},os=(e,t,n,r)=>{n.not={}},ss=(e,t,n,r)=>{let i=ct(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)},cs=(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}},ls=(e,t,n,r)=>{B(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},us=(e,t,n,r)=>{B(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ds=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=W(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 fs(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?fs(t.out):t.type===`catch`?fs(t.innerType):e._zod.optin}const ps=(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`?fs(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)},ms=(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},hs=(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 gs(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=gs(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=>gs(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`)?hr:mr).source)),p}const _s=/* @__PURE__ */ new WeakMap;function vs(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 _s.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=gs(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 ys=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=W(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,rs(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=_s.get(t);n||(n=[],_s.set(t,n),t.deferred.push(()=>vs(t))),n.push(e)}i.additionalProperties=V(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&fs(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))}},bs=(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`}]},xs=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ss=Symbol();function Cs(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`),Ss):JSON.parse(o)}const ws=(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=Cs(i.defaultValue,e,t,n,r);o!==Ss&&(n.default=o)},Ts=(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=Cs(i.defaultValue,e,t,n,r);o!==Ss&&(n._prefault=o)},Es=(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},Ds=(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},Os=(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},ks=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},As=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function js(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 G=/*@__PURE__*/ M(`ZodError`,(e,t)=>{gn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);As.has(n)||(As.add(n),js(n,`format`,e=>t=>yn(e,t)),js(n,`flatten`,e=>t=>vn(e,t)),js(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ut,2)}),js(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ut,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ms=/* @__PURE__ */ Cn(G),Ns=/* @__PURE__ */ wn(G),Ps=/* @__PURE__ */ Tn(G),Fs=/* @__PURE__ */ Dn(G),Is=/* @__PURE__ */ Nn(G),Ls=/* @__PURE__ */ Pn(G),Rs=/* @__PURE__ */ Fn(G),zs=/* @__PURE__ */ In(G),Bs=/* @__PURE__ */ Ln(G),Vs=/* @__PURE__ */ Rn(G),Hs=/* @__PURE__ */ zn(G),Us=/* @__PURE__ */ Bn(G);function Ws(){P.localeError||F(Ea())}function Gs(){P.memoizer||F({memoizer:Ca()})}const K=/*@__PURE__*/ M(`ZodType`,(e,t)=>(Ws(),L.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(sl(e,t))},superRefine(e,t){return this.check(cl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ z(e))},optional(){return Uc(this)},exactOptional(){return Gc(this)},nullable(){return qc(this)},nullish(){return Uc(qc(this))},nonoptional(e){return $c(this,e)},array(){return Dc(this)},or(e){return jc([this,e])},and(e){return Nc(this,e)},transform(e){return rl(this,Vc(e))},default(e){return Yc(this,e)},prefault(e){return Zc(this,e)},catch(e){return tl(this,e)},pipe(e){return rl(this,e)},readonly(){return al(this)},describe(e){let t=this.clone();return Aa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Aa.get(this);let t=this.clone();return Aa.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 Zt(this,`~standard`,{...zr(this),jsonSchema:{input:Wo(this,`input`),output:Wo(this,`output`)}})},set"~standard"(e){k(this,`~standard`,e)},parse:function e(t,n){return Ms(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ns(this,t,n,{callee:e})},safeParse(e,t){return Ps(this,e,t)},async safeParseAsync(e,t){return Fs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){k(this,`spa`,e)},validate(e,t){return An(this,e,t)},validateAsync(e,t){return Mn(this,e,t)},encode:function e(t,n){return Is(this,t,n,{callee:e})},decode:function e(t,n){return Ls(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Rs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await zs(this,t,n,{callee:e})},safeEncode(e,t){return Bs(this,e,t)},safeDecode(e,t){return Vs(this,e,t)},async safeEncodeAsync(e,t){return Hs(this,e,t)},async safeDecodeAsync(e,t){return Us(this,e,t)},toJSONSchema(e){return Uo(this,{})(e)},get description(){return Aa.get(this)?.description},get _def(){return this._zod.def}}),Ks=/*@__PURE__*/ M(`_ZodString`,(e,t)=>{Br.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)},/*@__PURE__*/ Qt({format:e=>W(e).format??null,minLength:e=>W(e).minimum??null,maxLength:e=>W(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ _o(...e))},includes(...e){return this.check(/* @__PURE__ */ bo(...e))},startsWith(...e){return this.check(/* @__PURE__ */ xo(...e))},endsWith(...e){return this.check(/* @__PURE__ */ So(...e))},min(...e){return this.check(/* @__PURE__ */ ho(...e))},max(...e){return this.check(/* @__PURE__ */ mo(...e))},length(...e){return this.check(/* @__PURE__ */ go(...e))},nonempty(...e){return this.check(/* @__PURE__ */ ho(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ vo(e))},uppercase(e){return this.check(/* @__PURE__ */ yo(e))},trim(){return this.check(/* @__PURE__ */ wo())},normalize(...e){return this.check(/* @__PURE__ */ Co(...e))},toLowerCase(){return this.check(/* @__PURE__ */ To())},toUpperCase(){return this.check(/* @__PURE__ */ Eo())},slugify(){return this.check(/* @__PURE__ */ Do())}})),qs=/*@__PURE__*/ M(`ZodString`,(e,t)=>{Br.init(e,t),Ks.init(e,t)},{email(e){return this.check(/* @__PURE__ */ Na($s,e))},url(e){return this.check(/* @__PURE__ */ za(nc,e))},jwt(e){return this.check(/* @__PURE__ */ eo(vc,e))},emoji(e){return this.check(/* @__PURE__ */ Ba(ic,e))},guid(e){return this.check(/* @__PURE__ */ Pa(ec,e))},uuid(e){return this.check(/* @__PURE__ */ Fa(tc,e))},uuidv4(e){return this.check(/* @__PURE__ */ Ia(tc,e))},uuidv6(e){return this.check(/* @__PURE__ */ La(tc,e))},uuidv7(e){return this.check(/* @__PURE__ */ Ra(tc,e))},nanoid(e){return this.check(/* @__PURE__ */ Va(ac,e))},cuid(e){return this.check(/* @__PURE__ */ Ha(oc,e))},cuid2(e){return this.check(/* @__PURE__ */ Ua(sc,e))},ulid(e){return this.check(/* @__PURE__ */ Wa(cc,e))},base64(e){return this.check(/* @__PURE__ */ Za(hc,e))},base64url(e){return this.check(/* @__PURE__ */ Qa(gc,e))},xid(e){return this.check(/* @__PURE__ */ Ga(lc,e))},ksuid(e){return this.check(/* @__PURE__ */ Ka(uc,e))},ipv4(e){return this.check(/* @__PURE__ */ qa(dc,e))},ipv6(e){return this.check(/* @__PURE__ */ Ja(fc,e))},cidrv4(e){return this.check(/* @__PURE__ */ Ya(pc,e))},cidrv6(e){return this.check(/* @__PURE__ */ Xa(mc,e))},e164(e){return this.check(/* @__PURE__ */ $a(_c,e))},datetime(e){return this.check(/* @__PURE__ */ to(Ys,e))},date(e){return this.check(/* @__PURE__ */ no(Xs,e))},time(e){return this.check(/* @__PURE__ */ ro(Zs,e))},duration(e){return this.check(/* @__PURE__ */ io(Qs,e))}});function Js(e){return/* @__PURE__ */ Ma(qs,e)}const q=/*@__PURE__*/ M(`ZodStringFormat`,(e,t)=>{R.init(e,t),Ks.init(e,t)}),Ys=/*@__PURE__*/ M(`ZodISODateTime`,(e,t)=>{ai.init(e,t),q.init(e,t)}),Xs=/*@__PURE__*/ M(`ZodISODate`,(e,t)=>{oi.init(e,t),q.init(e,t)}),Zs=/*@__PURE__*/ M(`ZodISOTime`,(e,t)=>{si.init(e,t),q.init(e,t)}),Qs=/*@__PURE__*/ M(`ZodISODuration`,(e,t)=>{ci.init(e,t),q.init(e,t)}),$s=/*@__PURE__*/ M(`ZodEmail`,(e,t)=>{Ur.init(e,t),q.init(e,t)}),ec=/*@__PURE__*/ M(`ZodGUID`,(e,t)=>{Vr.init(e,t),q.init(e,t)}),tc=/*@__PURE__*/ M(`ZodUUID`,(e,t)=>{Hr.init(e,t),q.init(e,t)}),nc=/*@__PURE__*/ M(`ZodURL`,(e,t)=>{Zr.init(e,t),q.init(e,t)});function rc(e){return/* @__PURE__ */ za(nc,e)}const ic=/*@__PURE__*/ M(`ZodEmoji`,(e,t)=>{Qr.init(e,t),q.init(e,t)}),ac=/*@__PURE__*/ M(`ZodNanoID`,(e,t)=>{$r.init(e,t),q.init(e,t)}),oc=/*@__PURE__*/ M(`ZodCUID`,(e,t)=>{ei.init(e,t),q.init(e,t)}),sc=/*@__PURE__*/ M(`ZodCUID2`,(e,t)=>{ti.init(e,t),q.init(e,t)}),cc=/*@__PURE__*/ M(`ZodULID`,(e,t)=>{ni.init(e,t),q.init(e,t)}),lc=/*@__PURE__*/ M(`ZodXID`,(e,t)=>{ri.init(e,t),q.init(e,t)}),uc=/*@__PURE__*/ M(`ZodKSUID`,(e,t)=>{ii.init(e,t),q.init(e,t)}),dc=/*@__PURE__*/ M(`ZodIPv4`,(e,t)=>{li.init(e,t),q.init(e,t)}),fc=/*@__PURE__*/ M(`ZodIPv6`,(e,t)=>{fi.init(e,t),q.init(e,t)}),pc=/*@__PURE__*/ M(`ZodCIDRv4`,(e,t)=>{pi.init(e,t),q.init(e,t)}),mc=/*@__PURE__*/ M(`ZodCIDRv6`,(e,t)=>{hi.init(e,t),q.init(e,t)}),hc=/*@__PURE__*/ M(`ZodBase64`,(e,t)=>{vi.init(e,t),q.init(e,t)}),gc=/*@__PURE__*/ M(`ZodBase64URL`,(e,t)=>{xi.init(e,t),q.init(e,t)}),_c=/*@__PURE__*/ M(`ZodE164`,(e,t)=>{Si.init(e,t),q.init(e,t)}),vc=/*@__PURE__*/ M(`ZodJWT`,(e,t)=>{wi.init(e,t),q.init(e,t)}),yc=/*@__PURE__*/ M(`ZodNumber`,(e,t)=>{Ti.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Qt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=W(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=W(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=W(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>W(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ uo(e,t))},gte(e,t){return this.check(/* @__PURE__ */ fo(e,t))},min(e,t){return this.check(/* @__PURE__ */ fo(e,t))},lt(e,t){return this.check(/* @__PURE__ */ co(e,t))},lte(e,t){return this.check(/* @__PURE__ */ lo(e,t))},max(e,t){return this.check(/* @__PURE__ */ lo(e,t))},int(e){return this.check(xc(e))},safe(e){return this.check(xc(e))},positive(e){return this.check(/* @__PURE__ */ uo(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ fo(0,e))},negative(e){return this.check(/* @__PURE__ */ co(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ lo(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ po(e,t))},step(e,t){return this.check(/* @__PURE__ */ po(e,t))},finite(){return this}})),bc=/*@__PURE__*/ M(`ZodNumberFormat`,(e,t)=>{Ei.init(e,t),yc.init(e,t)});function xc(e){return/* @__PURE__ */ ao(bc,e)}const Sc=/*@__PURE__*/ M(`ZodUnknown`,(e,t)=>{Di.init(e,t),K.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Cc(){return/* @__PURE__ */ oo(Sc)}const wc=/*@__PURE__*/ M(`ZodNever`,(e,t)=>{Oi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Tc(e){return/* @__PURE__ */ so(wc,e)}const Ec=/*@__PURE__*/ M(`ZodArray`,(e,t)=>{Gs(),Mi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ ho(e,t))},nonempty(e){return this.check(/* @__PURE__ */ ho(1,e))},max(e,t){return this.check(/* @__PURE__ */ mo(e,t))},length(e,t){return this.check(/* @__PURE__ */ go(e,t))},unwrap(){return this.element}});function Dc(e,t){return/* @__PURE__ */ Oo(Ec,e,t)}const Oc=/*@__PURE__*/ M(`ZodObject`,(e,t)=>{Gs(),Ri.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),rn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Lc(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:Cc()}))},loose(){return this.clone(S(this._zod.def,{catchall:Cc()}))},strict(){return this.clone(S(this._zod.def,{catchall:Tc()}))},strip(){return this.clone(S(this._zod.def,{catchall:void 0}))},extend(e){return Pt(this,e)},safeExtend(e){return It(this,e)},merge(e){return Lt(this,e)},pick(e){return jt(this,e)},omit(e){return Nt(this,e)},partial(...e){return Rt(Hc,this,e[0])},exactPartial(...e){return Rt(Wc,this,e[0],`exactPartial`)},required(...e){return zt(Qc,this,e[0])}});function kc(e,t){let n={type:`object`,shape:e??{},...E(t)};return new Oc(n)}const Ac=/*@__PURE__*/ M(`ZodUnion`,(e,t)=>{Bi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.options=t.options});function jc(e,t){return new Ac({type:`union`,options:e,...E(t)})}const Mc=/*@__PURE__*/ M(`ZodIntersection`,(e,t)=>{Vi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)});function Nc(e,t){return new Mc({type:`intersection`,left:e,right:t})}const Pc=/*@__PURE__*/ M(`ZodRecord`,(e,t)=>{Gs(),Wi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Fc(e,t,n){return!t||!t._zod?new Pc({type:`record`,keyType:Js(),valueType:e,...E(t)}):new Pc({type:`record`,keyType:e,valueType:t,...E(n)})}const Ic=/*@__PURE__*/ M(`ZodEnum`,(e,t)=>{Gi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(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 Ic({...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 Ic({...t,checks:[],...E(r),entries:i})}});function Lc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ic({type:`enum`,entries:n,...E(t)})}const Rc=/*@__PURE__*/ M(`ZodLiteral`,(e,t)=>{Ki.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(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 zc(e,t){return new Rc({type:`literal`,values:Array.isArray(e)?e:[e],...E(t)})}const Bc=/*@__PURE__*/ M(`ZodTransform`,(e,t)=>{Gs(),qi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new un(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Yt(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(Yt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Vc(e){return new Bc({type:`transform`,transform:e})}const Hc=/*@__PURE__*/ M(`ZodOptional`,(e,t)=>{Yi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e){return new Hc({type:`optional`,innerType:e})}const Wc=/*@__PURE__*/ M(`ZodExactOptional`,(e,t)=>{Xi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e){return new Wc({type:`optional`,innerType:e})}const Kc=/*@__PURE__*/ M(`ZodNullable`,(e,t)=>{Zi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qc(e){return new Kc({type:`nullable`,innerType:e})}const Jc=/*@__PURE__*/ M(`ZodDefault`,(e,t)=>{Qi.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yc(e,t){return new Jc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tt(t)}})}const Xc=/*@__PURE__*/ M(`ZodPrefault`,(e,t)=>{ea.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e,t){return new Xc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tt(t)}})}const Qc=/*@__PURE__*/ M(`ZodNonOptional`,(e,t)=>{ta.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e,t){return new Qc({type:`nonoptional`,innerType:e,...E(t)})}const el=/*@__PURE__*/ M(`ZodCatch`,(e,t)=>{ia.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function tl(e,t){return new el({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:an(t)})}const nl=/*@__PURE__*/ M(`ZodPipe`,(e,t)=>{aa.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.in=t.in,e.out=t.out});function rl(e,t){return new nl({type:`pipe`,in:e,out:t})}const il=/*@__PURE__*/ M(`ZodReadonly`,(e,t)=>{sa.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e){return new il({type:`readonly`,innerType:e})}const ol=/*@__PURE__*/ M(`ZodCustom`,(e,t)=>{la.init(e,t),K.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r)});function sl(e,t={}){return/* @__PURE__ */ ko(ol,e,t)}function cl(e,t){return/* @__PURE__ */ Ao(e,t)}const ll=kc({darwinArm64:kc({platform:zc(`darwin`),arch:zc(`arm64`),pythonVersion:Js().regex(/^\d+\.\d+\.\d+$/u,`pythonVersion 必须是三段数字的版本号`),release:Js(),url:rc({protocol:/^https$/u}).describe(`托管资产只允许 https 下载:http/file 会让安装器去取明文或本机文件`),sha256:Js().regex(/^[0-9a-f]{64}$/u,`sha256 必须是 64 位小写十六进制`),sizeBytes:xc().positive()}),unsupported:Fc(Js(),Js())}),ul=n(g.join(import.meta.dirname,`runtime-manifest.json`))?import.meta.dirname:g.resolve(import.meta.dirname,`..`);function dl(e){let t;try{t=JSON.parse(e)}catch(e){throw Error(`runtime-manifest.json is invalid: ${String(e)}`,{cause:e})}let n=ll.safeParse(t);if(!n.success)throw Error(`runtime-manifest.json is invalid: ${xn(n.error)}`);return n.data}let fl;const pl=/^version\s*=\s*(?<version>\S+)\s*$/mu;function ml(){return g.join(ul,`runtime-manifest.json`)}function hl(e=ml()){try{return r(e,`utf8`)}catch(t){throw Error(`runtime-manifest.json is unreadable: ${e}`,{cause:t})}}function gl(){return fl??=dl(hl()),fl}const J={get darwinArm64(){return gl().darwinArm64},get unsupported(){return gl().unsupported}};function _l(e){return g.join(e,`runtime`,`python`,J.darwinArm64.pythonVersion,`bin`,`python3`)}function vl(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 yl(e){return process.platform===`win32`?g.join(e,`_env`,`.venv`,`Scripts`,`python.exe`):g.join(e,`_env`,`.venv`,`bin`,`python`)}function bl(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:pl.exec(n))?.groups?.version}function xl(){let e;try{e=J.unsupported[`${process.platform}-${process.arch}`]}catch{
120
120
  /* v8 ignore next 2 -- 清单读不到才走到这条兜底:正常装配里它必须存在,要在用例里造出来
121
121
  得清掉模块级缓存,代价与「这条兜底不吞异常」的收益不成比例 */
122
- e=void 0}return e}function Sl(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=vl(e.dataDir);if(Y(t))return{pythonPath:t,via:`managed-venv`,version:bl(e.dataDir)??J.darwinArm64.pythonVersion};let n=_l(e.dataDir);if(Y(n))return{pythonPath:n,via:`managed`,version:J.darwinArm64.pythonVersion}}let n=e.repoRoot.length>0?yl(e.repoRoot):``;if(n.length>0&&Y(n))return{pythonPath:n,via:`repo`,version:`unknown`};let r=process.platform===`win32`?`python`:`python3`,i=xl();return i===void 0?{pythonPath:r,via:`path`,version:`unknown`}:{pythonPath:r,via:`path`,version:`unknown`,assetNote:i}}var Cl=/* @__PURE__ */ me((/* @__PURE__ */ 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=/* @__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>4294967295||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>16777215||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 wl=/(?<scheme>[a-z][a-z0-9+.!-]*:\/\/)[^\s/?#]*@/giu;function Tl(e){return e.toByteArray().reduce((e,t)=>e*256+t,0)}Tl(Cl.default.IPv4.parse(`198.18.0.0`)),Tl(Cl.default.IPv4.parse(`198.19.255.255`)),Tl(Cl.default.IPv4.parse(`100.64.0.0`)),Tl(Cl.default.IPv4.parse(`100.127.255.255`));function El(e){let t=e.trimStart(),n=e.slice(0,e.length-t.length),r=t.replaceAll(wl,`$<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 Dl=`state.json`,Ol=/No matching distribution|Could not find a version/iu,kl=/Network|Temporary failure|Connection|timed out/iu;function Al(e){return El(e)}function jl(){return process.platform===`darwin`&&process.arch===`arm64`}const Ml=/* @__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 Nl(e){return X(e)&&typeof e.code==`string`?e.code:void 0}const Pl=65536,Fl=`
123
- [installer] 输出过长,后续内容已丢弃`;function Il(e,t){if(e.endsWith(Fl))return e;let n=e+t;return n.length>Pl?`${n.slice(0,Pl)}${Fl}`:n}async function Ll(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=Il(a,e.toString(`utf8`))}),i.stderr.on(`data`,e=>{o=Il(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 Rl(e){return async t=>{let n=g.join(ne.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 d(n))}finally{await m(n,{force:!0})}if(await m(n,{force:!0}),r.code!==null)throw new Z(`INSTALL_NETWORK`,`curl failed for ${El(t)}: ${Al(r.stderr).slice(0,400)}`);let i=await fetch(t,{signal:AbortSignal.timeout(9e5)});if(!i.ok)throw new Z(`INSTALL_NETWORK`,`${El(t)} answered HTTP ${i.status}`);return new Uint8Array(await i.arrayBuffer())}}const zl={download:Rl(Ll),extract:async(e,t)=>{let n=await Ll([`tar`,`-xzf`,e,`-C`,t]);if(n.code!==0)throw new Z(`INSTALL_FAILED`,`tar failed: ${Al(n.stderr).slice(0,400)}`)},spawn:Ll};async function Bl(e){try{return await o(e,n.F_OK),!0}catch{return!1}}function Vl(t=e(import.meta.url)){let n;try{n=t(`fs-native-extensions`)}catch{n=void 0}if(X(n)){let e=n.tryLock,t=n.unlock;if(typeof e==`function`&&typeof t==`function`)return{tryLock:t=>!!e.call(n,t),unlock:e=>{t.call(n,e)}}}return null}const Hl=Vl();function Ul(e,t=Hl){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 Wl(e,t=Hl){let n;try{n=await u(e,`a+`)}catch(t){throw new Z(`INSTALL_LOCK_UNREADABLE`,`cannot open install lock ${e}: ${String(t)}`)}let r;try{r=Ul(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 Gl(e){let t=g.join(e,`runtime`);return await l(t,{recursive:!0}),process.platform!==`win32`&&await s(t,448),t}const Kl=new re;async function ql(e,t){let n=g.join(e,`runtime`),r=g.join(n,`install.lock`),i=g.resolve(r),a=Kl.getStore();if(a?.has(i)===!0)return t();await Gl(e);let o=await Wl(r),s=/* @__PURE__ */ new Set([...a??[],i]);try{return await Kl.run(s,t)}finally{await o.release()}}async function Jl(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 d(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 Yl(e,t,n,r){return ql(t,async()=>{let i=g.join(t,`runtime`,`.tmp`,_());await l(i,{recursive:!0});let a=g.join(i,`python.tar.gz`);try{let o=r===void 0?await n.download(e.url):await Jl(r,e.url),s=ie(`sha256`).update(o).digest(`hex`);if(s!==e.sha256)throw new Z(`INSTALL_HASH_MISMATCH`,`python archive hash ${s} does not match ${e.sha256}`);await te(a,o);let u=g.join(i,`extract`);await l(u,{recursive:!0}),await n.extract(a,u);let d=g.join(u,`python`),f=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(_l(t)));await l(g.dirname(h),{recursive:!0});let ee=`${h}.new-${_()}`;try{await c(f,ee,{recursive:!0,dereference:!0}),await m(h,{recursive:!0,force:!0}),await p(ee,h)}catch(e){throw await m(ee,{recursive:!0,force:!0}),e}let ne=_l(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 m(i,{recursive:!0,force:!0}),await h(g.join(t,`runtime`,`.tmp`)).catch(()=>null)}})}async function Xl(e){let t=g.join(e,`runtime`,Dl),n;try{n=await d(t,`utf8`)}catch(e){if(Nl(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 Zl(e,t){let n=await Gl(e),r=g.join(n,Dl),i=`${r}.${_()}.tmp`;try{await te(i,JSON.stringify(t,null,2),`utf8`),await p(i,r)}finally{try{await m(i,{force:!0})}catch{}}}async function Ql(e,t,n,r=e=>d(e,`utf8`)){let i=g.join(e,`bin`),a=`#!${t}/`,o=(await f(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 te(e,`#!${n}/${o.slice(a.length)}${s}`,`utf8`)}))}async function $l(e,t){let n=!1;if(t){try{await m(e.venv,{recursive:!0,force:!0})}catch{}try{await p(e.previousVenv,e.venv)}catch{n=!0}}if(!n)try{await m(e.previousVenv,{recursive:!0,force:!0})}catch{}try{await m(e.staging,{recursive:!0,force:!0})}catch{}}async function eu(e){let{io:t}=e;await ql(e.dataDir,async()=>{let n=await Gl(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`),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: ${Al(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`,`-r`,o,...u],{env:{PIP_DISABLE_PIP_VERSION_CHECK:`1`}});if(d.code!==0){let e=`${d.stdout}\n${d.stderr}`;throw Ol.test(e)?new Z(`INSTALL_NO_WHEEL`,`a dependency has no wheel for this platform`):kl.test(e)?new Z(`INSTALL_NETWORK`,`pip could not reach the package index`):new Z(`INSTALL_FAILED`,`pip failed: ${Al(d.stderr).slice(0,400)}`)}await Ql(i,i,r);try{await Bl(r)&&(await p(r,a),s=!0),await p(i,r)}catch(e){throw new Z(`INSTALL_FAILED`,`cannot replace ${r}: ${String(e)}`,{cause:e})}let f=await Xl(e.dataDir),m={...X(f.packs)?f.packs:{},core:`ready`};await Zl(e.dataDir,{...f,packs:m,python:e.pythonPath}),c=!0}finally{await $l({venv:r,previousVenv:a,staging:i},s&&!c)}})}async function tu(e){try{return(await f(e,{recursive:!0})).some(e=>Ml.has(g.basename(e)))}catch{return!1}}async function nu(e){return tu(g.join(e,`runtime`,`browsers`))}async function ru(e){let{io:t}=e;return ql(e.dataDir,async()=>{let n=g.join(e.dataDir,`runtime`,`browsers`);await l(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: ${Al(r.stderr).slice(0,400)}`);if(!await tu(n))throw new Z(`INSTALL_BROWSER_FAILED`,`no chromium executable found under ${n}`);let i=await Xl(e.dataDir),a={...X(i.packs)?i.packs:{},browser:`ready`};return await Zl(e.dataDir,{...i,packs:a,browsersPath:n}),{browsersPath:n}})}function iu(e,t){return e===`ready`?t?`ready`:`corrupt`:`missing`}async function au(e,t){if(!jl())return{core:`blocked`,browser:`blocked`,search:`blocked`,media:`blocked`,"adaptive-redis":`blocked`,mcp:`blocked`};let n=(await Xl(e)).packs,r=X(n)?n:{},i=iu(r.core,Y(vl(e))),a={core:i,browser:iu(r.browser,await nu(e)),search:i,media:i,"adaptive-redis":i,mcp:i};return t!==void 0&&(a[t]=`installing`),a}function ou(e){if(e?.aborted===!0)throw new Z(`INSTALL_CANCELLED`,`install cancelled`)}async function su(e,t,n,r,i){let a=_l(e);return Y(a)?a:(ou(n),(await Yl(r,e,t,i)).pythonPath)}async function cu(e,t){if(!jl())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 Bl(g.join(s,`wheels`)))throw new Z(`INSTALL_OFFLINE_ASSETS`,`offline wheelhouse missing: ${g.join(s,`wheels`)}`);ou(a),o?.(`installing ${e}`);let l=await su(n,i,a,c,s);ou(a),o?.(`installing core packages into ${l}`),await eu({pythonPath:l,dataDir:n,repoRoot:r,io:i,...s===void 0?{}:{assets:s}}),ou(a),e===`browser`&&(o?.(`installing full chromium`),await ru({pythonPath:vl(n),dataDir:n,io:i}),ou(a)),o?.(`${e} ready`)}const lu=cu;async function uu(e,t){await ql(t.dataDir,async()=>{let n=g.join(t.dataDir,`runtime`),r=e===`browser`?`browsers`:`venv`;await m(g.join(n,r),{recursive:!0,force:!0}),t.purge&&(await Promise.all([``,`-wal`,`-shm`].map(e=>m(g.join(t.dataDir,`elements_storage.db${e}`),{force:!0}))),await m(g.join(t.dataDir,`downloads`),{recursive:!0,force:!0}));let i=await Xl(t.dataDir);if(!X(i.packs))return;let a={...i.packs};Reflect.deleteProperty(a,e),await Zl(t.dataDir,{...i,packs:a})})}const du=/\r\n|\n|\r/u,fu=/[\t ]#.*$/u,pu=[`core`,`browser`,`search`,`media`,`adaptive-redis`,`mcp`],mu=new Set(pu),hu=/* @__PURE__ */ new Set([`setup`,`doctor`]),gu=/* @__PURE__ */ new Set([`status`,`apply`,`repair`,`purge`,`dry-run`,`with-auth`,`accept-risk`]),_u=/* @__PURE__ */ new Set([`port`,`mode`,`profile`,`offline`,`uninstall`,`feature`]);function vu(){let e=process.env.DSH_SCRAPLING_DATA_DIR;return e===void 0||e===``?g.join(ne.homedir(),`.dsh-scrapling`):g.resolve(e)}function yu(e){return mu.has(e)}function bu(e,t){if(!e.startsWith(`--`))return{kind:`invalid`};let n=e.slice(2);return gu.has(n)?{kind:`boolean`,name:n}:!_u.has(n)||t===void 0||t.startsWith(`--`)?{kind:`invalid`}:{kind:`value`,name:n,value:t}}function xu(e){let[t,...n]=e;if(t===void 0||!hu.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=bu(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 Su(e){return{io:zl,dataDir:vu(),repoRoot:g.resolve(import.meta.dirname,`..`),log:e=>{console.info(e)},installPackFn:cu,repairPackFn:lu,uninstallPackFn:uu,...e}}function Q(e,t){let n=e.get(t);return typeof n==`string`?n:void 0}function Cu(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 wu(e){let t=Q(e,`mode`);return t===void 0||!Ce(t)?null:t}function Tu(e,t,n){let r=typeof n==`string`?JSON.stringify(n):`(缺省)`;return`--${e} 要写 ${t.join(` / `)} 之一;现在给的是 ${r}`}function Eu(e){return Tu(`mode`,xe,e.get(`mode`))}function Du(e,t){return Tu(e,pu,t.get(e))}function Ou(e){return e.has(`apply`)&&!e.has(`dry-run`)}function ku(e,t){return e.has(`dry-run`)&&e.has(`apply`)?`dry-run:--dry-run 压过 --apply,${t.suppressed}`:t.missingApply}function Au(e){if(e.mode===`native`)return{text:at(),note:`native 模式不留 dsh-mcp-client 条目:原生工具已经在宿主名册里,再端一份就是两套。`,install:``};if(e.mode===`mcp`){let t=e.withAuth?`Authorization 在宿主装载时从宿主进程环境的 ${ve} 求值:变量缺席会写成 "Bearer undefined",加鉴权前先确认宿主环境里已设置它。`:``;return{text:it({port:e.port,withAuth:e.withAuth}),note:`mcp 模式起的是本插件的 server,URL 里的端口要与部署项 mcpPort 同值(当前按 ${String(e.port)} 生成)。${t}`,install:Te()}}let t=Me({dataDir:e.dataDir,enabled:e.enabled,acceptedRisk:e.acceptRisk});return{text:t.patch,note:t.risk,install:t.installCommand}}async function ju(e,t){await l(g.dirname(e),{recursive:!0}),await te(e,t,`utf8`)}async function Mu(e,t){let n=wu(e);if(n===null)return t.log(Eu(e)),2;let i=Cu(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 nt(o),c=Au({mode:n,port:a,withAuth:e.has(`with-auth`),acceptRisk:e.has(`accept-risk`),dataDir:t.dataDir,enabled:s?.officialMcpEnabled===!0});t.log(c.text),t.log(c.note),c.install!==``&&(t.log(`客户端没装就先跑:${c.install}`),t.log(`只接受 ${be.join(` 或 `)}:npm 的 latest 比宿主线旧,宿主拒绝装载不匹配的对端。`));let l=g.join(t.dataDir,`mcp`,rt(n));if(n===`official-mcp`){let e=De(t.dataDir);r(e)||t.log(`${e} 现在还不存在:先跑 setup --feature mcp --apply 把官方 server 装进托管 venv;在那之前这条条目连不上(failOnStartupError: true 会让宿主把这条报成红)。`)}return Ou(e)?(await ju(l,c.text),t.log(`wrote ${l}`),t.log(`profile 不会被这条命令改写:把这段并进 <profile>/cordis.patch.yml,再重启宿主。`),0):(t.log(ku(e,{suppressed:`只打印条目,不写 ${l}`,missingApply:`dry-run; add --apply to write ${l}`})),0)}function Nu(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`)}function Pu(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(fu,``).trim()}function $(e,t){let n=RegExp(`^[\\t ]*(?:-[\\t ]+)?${Nu(t)}:(?<value>[^\\r\\n]*)$`,`u`);return e.split(du).filter(e=>!e.trimStart().startsWith(`#`)).map(e=>Pu(n.exec(e)?.groups?.value??``)).filter(e=>e!==``).at(-1)}function Fu(e,t){return $(e,t)!==void 0}function Iu(e,t){let n=$(e,t);return n===`true`||n===`True`||n===`TRUE`}function Lu(e){return!e.includes(`/`)&&!e.includes(`\\`)?{value:e,relative:!1}:{value:g.resolve(e),relative:!g.isAbsolute(e)}}async function Ru(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 nt(t),r=$(n.patchText,`pythonBin`)??``,i=$(n.patchText,`dataDir`)??``,a=Lu(r),o=Lu(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 zu(e,t){let{profile:n,pythonBin:r,dataDirOverride:i}=await Ru(e),a=i??t.dataDir,o=Sl({pythonBin:r,dataDir:a,repoRoot:t.repoRoot}),s=await Xl(a),c=await au(a);return t.log(JSON.stringify({dataDir:a,profile:n,runtime:o,packs:c,state:s},null,2)),0}const Bu={tavily:`tavilyApiKey`,brave:`braveApiKey`,serper:`serperApiKey`,searxng:`searxngEndpoint`};function Vu(e){return e===void 0||st(e)?[]:[{code:`SEARCH_BACKEND_INVALID`,detail:`searchBackend=${e} 不是本包实现的后端:可写的取值是 ${ot.join(` / `)},删掉这一行即回到 auto。`}]}function Hu(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 Uu(e,t){let n=$(e,`searchProvider`),r=$(e,`searchBackend`),i=r??`auto`,a=Iu(e,`searchPublicFallback`),o=Fu(e,`tavilyApiKey`),s=Fu(e,`searxngEndpoint`),c=i===`auto`&&!o&&!s&&!a,l=i===`auto`?void 0:Bu[i],u=l!==void 0&&!Fu(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(...Vu(r)),d&&t!==`ready`&&p.push({code:`WEB_PROVIDER_CONFIGURED_UNAVAILABLE`,detail:Hu(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 Wu(e,t){let n=wu(e);if(n===null)return t.log(Eu(e)),2;let r=Q(e,`profile`);if(r===void 0)return t.log(`doctor 要 --profile <目录>:判据来自那份 profile 自己写下的 cordis.patch.yml。`),2;let i=Cu(e);if(i.invalid)return t.log(`--port 要写 1 到 65535 之间的整数;现在给的是 ${String(Q(e,`port`))}`),2;let a=await nt(r),o=await au($(a.patchText,`dataDir`)??t.dataDir),s=Ye({mode:n,expectedPort:i.port,...a}),c=Uu(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 Gu(e,t){let n=e.get(`uninstall`);if(typeof n!=`string`||!yu(n))return t.log(Du(`uninstall`,e)),2;let r=e.has(`purge`);return t.log(`uninstall ${n}${r?` (and purge user data)`:``} from ${g.join(t.dataDir,`runtime`)}`),Ou(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(ku(e,{suppressed:`只打印计划,不删任何 runtime 文件`,missingApply:`dry-run; add --apply to uninstall`})),0)}function Ku(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}`,`落地位置:${g.join(t.dataDir,`runtime`)}(Python 在 runtime/python/,wheel 在 runtime/venv/)`].join(`
122
+ e=void 0}return e}function Sl(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=vl(e.dataDir);if(Y(t))return{pythonPath:t,via:`managed-venv`,version:bl(e.dataDir)??J.darwinArm64.pythonVersion};let n=_l(e.dataDir);if(Y(n))return{pythonPath:n,via:`managed`,version:J.darwinArm64.pythonVersion}}let n=e.repoRoot.length>0?yl(e.repoRoot):``;if(n.length>0&&Y(n))return{pythonPath:n,via:`repo`,version:`unknown`};let r=process.platform===`win32`?`python`:`python3`,i=xl();return i===void 0?{pythonPath:r,via:`path`,version:`unknown`}:{pythonPath:r,via:`path`,version:`unknown`,assetNote:i}}var Cl=/* @__PURE__ */ me((/* @__PURE__ */ 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=/* @__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 wl=/(?<scheme>[a-z][a-z0-9+.!-]*:\/\/)[^\s/?#]*@/giu;function Tl(e){return e.toByteArray().reduce((e,t)=>e*256+t,0)}Tl(Cl.default.IPv4.parse(`198.18.0.0`)),Tl(Cl.default.IPv4.parse(`198.19.255.255`)),Tl(Cl.default.IPv4.parse(`100.64.0.0`)),Tl(Cl.default.IPv4.parse(`100.127.255.255`));function El(e){let t=e.trimStart(),n=e.slice(0,e.length-t.length),r=t.replaceAll(wl,`$<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 Dl=`state.json`,Ol=/No matching distribution|Could not find a version/iu,kl=/Network|Temporary failure|Connection|timed out/iu;function Al(e){return El(e)}function jl(){return process.platform===`darwin`&&process.arch===`arm64`}const Ml=/* @__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 Nl(e){return X(e)&&typeof e.code==`string`?e.code:void 0}const Pl=65536,Fl=`
123
+ [installer] 输出过长,后续内容已丢弃`;function Il(e,t){if(e.endsWith(Fl))return e;let n=e+t;return n.length>Pl?`${n.slice(0,Pl)}${Fl}`:n}async function Ll(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=Il(a,e.toString(`utf8`))}),i.stderr.on(`data`,e=>{o=Il(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 Rl(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 ${El(t)}: ${Al(r.stderr).slice(0,400)}`);let i=await fetch(t,{signal:AbortSignal.timeout(9e5)});if(!i.ok)throw new Z(`INSTALL_NETWORK`,`${El(t)} answered HTTP ${i.status}`);return new Uint8Array(await i.arrayBuffer())}}const zl={download:Rl(Ll),extract:async(e,t)=>{let n=await Ll([`tar`,`-xzf`,e,`-C`,t]);if(n.code!==0)throw new Z(`INSTALL_FAILED`,`tar failed: ${Al(n.stderr).slice(0,400)}`)},spawn:Ll};async function Bl(e){try{return await a(e,t.F_OK),!0}catch{return!1}}function Vl(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 Hl=Vl();function Ul(e,t=Hl){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 Wl(e,t=Hl){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=Ul(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 Gl(e){let t=g.join(e,`runtime`);return await c(t,{recursive:!0}),process.platform!==`win32`&&await o(t,448),t}const Kl=new ne;async function ql(e,t){let n=g.join(e,`runtime`),r=g.join(n,`install.lock`),i=g.resolve(r),a=Kl.getStore();if(a?.has(i)===!0)return t();await Gl(e);let o=await Wl(r),s=/* @__PURE__ */ new Set([...a??[],i]);try{return await Kl.run(s,t)}finally{await o.release()}}async function Jl(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 Yl(e,t,n,r){return ql(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 Jl(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(_l(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=_l(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 Xl(e){let t=g.join(e,`runtime`,Dl),n;try{n=await u(t,`utf8`)}catch(e){if(Nl(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 Zl(e,t){let n=await Gl(e),r=g.join(n,Dl),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 Ql(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 $l(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 eu(e){let{io:t}=e;await ql(e.dataDir,async()=>{let n=await Gl(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`),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: ${Al(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`,`-r`,o,...u],{env:{PIP_DISABLE_PIP_VERSION_CHECK:`1`}});if(d.code!==0){let e=`${d.stdout}\n${d.stderr}`;throw Ol.test(e)?new Z(`INSTALL_NO_WHEEL`,`a dependency has no wheel for this platform`):kl.test(e)?new Z(`INSTALL_NETWORK`,`pip could not reach the package index`):new Z(`INSTALL_FAILED`,`pip failed: ${Al(d.stderr).slice(0,400)}`)}await Ql(i,i,r);try{await Bl(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 Xl(e.dataDir),m={...X(p.packs)?p.packs:{},core:`ready`};await Zl(e.dataDir,{...p,packs:m,python:e.pythonPath}),c=!0}finally{await $l({venv:r,previousVenv:a,staging:i},s&&!c)}})}async function tu(e){try{return(await d(e,{recursive:!0})).some(e=>Ml.has(g.basename(e)))}catch{return!1}}async function nu(e){return tu(g.join(e,`runtime`,`browsers`))}async function ru(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: ${Al(r.stderr).slice(0,400)}`);if(!await tu(n))throw new Z(`INSTALL_BROWSER_FAILED`,`no chromium executable found under ${n}`);let i=await Xl(e.dataDir),a={...X(i.packs)?i.packs:{},browser:`ready`};return await Zl(e.dataDir,{...i,packs:a,browsersPath:n}),{browsersPath:n}})}function iu(e,t){return e===`ready`?t?`ready`:`corrupt`:`missing`}async function au(e,t){if(!jl())return{core:`blocked`,browser:`blocked`,search:`blocked`,media:`blocked`,"adaptive-redis":`blocked`,mcp:`blocked`};let n=(await Xl(e)).packs,r=X(n)?n:{},i=iu(r.core,Y(vl(e))),a={core:i,browser:iu(r.browser,await nu(e)),search:i,media:i,"adaptive-redis":i,mcp:i};return t!==void 0&&(a[t]=`installing`),a}function ou(e){if(e?.aborted===!0)throw new Z(`INSTALL_CANCELLED`,`install cancelled`)}async function su(e,t,n,r,i){let a=_l(e);return Y(a)?a:(ou(n),(await Yl(r,e,t,i)).pythonPath)}async function cu(e,t){if(!jl())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 Bl(g.join(s,`wheels`)))throw new Z(`INSTALL_OFFLINE_ASSETS`,`offline wheelhouse missing: ${g.join(s,`wheels`)}`);ou(a),o?.(`installing ${e}`);let l=await su(n,i,a,c,s);ou(a),o?.(`installing core packages into ${l}`),await eu({pythonPath:l,dataDir:n,repoRoot:r,io:i,...s===void 0?{}:{assets:s}}),ou(a),e===`browser`&&(o?.(`installing full chromium`),await ru({pythonPath:vl(n),dataDir:n,io:i}),ou(a)),o?.(`${e} ready`)}const lu=cu;async function uu(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 Xl(t.dataDir);if(!X(i.packs))return;let a={...i.packs};Reflect.deleteProperty(a,e),await Zl(t.dataDir,{...i,packs:a})})}const du=/\r\n|\n|\r/u,fu=/[\t ]#.*$/u,pu=[`core`,`browser`,`search`,`media`,`adaptive-redis`,`mcp`],mu=new Set(pu),hu=/* @__PURE__ */ new Set([`setup`,`doctor`]),gu=/* @__PURE__ */ new Set([`status`,`apply`,`repair`,`purge`,`dry-run`,`with-auth`,`accept-risk`]),_u=/* @__PURE__ */ new Set([`port`,`mode`,`profile`,`offline`,`uninstall`,`feature`]);function vu(){let e=process.env.DSH_SCRAPLING_DATA_DIR;return e===void 0||e===``?g.join(te.homedir(),`.dsh-scrapling`):g.resolve(e)}function yu(e){return mu.has(e)}function bu(e,t){if(!e.startsWith(`--`))return{kind:`invalid`};let n=e.slice(2);return gu.has(n)?{kind:`boolean`,name:n}:!_u.has(n)||t===void 0||t.startsWith(`--`)?{kind:`invalid`}:{kind:`value`,name:n,value:t}}function xu(e){let[t,...n]=e;if(t===void 0||!hu.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=bu(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 Su(e){return{io:zl,dataDir:vu(),repoRoot:g.resolve(import.meta.dirname,`..`),log:e=>{console.info(e)},installPackFn:cu,repairPackFn:lu,uninstallPackFn:uu,...e}}function Q(e,t){let n=e.get(t);return typeof n==`string`?n:void 0}function Cu(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 wu(e){let t=Q(e,`mode`);return t===void 0||!Ce(t)?null:t}function Tu(e,t,n){let r=typeof n==`string`?JSON.stringify(n):`(缺省)`;return`--${e} 要写 ${t.join(` / `)} 之一;现在给的是 ${r}`}function Eu(e){return Tu(`mode`,xe,e.get(`mode`))}function Du(e,t){return Tu(e,pu,t.get(e))}function Ou(e){return e.has(`apply`)&&!e.has(`dry-run`)}function ku(e,t){return e.has(`dry-run`)&&e.has(`apply`)?`dry-run:--dry-run 压过 --apply,${t.suppressed}`:t.missingApply}function Au(e){if(e.mode===`native`)return{text:at(),note:`native 模式不留 dsh-mcp-client 条目:原生工具已经在宿主名册里,再端一份就是两套。`,install:``};if(e.mode===`mcp`){let t=e.withAuth?`Authorization 在宿主装载时从宿主进程环境的 ${ve} 求值:变量缺席会写成 "Bearer undefined",加鉴权前先确认宿主环境里已设置它。`:``;return{text:it({port:e.port,withAuth:e.withAuth}),note:`mcp 模式起的是本插件的 server,URL 里的端口要与部署项 mcpPort 同值(当前按 ${String(e.port)} 生成)。${t}`,install:Te()}}let t=Me({dataDir:e.dataDir,enabled:e.enabled,acceptedRisk:e.acceptRisk});return{text:t.patch,note:t.risk,install:t.installCommand}}async function ju(e,t){await c(g.dirname(e),{recursive:!0}),await ee(e,t,`utf8`)}async function Mu(e,t){let r=wu(e);if(r===null)return t.log(Eu(e)),2;let i=Cu(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 nt(o),c=Au({mode:r,port:a,withAuth:e.has(`with-auth`),acceptRisk:e.has(`accept-risk`),dataDir:t.dataDir,enabled:s?.officialMcpEnabled===!0});t.log(c.text),t.log(c.note),c.install!==``&&(t.log(`客户端没装就先跑:${c.install}`),t.log(`只接受 ${be.join(` 或 `)}:npm 的 latest 比宿主线旧,宿主拒绝装载不匹配的对端。`));let l=g.join(t.dataDir,`mcp`,rt(r));if(r===`official-mcp`){let e=De(t.dataDir);n(e)||t.log(`${e} 现在还不存在:先跑 setup --feature mcp --apply 把官方 server 装进托管 venv;在那之前这条条目连不上(failOnStartupError: true 会让宿主把这条报成红)。`)}return Ou(e)?(await ju(l,c.text),t.log(`wrote ${l}`),t.log(`profile 不会被这条命令改写:把这段并进 <profile>/cordis.patch.yml,再重启宿主。`),0):(t.log(ku(e,{suppressed:`只打印条目,不写 ${l}`,missingApply:`dry-run; add --apply to write ${l}`})),0)}function Nu(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`)}function Pu(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(fu,``).trim()}function $(e,t){let n=RegExp(`^[\\t ]*(?:-[\\t ]+)?${Nu(t)}:(?<value>[^\\r\\n]*)$`,`u`);return e.split(du).filter(e=>!e.trimStart().startsWith(`#`)).map(e=>Pu(n.exec(e)?.groups?.value??``)).filter(e=>e!==``).at(-1)}function Fu(e,t){return $(e,t)!==void 0}function Iu(e,t){let n=$(e,t);return n===`true`||n===`True`||n===`TRUE`}function Lu(e){return!e.includes(`/`)&&!e.includes(`\\`)?{value:e,relative:!1}:{value:g.resolve(e),relative:!g.isAbsolute(e)}}async function Ru(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 nt(t),r=$(n.patchText,`pythonBin`)??``,i=$(n.patchText,`dataDir`)??``,a=Lu(r),o=Lu(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 zu(e,t){let{profile:n,pythonBin:r,dataDirOverride:i}=await Ru(e),a=i??t.dataDir,o=Sl({pythonBin:r,dataDir:a,repoRoot:t.repoRoot}),s=await Xl(a),c=await au(a);return t.log(JSON.stringify({dataDir:a,profile:n,runtime:o,packs:c,state:s},null,2)),0}const Bu={tavily:`tavilyApiKey`,brave:`braveApiKey`,serper:`serperApiKey`,searxng:`searxngEndpoint`};function Vu(e){return e===void 0||st(e)?[]:[{code:`SEARCH_BACKEND_INVALID`,detail:`searchBackend=${e} 不是本包实现的后端:可写的取值是 ${ot.join(` / `)},删掉这一行即回到 auto。`}]}function Hu(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 Uu(e,t){let n=$(e,`searchProvider`),r=$(e,`searchBackend`),i=r??`auto`,a=Iu(e,`searchPublicFallback`),o=Fu(e,`tavilyApiKey`),s=Fu(e,`searxngEndpoint`),c=i===`auto`&&!o&&!s&&!a,l=i===`auto`?void 0:Bu[i],u=l!==void 0&&!Fu(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(...Vu(r)),d&&t!==`ready`&&p.push({code:`WEB_PROVIDER_CONFIGURED_UNAVAILABLE`,detail:Hu(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 Wu(e,t){let n=wu(e);if(n===null)return t.log(Eu(e)),2;let r=Q(e,`profile`);if(r===void 0)return t.log(`doctor 要 --profile <目录>:判据来自那份 profile 自己写下的 cordis.patch.yml。`),2;let i=Cu(e);if(i.invalid)return t.log(`--port 要写 1 到 65535 之间的整数;现在给的是 ${String(Q(e,`port`))}`),2;let a=await nt(r),o=await au($(a.patchText,`dataDir`)??t.dataDir),s=Ye({mode:n,expectedPort:i.port,...a}),c=Uu(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 Gu(e,t){let n=e.get(`uninstall`);if(typeof n!=`string`||!yu(n))return t.log(Du(`uninstall`,e)),2;let r=e.has(`purge`);return t.log(`uninstall ${n}${r?` (and purge user data)`:``} from ${g.join(t.dataDir,`runtime`)}`),Ou(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(ku(e,{suppressed:`只打印计划,不删任何 runtime 文件`,missingApply:`dry-run; add --apply to uninstall`})),0)}function Ku(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}`,`落地位置:${g.join(t.dataDir,`runtime`)}(Python 在 runtime/python/,wheel 在 runtime/venv/)`].join(`
125
125
  `)}async function qu(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 Ju(e,t){let n=e.get(`feature`);if(typeof n!=`string`||!yu(n))return t.log(Du(`feature`,e)),2;let r=Q(e,`offline`);return r===``?(t.log(`--offline 要给一个资产目录`),2):(t.log(Ku(n,t)),r!==void 0&&t.log(`离线资产目录:${r}`),Ou(e)?(await qu(n,t,e.has(`repair`),r),t.log(`installed ${n}`),0):(t.log(ku(e,{suppressed:`只打印计划,不下载也不写 runtime`,missingApply:`dry-run; add --apply to install`})),0))}function Yu(e,t){return t.log(e instanceof Z||e instanceof Ee?`${e.code}: ${e.message}`:`command failed: ${String(e)}`),1}async function Xu(e,t={}){let n=Su(t),r=xu(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 Wu(i,n):i.has(`status`)?await zu(i,n):i.has(`mode`)?await Mu(i,n):i.has(`uninstall`)?await Gu(i,n):await Ju(i,n)}catch(e){return Yu(e,n)}}try{process.exitCode=await Xu(process.argv.slice(2))}catch(e){console.error(`command failed: ${String(e)}`),process.exitCode=1}export{};