eve 0.54.2 → 0.54.4

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  3. package/dist/src/cli/commands/init-project.d.ts +46 -0
  4. package/dist/src/cli/commands/init-project.js +1 -0
  5. package/dist/src/cli/commands/init-self-modification.d.ts +7 -0
  6. package/dist/src/cli/commands/init-self-modification.js +1 -0
  7. package/dist/src/cli/commands/init-target.js +2 -2
  8. package/dist/src/cli/commands/init-telemetry.d.ts +6 -0
  9. package/dist/src/cli/commands/init-telemetry.js +1 -0
  10. package/dist/src/cli/commands/init.d.ts +3 -0
  11. package/dist/src/cli/commands/init.js +1 -1
  12. package/dist/src/cli/dev/tui/setup-commands.js +1 -1
  13. package/dist/src/cli/telemetry/index.d.ts +1 -1
  14. package/dist/src/compiled/.vendor-stamp.json +8 -6
  15. package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
  16. package/dist/src/compiled/@ai-sdk/google/index.js +7 -7
  17. package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
  18. package/dist/src/compiled/@ai-sdk/openai/index.js +4 -4
  19. package/dist/src/compiled/@opentelemetry/api/index.d.ts +2 -0
  20. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +26 -0
  21. package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +41 -0
  22. package/dist/src/compiled/@workflow/core/index.js +2 -2
  23. package/dist/src/compiled/@workflow/core/replay-divergence.d.ts +25 -0
  24. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +75 -1
  25. package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +30 -8
  26. package/dist/src/compiled/@workflow/core/runtime/quickjs-log-view.d.ts +129 -0
  27. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +2 -21
  28. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +0 -22
  29. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  30. package/dist/src/compiled/@workflow/core/serialization.d.ts +2 -2
  31. package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +2 -0
  32. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +36 -0
  33. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  34. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  35. package/dist/src/compiled/@workflow/world/analytics.d.ts +23 -23
  36. package/dist/src/compiled/@workflow/world/events.d.ts +4 -2
  37. package/dist/src/compiled/@workflow/world/queue.d.ts +84 -0
  38. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  39. package/dist/src/compiled/@workflow/world-vercel/index.js +18 -13
  40. package/dist/src/compiled/_chunks/workflow/attribute-changes-BAcgmlXp.js +20 -0
  41. package/dist/src/compiled/_chunks/workflow/coerce-ro2dOxbr.js +1 -0
  42. package/dist/src/compiled/_chunks/workflow/dist-KPieTJHT.js +25 -0
  43. package/dist/src/compiled/_chunks/workflow/dist-PLkAQ-U7.js +2 -0
  44. package/dist/src/compiled/_chunks/workflow/frames-BvATzM2t.js +3 -0
  45. package/dist/src/compiled/_chunks/workflow/{functions-C02-JHBK.js → functions-wMCGZAVk.js} +1 -1
  46. package/dist/src/compiled/_chunks/workflow/resume-hook-BEHe0Uut.js +1 -0
  47. package/dist/src/compiled/_chunks/workflow/run-ChHLjaCt.js +1 -0
  48. package/dist/src/compiled/_chunks/workflow/schemas-DR7NTzNe.js +50 -0
  49. package/dist/src/compiled/_chunks/workflow/sleep-BB2HuVie.js +1 -0
  50. package/dist/src/compiled/_chunks/workflow/{wrapper-BxECO5nh.js → wrapper-CKui_eTd.js} +2 -2
  51. package/dist/src/compiled/_chunks/workflow/ws-transport-CVezyWwZ.js +1 -0
  52. package/dist/src/compiled/just-secrets/LICENSE +21 -0
  53. package/dist/src/compiled/just-secrets/index.d.ts +20 -0
  54. package/dist/src/compiled/just-secrets/index.js +2 -0
  55. package/dist/src/compiled/just-secrets/windows.ps1 +138 -0
  56. package/dist/src/compiler/extension-compatibility.d.ts +12 -12
  57. package/dist/src/compiler/extension-compatibility.js +1 -1
  58. package/dist/src/compiler/normalize-manifest-helpers.d.ts +2 -1
  59. package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
  60. package/dist/src/compiler/normalize-manifest.js +1 -1
  61. package/dist/src/compiler/resolve-workspace-subagent.d.ts +13 -0
  62. package/dist/src/compiler/resolve-workspace-subagent.js +1 -0
  63. package/dist/src/context/dynamic-model-lifecycle.d.ts +0 -6
  64. package/dist/src/context/dynamic-model-lifecycle.js +1 -1
  65. package/dist/src/context/dynamic-resolve-context.js +1 -1
  66. package/dist/src/context/effective-model.d.ts +5 -0
  67. package/dist/src/context/effective-model.js +1 -0
  68. package/dist/src/context/keys.d.ts +2 -0
  69. package/dist/src/context/keys.js +1 -1
  70. package/dist/src/dynamic/definition.d.ts +4 -0
  71. package/dist/src/eve-channel/index.js +1 -1
  72. package/dist/src/eve-channel/types.d.ts +9 -7
  73. package/dist/src/execution/durable-session-migrations/snapshot.d.ts +0 -16
  74. package/dist/src/execution/durable-session-migrations/snapshot.js +1 -1
  75. package/dist/src/execution/eve-workflow-attributes.d.ts +1 -1
  76. package/dist/src/execution/run-session-limits.js +1 -1
  77. package/dist/src/execution/session.js +1 -1
  78. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  79. package/dist/src/execution/workflow-steps.js +1 -1
  80. package/dist/src/harness/compaction.js +1 -1
  81. package/dist/src/harness/messages.d.ts +1 -1
  82. package/dist/src/harness/messages.js +1 -1
  83. package/dist/src/harness/step-hooks.d.ts +16 -10
  84. package/dist/src/harness/step-hooks.js +1 -1
  85. package/dist/src/harness/tool-loop.js +2 -2
  86. package/dist/src/instrumentation/parent-lineage.js +1 -1
  87. package/dist/src/internal/application/package.js +1 -1
  88. package/dist/src/internal/nitro/routes/index.d.ts +6 -0
  89. package/dist/src/internal/nitro/routes/index.js +7 -7
  90. package/dist/src/internal/vercel/assemble-eve-services.js +1 -1
  91. package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
  92. package/dist/src/internal/vercel/build-multi-agent-landing-page.d.ts +3 -0
  93. package/dist/src/internal/vercel/build-multi-agent-landing-page.js +1 -0
  94. package/dist/src/internal/vercel/eve-service-contribution.d.ts +4 -0
  95. package/dist/src/internal/vercel/eve-service-contribution.js +1 -1
  96. package/dist/src/internal/vercel/vercel-services-config.js +1 -1
  97. package/dist/src/protocol/baggage.d.ts +6 -0
  98. package/dist/src/protocol/baggage.js +1 -1
  99. package/dist/src/protocol/traceparent.d.ts +13 -0
  100. package/dist/src/protocol/traceparent.js +1 -1
  101. package/dist/src/public/definitions/workspace-agent.d.ts +25 -0
  102. package/dist/src/public/definitions/workspace-agent.js +1 -0
  103. package/dist/src/public/index.d.ts +1 -0
  104. package/dist/src/public/index.js +1 -1
  105. package/dist/src/public/models/openai/chatgpt/codex-app-server.d.ts +41 -0
  106. package/dist/src/public/models/openai/chatgpt/codex-app-server.js +1 -0
  107. package/dist/src/public/models/openai/chatgpt/credential-store.d.ts +26 -4
  108. package/dist/src/public/models/openai/chatgpt/credential-store.js +1 -1
  109. package/dist/src/public/models/openai/chatgpt/oauth.d.ts +6 -4
  110. package/dist/src/public/models/openai/chatgpt/token-broker.d.ts +7 -7
  111. package/dist/src/public/models/openai/chatgpt/token-broker.js +1 -1
  112. package/dist/src/public/models/openai/chatgpt/token.d.ts +13 -0
  113. package/dist/src/public/models/openai/chatgpt/token.js +1 -0
  114. package/dist/src/public/models/openai/chatgpt/transport.d.ts +2 -1
  115. package/dist/src/public/models/openai/index.d.ts +3 -2
  116. package/dist/src/public/vercel/index.d.ts +50 -0
  117. package/dist/src/public/vercel/index.js +1 -0
  118. package/dist/src/self-modification/setup.js +7 -2
  119. package/dist/src/setup/flows/chatgpt-auth.d.ts +2 -1
  120. package/dist/src/setup/flows/chatgpt-auth.js +1 -1
  121. package/dist/src/setup/flows/model.d.ts +0 -2
  122. package/dist/src/setup/flows/model.js +1 -1
  123. package/dist/src/setup/scaffold/create/project.js +1 -1
  124. package/dist/src/subagents/remote-dispatch.d.ts +3 -1
  125. package/dist/src/subagents/remote-dispatch.js +1 -1
  126. package/dist/src/tracing/agent-otel-attributes.js +1 -1
  127. package/dist/src/tracing/agent-otel-runtime-context.js +1 -1
  128. package/docs/agent-config.md +3 -3
  129. package/docs/guides/deployment/vercel.mdx +52 -1
  130. package/docs/guides/dynamic-capabilities.md +19 -7
  131. package/docs/guides/instrumentation-providers.md +1 -1
  132. package/docs/guides/instrumentation.md +25 -6
  133. package/docs/guides/remote-agents.md +5 -5
  134. package/docs/reference/cli.md +2 -2
  135. package/docs/reference/telemetry.md +1 -1
  136. package/docs/reference/typescript-api.md +14 -7
  137. package/docs/subagents/index.mdx +31 -0
  138. package/package.json +13 -6
  139. package/dist/src/compiled/_chunks/workflow/attribute-changes-C6H-fRVP.js +0 -20
  140. package/dist/src/compiled/_chunks/workflow/dist-DDeH-1ER.js +0 -40
  141. package/dist/src/compiled/_chunks/workflow/dist-DhncQSl7.js +0 -74
  142. package/dist/src/compiled/_chunks/workflow/frames-DsEqSDes.js +0 -3
  143. package/dist/src/compiled/_chunks/workflow/resume-hook-BRDLAb67.js +0 -1
  144. package/dist/src/compiled/_chunks/workflow/run-BM2OFphk.js +0 -1
  145. package/dist/src/compiled/_chunks/workflow/sleep-6cG0F99-.js +0 -1
  146. package/dist/src/compiled/_chunks/workflow/ws-transport-DuK82LLz.js +0 -1
@@ -1,74 +0,0 @@
1
- import{AISDKError as e,APICallError as t,EmptyResponseBodyError as n,InvalidArgumentError as r,InvalidResponseDataError as i,JSONParseError as a,LoadAPIKeyError as o,NoSuchProviderReferenceError as s,TypeValidationError as c,UnsupportedFunctionalityError as l,getErrorMessage as u}from"../../@ai-sdk/provider/index.js";function d(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 f(e,t=`|`){return e.map(e=>ue(e)).join(t)}function p(e,t){return typeof t==`bigint`?t.toString():t}function m(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function h(e){return e==null}function ee(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function te(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}const ne=Symbol(`evaluating`);function re(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ne)return r===void 0&&(r=ne,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function g(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ie(e){return JSON.stringify(e)}function ae(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const oe=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const se=m(()=>{if(M.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function y(e){if(v(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return v(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ce(e){return y(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const le=new Set([`string`,`number`,`symbol`]);function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function x(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function S(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 ue(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function de(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const fe={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pe(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`);return x(e,_(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&g(e,r,n.shape[r])}return g(this,`shape`,e),e},checks:[]}))}function me(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`);return x(e,_(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return g(this,`shape`,r),r},checks:[]}))}function he(e,t){if(!y(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;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 x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return g(this,`shape`,n),n}}))}function ge(e,t){if(!y(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return g(this,`shape`,n),n}}))}function _e(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.`);return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return g(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ve(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`);return x(t,_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return g(this,`shape`,i),i},checks:[]}))}function ye(e,t,n){return x(t,_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return g(this,`shape`,i),i}}))}function C(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 be(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 w(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function T(e){return typeof e==`string`?e:e?.message}function xe(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function E(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:T(e.inst?._zod.def?.error?.(e))??T(a?.(e))??T(t?.error?.(e))??T(n.customError?.(e))??T(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}const Se=/[\uD800-\uDBFF]/;function Ce(e){let t=e.length;if(!Se.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 we(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Te(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 Ee(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function De(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ke(e,n,r.value)}}function D(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Oe(e,t,n){return D(e,t,n,!1)}function ke(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:D(this,t,n.bind(this))},set(e){D(this,t,e)}})}function Ae(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let je,O=!1;const Me={configurable:!0,get(){O=!0}};function k(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&je!==e._zod){je=void 0;return}je=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Me);let e=O;O=!1;try{let r=n(this);return O?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),O||=e,r}catch(n){throw delete this[t],O||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Ne(e,t,n,r){let i=Ae(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 Pe(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Fe;const Ie=Object.freeze({status:`aborted`}),Le={value:void 0,enumerable:!1};let Re=`captureStackTrace`in Error?Error:null;function ze(e){let t=Re;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Re=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function A(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Le.value=new a(r);try{Object.defineProperty(n,"_zod",Le)}finally{Le.value=void 0}}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),De(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?ze(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var j=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Be=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Fe=globalThis).__zod_globalConfig??(Fe.__zod_globalConfig={});const M=globalThis.__zod_globalConfig;function N(e){return e&&Object.assign(M,e),M}function Ve(){let e=this._zod;return e.message??=JSON.stringify(e.def,p,2),e.message}function He(e){this._zod.message=e}const Ue={get:Ve,set:He,enumerable:!0,configurable:!0},We={value:void 0,enumerable:!1},Ge={value:void 0,enumerable:!1},Ke=new WeakSet([Object.prototype,Error.prototype]),qe=(e,t)=>{e.name=`$ZodError`,We.value=e._zod,Object.defineProperty(e,"_zod",We),Ge.value=t,Object.defineProperty(e,"issues",Ge),We.value=void 0,Ge.value=void 0,Object.defineProperty(e,"message",Ue);let n=Object.getPrototypeOf(e);Ke.has(n)||(Ke.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})}}))},Je=A(`$ZodError`,qe),Ye=A(`$ZodError`,qe,void 0,{Parent:Error});function Xe(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 Ze(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Xe(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Qe(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 $e(e,t){return{callee:t?.callee??e,Err:t?.Err}}const et=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new j;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>E(e,o,N())));throw oe(n,a?.callee??t),n}return s.value};return t},tt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>E(e,o,N())));throw oe(n,a?.callee??t),n}return s.value};return t},nt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new j;return a.issues.length?{success:!1,error:new(e??Je)(a.issues.map(e=>E(e,i,N())))}:{success:!0,data:a.value}},rt=nt(Ye),it=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?{success:!1,error:new e(a.issues.map(e=>E(e,i,N())))}:{success:!0,data:a.value}},at=it(Ye),ot=e=>{let t=et(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,$e(n,a))};return n},st=e=>{let t=et(e),n=(e,r,i,a)=>t(e,r,i,$e(n,a));return n},ct=e=>{let t=tt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,$e(n,a))};return n},lt=e=>{let t=tt(e),n=async(e,r,i,a)=>await t(e,r,i,$e(n,a));return n},ut=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return nt(e)(t,n,i)},dt=e=>(t,n,r)=>nt(e)(t,n,r),ft=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return it(e)(t,n,i)},pt=e=>async(t,n,r)=>it(e)(t,n,r),mt=/^[cC][0-9a-z]{6,}$/,ht=/^[0-9a-z]+$/,gt=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_t=/^[0-9a-vA-V]{20}$/,vt=/^[A-Za-z0-9]{27}$/,yt=/^[a-zA-Z0-9_-]{21}$/;function bt(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const xt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,St=/^([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})$/,Ct=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)$/,wt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Tt(){return RegExp(`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const Et=/^(?:(?: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])$/,Dt=/^(([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}|:))$/,Ot=/^((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])$/,kt=/^(([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])$/,At=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jt=/^[A-Za-z0-9_-]*$/,Mt=/^https?$/,Nt=/^\+[1-9]\d{6,14}$/,Pt=`(?:(?:\\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 Ft(e){return RegExp(`^${e}$`)}const It=Ft(Pt);function Lt(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 Rt(e){return RegExp(`^${Lt(e)}$`)}function zt(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Lt({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Lt({precision:e.precision})}`:n;return RegExp(`^${Pt}T(?:${r})$`)}const Bt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Vt=/^-?\d+$/,Ht=/^-?\d+(?:\.\d+)?$/,Ut=/^(?:true|false)$/i,Wt=/^null$/i,Gt=/^[^A-Z]*$/,Kt=/^[^a-z]*$/,P=A(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qt=e=>{let t=e.value;return!h(t)&&t.length!==void 0},Jt={number:`number`,bigint:`bigint`,object:`date`},Yt=A(`$ZodCheckLessThan`,(e,t)=>{P.init(e,t);let n=Jt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Jt[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})}}),Xt=A(`$ZodCheckGreaterThan`,(e,t)=>{P.init(e,t);let n=Jt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Jt[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})}}),Zt=A(`$ZodCheckMultipleOf`,(e,t)=>{P.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),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):te(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})}}),Qt=A(`$ZodCheckNumberFormat`,(e,t)=>{P.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=fe[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Vt)}),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})}}),$t=A(`$ZodCheckMaxLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=qt),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ce(r):i)<=t.maximum)return;let a=we(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),en=A(`$ZodCheckMinLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=qt),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ce(r):i)>=t.minimum)return;let a=we(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),tn=A(`$ZodCheckLengthEquals`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=qt),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ce(r):i;if(a===t.length)return;let o=we(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})}}),nn=A(`$ZodCheckStringFormat`,(e,t)=>{var n,r;P.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),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=()=>{})}),rn=A(`$ZodCheckRegex`,(e,t)=>{nn.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})}}),an=A(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Gt,nn.init(e,t)}),on=A(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Kt,nn.init(e,t)}),sn=A(`$ZodCheckIncludes`,(e,t)=>{P.init(e,t);let n=b(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),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})}}),cn=A(`$ZodCheckStartsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`^${b(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(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})}}),ln=A(`$ZodCheckEndsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`.*${b(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(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})}}),un=A(`$ZodCheckOverwrite`,(e,t)=>{P.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var dn=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
- `).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(`
3
- `)}\n};`)(...Object.values(this.closed))}};const fn={major:4,minor:5,patch:4},F=A(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=fn;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=C(t),a;for(let o of n){if(o._zod.def.when){if(be(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new j;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(xe(t.issues,n,e),i||=C(t,n))});else{if(t.issues.length===n)continue;xe(t.issues,n,e),i||=C(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(C(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new j;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new j;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Oe(this,`~standard`,mn(this))},set"~standard"(e){D(this,`~standard`,e)}}),pn=e=>e.success?{value:e.data}:{issues:e.error?.issues};function mn(e){return{validate:t=>{try{return pn(rt(e,t))}catch{return at(e,t).then(pn)}},vendor:`zod`,version:1}}const hn=A(`$ZodString`,(e,t)=>{F.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Bt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),I=A(`$ZodStringFormat`,(e,t)=>{nn.init(e,t),hn.init(e,t)}),gn=A(`$ZodGUID`,(e,t)=>{t.pattern??=St,I.init(e,t)}),_n=A(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ct(e)}else t.pattern??=Ct();I.init(e,t)}),vn=A(`$ZodEmail`,(e,t)=>{t.pattern??=wt,I.init(e,t)});function yn(e,t){if(!t.normalize&&t.protocol?.source===Mt.source&&!/^https?:\/\//i.test(e))return 1;try{return new URL(e)}catch{return 2}}const bn=/[\t\n\r]/g;function xn(e){return e.replace(bn,``)}function Sn(e,t){return t.lastIndex=0,t.test(e.hostname)}function Cn(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const wn=A(`$ZodURL`,(e,t)=>{I.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=yn(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}t.hostname&&!Sn(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&&!Cn(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:xn(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Tn=A(`$ZodEmoji`,(e,t)=>{t.pattern??=Tt(),I.init(e,t)}),En=A(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?yt:bt(t.length),I.init(e,t)}),Dn=A(`$ZodCUID`,(e,t)=>{t.pattern??=mt,I.init(e,t)}),On=A(`$ZodCUID2`,(e,t)=>{t.pattern??=ht,I.init(e,t)}),kn=A(`$ZodULID`,(e,t)=>{t.pattern??=gt,I.init(e,t)}),An=A(`$ZodXID`,(e,t)=>{t.pattern??=_t,I.init(e,t)}),jn=A(`$ZodKSUID`,(e,t)=>{t.pattern??=vt,I.init(e,t)}),Mn=A(`$ZodISODateTime`,(e,t)=>{t.pattern??=zt(t),I.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(e=>{e._zod.bag.laxFormat=!0}))}),Nn=A(`$ZodISODate`,(e,t)=>{t.pattern??=It,I.init(e,t)}),Pn=A(`$ZodISOTime`,(e,t)=>{t.pattern??=Rt(t),I.init(e,t)}),Fn=A(`$ZodISODuration`,(e,t)=>{t.pattern??=xt,I.init(e,t)}),In=A(`$ZodIPv4`,(e,t)=>{t.pattern??=Et,I.init(e,t),e._zod.bag.format=`ipv4`}),Ln=/^[0-9a-fA-F:.]+$/;function Rn(e){if(!Ln.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const zn=A(`$ZodIPv6`,(e,t)=>{t.pattern??=Dt,I.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{Rn(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Bn=A(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ot,I.init(e,t)});function Vn(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:Rn(n)}const Hn=A(`$ZodCIDRv6`,(e,t)=>{t.pattern??=kt,I.init(e,t),e._zod.check=n=>{Vn(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Un(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Wn=A(`$ZodBase64`,(e,t)=>{t.pattern??=At,I.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Un(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Gn(e){if(!jt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Un(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Kn=A(`$ZodBase64URL`,(e,t)=>{t.pattern??=jt,I.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Gn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),qn=A(`$ZodE164`,(e,t)=>{t.pattern??=Nt,I.init(e,t)});function Jn(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 Yn=A(`$ZodJWT`,(e,t)=>{I.init(e,t),e._zod.check=n=>{Jn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Xn=A(`$ZodNumber`,(e,t)=>{F.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ht,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}}),Zn=A(`$ZodNumberFormat`,(e,t)=>{Qt.init(e,t),Xn.init(e,t)}),Qn=A(`$ZodBoolean`,(e,t)=>{F.init(e,t),e._zod.pattern=Ut,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),$n=A(`$ZodNull`,(e,t)=>{F.init(e,t),e._zod.pattern=Wt,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),er=A(`$ZodAny`,(e,t)=>{F.init(e,t),e._zod.parse=e=>e}),tr=A(`$ZodUnknown`,(e,t)=>{F.init(e,t),e._zod.parse=e=>e}),nr=A(`$ZodNever`,(e,t)=>{F.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function rr(e,t,n){e.issues.length&&t.issues.push(...w(n,e.issues)),t.value[n]=e.value}const ir=A(`$ZodArray`,(e,t)=>{F.init(e,t);let n=M.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[];for(let e=0;e<a.length;e++){let n=a[e],s=t.element._zod.run({value:n,issues:[]},i);s instanceof Promise?o.push(s.then(t=>rr(t,r,e))):rr(s,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function ar(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(...w(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}}const or=[];function sr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:or,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=de(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function cr(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin,d=c.optout;for(let i in t){if(s.has(i))continue;if(i===`__proto__`){l===`never`&&o.push(i);continue}if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ar(e,n,i,t,u,d))):ar(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const lr=new WeakMap,ur=A(`$ZodObject`,(e,t)=>{if(F.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;lr.set(t,e),Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),lr.set(t,n),n}})}let n=m(()=>sr(t));k(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||g(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let r=v,i=t.catchall,a,o=M.memoizer;o?.attach(e),e._zod.parse=(t,s)=>{a??=n.value;let c=t.value;if(!r(c))return t.issues.push({expected:`object`,code:`invalid_type`,input:c,inst:e}),t;t.value=o?o.alloc(e,t,{},s):{};let l=[],u=a.shape;for(let e of a.allKeys){if(e===`__proto__`)continue;let n=u[e],r=n._zod.optin,i=n._zod.optout,a=n._zod.run({value:c[e],issues:[]},s);a instanceof Promise?l.push(a.then(n=>ar(n,t,e,c,r,i))):ar(a,t,e,c,r,i)}return i?cr(l,c,t,s,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),dr=A(`$ZodObjectJIT`,(e,t)=>{ur.init(e,t);let n=e._zod.parse,r=m(()=>sr(t)),i=M.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new dn([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
4
- for (let i = 0; i < ${e}.issues.length; i++) {
5
- const iss = ${e}.issues[i];
6
- iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
7
- payload.issues.push(iss);
8
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:ie(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
9
- const ${n}_present = ${i};
10
- if (!${n}.issues.length || ${n}_present) {
11
- if (${n}.issues.length) {${c(n,r)}
12
- }
13
-
14
- if (${e}) {
15
- newResult[${r}] = ${n}.value;
16
- }
17
- }
18
-
19
- `)}else f?o.write(`
20
- if (${n}.issues.length) {${c(n,r)}
21
- }
22
-
23
- if (${n}.value === undefined) {
24
- if (${i}) {
25
- newResult[${r}] = undefined;
26
- }
27
- } else {
28
- newResult[${r}] = ${n}.value;
29
- }
30
-
31
- `):o.write(`
32
- const ${n}_present = ${i};
33
- if (${n}.issues.length) {${c(n,r)}
34
- }
35
- if (!${n}_present && !${n}.issues.length) {
36
- payload.issues.push({
37
- code: "invalid_type",
38
- expected: "nonoptional",
39
- input: undefined,
40
- path: [${r}]
41
- });
42
- }
43
-
44
- if (${n}_present) {
45
- newResult[${r}] = ${n}.value;
46
- }
47
-
48
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=v,c=!M.jitless,l=c&&se.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?cr([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function fr(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=>!C(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>E(e,r,N())))}),t)}const pr=A(`$ZodUnion`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),k(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),k(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),k(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ee(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=>fr(t,r,e,i)):fr(o,r,e,i)}}),mr=A(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,pr.init(e,t);let n=e._zod.parse;k(e,`propValues`,e=>{let t={};for(let n of e.def.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(n)}"`);for(let[e,n]of Object.entries(r)){Object.prototype.hasOwnProperty.call(t,e)||g(t,e,new Set);for(let r of n)t[e].add(r)}}return t}),t.options.forEach((e,n)=>{let r=lr.get(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=m(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!v(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),hr=A(`$ZodIntersection`,(e,t)=>{F.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>_r(e,t,n)):_r(e,i,a)}});function gr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(y(e)&&y(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=gr(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=gr(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 _r(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=gr(t.value,n.value);if(!c.valid){if(C(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const vr=A(`$ZodTuple`,(e,t)=>{F.init(e,t);let n=t.items,r=M.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=yr(n,`optin`),l=yr(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):u[e]=t}if(t.rest){let e=n.length-1,r=o.slice(n.length);for(let n of r){e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>br(t,i,e))):br(r,i,e)}}return s.length?Promise.all(s).then(()=>xr(u,i,n,o,l)):xr(u,i,n,o,l)}});function yr(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function br(e,t,n){e.issues.length&&t.issues.push(...w(n,e.issues)),t.value[n]=e.value}function xr(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...w(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}const Sr=A(`$ZodRecord`,(e,t)=>{F.init(e,t);let n=M.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!y(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>E(e,i,N())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...w(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...w(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`&&Ht.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>E(e,i,N())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...w(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...w(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}}),Cr=A(`$ZodEnum`,(e,t)=>{F.init(e,t);let n=d(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>le.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>b(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}}),wr=A(`$ZodLiteral`,(e,t)=>{F.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?b(e):e?b(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}}),Tr=A(`$ZodTransform`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,M.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Be(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new j;return n.value=i,n}});function Er(e,t){return e.value=t.issues.length?void 0:t.value,e}const Dr=A(`$ZodOptional`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,k(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),k(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ee(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=>Er(e,t)):Er(e,r)}return t.innerType._zod.run(e,n)}}),Or=A(`$ZodExactOptional`,(e,t)=>{Dr.init(e,t),k(e,`values`,e=>e.def.innerType._zod.values),k(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),kr=A(`$ZodNullable`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.innerType._zod.optin),k(e,`optout`,e=>e.def.innerType._zod.optout),k(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ee(t.source)}|null)$`):void 0}),k(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ar=A(`$ZodDefault`,(e,t)=>{F.init(e,t),e._zod.optin=`defaulted`,k(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>jr(e,t)):jr(r,t)}});function jr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Mr=A(`$ZodPrefault`,(e,t)=>{F.init(e,t),e._zod.optin=`defaulted`,k(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Nr=A(`$ZodNonOptional`,(e,t)=>{F.init(e,t),k(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Pr(t,e)):Pr(i,e)}});function Pr(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 Fr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>E(e,r,N()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Ir=A(`$ZodCatch`,(e,t)=>{F.init(e,t),k(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),k(e,`optout`,e=>e.def.innerType._zod.optout),k(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Fr(e,r,t,n)):Fr(e,r,t,n)}}),Lr=A(`$ZodPipe`,(e,t)=>{F.init(e,t),k(e,`values`,e=>e.def.in._zod.values),k(e,`optin`,e=>e.def.in._zod.optin),k(e,`optout`,e=>e.def.out._zod.optout),k(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Rr(e,t.in,n)):Rr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Rr(e,t.out,n)):Rr(r,t.out,n)}});function Rr(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 zr=A(`$ZodReadonly`,(e,t)=>{F.init(e,t),k(e,`propValues`,e=>e.def.innerType._zod.propValues),k(e,`values`,e=>e.def.innerType._zod.values),k(e,`optin`,e=>e.def.innerType?._zod?.optin),k(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Br):Br(r)}});function Br(e){return e.memo||(e.value=Object.freeze(e.value)),e}const Vr=A(`$ZodLazy`,(e,t)=>{F.init(e,t),re(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),k(e,`pattern`,e=>e.innerType?._zod?.pattern),k(e,`propValues`,e=>e.innerType?._zod?.propValues),k(e,`optin`,e=>e.innerType?._zod?.optin??void 0),k(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Hr=A(`$ZodCustom`,(e,t)=>{P.init(e,t),F.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ur(t,n,r,e));Ur(i,n,r,e)}});function Ur(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(Ee(e))}}var Wr=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const Gr=`~memo`,Kr=[];function qr(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const Jr=new WeakMap;function Yr(e,t){let n=Jr.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&Yr(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);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 a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),Jr.set(e,r),r}function Xr(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let Zr;const Qr=[],$r={alloc(e,t,n){let r=Zr;if(!r)return n;Zr=void 0;let i={value:n,issues:null};return r.set(t.value,i),Qr.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`&&ti(n,e.value))throw new Wr;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=Yr(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[Gr];l||(l={buckets:new Map,backEdges:void 0},s[Gr]=l);let u;r===s?u=i:(u=Xr(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...qr(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;Zr=u;let f=Qr.length,p=t(o,s);Zr=void 0;let m=Qr.length>f?Qr.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?qr(e.issues):Kr),e)):(m&&(m.issues=p.issues.length?qr(p.issues):Kr),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function ei(){return $r}function ti(e,t){let n=e[Gr]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}const ni=()=>{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`,credit_card:`credit card number`,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(Te(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ue(e.values[0])}`:`Invalid option: expected one of ${f(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`:``}: ${f(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 ri(){return{localeError:ni()}}var ii,ai=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function oi(){return new ai}(ii=globalThis).__zod_globalRegistry??(ii.__zod_globalRegistry=oi());const si=globalThis.__zod_globalRegistry;function ci(e,t){return new e({type:`string`,...S(t)})}function li(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...S(t)})}function ui(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...S(t)})}function di(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...S(t)})}function fi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...S(t)})}function pi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...S(t)})}function mi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...S(t)})}function hi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...S(t)})}function gi(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...S(t)})}function _i(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...S(t)})}function vi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...S(t)})}function yi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...S(t)})}function bi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...S(t)})}function xi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...S(t)})}function Si(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...S(t)})}function Ci(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...S(t)})}function wi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...S(t)})}function Ti(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...S(t)})}function Ei(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...S(t)})}function Di(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...S(t)})}function Oi(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...S(t)})}function ki(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...S(t)})}function Ai(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...S(t)})}function ji(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...S(t)})}function Mi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...S(t)})}function Ni(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...S(t)})}function Pi(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...S(t)})}function Fi(e,t){return new e({type:`number`,checks:[],...S(t)})}function Ii(e,t){return new e({type:`number`,coerce:!0,checks:[],...S(t)})}function Li(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...S(t)})}function Ri(e,t){return new e({type:`boolean`,...S(t)})}function zi(e,t){return new e({type:`null`,...S(t)})}function Bi(e){return new e({type:`any`})}function Vi(e){return new e({type:`unknown`})}function Hi(e,t){return new e({type:`never`,...S(t)})}function Ui(e,t){return new Yt({check:`less_than`,...S(t),value:e,inclusive:!1})}function Wi(e,t){return new Yt({check:`less_than`,...S(t),value:e,inclusive:!0})}function Gi(e,t){return new Xt({check:`greater_than`,...S(t),value:e,inclusive:!1})}function Ki(e,t){return new Xt({check:`greater_than`,...S(t),value:e,inclusive:!0})}function qi(e,t){return new Zt({check:`multiple_of`,...S(t),value:e})}function Ji(e,t){return new $t({check:`max_length`,...S(t),maximum:e})}function Yi(e,t){return new en({check:`min_length`,...S(t),minimum:e})}function Xi(e,t){return new tn({check:`length_equals`,...S(t),length:e})}function Zi(e,t){return new rn({check:`string_format`,format:`regex`,...S(t),pattern:e})}function Qi(e){return new an({check:`string_format`,format:`lowercase`,...S(e)})}function $i(e){return new on({check:`string_format`,format:`uppercase`,...S(e)})}function ea(e,t){return new sn({check:`string_format`,format:`includes`,...S(t),includes:e})}function ta(e,t){return new cn({check:`string_format`,format:`starts_with`,...S(t),prefix:e})}function na(e,t){return new ln({check:`string_format`,format:`ends_with`,...S(t),suffix:e})}function L(e){return new un({check:`overwrite`,tx:e})}function ra(e){return L(t=>t.normalize(e))}function ia(){return L(e=>e.trim())}function aa(){return L(e=>e.toLowerCase())}function oa(){return L(e=>e.toUpperCase())}function sa(){return L(e=>ae(e))}function ca(e,t,n){return new e({type:`array`,element:t,...S(n)})}function la(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...S(n)})}function ua(e,t){let n=da(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ee(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(Ee(r))}},e(t.value,t)),t);return n}function da(e,t){let n=new P({check:`custom`,...S(t)});return n._zod.check=e,n}function fa(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&g(e,t,n[t]);return e}function pa(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??si,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function R(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function z(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,z(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&fa(o.schema,c),t.io===`input`&&B(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ma(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ha(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${ma(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+ma(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>
49
-
50
- 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);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function ga(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;ga(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 _a=new Set([`type`,`properties`,`required`,`additionalProperties`]),va=[`oneOf`,`anyOf`];function ya(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function ba(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!_a.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??ya(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}g(n,r,e.length===1?e[0]:ba(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=ya(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 xa(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of _a)if(t in e)return;let n=t.filter(e=>va.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=ba(t);else{let e=n[0],i=va.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=>ba([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,fa(e,r))}function Sa(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)):fa(i,s),fa(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())ga(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])xa(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)}fa(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,g(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:wa(t,`input`,e.processors),output:wa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function B(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return B(r.element,n);if(r.type===`set`)return B(r.valueType,n);if(r.type===`lazy`)return B(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return B(r.innerType,n);if(r.type===`intersection`)return B(r.left,n)||B(r.right,n);if(r.type===`record`||r.type===`map`)return B(r.keyType,n)||B(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:B(r.in,n)||B(r.out,n);if(r.type===`object`){for(let e in r.shape)if(B(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(B(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(B(e,n))return!0;return!!(r.rest&&B(r.rest,n))}return!1}const Ca=(e,t={})=>n=>{let r=pa({...n,processors:t});return z(e,r),ha(r,e),Sa(r,e)},wa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=pa({...i??{},target:a,io:t,processors:n});return z(e,o),ha(o,e),Sa(o,e)},Ta={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ea=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ta[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];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}))])}},Da=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):R(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},Oa=(e,t,n,r)=>{n.type=`boolean`},ka=(e,t,n,r)=>{R(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},Aa=(e,t,n,r)=>{R(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},ja=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Ma=(e,t,n,r)=>{R(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},Na=(e,t,n,r)=>{R(e,t,n,r,`Void cannot be represented in JSON Schema`)},Pa=(e,t,n,r)=>{n.not={}},Fa=(e,t,n,r)=>{},Ia=(e,t,n,r)=>{},La=(e,t,n,r)=>{R(e,t,n,r,`Date cannot be represented in JSON Schema`)},Ra=(e,t,n,r)=>{let i=e._zod.def,a=d(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},za=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(R(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(R(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Ba=(e,t,n,r)=>{R(e,t,n,r,`NaN cannot be represented in JSON Schema`)},Va=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},Ha=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},Ua=(e,t,n,r)=>{n.type=`boolean`},Wa=(e,t,n,r)=>{R(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ga=(e,t,n,r)=>{R(e,t,n,r,`Function types cannot be represented in JSON Schema`)},Ka=(e,t,n,r)=>{R(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},qa=(e,t,n,r)=>{R(e,t,n,r,`Map cannot be represented in JSON Schema`)},Ja=(e,t,n,r)=>{R(e,t,n,r,`Set cannot be represented in JSON Schema`)},Ya=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=z(a.element,t,{...r,path:[...r.path,`items`]})};function V(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?V(t.out):t.type===`catch`?V(t.innerType):e._zod.optin}const Xa=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&R(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)g(i.properties,e,z(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?V(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=z(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Za=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>z(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Qa=(e,t,n,r)=>{let i=e._zod.def,a=z(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=z(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},$a=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>z(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?z(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?V(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=e._zod.bag;typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function eo(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=eo(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=>eo(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`)?Ht:Vt).source),p):p}const to=new WeakMap;function no(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of to.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=eo(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const ro=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=z(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)g(i.patternProperties,t.source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=z(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=to.get(t);n||(n=[],to.set(t,n),t.deferred.push(()=>no(t))),n.push(e)}i.additionalProperties=z(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&V(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))}},io=(e,t,n,r)=>{let i=e._zod.def,a=z(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ao=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},oo=Symbol();function so(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(R(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),oo):JSON.parse(o)}const co=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=so(i.defaultValue,e,t,n,r);o!==oo&&(n.default=o)},lo=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=so(i.defaultValue,e,t,n,r);o!==oo&&(n._prefault=o)},uo=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{R(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},fo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;z(o,t,r);let s=t.seen.get(e);s.ref=o},po=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},mo=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ho=(e,t,n,r)=>{let i=e._zod.def;z(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},go=(e,t,n,r)=>{let i=e._zod.innerType;z(i,t,r);let a=t.seen.get(e);a.ref=i},_o={string:Ea,number:Da,boolean:Oa,bigint:ka,symbol:Aa,null:ja,undefined:Ma,void:Na,never:Pa,any:Fa,unknown:Ia,date:La,enum:Ra,literal:za,nan:Ba,template_literal:Va,file:Ha,success:Ua,custom:Wa,function:Ga,transform:Ka,map:qa,set:Ja,array:Ya,object:Xa,union:Za,intersection:Qa,tuple:$a,record:ro,nullable:io,nonoptional:ao,default:co,prefault:lo,catch:uo,pipe:fo,readonly:po,promise:mo,optional:ho,lazy:go};function vo(e,t){if(`_idmap`in e){let n=e,r=pa({...t,processors:_o}),i={};for(let e of n._idmap.entries()){let[t,n]=e;z(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;ha(r,n),g(a,t,Sa(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=pa({...t,processors:_o});return z(e,n),ha(n,e),Sa(n,e)}const yo=new WeakSet([Object.prototype,Error.prototype]);function bo(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 H=A(`ZodError`,(e,t)=>{Je.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);yo.has(n)||(yo.add(n),bo(n,`format`,e=>t=>Qe(e,t)),bo(n,`flatten`,e=>t=>Ze(e,t)),bo(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,p,2)}),bo(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,p,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),xo=et(H),So=tt(H),Co=nt(H),wo=it(H),To=ot(H),Eo=st(H),Do=ct(H),Oo=lt(H),ko=ut(H),Ao=dt(H),jo=ft(H),Mo=pt(H);function No(){M.localeError||N(ri())}function Po(){M.memoizer||N({memoizer:ei()})}const U=A(`ZodType`,(e,t)=>(No(),F.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(_(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 x(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(uc(e,t))},superRefine(e,t){return this.check(dc(e,t))},overwrite(e){return this.check(L(e))},optional(){return Ws(this)},exactOptional(){return Ks(this)},nullable(){return Js(this)},nullish(){return Ws(Js(this))},nonoptional(e){return ec(this,e)},array(){return Cs(this)},or(e){return Os([this,e])},and(e){return Ms(this,e)},transform(e){return ic(this,Hs(e))},default(e){return Xs(this,e)},prefault(e){return Qs(this,e)},catch(e){return nc(this,e)},pipe(e){return ic(this,e)},readonly(){return oc(this)},describe(e){let t=this.clone();return si.add(t,{description:e}),t},meta(...e){if(e.length===0)return si.get(this);let t=this.clone();return si.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 Oe(this,`~standard`,{...mn(this),jsonSchema:{input:wa(this,`input`),output:wa(this,`output`)}})},set"~standard"(e){D(this,`~standard`,e)},parse:function e(t,n){return xo(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await So(this,t,n,{callee:e})},safeParse(e,t){return Co(this,e,t)},async safeParseAsync(e,t){return wo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){D(this,`spa`,e)},encode:function e(t,n){return To(this,t,n,{callee:e})},decode:function e(t,n){return Eo(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Do(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Oo(this,t,n,{callee:e})},safeEncode(e,t){return ko(this,e,t)},safeDecode(e,t){return Ao(this,e,t)},async safeEncodeAsync(e,t){return jo(this,e,t)},async safeDecodeAsync(e,t){return Mo(this,e,t)},toJSONSchema(e){return Ca(this,{})(e)},get description(){return si.get(this)?.description},get _def(){return this._zod.def}}),Fo=A(`_ZodString`,(e,t)=>{hn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ea(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(Zi(...e))},includes(...e){return this.check(ea(...e))},startsWith(...e){return this.check(ta(...e))},endsWith(...e){return this.check(na(...e))},min(...e){return this.check(Yi(...e))},max(...e){return this.check(Ji(...e))},length(...e){return this.check(Xi(...e))},nonempty(...e){return this.check(Yi(1,...e))},lowercase(e){return this.check(Qi(e))},uppercase(e){return this.check($i(e))},trim(){return this.check(ia())},normalize(...e){return this.check(ra(...e))},toLowerCase(){return this.check(aa())},toUpperCase(){return this.check(oa())},slugify(){return this.check(sa())}}),Io=A(`ZodString`,(e,t)=>{hn.init(e,t),Fo.init(e,t)},{email(e){return this.check(li(Ho,e))},url(e){return this.check(hi(Go,e))},jwt(e){return this.check(Ai(ss,e))},emoji(e){return this.check(gi(Ko,e))},guid(e){return this.check(ui(Uo,e))},uuid(e){return this.check(di(Wo,e))},uuidv4(e){return this.check(fi(Wo,e))},uuidv6(e){return this.check(pi(Wo,e))},uuidv7(e){return this.check(mi(Wo,e))},nanoid(e){return this.check(_i(qo,e))},cuid(e){return this.check(vi(Jo,e))},cuid2(e){return this.check(yi(Yo,e))},ulid(e){return this.check(bi(Xo,e))},base64(e){return this.check(Di(rs,e))},base64url(e){return this.check(Oi(as,e))},xid(e){return this.check(xi(Zo,e))},ksuid(e){return this.check(Si(Qo,e))},ipv4(e){return this.check(Ci($o,e))},ipv6(e){return this.check(wi(es,e))},cidrv4(e){return this.check(Ti(ts,e))},cidrv6(e){return this.check(Ei(ns,e))},e164(e){return this.check(ki(os,e))},datetime(e){return this.check(ji(Ro,e))},date(e){return this.check(Mi(zo,e))},time(e){return this.check(Ni(Bo,e))},duration(e){return this.check(Pi(Vo,e))}});function Lo(e){return ci(Io,e)}const W=A(`ZodStringFormat`,(e,t)=>{I.init(e,t),Fo.init(e,t)}),Ro=A(`ZodISODateTime`,(e,t)=>{Mn.init(e,t),W.init(e,t)}),zo=A(`ZodISODate`,(e,t)=>{Nn.init(e,t),W.init(e,t)}),Bo=A(`ZodISOTime`,(e,t)=>{Pn.init(e,t),W.init(e,t)}),Vo=A(`ZodISODuration`,(e,t)=>{Fn.init(e,t),W.init(e,t)}),Ho=A(`ZodEmail`,(e,t)=>{vn.init(e,t),W.init(e,t)}),Uo=A(`ZodGUID`,(e,t)=>{gn.init(e,t),W.init(e,t)}),Wo=A(`ZodUUID`,(e,t)=>{_n.init(e,t),W.init(e,t)}),Go=A(`ZodURL`,(e,t)=>{wn.init(e,t),W.init(e,t)}),Ko=A(`ZodEmoji`,(e,t)=>{Tn.init(e,t),W.init(e,t)}),qo=A(`ZodNanoID`,(e,t)=>{En.init(e,t),W.init(e,t)}),Jo=A(`ZodCUID`,(e,t)=>{Dn.init(e,t),W.init(e,t)}),Yo=A(`ZodCUID2`,(e,t)=>{On.init(e,t),W.init(e,t)}),Xo=A(`ZodULID`,(e,t)=>{kn.init(e,t),W.init(e,t)}),Zo=A(`ZodXID`,(e,t)=>{An.init(e,t),W.init(e,t)}),Qo=A(`ZodKSUID`,(e,t)=>{jn.init(e,t),W.init(e,t)}),$o=A(`ZodIPv4`,(e,t)=>{In.init(e,t),W.init(e,t)}),es=A(`ZodIPv6`,(e,t)=>{zn.init(e,t),W.init(e,t)}),ts=A(`ZodCIDRv4`,(e,t)=>{Bn.init(e,t),W.init(e,t)}),ns=A(`ZodCIDRv6`,(e,t)=>{Hn.init(e,t),W.init(e,t)}),rs=A(`ZodBase64`,(e,t)=>{Wn.init(e,t),W.init(e,t)});function is(e){return Di(rs,e)}const as=A(`ZodBase64URL`,(e,t)=>{Kn.init(e,t),W.init(e,t)}),os=A(`ZodE164`,(e,t)=>{qn.init(e,t),W.init(e,t)}),ss=A(`ZodJWT`,(e,t)=>{Yn.init(e,t),W.init(e,t)}),cs=A(`ZodNumber`,(e,t)=>{Xn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Da(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(Gi(e,t))},gte(e,t){return this.check(Ki(e,t))},min(e,t){return this.check(Ki(e,t))},lt(e,t){return this.check(Ui(e,t))},lte(e,t){return this.check(Wi(e,t))},max(e,t){return this.check(Wi(e,t))},int(e){return this.check(ds(e))},safe(e){return this.check(ds(e))},positive(e){return this.check(Gi(0,e))},nonnegative(e){return this.check(Ki(0,e))},negative(e){return this.check(Ui(0,e))},nonpositive(e){return this.check(Wi(0,e))},multipleOf(e,t){return this.check(qi(e,t))},step(e,t){return this.check(qi(e,t))},finite(){return this}});function ls(e){return Fi(cs,e)}const us=A(`ZodNumberFormat`,(e,t)=>{Zn.init(e,t),cs.init(e,t)});function ds(e){return Li(us,e)}const fs=A(`ZodBoolean`,(e,t)=>{Qn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oa(e,t,n,r)});function ps(e){return Ri(fs,e)}const ms=A(`ZodNull`,(e,t)=>{$n.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ja(e,t,n,r)});function hs(e){return zi(ms,e)}const gs=A(`ZodAny`,(e,t)=>{er.init(e,t),U.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _s(){return Bi(gs)}const vs=A(`ZodUnknown`,(e,t)=>{tr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ys(){return Vi(vs)}const bs=A(`ZodNever`,(e,t)=>{nr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pa(e,t,n,r)});function xs(e){return Hi(bs,e)}const Ss=A(`ZodArray`,(e,t)=>{Po(),ir.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Yi(e,t))},nonempty(e){return this.check(Yi(1,e))},max(e,t){return this.check(Ji(e,t))},length(e,t){return this.check(Xi(e,t))},unwrap(){return this.element}});function Cs(e,t){return ca(Ss,e,t)}const ws=A(`ZodObject`,(e,t)=>{Po(),dr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r),Ne(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Rs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:ys()})},loose(){return this.clone({...this._zod.def,catchall:ys()})},strict(){return this.clone({...this._zod.def,catchall:xs()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return he(this,e)},safeExtend(e){return ge(this,e)},merge(e){return _e(this,e)},pick(e){return pe(this,e)},omit(e){return me(this,e)},partial(...e){return ve(Us,this,e[0])},exactPartial(...e){return ve(Gs,this,e[0],`exactPartial`)},required(...e){return ye($s,this,e[0])}});function Ts(e,t){let n={type:`object`,shape:e??{},...S(t)};return new ws(n)}function Es(e,t){return new ws({type:`object`,shape:e,catchall:ys(),...S(t)})}const Ds=A(`ZodUnion`,(e,t)=>{pr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r),e.options=t.options});function Os(e,t){return new Ds({type:`union`,options:e,...S(t)})}const ks=A(`ZodDiscriminatedUnion`,(e,t)=>{Ds.init(e,t),mr.init(e,t)});function As(e,t,n){return new ks({type:`union`,options:t,discriminator:e,...S(n)})}const js=A(`ZodIntersection`,(e,t)=>{hr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r)});function Ms(e,t){return new js({type:`intersection`,left:e,right:t})}const Ns=A(`ZodTuple`,(e,t)=>{Po(),vr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new Us({type:`optional`,innerType:e}))})}});function Ps(e,t,n){let r=t instanceof F;return new Ns({type:`tuple`,items:e,rest:r?t:null,...S(r?n:t)})}const Fs=A(`ZodRecord`,(e,t)=>{Po(),Sr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Is(e,t,n){return!t||!t._zod?new Fs({type:`record`,keyType:Lo(),valueType:e,...S(t)}):new Fs({type:`record`,keyType:e,valueType:t,...S(n)})}const Ls=A(`ZodEnum`,(e,t)=>{Cr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);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 Ls({...t,checks:[],...S(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 Ls({...t,checks:[],...S(r),entries:i})}});function Rs(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ls({type:`enum`,entries:n,...S(t)})}const zs=A(`ZodLiteral`,(e,t)=>{wr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>za(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 Bs(e,t){return new zs({type:`literal`,values:Array.isArray(e)?e:[e],...S(t)})}const Vs=A(`ZodTransform`,(e,t)=>{Po(),Tr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Be(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ee(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(Ee(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Hs(e){return new Vs({type:`transform`,transform:e})}const Us=A(`ZodOptional`,(e,t)=>{Dr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ws(e){return new Us({type:`optional`,innerType:e})}const Gs=A(`ZodExactOptional`,(e,t)=>{Or.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ks(e){return new Gs({type:`optional`,innerType:e})}const qs=A(`ZodNullable`,(e,t)=>{kr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Js(e){return new qs({type:`nullable`,innerType:e})}const Ys=A(`ZodDefault`,(e,t)=>{Ar.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xs(e,t){return new Ys({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ce(t)}})}const Zs=A(`ZodPrefault`,(e,t)=>{Mr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e,t){return new Zs({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ce(t)}})}const $s=A(`ZodNonOptional`,(e,t)=>{Nr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ec(e,t){return new $s({type:`nonoptional`,innerType:e,...S(t)})}const tc=A(`ZodCatch`,(e,t)=>{Ir.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nc(e,t){return new tc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Pe(t)})}const rc=A(`ZodPipe`,(e,t)=>{Lr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.in=t.in,e.out=t.out});function ic(e,t){return new rc({type:`pipe`,in:e,out:t})}const ac=A(`ZodReadonly`,(e,t)=>{zr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oc(e){return new ac({type:`readonly`,innerType:e})}const sc=A(`ZodLazy`,(e,t)=>{Vr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function cc(e){return new sc({type:`lazy`,getter:e})}const lc=A(`ZodCustom`,(e,t)=>{Hr.init(e,t),U.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r)});function uc(e,t={}){return la(lc,e,t)}function dc(e,t){return ua(e,t)}function fc(e){let t=cc(()=>Os([Lo(e),ls(),ps(),hs(),Cs(t),Is(Lo(),t)]));return t}var pc=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function mc(e){}function hc(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=mc,onError:n=mc,onRetry:r=mc,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=ee(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
51
- `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=ee(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new pc(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function ee(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
52
- `,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(`
53
- `,n);continue}let i=e.charCodeAt(n);if(gc(e,n,i)){let i=e.charCodeAt(n+5)===32?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===10){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
54
- `,n);continue}u=d===0?a:`${u}
55
- ${a}`,d++}else _c(e,n,i)?f=e.slice(e.charCodeAt(n+6)===32?n+7:n+6,r)||void 0:te(e,n,r);n=r+1,r=e.indexOf(`
56
- `,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
57
- `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;te(e,n,i),n=i+1,e.charCodeAt(n-1)===13&&e.charCodeAt(n)===10&&n++}return e.slice(n)}function te(e,t,n){if(t===n){re();return}let r=e.charCodeAt(t);if(gc(e,t,r)){let r=e.charCodeAt(t+5)===32?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
58
- ${i}`,d++;return}if(_c(e,t,r)){f=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===32?t+4:t+3,n);l=r.includes(`\0`)?void 0:r;return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===32?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){ne(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===32?2:1;ne(s,a.slice(o+c),a)}function ne(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
59
- ${t}`,d++;break;case`id`:l=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new pc(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new pc(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function re(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function g(e={}){if(e.consume&&o.length>0){let e=o.join(``);te(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:g}}function gc(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function _c(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var vc=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=hc({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}};function yc(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function bc(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}async function xc(e,t){if(e==null)return Promise.resolve();let n=t?.abortSignal;return new Promise((t,r)=>{if(n?.aborted){r(Sc());return}let i=setTimeout(()=>{a(),t()},e),a=()=>{clearTimeout(i),n?.removeEventListener(`abort`,o)},o=()=>{a(),r(Sc())};n?.addEventListener(`abort`,o)})}function Sc(){return new DOMException(`Delay was aborted`,`AbortError`)}function Cc(e){let t=e??globalThis.WebSocket;if(t==null)throw Error(`No WebSocket implementation available.`);return t}function wc(e){let t=new URL(e);return t.protocol===`http:`?t.protocol=`ws:`:t.protocol===`https:`&&(t.protocol=`wss:`),t}var Tc=new TextDecoder;async function Ec(e){return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Tc.decode(e):typeof Blob<`u`&&e instanceof Blob?e.text():String(e)}var Dc=1;async function Oc(e,{highWaterMark:t=1048576,pollIntervalMs:n=20,abortSignal:r}={}){for(;e.readyState===Dc&&(e.bufferedAmount??0)>t;){if(r?.aborted===!0)return;await xc(n)}}function kc({url:e,protocols:t,headers:n,webSocket:r,abortSignal:i,onOpen:a,onMessageText:o,onProcessingError:s,onSocketError:c,onClose:l,onAbort:u}){let d,f,p=e=>{f!=null&&(i?.removeEventListener(`abort`,f),f=void 0);try{d?.close(e)}catch{}};if(i?.aborted)return u?.(i.reason??Error(`Aborted`)),{socket:void 0,close:p};try{d=new(Cc(r))(e,t,{headers:bc(n??{})})}catch(e){return s(e),{socket:void 0,close:p}}i!=null&&u!=null&&(f=()=>u(i.reason??Error(`Aborted`)),i.addEventListener(`abort`,f,{once:!0}));let m=d;d.onopen=()=>{try{a?.(m)}catch(e){s(e)}};let h=Promise.resolve();return d.onmessage=e=>{h=h.then(()=>Ec(e.data)).then(e=>o(e)).catch(s)},d.onerror=()=>{h=h.then(()=>c?.()).catch(s)},d.onclose=e=>{let t=e,n=typeof t?.code==`number`?t.code:void 0,r=typeof t?.reason==`string`?t.reason:void 0;h=h.then(()=>l?.({code:n,reason:r})).catch(s)},{socket:d,close:p}}function Ac(e){let t=!1;return new ReadableStream({async pull(n){if(!t)try{let{value:t,done:r}=await e.next();r?n.close():n.enqueue(t)}catch(e){n.error(e)}},async cancel(n){if(t=!0,e.return)try{await e.return(n)}catch{}}})}var{btoa:jc,atob:Mc}=globalThis;function Nc(e){let t=Mc(e.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(t,e=>e.codePointAt(0))}function Pc(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return jc(t)}function Fc(e){return e instanceof Uint8Array?Pc(e):e}function Ic(e){if(e.type===`stream`){let t=new l({functionality:`streaming file upload`});throw e.stream.cancel(t).catch(()=>{}),t}return e.type===`text`?new TextEncoder().encode(e.text):e.data instanceof Uint8Array?e.data:e.data instanceof ArrayBuffer?new Uint8Array(e.data):Nc(e.data)}function Lc(e,t={}){let{useArrayBrackets:n=!0}=t,r=new FormData;for(let[t,i]of Object.entries(e))if(i!=null){if(Array.isArray(i)){if(i.length===1){r.append(t,i[0]);continue}let e=n?`${t}[]`:t;for(let t of i)r.append(e,t);continue}r.append(t,i)}return r}function Rc({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n==null?void 0:new Date(n*1e3)}}function zc(){return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0}}function Bc({tools:e=[],providerToolNames:t}){let n={},r={};for(let i of e)if(i.type===`provider`&&i.id in t){let e=t[i.id];n[i.name]=e,r[e]=i.name}return{toProviderToolName:e=>n[e]??e,toCustomToolName:e=>r[e]??e}}var Vc=Symbol.for(`vercel.ai.providerStreamError`);function Hc({message:e,type:t,code:n,statusCode:r,isRetryable:i,data:a}){let o={message:e,type:t,code:n,statusCode:r,isRetryable:i,data:a};return Object.defineProperty(o,Vc,{value:!0}),o}function Uc(e){return typeof e==`object`&&!!e&&e[Vc]===!0}function G(e){return Object.fromEntries([...e.headers])}function Wc(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function K(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var Gc=[`fetch failed`,`failed to fetch`],Kc=new Set([`ConnectionRefused`,`ConnectionClosed`,`FailedToOpenSocket`,`ECONNRESET`,`ECONNREFUSED`,`ETIMEDOUT`,`EPIPE`,`UND_ERR_SOCKET`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CONNECT_TIMEOUT`]);function qc(e){let t=new Set,n=e;for(;n instanceof Error&&!t.has(n);){t.add(n);let e=n;if(typeof e.code==`string`&&Kc.has(e.code))return e;n=n.cause}}function Jc({error:e,url:n,requestBodyValues:r}){if(K(e))return e;if(e instanceof TypeError&&Gc.includes(e.message.toLowerCase())){let i=e.cause;if(i!=null)return new t({message:`Cannot connect to API: ${i.message}`,cause:i,url:n,requestBodyValues:r,isRetryable:!0})}let i=qc(e);return i==null?e:t.isInstance(e)?new t({message:e.message,cause:e.cause,url:e.url,requestBodyValues:e.requestBodyValues,statusCode:e.statusCode,responseHeaders:e.responseHeaders,responseBody:e.responseBody,data:e.data,isRetryable:!0}):new t({message:`Cannot connect to API: ${e instanceof Error?e.message:i.message}`,cause:e,url:n,requestBodyValues:r,isRetryable:!0})}var Yc=`5.0.36`;function Xc(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function Zc(e,...t){let n=new Headers(Xc(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var Qc=()=>globalThis.fetch,$c=async({url:e,headers:n={},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o=Qc()})=>{try{let s=await o(e,{method:`DELETE`,headers:Zc(n,`ai-sdk/provider-utils/${Yc}`,Wc()),signal:a}),c=G(s);if(!s.ok){let n;try{n=await r({response:s,url:e,requestBodyValues:{}})}catch(n){throw K(n)||t.isInstance(n)?n:new t({message:`Failed to process error response`,cause:n,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:{}})}throw n.value}try{return await i({response:s,url:e,requestBodyValues:{}})}catch(n){throw n instanceof Error&&(K(n)||t.isInstance(n))?n:new t({message:`Failed to process successful response`,cause:n,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:{}})}}catch(t){throw Jc({error:t,url:e,requestBodyValues:{}})}},el=[{mediaType:`image/gif`,bytesPrefix:[71,73,70]},{mediaType:`image/png`,bytesPrefix:[137,80,78,71]},{mediaType:`image/jpeg`,bytesPrefix:[255,216]},{mediaType:`image/webp`,bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:`image/bmp`,bytesPrefix:[66,77]},{mediaType:`image/tiff`,bytesPrefix:[73,73,42,0]},{mediaType:`image/tiff`,bytesPrefix:[77,77,0,42]},{mediaType:`image/avif`,bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:`image/heic`,bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],tl=[{mediaType:`application/pdf`,bytesPrefix:[37,80,68,70]}],nl=[{mediaType:`audio/mpeg`,bytesPrefix:[255,251]},{mediaType:`audio/mpeg`,bytesPrefix:[255,250]},{mediaType:`audio/mpeg`,bytesPrefix:[255,243]},{mediaType:`audio/mpeg`,bytesPrefix:[255,242]},{mediaType:`audio/mpeg`,bytesPrefix:[255,227]},{mediaType:`audio/mpeg`,bytesPrefix:[255,226]},{mediaType:`audio/wav`,bytesPrefix:[82,73,70,70,null,null,null,null,87,65,86,69]},{mediaType:`audio/ogg`,bytesPrefix:[79,103,103,83]},{mediaType:`audio/flac`,bytesPrefix:[102,76,97,67]},{mediaType:`audio/aac`,bytesPrefix:[64,21,0,0]},{mediaType:`audio/webm`,bytesPrefix:[26,69,223,163]}],rl=[...nl,{mediaType:`audio/mp4`,bytesPrefix:[0,0,0,null,102,116,121,112]}],il=[{mediaType:`video/mp4`,bytesPrefix:[0,0,0,null,102,116,121,112]},{mediaType:`video/webm`,bytesPrefix:[26,69,223,163]},{mediaType:`video/quicktime`,bytesPrefix:[0,0,0,20,102,116,121,112,113,116]},{mediaType:`video/x-msvideo`,bytesPrefix:[82,73,70,70]}],al=18,ol=131084;function sl(e,t){if(typeof e!=`string`)return e.length>t?e.subarray(0,t):e;let n=Math.ceil(t/3)*4,r=Nc(e.substring(0,Math.min(e.length,n)));return r.length>t?r.subarray(0,t):r}function cl(e){return e.length>10&&e[0]===73&&e[1]===68&&e[2]===51}var ll=e=>{let t=(e[6]&127)<<21|(e[7]&127)<<14|(e[8]&127)<<7|e[9]&127;return e.subarray(t+10)};function ul({data:e,signatures:t}){let n=sl(e,al);cl(n)&&(n=ll(sl(e,ol)));for(let e of t)if(n.length>=e.bytesPrefix.length&&e.bytesPrefix.every((e,t)=>e===null||n[t]===e))return e.mediaType}var dl={image:el,audio:rl,video:il,application:tl};function fl({data:e,topLevelType:t}){if(t===void 0)return ul({data:e,signatures:[...el,...tl,...nl,...il]});let n=dl[t];if(n!==void 0)return ul({data:e,signatures:n})}function pl(e){let t=e.indexOf(`/`);return t===-1?e:e.substring(0,t)}function ml(e){let t=e.indexOf(`/`);if(t===-1)return!1;let n=e.substring(t+1);return n.length>0&&n!==`*`}async function hl(e){try{await e.body?.cancel()}catch{}}var gl=`AI_DownloadError`,_l=`vercel.ai.error.${gl}`,vl=Symbol.for(_l),yl,bl,q=class extends (bl=e,yl=vl,bl){constructor({url:e,statusCode:t,statusText:n,cause:r,message:i=r==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${r}`}){super({name:gl,message:i,cause:r}),this[yl]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(t){return e.hasMarker(t,_l)}};function xl(e=globalThis){return e.window!=null}function Sl(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}function Cl(e){let t;try{t=new URL(e)}catch{throw new q({url:e,message:`Invalid URL: ${e}`})}if(t.protocol===`data:`)return;if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new q({url:e,message:`URL scheme must be http, https, or data, got ${t.protocol}`});let n=t.hostname.toLowerCase().replace(/\.+$/,``);if(!n)throw new q({url:e,message:`URL must have a hostname`});if(n===`localhost`||n.endsWith(`.local`)||n.endsWith(`.localhost`))throw new q({url:e,message:`URL with hostname ${n} is not allowed`});if(n.startsWith(`[`)&&n.endsWith(`]`)){if(Ol(n.slice(1,-1)))throw new q({url:e,message:`URL with IPv6 address ${n} is not allowed`});return}if(Tl(n)){if(El(n))throw new q({url:e,message:`URL with IP address ${n} is not allowed`});return}}function wl({address:e,family:t,hostname:n}){if(t===4?!Tl(e)||El(e):t!==6||Ol(e))throw new q({url:n,message:`Hostname ${n} resolved to disallowed IP address ${e}`})}function Tl(e){let t=e.split(`.`);return t.length===4&&t.every(e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=255&&String(t)===e})}function El(e){let[t,n,r]=e.split(`.`).map(Number);return t===0||t===10||t===100&&n>=64&&n<=127||t===127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===0&&r===0||t===192&&n===0&&r===2||t===192&&n===168||t===198&&(n===18||n===19)||t===198&&n===51&&r===100||t===203&&n===0&&r===113||t>=224}function Dl(e){let t=e.toLowerCase(),n=t.indexOf(`%`);n!==-1&&(t=t.slice(0,n));let r=t.split(`::`);if(r.length>2)return null;let i=e=>{if(e===``)return[];let t=[],n=e.split(`:`);for(let e=0;e<n.length;e++){let r=n[e];if(r.includes(`.`)){if(e!==n.length-1||!Tl(r))return null;let[i,a,o,s]=r.split(`.`).map(Number);t.push(i<<8|a,o<<8|s);continue}if(!/^[0-9a-f]{1,4}$/.test(r))return null;t.push(parseInt(r,16))}return t},a=i(r[0]);if(a===null)return null;if(r.length===2){let e=i(r[1]);if(e===null)return null;let t=8-a.length-e.length;return t<0?null:[...a,...Array(t).fill(0),...e]}return a.length===8?a:null}function Ol(e){let t=Dl(e);if(t===null)return!0;let n=e=>t.slice(0,e).every(e=>e===0);return n(7)&&(t[7]===0||t[7]===1)||(t[0]&65024)==64512||(t[0]&65472)==65152||(t[0]&65472)==65216||(t[0]&65280)==65280||t[0]===8193&&t[1]===3512||t[0]===16383&&!(t[1]&61440)?!0:n(6)||n(5)&&t[5]===65535||n(4)&&t[4]===65535&&t[5]===0||t[0]===100&&t[1]===65435&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===0||t[0]===100&&t[1]===65435&&t[2]===1?El(`${t[6]>>8&255}.${t[6]&255}.${t[7]>>8&255}.${t[7]&255}`):!1}function kl(e){return((t,n,r)=>{e(t,{...n,all:!0},(e,i)=>{if(e){r(e);return}try{let[e]=i;if(e==null)throw Error(`Hostname ${t} did not resolve to an address`);for(let{address:e,family:n}of i)wl({address:e,family:n,hostname:t});n.all===!0?r(null,i):r(null,e.address,e.family)}catch(e){r(e instanceof Error?e:Error(String(e)))}})})}var Al,jl=globalThis.fetch,Ml=Fl(jl);function Nl(){let e=globalThis.process;return e?.release?.name===`node`&&e.versions?.bun==null}async function Pl(){return!Nl()||!Ml||globalThis.fetch!==jl?globalThis.fetch:Al??=Promise.resolve().then(Il)}function Fl(e){if(typeof e!=`function`)return!1;let t=Function.prototype.toString.call(e);return t.includes(`internal/deps/undici`)||t.includes(`lazy loading of undici`)}function Il(){let{createRequire:e}=Ll(`node:module`),{lookup:t}=Ll(`node:dns`),{Agent:n,fetch:r}=e(Rl())(`undici`),i=new n({connect:{lookup:kl(t)}});return((e,t)=>r(e,{...t,dispatcher:i}))}function Ll(e){let t=globalThis.process,n=(t?.getBuiltinModule)?.call(t,e);if(n==null)throw Error(`Node.js built-in module ${e} is unavailable`);return n}function Rl(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error(`Capture current module path`);Error.captureStackTrace(e,Rl);let[t]=e.stack,n=t?.getFileName();if(n==null)throw Error(`Unable to determine the current module path`);return n}finally{Error.prepareStackTrace=e}}var zl=[`connection`,`keep-alive`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`host`,`forwarded`,`proxy-authorization`,`via`,`x-forwarded-for`,`x-forwarded-host`,`x-forwarded-proto`,`x-real-ip`,`metadata`,`metadata-flavor`,`x-aws-ec2-metadata-token`,`x-metadata-token`,`cookie`,`set-cookie`];function Bl(e){let t=new Headers(e);for(let e of zl)t.delete(e);return t}var Vl=10,Hl=new Set([301,302,303,307,308]);async function Ul({url:e,headers:t,abortSignal:n,maxRedirects:r=Vl,fetch:i,trustedOrigin:a}){let o=t===void 0?void 0:Bl(t),s=e=>{let t={signal:n,redirect:e};return o!==void 0&&(t.headers=new Headers(o)),t},c=e;for(let t=0;t<=r;t++){let t=a!==void 0&&Sl(c,a);t||Cl(c);let n=i??(t?globalThis.fetch:await Pl()),r=await n(c,s(`manual`));if(r.type===`opaqueredirect`){if(!xl())throw new q({url:e,message:`Redirect from ${c} could not be validated and was blocked`});return await n(c,s(`follow`))}let l=r.headers.get(`location`);if(Hl.has(r.status)&&l){await hl(r);let e=new URL(l,c).toString();if(o!==void 0&&!Sl(e,c)){let e=o.get(`user-agent`);o=new Headers(e==null?void 0:{"user-agent":e})}c=e;continue}return r}throw new q({url:e,message:`Too many redirects (max ${r})`})}var Wl=2147483648;async function Gl({response:e,url:t,maxBytes:n=Wl}){let r=e.headers.get(`content-length`);if(r!=null){let i=parseInt(r,10);if(!isNaN(i)&&i>n)throw await hl(e),new q({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes (Content-Length: ${i}).`})}let i=e.body;if(i==null)return new Uint8Array;let a=i.getReader(),o=[],s=0;try{for(;;){let{done:e,value:r}=await a.read();if(e)break;if(s+=r.length,s>n)throw new q({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes.`});o.push(r)}}finally{try{await a.cancel()}catch{}finally{a.releaseLock()}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}async function Kl(e,t){try{let n=await Ul({url:e,abortSignal:t?.abortSignal});if(!n.ok)throw await hl(n),new q({url:e,statusCode:n.status,statusText:n.statusText});let r=await Gl({response:n,url:e,maxBytes:t?.maxBytes??Wl}),i=n.headers.get(`content-type`)??void 0;return new Blob([r],i?{type:i}:void 0)}catch(t){throw q.isInstance(t)?t:new q({url:e,cause:t})}}var ql=Symbol.for(`vercel.ai.embeddingModel.maxInputBytesPerCall`),Jl=(({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:i=`-`}={})=>{let a=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return a;if(n.includes(i))throw new r({argument:`separator`,message:`The separator "${i}" must not be part of the alphabet "${n}".`});return()=>`${e}${i}${a()}`})(),Yl=()=>globalThis.fetch,Xl=async({url:e,headers:n={},successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o,validateUrl:s,credentialedOrigin:c,trustedOrigin:l})=>{try{let u=o??Yl(),d=Zc(c!==void 0&&!Sl(e,c)?{}:n,`ai-sdk/provider-utils/${Yc}`,Wc()),f=s?await Ul({url:e,headers:d,abortSignal:a,fetch:o,trustedOrigin:l}):await u(e,{method:`GET`,headers:d,signal:a}),p=G(f);if(!f.ok){let n;try{n=await i({response:f,url:e,requestBodyValues:{}})}catch(n){throw K(n)||t.isInstance(n)?n:new t({message:`Failed to process error response`,cause:n,statusCode:f.status,url:e,responseHeaders:p,requestBodyValues:{}})}throw n.value}try{return await r({response:f,url:e,requestBodyValues:{}})}catch(n){throw n instanceof Error&&(K(n)||t.isInstance(n))?n:new t({message:`Failed to process successful response`,cause:n,statusCode:f.status,url:e,responseHeaders:p,requestBodyValues:{}})}}catch(t){throw Jc({error:t,url:e,requestBodyValues:{}})}};function Zl(e){return e!=null}function Ql(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $l({apiKey:e,environmentVariableName:t,apiKeyParameterName:n=`apiKey`,description:r}){if(typeof e==`string`)return e;if(e!=null)throw new o({message:`${r} API key must be a string.`});if(typeof process>`u`)throw new o({message:`${r} API key is missing. Pass it using the '${n}' parameter. Environment variables are not supported in this environment.`});if(e=process.env[t],e==null)throw new o({message:`${r} API key is missing. Pass it using the '${n}' parameter or the ${t} environment variable.`});if(typeof e!=`string`)throw new o({message:`${r} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}function eu({settingValue:e,environmentVariableName:t}){if(typeof e==`string`||!(e!=null||typeof process>`u`)&&(e=process.env[t],e!=null&&typeof e==`string`))return e}function tu(e){return e!==void 0&&e!==`provider-default`}function nu({reasoning:e,effortMap:t,warnings:n}){let r=t[e];if(r==null){n.push({type:`unsupported`,feature:`reasoning`,details:`reasoning "${e}" is not supported by this model.`});return}return r!==e&&n.push({type:`compatibility`,feature:`reasoning`,details:`reasoning "${e}" is not directly supported by this model. mapped to effort "${r}".`}),r}var ru={minimal:.02,low:.1,medium:.3,high:.6,xhigh:.9};function iu({reasoning:e,maxOutputTokens:t,maxReasoningBudget:n,minReasoningBudget:r=1024,budgetPercentages:i=ru,warnings:a}){let o=i[e];if(o==null){a.push({type:`unsupported`,feature:`reasoning`,details:`reasoning "${e}" is not supported by this model.`});return}return Math.min(n,Math.max(r,Math.round(t*o)))}function au(e){let[t,n=``]=e.toLowerCase().split(`/`);return{mpeg:`mp3`,"x-wav":`wav`,opus:`ogg`,mp4:`m4a`,"x-m4a":`m4a`}[n]??n}function ou({total:e,pending:t,completed:n,failed:r}){if(su(e)&&su(t)&&su(n)&&su(r)&&t+n+r===e)return{total:e,pending:t,completed:n,failed:r}}function su(e){return e!=null&&Number.isSafeInteger(e)&&e>=0}var cu=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,lu=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function uu(e){let t=JSON.parse(e);return typeof t!=`object`||!t||cu.test(e)===!1&&lu.test(e)===!1?t:du(t)}function du(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function fu(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return uu(e)}try{return uu(e)}finally{Error.stackTraceLimit=t}}function pu(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&J(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=J(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(J):J(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(J)),e.allOf!=null&&(e.allOf=e.allOf.map(J)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(J));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=J(t[e]);return e}function J(e){return typeof e==`boolean`?e:pu(e)}var mu=Symbol(`Let zodToJsonSchema decide on which parser to use`),hu={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},gu=e=>typeof e==`string`?{...hu,name:e}:{...hu,...e};function Y(){return{}}function _u(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=$(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function vu(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function yu(){return{type:`boolean`}}function bu(e,t){return $(e.type._def,t)}var xu=(e,t)=>$(e.innerType._def,t);function Su(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>Su(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Cu(e)}}var Cu=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function wu(e,t){return{...$(e.innerType._def,t),default:e.defaultValue()}}function Tu(e,t){return t.effectStrategy===`input`?$(e.schema._def,t):Y()}function Eu(e){return{type:`string`,enum:Array.from(e.values)}}var Du=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function Ou(e,t){let n=[$(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),$(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(Du(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function ku(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var Au=void 0,X={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Au===void 0&&(Au=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),Au),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ju(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:Z(n,`email`,r.message,t);break;case`format:idn-email`:Z(n,`idn-email`,r.message,t);break;case`pattern:zod`:Q(n,X.email,r.message,t)}break;case`url`:Z(n,`uri`,r.message,t);break;case`uuid`:Z(n,`uuid`,r.message,t);break;case`regex`:Q(n,r.regex,r.message,t);break;case`cuid`:Q(n,X.cuid,r.message,t);break;case`cuid2`:Q(n,X.cuid2,r.message,t);break;case`startsWith`:Q(n,RegExp(`^${Mu(r.value,t)}`),r.message,t);break;case`endsWith`:Q(n,RegExp(`${Mu(r.value,t)}$`),r.message,t);break;case`datetime`:Z(n,`date-time`,r.message,t);break;case`date`:Z(n,`date`,r.message,t);break;case`time`:Z(n,`time`,r.message,t);break;case`duration`:Z(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:Q(n,RegExp(Mu(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&Z(n,`ipv4`,r.message,t),r.version!==`v4`&&Z(n,`ipv6`,r.message,t);break;case`base64url`:Q(n,X.base64url,r.message,t);break;case`jwt`:Q(n,X.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&Q(n,X.ipv4Cidr,r.message,t),r.version!==`v4`&&Q(n,X.ipv6Cidr,r.message,t);break;case`emoji`:Q(n,X.emoji(),r.message,t);break;case`ulid`:Q(n,X.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:Z(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:Q(n,X.base64,r.message,t)}break;case`nanoid`:Q(n,X.nanoid,r.message,t)}return n}function Mu(e,t){return t.patternStrategy===`escape`?Pu(e):e}var Nu=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function Pu(e){let t=``;for(let n=0;n<e.length;n++)Nu.has(e[n])||(t+=`\\`),t+=e[n];return t}function Z(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Q(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Fu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Fu(t,r)}function Fu(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
60
- ]))`;continue}if(r[e]===`$`){i+=`($|(?=[\r
61
- ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r
62
- `:`[${r[e]}\r
63
- ]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Iu(e,t){let n={type:`object`,additionalProperties:$(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=ju(e.keyType._def,t);return{...n,propertyNames:i}}if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=bu(e.keyType._def,t);return{...n,propertyNames:i}}return n}function Lu(e,t){return t.mapStrategy===`record`?Iu(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[$(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Y(),$(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Y()],minItems:2,maxItems:2}}}function Ru(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function zu(){return{not:Y()}}function Bu(){return{type:`null`}}var Vu={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Hu(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Vu&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Vu[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Uu(e,t)}var Uu=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>$(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Wu(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Vu[e.innerType._def.typeName],`null`]};let n=$(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Gu(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function Ku(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Ju(a),s=$(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=qu(e,t);return a!==void 0&&(n.additionalProperties=a),n}function qu(e,t){if(e.catchall._def.typeName!==`ZodNever`)return $(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Ju(e){try{return e.isOptional()}catch{return!0}}var Yu=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return $(e.innerType._def,t);let n=$(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Y()},n]}:Y()},Xu=(e,t)=>{if(t.pipeStrategy===`input`)return $(e.in._def,t);if(t.pipeStrategy===`output`)return $(e.out._def,t);let n=$(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,$(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Zu(e,t){return $(e.type._def,t)}function Qu(e,t){let n={type:`array`,uniqueItems:!0,items:$(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function $u(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>$(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:$(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>$(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function ed(){return{not:Y()}}function td(){return Y()}var nd=(e,t)=>$(e.innerType._def,t),rd=(e,t,n)=>{switch(t){case`ZodString`:return ju(e,n);case`ZodNumber`:return Gu(e);case`ZodObject`:return Ku(e,n);case`ZodBigInt`:return vu(e);case`ZodBoolean`:return yu();case`ZodDate`:return Su(e,n);case`ZodUndefined`:return ed();case`ZodNull`:return Bu();case`ZodArray`:return _u(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return Hu(e,n);case`ZodIntersection`:return Ou(e,n);case`ZodTuple`:return $u(e,n);case`ZodRecord`:return Iu(e,n);case`ZodLiteral`:return ku(e);case`ZodEnum`:return Eu(e);case`ZodNativeEnum`:return Ru(e);case`ZodNullable`:return Wu(e,n);case`ZodOptional`:return Yu(e,n);case`ZodMap`:return Lu(e,n);case`ZodSet`:return Qu(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Zu(e,n);case`ZodNaN`:case`ZodNever`:return zu();case`ZodEffects`:return Tu(e,n);case`ZodAny`:return Y();case`ZodUnknown`:return td();case`ZodDefault`:return wu(e,n);case`ZodBranded`:return bu(e,n);case`ZodReadonly`:return nd(e,n);case`ZodCatch`:return xu(e,n);case`ZodPipeline`:return Xu(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},id=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function $(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.call(t,e,t,r,n);if(i!==mu)return i}if(r&&!n){let e=ad(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=rd(e,e.typeName,t),o=typeof a==`function`?$(a(),t):a;if(o&&od(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var ad=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:id(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Y()):t.$refStrategy===`seen`?Y():void 0}},od=(e,t,n)=>(e.description&&(n.description=e.description),n),sd=e=>{let t=gu(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},cd=(e,t)=>{let n=sd(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:$(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Y()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=$(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Y(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},ld=Symbol.for(`vercel.ai.schema`);function ud(e){let t;return()=>(t??=e(),t)}function dd(e,{validate:t}={}){return{[ld]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function fd(e){return typeof e==`object`&&!!e&&ld in e&&e[ld]===!0&&`jsonSchema`in e&&`validate`in e}function pd(e){return e==null?dd({type:`object`,properties:{},additionalProperties:!1}):fd(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?yd(e):md(e):e()}function md(e){return dd(()=>{if(!hd(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return pu(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return`value`in n?{success:!0,value:n.value}:{success:!1,error:new c({value:t,cause:n.issues})}}})}function hd(e){return e[`~standard`].jsonSchema!=null}function gd(e,t){let n=t?.useReferences??!1;return dd(()=>cd(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function _d(e,t){let n=t?.useReferences??!1;return dd(()=>pu(vo(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await wo(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function vd(e){return`_zod`in e}function yd(e,t){return vd(e)?_d(e,t):gd(e,t)}async function bd({value:e,schema:t,context:n}){let r=await xd({value:e,schema:t,context:n});if(!r.success)throw c.wrap({value:e,cause:r.error,context:n});return r.value}async function xd({value:e,schema:t,context:n}){let r=pd(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:c.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:c.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function Sd({text:e,schema:t}){try{let n=fu(e);return t==null?n:await bd({value:n,schema:t})}catch(t){throw a.isInstance(t)||c.isInstance(t)?t:new a({text:e,cause:t})}}async function Cd({text:e,schema:t}){try{let n=fu(e);return t==null?{success:!0,value:n,rawValue:n}:await xd({value:n,schema:t})}catch(t){return{success:!1,error:a.isInstance(t)?t:new a({text:e,cause:t}),rawValue:void 0}}}function wd({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new vc).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await Cd({text:e,schema:t}))}}))}async function Td({provider:e,providerOptions:t,schema:n}){if(t?.[e]==null)return;let i=await xd({value:t[e],schema:n});if(!i.success)throw new r({argument:`providerOptions`,message:`invalid ${e} provider options`,cause:i.error});return i.value}var Ed=()=>globalThis.fetch;function Dd(e){return e.replace(/[\r\n]/g,``).replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Od(e,t){let n=new TextEncoder,r=!1,i,a=new Set;async function*o(){for(let o of e){if(r)return;let e=`--${t}\r
64
- Content-Disposition: form-data; name="${Dd(o.name)}"`;if(o.type===`field`){yield n.encode(`${e}\r
65
- \r
66
- ${o.value}\r
67
- `);continue}let s=`; filename="${Dd(o.filename??`blob`)}"`,c=(o.mediaType??`application/octet-stream`).replace(/[\r\n]/g,``);if(yield n.encode(`${e}${s}\r
68
- Content-Type: ${c}\r
69
- \r
70
- `),o.content instanceof Uint8Array)yield o.content;else{let e=o.content.getReader();i=e,a.add(o.content);let t=!1;try{for(;;){let{done:n,value:i}=await e.read();if(n||r){t=n;break}yield i}}finally{i=void 0,t||await e.cancel().catch(()=>{}),e.releaseLock()}if(r)return}yield n.encode(`\r
71
- `)}yield n.encode(`--${t}--\r
72
- `)}return{stream:Ac(o()),async dispose(t){if(r)return;r=!0;let n=i;n!=null&&await n.cancel(t).catch(()=>{});for(let n of e)n.type===`file`&&!(n.content instanceof Uint8Array)&&!a.has(n.content)&&await n.content.cancel(t).catch(()=>{})}}}var kd=async({url:e,headers:n={},parts:r,failedResponseHandler:i,successfulResponseHandler:a,abortSignal:o,fetch:s=Ed()})=>{let c=`ai-sdk-multipart-${Jl()}`,l=Object.fromEntries(r.map(e=>[e.name,e.type===`field`?e.value:`<file:${e.filename??e.name}>`])),u=Od(r,c);try{let r=await s(e,{method:`POST`,headers:Zc({...n,"Content-Type":`multipart/form-data; boundary=${c}`},`ai-sdk/provider-utils/${Yc}`,Wc()),body:u.stream,duplex:`half`,signal:o}),d=G(r);if(!r.ok){let n;try{n=await i({response:r,url:e,requestBodyValues:l})}catch(n){throw K(n)||t.isInstance(n)?n:new t({message:`Failed to process error response`,cause:n,statusCode:r.status,url:e,responseHeaders:d,requestBodyValues:l})}throw n.value}try{return await a({response:r,url:e,requestBodyValues:l})}catch(n){throw n instanceof Error&&(K(n)||t.isInstance(n))?n:new t({message:`Failed to process successful response`,cause:n,statusCode:r.status,url:e,responseHeaders:d,requestBodyValues:l})}}catch(t){throw await u.dispose(t),Jc({error:t,url:e,requestBodyValues:l})}},Ad=()=>globalThis.fetch,jd=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>await Nd({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),Md=async({url:e,headers:t,formData:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>await Nd({url:e,headers:t,body:{content:n,values:Object.fromEntries(n.entries())},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),Nd=async({url:e,headers:n={},body:r,successfulResponseHandler:i,failedResponseHandler:a,abortSignal:o,fetch:s=Ad()})=>{try{let c=await s(e,{method:`POST`,headers:Zc(n,`ai-sdk/provider-utils/${Yc}`,Wc()),body:r.content,signal:o}),l=G(c);if(!c.ok){let n;try{n=await a({response:c,url:e,requestBodyValues:r.values})}catch(n){throw K(n)||t.isInstance(n)?n:new t({message:`Failed to process error response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw n.value}try{return await i({response:c,url:e,requestBodyValues:r.values})}catch(n){throw n instanceof Error&&(K(n)||t.isInstance(n))?n:new t({message:`Failed to process successful response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(t){throw Jc({error:t,url:e,requestBodyValues:r.values})}};function Pd(e){return e}function Fd(e){return{...e,type:`dynamic`}}function Id({id:e,inputSchema:t}){return({execute:n,outputSchema:r,needsApproval:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>Pd({type:`provider`,isProviderExecuted:!1,id:e,args:l,inputSchema:t,outputSchema:r,execute:n,needsApproval:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}function Ld({id:e,inputSchema:t,outputSchema:n}){return({execute:r,needsApproval:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>Pd({type:`provider`,isProviderExecuted:!1,id:e,args:l,inputSchema:t,outputSchema:n,execute:r,needsApproval:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}function Rd({id:e,inputSchema:t,outputSchema:n,supportsDeferredResults:r}){return({onInputStart:i,onInputDelta:a,onInputAvailable:o,...s})=>Pd({type:`provider`,isProviderExecuted:!0,id:e,args:s,inputSchema:t,outputSchema:n,onInputStart:i,onInputDelta:a,onInputAvailable:o,supportsDeferredResults:r})}async function zd(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}function Bd({part:e}){if(ml(e.mediaType))return e.mediaType;if(e.data.type===`data`){let t=fl({data:e.data.data,topLevelType:pl(e.mediaType)});if(t)return t;throw new l({functionality:`file of media type "${e.mediaType}" must specify subtype since it could not be auto-detected`})}throw new l({functionality:`file of media type "${e.mediaType}" must specify subtype since it is not passed as inline bytes`})}function Vd({reference:e,provider:t}){let n=e[t];if(n!=null)return n;throw new s({provider:t,reference:e})}var Hd=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r,shouldRetry:i,getDelayInMs:a=({exponentialBackoffDelay:e})=>e,createRetryError:o=({message:e})=>Error(e)})=>async s=>Ud(s,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:r,shouldRetry:i,getDelayInMs:a,createRetryError:o});async function Ud(e,{maxRetries:t,delayInMs:n,backoffFactor:r,abortSignal:i,shouldRetry:a,getDelayInMs:o,createRetryError:s},c=[]){try{return await e()}catch(l){if(K(l)||t===0)throw l;let d=u(l),f=[...c,l],p=f.length;if(p>t)throw s({message:`Failed after ${p} attempts. Last error: ${d}`,reason:`maxRetriesExceeded`,errors:f});if(await a(l)&&p<=t)return await xc(o({error:l,exponentialBackoffDelay:n}),{abortSignal:i}),Ud(e,{maxRetries:t,delayInMs:r*n,backoffFactor:r,abortSignal:i,shouldRetry:a,getDelayInMs:o,createRetryError:s},f);throw p===1?l:s({message:`Failed after ${p} attempts with non-retryable error: '${d}'`,reason:`errorNotRetryable`,errors:f})}}var Wd=new TextDecoder;function Gd({stream:e,url:n,requestBodyValues:r,statusCode:i,responseHeaders:a}){let o=e.getReader(),s=!1,c=()=>{s||=(o.releaseLock(),!0)};return new ReadableStream({async pull(e){try{let{done:t,value:n}=await o.read();t?(c(),e.close()):e.enqueue(n)}catch(o){if(c(),K(o)){e.error(o);return}e.error(Jc({error:new t({message:`Failed to process successful response`,cause:o,statusCode:i,url:n,responseHeaders:a,requestBodyValues:r}),url:n,requestBodyValues:r}))}},async cancel(e){try{await o.cancel(e)}finally{c()}}})}async function Kd({response:e,url:t}){return Wd.decode(await Gl({response:e,url:t}))}var qd=({errorSchema:e,errorToMessage:n,isRetryable:r})=>async({response:i,url:a,requestBodyValues:o})=>{let s=await Kd({response:i,url:a}),c=G(i);if(s.trim()===``)return{responseHeaders:c,value:new t({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})};try{let l=await Sd({text:s,schema:e});return{responseHeaders:c,value:new t({message:n(l),url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,data:l,isRetryable:r?.(i,l)})}}catch{return{responseHeaders:c,value:new t({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})}}},Jd=e=>async({response:t,url:r,requestBodyValues:i})=>{let a=G(t);if(t.body==null)throw new n({});return{responseHeaders:a,value:wd({stream:Gd({stream:t.body,url:r,requestBodyValues:i,statusCode:t.status,responseHeaders:a}),schema:e})}},Yd=e=>async({response:n,url:r,requestBodyValues:i})=>{let a=await Kd({response:n,url:r}),o=await Cd({text:a,schema:e}),s=G(n);if(!o.success)throw new t({message:`Invalid JSON response`,cause:o.error,statusCode:n.status,responseHeaders:s,responseBody:a,url:r,requestBodyValues:i});return{responseHeaders:s,value:o.value,rawValue:o.rawValue}},Xd=e=>async({response:t})=>{let r=G(t);if(t.body==null)throw new n({});return{responseHeaders:r,value:Zd({stream:t.body,schema:e})}};async function*Zd({stream:e,schema:t}){let n=e.getReader(),r=new TextDecoder,i=``,a=!1;try{for(;;){let{done:e,value:o}=await n.read();if(e){a=!0,i+=r.decode();break}i+=r.decode(o,{stream:!0});let s=i.indexOf(`
73
- `);for(;s!==-1;){let e=i.slice(0,s).replace(/\r$/,``);i=i.slice(s+1),e.trim().length>0&&(yield await Sd({text:e,schema:t})),s=i.indexOf(`
74
- `)}}let e=i.replace(/\r$/,``);e.trim().length>0&&(yield await Sd({text:e,schema:t}))}finally{a||await n.cancel().catch(()=>{}),n.releaseLock()}}var Qd=()=>async({response:e,url:n,requestBodyValues:r})=>{let i=G(e);if(!e.body)throw new t({message:`Response body is empty`,url:n,requestBodyValues:r,statusCode:e.status,responseHeaders:i,responseBody:void 0});try{let t=await e.arrayBuffer();return{responseHeaders:i,value:new Uint8Array(t)}}catch(a){throw new t({message:`Failed to read response as array buffer`,url:n,requestBodyValues:r,statusCode:e.status,responseHeaders:i,responseBody:void 0,cause:a})}},$d=()=>async({response:e,url:t,requestBodyValues:r})=>{let i=G(e);if(e.body==null)throw new n({});return{responseHeaders:i,value:Gd({stream:e.body,url:t,requestBodyValues:r,statusCode:e.status,responseHeaders:i})}};function ef(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`number`||t===`boolean`?!0:t===`function`||t===`symbol`||t===`bigint`?!1:Array.isArray(e)?e.every(ef):Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(ef)}var tf=`AI_SerializationError`,nf=`vercel.ai.error.${tf}`,rf=Symbol.for(nf),af,of,sf=class extends (of=e,af=rf,of){constructor({message:e=`Failed to serialize value.`,cause:t}={}){super({name:tf,message:e,cause:t}),this[af]=!0}static isInstance(t){return e.hasMarker(t,nf)}};function cf(e){let t={};for(let[n,r]of Object.entries(e.config))if(n===`headers`){let e=lf(r);ef(e)&&(t[n]=e)}else ef(r)&&(t[n]=r);return{modelId:e.modelId,config:t}}function lf(e){let t=e;if(typeof e==`function`&&(t=e()),t instanceof Promise)throw new sf({message:`Cannot serialize asynchronous model options.`});return t}var uf=class{constructor(e,t={}){this.toolCalls=new Set,this.toolCallsById=new Map,this.toolCallsByIndex=new Map,this.controller=e,this._generateId=t.generateId??Jl,this.typeValidation=t.typeValidation??`none`,this.extractMetadata=t.extractMetadata,this.buildToolCallProviderMetadata=t.buildToolCallProviderMetadata}processDelta(e){let{id:t,index:n}=e,r=t!=null&&t.length>0?this.toolCallsById.get(t):n==null?this.latestToolCall:this.toolCallsByIndex.get(n);r==null?r=this.processNewToolCall(e):this.processExistingToolCall(r,e),n!=null&&this.toolCallsByIndex.set(n,r),this.latestToolCall=r}flush(){for(let e of this.toolCalls)e.hasFinished||this.finishToolCall(e)}processNewToolCall(e){if(this.typeValidation===`required`){if(e.type!==`function`)throw new i({data:e,message:`Expected 'function' type.`})}else if(this.typeValidation===`if-present`&&e.type!=null&&e.type!==`function`)throw new i({data:e,message:`Expected 'function' type.`});if(e.id==null)throw new i({data:e,message:`Expected 'id' to be a string.`});if(e.function?.name==null)throw new i({data:e,message:`Expected 'function.name' to be a string.`});this.controller.enqueue({type:`tool-input-start`,id:e.id,toolName:e.function.name});let t=this.extractMetadata?.call(this,e),n={id:e.id,type:`function`,function:{name:e.function.name,arguments:e.function.arguments??``},hasFinished:!1,metadata:t};return this.toolCalls.add(n),n.id.length>0&&this.toolCallsById.set(n.id,n),n.function.arguments.length>0&&this.controller.enqueue({type:`tool-input-delta`,id:n.id,delta:n.function.arguments}),n}processExistingToolCall(e,t){e.hasFinished||t.function?.arguments!=null&&(e.function.arguments+=t.function.arguments,this.controller.enqueue({type:`tool-input-delta`,id:e.id,delta:t.function.arguments}))}finishToolCall(e){this.controller.enqueue({type:`tool-input-end`,id:e.id});let t=this.buildToolCallProviderMetadata?.call(this,e.metadata);this.controller.enqueue({type:`tool-call`,toolCallId:e.id??this._generateId(),toolName:e.function.name,input:e.function.arguments,...t?{providerMetadata:t}:{}}),e.hasFinished=!0}};function df(e){if(e?.trim()===``)throw new r({argument:`baseURL`,message:`baseURL must be a non-empty string.`});return e}function ff(e){return e?.replace(/\/$/,``)}function pf(e,t){return Object.defineProperty({...e},"experimental_toolCaller",{value:t})}export{kd as $,Xl as A,cc as At,dd as B,Os as Bt,Hc as C,_s as Ct,Kl as D,As as Dt,$c as E,ps as Et,ml as F,Ts as Ft,nu as G,$l as H,Ii as Ht,Zl as I,Ws as It,Xc as J,au as K,Uc as L,Is as Lt,pl as M,Es as Mt,K as N,xs as Nt,Fd as O,Ms as Ot,tu as P,ls as Pt,jd as Q,Ql as R,Lo as Rt,Rd as S,hs as St,xc as T,is as Tt,eu as U,Ie as Ut,ud as V,ys as Vt,iu as W,Td as X,Sd as Y,Md as Z,Yd as _,ff as _t,kc as a,Cd as at,Id as b,cs as bt,Ic as c,cf as ct,Pc as d,pf as dt,Nd as et,Qd as f,df as ft,Xd as g,Zc as gt,qd as h,Oc as ht,yc as i,Hd as it,Wc as j,Bs as jt,Jl as k,fc as kt,Fc as l,wc as lt,Jd as m,bd as mt,uf as n,Bd as nt,Ac as o,xd as ot,$d as p,Cl as pt,ou as q,pd as r,Vd as rt,Nc as s,fu as st,ql as t,zd as tt,Lc as u,Pd as ut,Rc as v,yd as vt,Bc as w,Cs as wt,Ld as x,Rs as xt,zc as y,vc as yt,Sl as z,Ps as zt};
@@ -1,3 +0,0 @@
1
- import{a as e,i as t,t as n}from"./rolldown-runtime-DPpTSio4.js";import{Kr as r,O as i,Zr as a,ui as o,v as s,zl as c}from"./dist-DDeH-1ER.js";import{A as l,_ as u,c as d,d as f,g as p,r as m,v as h,y as g}from"./dist-xTushGCp.js";import{a as ee,n as _,r as v}from"./signal-exit-Dsy-TT0V.js";import{n as y,r as b,t as x}from"./token-util-BkqzD0OM.js";import{createRequire as S}from"module";import{inspect as te}from"node:util";import C from"node:os";var ne=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),re=n(((t,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{getVercelOidcToken:()=>p,getVercelOidcTokenSync:()=>m}),n.exports=l(u);var d=ne(),f=b();async function p(t){let n=``,r;try{n=m()}catch(e){r=e}try{let[{getTokenPayload:r,isExpired:i},{refreshToken:a}]=await Promise.all([await import(`./token-util-BkqzD0OM.js`).then(t=>e(t.t())),await import(`./token-CrFhCmWs.js`).then(t=>e(t.default))]);(!n||i(r(n),t?.expirationBufferMs))&&(await a(t),n=m())}catch(e){let t=r instanceof Error?r.message:``;throw e instanceof Error&&(t=`${t}
2
- ${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}function m(){let e=(0,d.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`);return e}0&&(n.exports={getVercelOidcToken:p,getVercelOidcTokenSync:m})})),ie=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>f.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>f.RefreshAccessTokenFailedError,getContext:()=>d.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>u.getVercelOidcTokenSync,getVercelToken:()=>p.getVercelToken}),t.exports=c(l);var u=re(),d=ne(),f=y(),p=x();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})})),ae=ie();let oe;try{oe=new TextDecoder}catch{}let w,T,E=0;const se=[],ce=57337,le={};let ue=11281e4,D=1681e4,O=se,de=0,k={},A,fe,pe=0,j=0,M,N,P=[],me=[],F,I,he,ge={useRecords:!1,mapsAsObjects:!0},_e=!1,ve=2;try{Function(``)}catch{ve=1/0}var ye=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[R(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(w)return Ue(()=>(We(),this?this.decode(t,n):e.prototype.decode.call(ge,t,n)));T=n>-1?n:t.length,E=0,de=0,j=0,fe=null,O=se,M=null,w=t;try{I=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw w=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(k=this,F=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return A=this.structures,be();(!A||A.length>0)&&(A=[])}else k=ge,(!A||A.length>0)&&(A=[]),F=null;return be()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;_e=!0;let a=this?this.decode(e,i):Ke.decode(e,i);if(t){if(t(a)===!1)return;for(;E<i;)if(r=E,t(be())===!1)return}else{for(n=[a];E<i;)r=E,n.push(be());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{_e=!1,We()}}};function be(){try{let e=L();if(M){if(E>=M.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}E=M.postBundlePosition,M=null}if(E==T)A=null,w=null,N&&=null;else if(E>T){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!_e)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw We(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function L(){let e=w[E++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=w[E++];break;case 25:if(t==7)return je();e=I.getUint16(E),E+=2;break;case 26:if(t==7){let e=I.getFloat32(E);if(k.useFloat32>2){let t=Ge[(w[E]&127)<<1|w[E+1]>>7];return E+=4,(t*e+(e>0?.5:-.5)>>0)/t}return E+=4,e}e=I.getUint32(E),E+=4;break;case 27:if(t==7){let e=I.getFloat64(E);return E+=8,e}if(t>1){if(I.getUint32(E)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=I.getUint32(E+4)}else k.int64AsNumber?(e=I.getUint32(E)*4294967296,e+=I.getUint32(E+4)):e=I.getBigUint64(E);E+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=L())!=le;){if(r>=ue)throw Error(`Array length exceeds ${ue}`);e[r++]=n}return t==4?e:t==3?e.join(``):Buffer.concat(e);case 5:let i;if(k.mapsAsObjects){let e={},t=0;if(k.keyMap)for(;(i=L())!=le;){if(t++>=D)throw Error(`Property count exceeds ${D}`);e[R(k.decodeKey(i))]=L()}else for(;(i=L())!=le;){if(t++>=D)throw Error(`Property count exceeds ${D}`);e[R(i)]=L()}return e}{he&&=(k.mapsAsObjects=!0,!1);let e=new Map;if(k.keyMap){let t=0;for(;(i=L())!=le;){if(t++>=D)throw Error(`Map size exceeds ${D}`);e.set(k.decodeKey(i),L())}}else{let t=0;for(;(i=L())!=le;){if(t++>=D)throw Error(`Map size exceeds ${D}`);e.set(i,L())}}return e}case 7:return le;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return Oe(e);case 3:if(j>=E)return fe.slice(E-pe,(E+=e)-pe);if(j==0&&T<140&&e<32){let t=e<16?De(e):Ee(e);if(t!=null)return t}return Ce(e);case 4:if(e>=ue)throw Error(`Array length exceeds ${ue}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=L();return t;case 5:if(e>=D)throw Error(`Map size exceeds ${ue}`);if(k.mapsAsObjects){let t={};if(k.keyMap)for(let n=0;n<e;n++)t[R(k.decodeKey(L()))]=L();else for(let n=0;n<e;n++)t[R(L())]=L();return t}{he&&=(k.mapsAsObjects=!0,!1);let t=new Map;if(k.keyMap)for(let n=0;n<e;n++)t.set(k.decodeKey(L()),L());else for(let n=0;n<e;n++)t.set(L(),L());return t}case 6:if(e>=ce){let t=A[e&8191];if(t)return t.read||(t.read=Se(t)),t.read();if(e<65536){if(e==57343){let e=Ve(),t=L(),n=L();Me(t,n);let r={};if(k.keyMap)for(let t=2;t<e;t++){let e=k.decodeKey(n[t-2]);r[R(e)]=L()}else for(let t=2;t<e;t++){let e=n[t-2];r[R(e)]=L()}return r}if(e==57342){let e=Ve(),t=L();for(let n=2;n<e;n++)Me(t++,L());return L()}if(e==ce)return Be();if(k.getShared&&(He(),t=A[e&8191],t))return t.read||(t.read=Se(t)),t.read()}}let n=P[e];if(n)return n.handlesRead?n(L):n(L());{let t=L();for(let n=0;n<me.length;n++){let r=me[n](e,t);if(r!==void 0)return r}return new B(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(F||V())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}const xe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Se(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=w[E++];if(e&=31,e>23)switch(e){case 24:e=w[E++];break;case 25:e=I.getUint16(E),E+=2;break;case 26:e=I.getUint32(E),E+=4;break;default:throw Error(`Expected array header, but got `+w[E-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(L);t=t.next}if(this.slowReads++>=ve){let n=this.length==e?this:this.slice(0,e);return t=k.keyMap?Function(`r`,`return {`+n.map(e=>k.decodeKey(e)).map(e=>xe.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>xe.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(L)}let n={};if(k.keyMap)for(let t=0;t<e;t++)n[R(k.decodeKey(this[t]))]=L();else for(let t=0;t<e;t++)n[R(this[t])]=L();return n}return e.slowReads=0,t}function R(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}let Ce=Te;function we(e){Ce=t(1);function t(t){return function(t){let n=O[de++];if(n==null){if(M)return Te(t);let r=e(E,T,t,w);if(typeof r==`string`)n=r,O=se;else if(O=r,de=1,j=1,n=O[0],n===void 0)throw Error(`Unexpected end of buffer`)}let r=n.length;return r<=t?(E+=t,n):(fe=n,pe=E,j=E+r,E+=t,n.slice(0,t))}}}function Te(e){let t;if(e<16&&(t=De(e)))return t;if(e>64&&oe)return oe.decode(w.subarray(E,E+=e));let n=E+e,r=[];for(t=``;E<n;){let e=w[E++];if(!(e&128))r.push(e);else if((e&224)==192){let t=w[E++]&63;r.push((e&31)<<6|t)}else if((e&240)==224){let t=w[E++]&63,n=w[E++]&63;r.push((e&31)<<12|t<<6|n)}else if((e&248)==240){let t=w[E++]&63,n=w[E++]&63,i=w[E++]&63,a=(e&7)<<18|t<<12|n<<6|i;a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a)}else r.push(e);r.length>=4096&&(t+=z.apply(String,r),r.length=0)}return r.length>0&&(t+=z.apply(String,r)),t}let z=String.fromCharCode;function Ee(e){let t=E,n=Array(e);for(let r=0;r<e;r++){let e=w[E++];if((e&128)>0){E=t;return}n[r]=e}return z.apply(String,n)}function De(e){if(e<4){if(e<2){if(e===0)return``;{let e=w[E++];if((e&128)>1){--E;return}return z(e)}}{let t=w[E++],n=w[E++];if((t&128)>0||(n&128)>0){E-=2;return}if(e<3)return z(t,n);let r=w[E++];if((r&128)>0){E-=3;return}return z(t,n,r)}}{let t=w[E++],n=w[E++],r=w[E++],i=w[E++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){E-=4;return}if(e<6){if(e===4)return z(t,n,r,i);{let e=w[E++];if((e&128)>0){E-=5;return}return z(t,n,r,i,e)}}if(e<8){let a=w[E++],o=w[E++];if((a&128)>0||(o&128)>0){E-=6;return}if(e<7)return z(t,n,r,i,a,o);let s=w[E++];if((s&128)>0){E-=7;return}return z(t,n,r,i,a,o,s)}{let a=w[E++],o=w[E++],s=w[E++],c=w[E++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){E-=8;return}if(e<10){if(e===8)return z(t,n,r,i,a,o,s,c);{let e=w[E++];if((e&128)>0){E-=9;return}return z(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=w[E++],u=w[E++];if((l&128)>0||(u&128)>0){E-=10;return}if(e<11)return z(t,n,r,i,a,o,s,c,l,u);let d=w[E++];if((d&128)>0){E-=11;return}return z(t,n,r,i,a,o,s,c,l,u,d)}{let l=w[E++],u=w[E++],d=w[E++],f=w[E++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){E-=12;return}if(e<14){if(e===12)return z(t,n,r,i,a,o,s,c,l,u,d,f);{let e=w[E++];if((e&128)>0){E-=13;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=w[E++],m=w[E++];if((p&128)>0||(m&128)>0){E-=14;return}if(e<15)return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=w[E++];if((h&128)>0){E-=15;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Oe(e){return k.copyBuffers?Uint8Array.prototype.slice.call(w,E,E+=e):w.subarray(E,E+=e)}let ke=new Float32Array(1),Ae=new Uint8Array(ke.buffer,0,4);function je(){let e=w[E++],t=w[E++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return Ae[3]=e&128|(n>>1)+56,Ae[2]=(e&7)<<5|t>>3,Ae[1]=t<<5,Ae[0]=0,ke[0]}Array(4096);var B=class{constructor(e,t){this.value=e,this.tag=t}};P[0]=e=>new Date(e),P[1]=e=>new Date(Math.round(e*1e3)),P[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},P[3]=e=>BigInt(-1)-P[2](e),P[4]=e=>+(e[1]+`e`+e[0]),P[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));const Me=(e,t)=>{e-=57344;let n=A[e];n&&n.isShared&&((A.restoreStructures||(A.restoreStructures=[]))[e]=n),A[e]=t,t.read=Se(t)};P[105]=e=>{let t=e.length,n=e[1];Me(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[R(t)]=e[i]}return r},P[14]=e=>M?M[0].slice(M.position0,M.position0+=e):new B(e,14),P[15]=e=>M?M[1].slice(M.position1,M.position1+=e):new B(e,15);let Ne={Error,RegExp};P[27]=e=>(Ne[e[0]]||Error)(e[1],e[2]);const Pe=e=>{if(w[E++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw w.length<E&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return F=F?t.concat(F.slice(t.length)):t,F.prefixes=e(),F.suffixes=e(),e()};Pe.handlesRead=!0,P[51]=Pe,P[6]=e=>{if(!F){if(k.getShared)He();else return new B(e,6)}if(typeof e==`number`)return F[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},P[28]=e=>{N||(N=new Map,N.id=0);let t=N.id++,n=E,r=w[E],i;i=r>>5==4?[]:{};let a={target:i};N.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(E=n,i=o,N.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},P[28].handlesRead=!0,P[29]=e=>{let t=N.get(e);return t.used=!0,t.target},P[258]=e=>new Set(e),(P[259]=e=>(k.mapsAsObjects&&(k.mapsAsObjects=!1,he=!0),e())).handlesRead=!0;function Fe(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function V(){if(!F){if(k.getShared)He();else throw Error(`No packed values available`)}return F}me.push((e,t)=>{if(e>=225&&e<=255)return Fe(V().prefixes[e-224],t);if(e>=28704&&e<=32767)return Fe(V().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return Fe(V().prefixes[e-1879048192],t);if(e>=216&&e<=223)return Fe(t,V().suffixes[e-216]);if(e>=27647&&e<=28671)return Fe(t,V().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return Fe(t,V().suffixes[e-1811939328]);if(e==1399353956)return{packedValues:F,structures:A.slice(0),version:t};if(e==55799)return t});const Ie=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Le=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],Re=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<Le.length;e++)ze(Le[e],Re[e]);function ze(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;P[i?t:t-4]=r==1||i==Ie?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!k.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function Be(){let e=Ve(),t=E+L();for(let t=2;t<e;t++){let e=Ve();E+=e}let n=E;return E=t,M=[Te(Ve()),Te(Ve())],M.position0=0,M.position1=0,M.postBundlePosition=E,E=n,L()}function Ve(){let e=w[E++]&31;if(e>23)switch(e){case 24:e=w[E++];break;case 25:e=I.getUint16(E),E+=2;break;case 26:e=I.getUint32(E),E+=4}return e}function He(){if(k.getShared){let e=Ue(()=>(w=null,k.getShared()))||{},t=e.structures||[];k.sharedVersion=e.version,F=k.sharedValues=e.packedValues,A===!0?k.structures=A=t:A.splice.apply(A,[0,t.length].concat(t))}}function Ue(e){let t=T,n=E,r=de,i=pe,a=j,o=fe,s=O,c=N,l=M,u=new Uint8Array(w.slice(0,T)),d=A,f=k,p=_e,m=e();return T=t,E=n,de=r,pe=i,j=a,fe=o,O=s,N=c,M=l,w=u,_e=p,A=d,k=f,I=new DataView(w.buffer,w.byteOffset,w.byteLength),m}function We(){w=null,N=null,A=null}const Ge=Array(147);for(let e=0;e<256;e++)Ge[e]=+(`1e`+Math.floor(45.15-e*.30103));let Ke=new ye({useRecords:!1});const qe=Ke.decode;Ke.decodeMultiple;const Je={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let Ye;try{Ye=new TextEncoder}catch{}let Xe,Ze;const Qe=typeof globalThis==`object`&&globalThis.Buffer,$e=Qe!==void 0,et=$e?Qe.allocUnsafeSlow:Uint8Array,tt=$e?Qe:Uint8Array,nt=$e?4294967296:2144337920;let rt,H,U,W=0,G,K=null;const it=/[\u0080-\uFFFF]/,q=Symbol(`record-id`);var at=class extends ye{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=tt.prototype.utf8Write?function(e,t,n){return H.utf8Write(e,t,n)}:Ye&&Ye.encodeInto?function(e,t){return Ye.encodeInto(e,H.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,ee=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e))}return this.encode(e,t)},this.encode=function(o,c){if(H||(H=new et(8192),U=new DataView(H.buffer,0,8192),W=0),G=H.length-10,G-W<2048?(H=new et(H.length),U=new DataView(H.buffer,0,H.length),G=H.length-10,W=0):c===512&&(W=W+7&2147483640),t=W,s.useSelfDescribedHeader&&(U.setUint32(W,3654940416),W+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(K=[],K.size=1/0):K=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[q]===void 0&&(i[q]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[q]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,ut(o,t),t.values.length>0){H[W++]=216,H[W++]=51,J(4);let e=t.values;_(e),J(0),J(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}rt=c&xt;try{if(rt)return;if(_(o),K&&mt(t,_),s.offset=W,a&&a.idsToInsert){W+=a.idsToInsert.length*2,W>G&&y(W),s.offset=W;let e=pt(H.subarray(t,W),a.idsToInsert);return a=null,e}return c&512?(H.start=t,H.end=W,H):H.subarray(t,W)}finally{if(n){if(ee<10&&ee++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,ee=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][q]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=H.subarray(t,W);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(W=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let _=n=>{W>G&&(H=y(W));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?H[W++]=t+224:(H[W++]=198,t&1?_(15-t>>1):_(t-16>>1));return}if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(K&&r>=4&&r<1024){if((K.size+=r)>61440){let e,n=(K[0]?K[0].length*3+K[1].length:0)+10;W+n>G&&(H=y(W+n)),H[W++]=217,H[W++]=223,H[W++]=249,H[W++]=K.position?132:130,H[W++]=26,e=W-t,W+=4,K.position&&mt(t,_),K=[``,``],K.size=0,K.position=e}let e=it.test(n);K[+!e]+=n,H[W++]=e?206:207,_(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(W+s>G&&(H=y(W+s)),r<64||!o){let e,t,o,s=W+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?H[s++]=t:t<2048?(H[s++]=t>>6|192,H[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,H[s++]=t>>18|240,H[s++]=t>>12&63|128,H[s++]=t>>6&63|128,H[s++]=t&63|128):(H[s++]=t>>12|224,H[s++]=t>>6&63|128,H[s++]=t&63|128);i=s-W-a}else i=o(n,W+a,s);i<24?H[W++]=96|i:i<256?(a<2&&H.copyWithin(W+2,W+1,W+1+i),H[W++]=120,H[W++]=i):i<65536?(a<3&&H.copyWithin(W+3,W+2,W+2+i),H[W++]=121,H[W++]=i>>8,H[W++]=i&255):(a<5&&H.copyWithin(W+5,W+3,W+3+i),H[W++]=122,U.setUint32(W,i),W+=4),W+=i}else if(r===`number`){if(!this.alwaysUseFloat&&n>>>0===n)n<24?H[W++]=n:n<256?(H[W++]=24,H[W++]=n):n<65536?(H[W++]=25,H[W++]=n>>8,H[W++]=n&255):(H[W++]=26,U.setUint32(W,n),W+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?H[W++]=31-n:n>=-256?(H[W++]=56,H[W++]=~n):n>=-65536?(H[W++]=57,U.setUint16(W,~n),W+=2):(H[W++]=58,U.setUint32(W,~n),W+=4);else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){H[W++]=250,U.setFloat32(W,n);let t;if(e<4||(t=n*Ge[(H[W]&127)<<1|H[W+1]>>7])>>0===t){W+=4;return}W--}H[W++]=251,U.setFloat64(W,n),W+=8}}else if(r===`object`){if(!n)H[W++]=246;else{if(a){let e=a.get(n);if(e){if(H[W++]=216,H[W++]=29,H[W++]=25,!e.references){let t=a.idsToInsert||(a.idsToInsert=[]);e.references=[],t.push(e)}e.references.push(W-t),W+=2;return}a.set(n,{offset:W-t})}let e=n.constructor;if(e===Object)v(n);else if(e===Array){i=n.length,i<24?H[W++]=128|i:J(i);for(let e=0;e<i;e++)_(n[e])}else if(e===Map){if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(H[W++]=217,H[W++]=1,H[W++]=3),i=n.size,i<24?H[W++]=160|i:i<256?(H[W++]=184,H[W++]=i):i<65536?(H[W++]=185,H[W++]=i>>8,H[W++]=i&255):(H[W++]=186,U.setUint32(W,i),W+=4),s.keyMap)for(let[e,t]of n)_(s.encodeKey(e)),_(t);else for(let[e,t]of n)_(e),_(t)}else{for(let e=0,t=Xe.length;e<t;e++){let t=Ze[e];if(n instanceof t){let t=Xe[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?H[W++]=192|r:r<256?(H[W++]=216,H[W++]=r):r<65536?(H[W++]=217,H[W++]=r>>8,H[W++]=r&255):r>-1&&(H[W++]=218,U.setUint32(W,r),W+=4),t.encode.call(this,n,_,y);return}}if(n[Symbol.iterator]){if(rt){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}H[W++]=159;for(let e of n)_(e);H[W++]=255;return}if(n[Symbol.asyncIterator]||lt(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return _(e)}v(n)}}}else if(r===`boolean`)H[W++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)H[W++]=27,U.setBigUint64(W,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)H[W++]=59,U.setBigUint64(W,-n-BigInt(1));else if(this.largeBigIntToFloat)H[W++]=251,U.setFloat64(W,Number(n));else{n>=BigInt(0)?H[W++]=194:(H[W++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);ft(new Uint8Array(e.reverse()),y);return}W+=8}else if(r===`undefined`)H[W++]=247;else throw Error(`Unknown type: `+r)},v=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?H[W++]=160|r:r<256?(H[W++]=184,H[W++]=r):r<65536?(H[W++]=185,H[W++]=r>>8,H[W++]=r&255):(H[W++]=186,U.setUint32(W,r),W+=4),s.keyMap)for(let e=0;e<r;e++)_(s.encodeKey(t[e])),_(n[e]);else for(let e=0;e<r;e++)_(t[e]),_(n[e])}:e=>{H[W++]=185;let n=W-t;W+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(_(s.encodeKey(t)),_(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(_(t),_(e[t]),r++);H[n+++t]=r>>8,H[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||(i.transitions=Object.create(null)),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[q]&1048576&&(c=a[q]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[q];if(d!==void 0)d&=65535,H[W++]=217,H[W++]=d>>8|224,H[W++]=d&255;else if(u||=a.__keys__||(a.__keys__=Object.keys(e)),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=256&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){H[W++]=217,H[W++]=d>>8|224,H[W++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[q]===void 0||a[q]&1048576)&&(a[q]=d),a=a[u[e]];a[q]=d|1048576,r=!0}else{if(a[q]=d,U.setUint32(W,3655335680),W+=3,o&&(g+=ee*o),h.length>=256-l&&(h.shift()[q]=void 0),h.push(a),J(s+2),_(57344+d),_(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&_(e[t]);return}if(s<24?H[W++]=128|s:J(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&_(e[t])},y=e=>{let n;if(e>16777216){if(e-t>nt)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(nt,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,H.length-1)>>12)+1<<12;let r=new et(n);return U=new DataView(r.buffer,0,n),H.copy?H.copy(r,0,t,e):r.set(H.slice(t,e)),W-=t,t=0,G=r.length-10,H=r},b=100,x=1e3;this.encodeAsIterable=function(e,t){return ne(e,t,S)},this.encodeAsAsyncIterable=function(e,t){return ne(e,t,re)};function*S(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?v(e,!0):ot(Object.keys(e).length,160);for(let r in e){let i=e[r];t||_(r),i&&typeof i==`object`?n[r]?yield*S(i,n[r]):yield*te(i,n,r):_(i)}}else if(i===Array){let r=e.length;J(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||W-t>b)?n.element?yield*S(r,n.element):yield*te(r,n,`element`):_(r)}}else if(e[Symbol.iterator]&&!e.buffer){H[W++]=159;for(let r of e)r&&(typeof r==`object`||W-t>b)?n.element?yield*S(r,n.element):yield*te(r,n,`element`):_(r);H[W++]=255}else lt(e)?(ot(e.size,64),yield H.subarray(t,W),yield e,C()):e[Symbol.asyncIterator]?(H[W++]=159,yield H.subarray(t,W),yield e,C(),H[W++]=255):_(e);r&&W>t?yield H.subarray(t,W):W-t>b&&(yield H.subarray(t,W),C())}function*te(e,n,r){let i=W-t;try{_(e),W-t>b&&(yield H.subarray(t,W),C())}catch(a){if(a.iteratorNotHandled)n[r]={},W=t+i,yield*S.call(this,e,n[r]);else throw a}}function C(){b=x,s.encode(null,xt)}function ne(e,t,n){return b=t&&t.chunkThreshold?x=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,xt),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*re(e,t){for(let n of S(e,t,!0)){let e=n.constructor;if(e===tt||e===Uint8Array)yield n;else if(lt(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)C(),e?yield*re(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){H=e,U=new DataView(H.buffer,H.byteOffset,H.byteLength),W=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new st(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function ot(e,t){e<24?H[W++]=t|e:e<256?(H[W++]=t|24,H[W++]=e):e<65536?(H[W++]=t|25,H[W++]=e>>8,H[W++]=e&255):(H[W++]=t|26,U.setUint32(W,e),W+=4)}var st=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function J(e){e<24?H[W++]=128|e:e<256?(H[W++]=152,H[W++]=e):e<65536?(H[W++]=153,H[W++]=e>>8,H[W++]=e&255):(H[W++]=154,U.setUint32(W,e),W+=4)}const ct=typeof Blob>`u`?function(){}:Blob;function lt(e){if(e instanceof ct)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function ut(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e){if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)ut(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&ut(n,t),ut(e[n],t))}}break;case`function`:console.log(e)}}const dt=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Ze=[Date,Set,Error,RegExp,B,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,st],Xe=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(H[W++]=26,U.setUint32(W,n),W+=4):(H[W++]=251,U.setFloat64(W,n),W+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){ft(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||$e&&this.tagUint8Array!==!1))return 64},encode(e,t,n){ft(e,n)}},Y(68,1),Y(69,2),Y(70,4),Y(71,8),Y(72,1),Y(77,2),Y(78,4),Y(79,8),Y(85,4),Y(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){H[W++]=216,H[W++]=51,J(4);let e=n.values;t(e),J(0),J(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){U.setUint32(W,3655335424),W+=3;let n=r.slice(0);n.unshift(57344),n.push(new B(e.version,1399353956)),t(n)}else t(new B(e.version,1399353956))}}];function Y(e,t){return!dt&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t($e?Qe.from(i,r,n):new Uint8Array(i,r,n))}}}function ft(e,t){let n=e.byteLength;n<24?H[W++]=64+n:n<256?(H[W++]=88,H[W++]=n):n<65536?(H[W++]=89,H[W++]=n>>8,H[W++]=n&255):(H[W++]=90,U.setUint32(W,n),W+=4),W+n>=H.length&&t(W+n),H.set(e.buffer?e:new Uint8Array(e),W),W+=n}function pt(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function mt(e,t){U.setUint32(K.position+e,W-K.position-e+1);let n=K;K=null,t(n[0]),t(n[1])}let ht=new at({useRecords:!1});const gt=ht.encode;ht.encodeAsIterable,ht.encodeAsAsyncIterable;const{NEVER:_t,ALWAYS:vt,DECIMAL_ROUND:yt,DECIMAL_FIT:bt}=Je,xt=2048;if(process.env.CBOR_NATIVE_ACCELERATION_DISABLED===void 0||process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase()!==`true`){let e;try{e=typeof t==`function`?t(`cbor-extract`):S(import.meta.url)(`cbor-extract`),e&&we(e.extractStrings)}catch{}}var X=_();const St=`5.0.0-beta.45`,Z=c(`@workflow/world-vercel//httpPools`,1,()=>({dispatcher:void 0,queueDispatcher:void 0,streamDispatcher:void 0,streamCloseDispatcher:void 0,nodeHttpAgents:void 0})),Ct={connections:8,keepAliveTimeout:1e4},wt=3e5,Tt=3e5,Et={...Ct,allowH2:!1,pipelining:1},Dt=()=>i(`WORKFLOW_VERCEL_QUEUE_TIMEOUT_MS`,3e4,{integer:!0,min:5e3,max:12e4});function Ot(){let e=Dt();return{...Et,connections:i(`WORKFLOW_VERCEL_QUEUE_CONNECTIONS`,64,{integer:!0,min:1,max:1024}),headersTimeout:e,bodyTimeout:e}}const kt=X.DecoratorHandler;function At(e){class t extends kt{#e=!1;#t;#n;constructor(t){super(t),this.#n=setTimeout(()=>{this.#e=!0,this.#r()},e),this.#n.unref?.()}#r(){this.#t?.abort(Error(`Queue request exceeded its ${e}ms deadline`))}onRequestStart(e,t){this.#t=e,super.onRequestStart(e,t),this.#e&&this.#r()}onResponseEnd(e,t){clearTimeout(this.#n),super.onResponseEnd(e,t)}onResponseError(e,t){clearTimeout(this.#n),super.onResponseError(e,t)}}return e=>(n,r)=>e(n,new t(r))}const jt={...Ct,allowH2:!0,pipelining:100,initialWindowSize:4194304,connectionWindowSize:16777216},Mt={...Ct,allowH2:!1,pipelining:1},Nt={...Ct,allowH2:!0,pipelining:1},Pt={retryAfter:!0,statusCodes:[500,502,503,504]},Ft={retryAfter:!0,methods:[`PUT`],statusCodes:[429]},It={retryAfter:!0,methods:[`PUT`],statusCodes:[429,500,502,503,504]};function Lt(){return process.env.WORKFLOW_H2_MULTIPLEX!==`0`}function Rt(e){if(!e||typeof e!=`object`||Array.isArray(e))return NaN;let t=e,n=t[`content-length`]??t[`Content-Length`];return typeof n==`string`||typeof n==`number`?Number(n):NaN}function zt(e){return(t,n)=>{let r=t.body,i=!!r&&typeof r!=`string`&&!Buffer.isBuffer(r)&&typeof r[Symbol.asyncIterator]==`function`,a=Rt(t.headers);return!i||!(a>=0)||a>1048576?e({...t,idempotent:!0},n):((async()=>{try{let i=[];for await(let e of r)i.push(Buffer.from(e));e({...t,body:Buffer.concat(i),idempotent:!0},n)}catch(e){n.onError?.(e)}})(),!0)}}const Bt=new Set([`UND_ERR_INFO`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`]);function Vt(e){let t=e;for(let e=0;t&&e<8;e++){let e=t.code;if(typeof e==`string`&&Bt.has(e))return!0;t=t.cause}return!1}function Ht(e,t){let n,r=0,i=0;function a(e){let t=setTimeout(()=>{Promise.resolve(e.close?.()).catch(()=>void 0)},5e3),n=setTimeout(()=>{Promise.resolve(e.destroy?.()).catch(()=>void 0)},6e4);t.unref?.(),n.unref?.()}return{get(){return n??=e(),n},note(e,o){if(!n||e!==n)return;if(o===void 0){r=0;return}if(!Vt(o)||(r++,r<3))return;let s=Date.now();if(s-i<5e3)return;i=s,r=0;let c=n;n=void 0,console.warn(`[workflow] ${t}: rebuilding connection pool after 3 consecutive transport failures`),a(c)}}}const Ut=c(`@workflow/world-vercel//eventsDispatcherRecycler@${St}`,1,()=>Ht(()=>$t(),`events transport`));function Wt(e,t){Ut.note(e,t)}function Gt(e,t){return e?.dispatcher?e.dispatcher:s()?void 0:t()}function Kt(e){if(!e?.dispatcher&&s())return Z.nodeHttpAgents??=v({maxSockets:Ct.connections,keepAliveMs:Ct.keepAliveTimeout}),Z.nodeHttpAgents}function qt(e){return Gt(e,an)}function Jt(e){return Gt(e,rn)}function Yt(e){return Gt(e,()=>Ut.get())}function Xt(e){return Gt(e,on)}function Zt(e){return Gt(e,sn)}function Qt(e,t){return new X.RetryAgent(new X.Agent(e),t)}function $t(e){let t=Lt(),n=new X.RetryAgent(new X.Agent({...t?jt:Mt,...e}),Pt);return t?en(n,n.compose(zt)):n}function en(e,t){return new Proxy(t,{get:(t,n)=>n===`close`||n===`destroy`?e[n].bind(e):t[n]})}function tn(e,t){return new X.RetryAgent(new X.Agent({...Nt,...t}),e)}function nn(){return new X.RetryAgent(new X.Agent(Ot()).compose(At(Dt())),Pt)}function rn(){return Z.queueDispatcher??=nn(),Z.queueDispatcher}function an(){return Z.dispatcher??=Qt(Et,Pt),Z.dispatcher}function on(){return Z.streamDispatcher??=tn(Ft),Z.streamDispatcher}function sn(){return Z.streamCloseDispatcher??=tn(It),Z.streamCloseDispatcher}const cn=c(`@workflow/world-vercel//telemetry`,1,()=>({apiPromise:null,tracerPromise:null}));async function ln(){return cn.apiPromise||=import(`../../@opentelemetry/api/index.js`).catch(e=>(typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)&&console.warn(`[workflow] @opentelemetry/api unavailable — world-vercel spans disabled:`,e instanceof Error?e.message:e),null)),cn.apiPromise}function un(){return typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)}let dn=!1;function fn(e,t){if(!dn&&un()){dn=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.world_vercel`);console.warn(`[workflow:otel-diag] world-vercel`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] world-vercel failed:`,e instanceof Error?e.message:e)}}}async function pn(){return cn.tracerPromise||=ln().then(e=>{if(!e)return null;let t=e.trace.getTracer(`workflow`);return fn(e,t),t}),cn.tracerPromise}async function mn(e,...t){let[n,r]=await Promise.all([pn(),ln()]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),t}finally{e.end()}})}async function hn(e){let t=await ln();if(t)return t.SpanKind[e]}async function gn(e){let t=await ln();if(!t)return;let n={};t.propagation.inject(t.context.active(),n);for(let[t,r]of Object.entries(n))e.set(t,r)}function Q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const _n=Q(`http.request.method`),vn=Q(`url.full`),yn=Q(`server.address`),bn=Q(`server.port`),xn=Q(`http.response.status_code`),$=Q(`error.type`),Sn=Q(`network.protocol.name`),Cn=Q(`workflow.world.parse.format`),wn=Q(`peer.service`),Tn=Q(`rpc.system`),En=Q(`rpc.service`),Dn=Q(`rpc.method`),On=Q(`workflow.run.id`),kn=Q(`step.id`),An=Q(`workflow.stream.name`),jn=Q(`workflow.stream.operation`),Mn=Q(`workflow.stream.start_index`),Nn=Q(`workflow.events.transport`),Pn=Q(`workflow.http.transport`),Fn=Q(`workflow.event.type`),In=Q(`workflow.client.version`),Ln=Q(`step.stso_ms`),Rn=Q(`step.latency_optimizations`),zn=Q(`workflow.events.ws.url`),Bn=Q(`workflow.events.ws.req_id`),Vn=Q(`workflow.events.ws.reconnect_attempt`),Hn=new Set([`UND_ERR_INFO`,`UND_ERR_REQ_RETRY`,`UND_ERR_SOCKET`,`UND_ERR_CONNECT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CLOSED`,`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`EAI_AGAIN`,`EPIPE`,`ETIMEDOUT`]);function Un(e){let t=e;for(let e=0;t&&e<8;e++){let e=t.code;if(typeof e==`string`&&Hn.has(e))return e;t=t.cause}}const Wn=()=>i(`WORKFLOW_REQUEST_TIMEOUT_MS`,6e4,{integer:!0,min:1e4,max:12e4}),Gn=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`),Kn=[`x-vercel-id`,`x-vercel-error`,`x-vercel-mitigated`];function qn(e){return Kn.flatMap(t=>{let n=e.get(t);return n?[`${t}=${n}`]:[]})}function Jn(e){let t=qn(e);return t.length>0?` (${t.join(`; `)})`:``}function Yn(e,t,n,r){if(!Gn)return;let i=qn(n.headers),a=i.length>0?`; ${i.join(`; `)}`:``;console.debug(`[workflow:world-vercel:http] ${e} ${t} -> ${n.status} (${r}ms${a})`)}function Xn(e,t,n){if(!process.env.DEBUG)return;let r=Array.from(n.entries()).filter(([e])=>e.toLowerCase()!==`authorization`).map(([e,t])=>`-H "${e}: ${t}"`).join(` `);console.error(`Failed to fetch, reproduce with:\ncurl -X ${e} ${r} "${t}"`)}function Zn(e){if(!e)return;let t=parseInt(e,10);return Number.isNaN(t)?void 0:t}function Qn(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function $n(e,t,n={}){let{retryAfter:r,code:i,url:a,mitigated:o,details:s}=n;if(e===409)return new m(t);if(e===410){if(i===`stream-expired`){let e=s&&typeof s==`object`?s:void 0,n=typeof e?.expiredAt==`string`?new Date(e.expiredAt):void 0;return new u(t,typeof e?.runId==`string`?e.runId:void 0,typeof e?.streamId==`string`?e.streamId:void 0,n&&!Number.isNaN(n.getTime())?n:void 0)}return new f(t)}return e===412?new d(t,{retryAfter:r,details:s}):e===425?new g(t,{retryAfter:r}):e===429?er(e,o)?new l(`${t} (x-vercel-mitigated=challenge)`,{url:a,status:e,code:`TRANSPORT`,retryAfter:r}):new h(t,{retryAfter:r}):new l(t,{url:a,status:e,code:i,retryAfter:r})}function er(e,t){return e===429&&t===`challenge`}async function tr(e){return e?.token??process.env.VERCEL_TOKEN??await(0,ae.getVercelOidcToken)().catch(()=>null)}function nr(e){try{let t=new URL(e),n=t.protocol===`https:`||t.protocol===`wss:`;return{serverAddress:t.hostname,serverPort:t.port?parseInt(t.port,10):n?443:80}}catch{return{}}}function rr(e){let{method:t,url:n,peerService:r}=e,{serverAddress:i,serverPort:a}=nr(n);return{..._n(t),...vn(n),...i?yn(i):{},...a?bn(a):{},...wn(r),...Tn(`http`),...En(r)}}async function ir(e,t){let{method:n,url:r,peerService:i=`workflow-server`,spanName:a,attributes:o}=e;return mn(a??`http ${n}`,{kind:await hn(`CLIENT`)},async e=>{if(a&&Gn&&e){let t=e.spanContext();console.warn(`[workflow:otel-diag] span-open`,JSON.stringify({spanName:a,traceId:t.traceId,spanId:t.spanId,recording:e.isRecording()}))}return e?.setAttributes(rr({method:n,url:r,peerService:i})),o&&e?.setAttributes(o),t(e)})}function ar(e,t){e?.setAttributes({...xn(t)}),(t<200||t>=300)&&e?.setAttributes({...$(`HTTP ${t}`)})}async function or(e){let{method:t,url:n,headers:r,body:i,dispatcher:a,peerService:o,timeoutMs:s=Wn(),signal:c,injectTraceContext:u=!0,cacheBust:d=!0,logLabel:f,buildError:m,spanName:h,attributes:g,durationAttribute:_,onTransportOutcome:v,deferTransportSuccessUntilBody:y=!1,transportErrorCode:b=`TRANSPORT`}=e,x=f??n;return ir({method:t,url:n,peerService:o,spanName:h,attributes:g},async e=>{u&&await gn(r),d&&r.set(`X-Request-Time`,Date.now().toString());let o=s==null?void 0:AbortSignal.timeout(s),f=c&&o?AbortSignal.any([c,o]):c??o,h=Date.now(),g;try{let o=a?void 0:Kt();e?.setAttributes({...Pn(o?`node-http`:`undici`)}),g=o?await ee(n,{method:t,headers:r,body:i,signal:f,agents:o,headersTimeoutMs:wt,bodyTimeoutMs:Tt}):await fetch(n,{method:t,headers:r,body:i,signal:f,dispatcher:a})}catch(r){let i=Date.now()-h;if(v?.(r),r instanceof Error&&(r.name===`TimeoutError`||r.name===`AbortError`)){let a=`${t} ${x} timed out after ${i}ms`,o=b===`STREAM_ERROR`?`STREAM_ERROR`:`TIMEOUT`,s=o===`STREAM_ERROR`?new p(a,{url:n,cause:r}):new l(a,{url:n,code:o,cause:r});throw e?.setAttributes({...$(o)}),e?.recordException?.(s),s}let a=Un(r);if(a){let o=`${t} ${x} transport failure after ${i}ms (${a})`,s=b===`STREAM_ERROR`?`STREAM_ERROR`:`TRANSPORT`,c=s===`STREAM_ERROR`?new p(o,{url:n,cause:r}):new l(o,{url:n,code:s,cause:r});throw e?.setAttributes({...$(s)}),e?.recordException?.(c),c}throw r}let S=Date.now()-h;if(g.ok&&!y&&v?.(void 0,g),Yn(t,x,g,S),ar(e,g.status),_&&e?.setAttributes({[_]:S}),!g.ok){if(Xn(t,n,r),m){let r;try{r=await m(g)}catch(r){let i=Un(r);if(i){v?.(r,g);let a=`${t} ${x} response body transport failure (${i})`,o=b===`STREAM_ERROR`?new p(a,{url:n,cause:r}):new l(a,{url:n,code:`TRANSPORT`,cause:r});throw e?.setAttributes({...$(b)}),e?.recordException?.(o),o}throw v?.(void 0,g),r}throw v?.(void 0,g),e?.recordException?.(r),r}let i=``;try{i=await g.text(),v?.(void 0,g)}catch(e){v?.(e,g)}let a=$n(g.status,`${t} ${x} -> HTTP ${g.status}: ${g.statusText}${i?` ${i}`:``}${Jn(g.headers)}`,{url:n,retryAfter:Zn(g.headers.get(`Retry-After`))});throw e?.recordException?.(a),a}return g})}const sr=new Set([`GET`,`HEAD`]),cr=()=>process.env.VERCEL_WORKFLOW_SERVER_URL||``,lr=()=>process.env.WORKFLOW_TEST_LIMIT_OVERRIDES?.trim()||``;function ur(e){return e}const dr=(...e)=>e.filter(Boolean).join(` `),fr=()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;return e?`@workflow/world-vercel/${St} node-${process.version} ${C.platform()} (${C.arch()}) ${e}`:`@workflow/world-vercel/${St} node-${process.version} ${C.platform()} (${C.arch()})`},pr=e=>{let t=e?.projectConfig,n=cr()||`https://vercel-workflow.com`,r=process.env.WORKFLOW_VERCEL_BACKEND_URL,i=!!(t?.projectId&&t?.teamId);return{baseUrl:i?r||`https://api.vercel.com/v1/workflow`:`${n}/api`,usingProxy:i}},mr=e=>{let t=e?.projectConfig;return t?t.environment||`production`:process.env.VERCEL_TARGET_ENV||process.env.VERCEL_ENV||void 0},hr=(e,t)=>{let n=e?.projectConfig,r=new Headers(e?.headers);r.set(`User-Agent`,dr(fr(),r.get(`User-Agent`)));let i=lr();i&&r.set(`x-workflow-test-limit-overrides`,i),n&&(r.set(`x-vercel-environment`,mr(e)),n.projectId&&r.set(`x-vercel-project-id`,n.projectId),n.teamId&&r.set(`x-vercel-team-id`,n.teamId));let a=cr();return a&&t.usingProxy&&r.set(`x-vercel-workflow-api-url`,a),r};async function gr(e){let{baseUrl:t,usingProxy:n}=pr(e),r=hr(e,{usingProxy:n});if(n){if(!e?.token)throw Error(`world-vercel: api-workflow proxy requested (${t}) but no Vercel auth token was provided. Pass one as \`config.token\` (the SDK reads it from \`WORKFLOW_VERCEL_AUTH_TOKEN\`).`);r.set(`Authorization`,`Bearer ${e.token}`)}else{let t;try{t=await(0,ae.getVercelOidcToken)()}catch{}let n=e?.token??t;n&&r.set(`Authorization`,`Bearer ${n}`),t&&r.set(`x-vercel-trusted-oidc-idp-token`,t)}return{baseUrl:t,headers:r,usingProxy:n}}async function _r({endpoint:e,options:t={},config:n={},schema:r,data:i,onResponse:a,retryConnectTimeout:o=!1}){let s=(t.method||`GET`).toUpperCase(),{baseUrl:c,headers:u}=await gr(n),d=`${c}${e}`;return mn(`http ${s}`,{kind:await hn(`CLIENT`)},async c=>{c?.setAttributes(rr({method:s,url:d,peerService:`workflow-server`})),u.set(`Accept`,`application/cbor`),await gn(u);let f;i!==void 0&&(u.set(`Content-Type`,`application/cbor`),f=gt(i));let p=sr.has(s),m,h=``;for(let r=0;;r++){u.set(`X-Request-Time`,Date.now().toString());let i=AbortSignal.timeout(Wn()),g=t.signal?AbortSignal.any([t.signal,i]):i,_=Date.now(),v;try{let e=Kt(n);c?.setAttributes({...Pn(e?`node-http`:`undici`)}),v=e?await ee(d,{method:s,headers:u,body:f,signal:g,agents:e,headersTimeoutMs:wt,bodyTimeoutMs:Tt}):await fetch(new Request(d,{...t,body:f,headers:u,signal:g}),{dispatcher:qt(n)})}catch(t){let n=Date.now()-_;if(t instanceof Error&&(t.name===`TimeoutError`||t.name===`AbortError`)){let r=new l(`${s} ${e} timed out after ${n}ms`,{url:d,code:`TIMEOUT`,cause:t});throw c?.setAttributes({...$(`TIMEOUT`)}),c?.recordException?.(r),r}let i=Un(t);if(i){if(o&&p&&i===`UND_ERR_CONNECT_TIMEOUT`&&r===0){await new Promise(e=>setTimeout(e,100));continue}let a=new l(`${s} ${e} transport failure after ${n}ms (${i})`,{url:d,code:`TRANSPORT`,cause:t});throw c?.setAttributes({...$(`TRANSPORT`)}),c?.recordException?.(a),a}throw t}let y=Date.now()-_;if(h=Jn(v.headers),Yn(s,e,v,y),c?.setAttributes({...xn(v.status)}),!v.ok){let t=await yr(v).then(e=>e.data).catch(()=>({})),n=t.code??t.error;Xn(s,d,u);let r=Zn(v.headers.get(`Retry-After`)),i=(t.message||`${s} ${e} -> HTTP ${v.status}: ${v.statusText}`)+h,a=$n(v.status,i,{url:d,code:n,retryAfter:r,mitigated:v.headers.get(`x-vercel-mitigated`),details:t.details});throw c?.setAttributes({...$(n||`HTTP ${v.status}`)}),c?.recordException?.(a),a}a?.(v);try{m=await mn(`world.parse`,async e=>{let t=await yr(v),n=(v.headers.get(`Content-Type`)||``).includes(`application/cbor`);return e?.setAttributes({...Cn(n?`cbor`:`json`)}),t});break}catch(t){if(p&&r<2){let n=100*2**r;c?.setAttributes({...$(`PARSE_ERROR_RETRYING`)}),Gn&&console.debug(`[workflow:world-vercel:http] ${s} ${e} body parse failed (attempt ${r+1}/3); retrying in ${n}ms: ${t}`),await new Promise(e=>setTimeout(e,n));continue}let n=v.headers.get(`Content-Type`)||`unknown`;throw new l(`Failed to parse response body for ${s} ${e}${h} (Content-Type: ${n}):\n\n${t}`,{url:d,code:`PARSE_ERROR`,cause:t})}}return await mn(`world.validate`,async()=>{let t=r.safeParse(m.data);if(!t.success){let n=t.error.issues.map(e=>` ${e.path.length>0?e.path.join(`.`):`<root>`}: ${e.message}`).join(`
3
- `),r=process.env.DEBUG?`\n\nResponse context: ${m.getDebugContext()}`:``;throw new l(`Schema validation failed for ${s} ${e}${h}:\n${n}${r}`,{url:d,code:`SCHEMA_VALIDATION`,cause:t.error})}return t.data})})}function vr(e){let t=te(e,{depth:3,maxArrayLength:10,breakLength:120});return t.length>500?`${t.slice(0,500)}...`:t}async function yr(e){let t=e.headers.get(`Content-Type`)||``;if(t.includes(`application/cbor`)){let n=await e.arrayBuffer(),r=qe(new Uint8Array(n));return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.byteLength} bytes (CBOR), preview: ${vr(r)}`}}let n=await e.text(),r=JSON.parse(n);return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.length} bytes, preview: ${vr(r)}`}}function br(){return process.env.WORKFLOW_EVENTS_TRANSPORT?.trim().toLowerCase()!==`http`}function xr(){let e=process.env.WORKFLOW_INTERNAL_EVENTS_TRANSPORT_STRICT;return e===`1`||e===`true`}const Sr=`application/vnd.workflow.v4-frames`;var Cr=class extends Error{};const wr=r(a(),o());function Tr(e,t){let n=new Uint8Array(gt(e)),r=new Uint8Array(4+n.byteLength+4+t.byteLength),i=new DataView(r.buffer);return i.setUint32(0,n.byteLength,!1),r.set(n,4),i.setUint32(4+n.byteLength,t.byteLength,!1),r.set(t,4+n.byteLength+4),r}async function*Er(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():Or(e.getReader()),n=new Uint8Array,r=async e=>{if(n.byteLength>=e)return!0;let r=[n],i=n.byteLength;for(;i<e;){let e;try{e=await t.next()}catch(e){throw new Cr(`decodeFrames: source stream failed`,{cause:e})}if(e.done)return!1;e.value.byteLength!==0&&(r.push(e.value),i+=e.value.byteLength)}n=new Uint8Array(i);let a=0;for(let e of r)n.set(e,a),a+=e.byteLength;return!0},i=e=>{let t=n.subarray(0,e);return n=n.subarray(e),t};try{for(;;){if(!await r(4))return;let e=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),!await r(e))throw new Cr(`decodeFrames: truncated meta block`);let t=wr.parse(qe(i(e)));if(!await r(4))throw new Cr(`decodeFrames: truncated body length`);let a=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),a>0&&!await r(a))throw new Cr(`decodeFrames: truncated body bytes`);if(yield{meta:t,body:n.slice(0,a)},i(a),t._end===1)return}}finally{Dr(()=>t.return?.())}}function Dr(e){try{Promise.resolve(e()).catch(()=>{})}catch{}}async function*Or(e){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{Dr(()=>e.cancel())}}export{gt as $,kn as A,Vn as B,ir as C,Dn as D,wn as E,Nn as F,mn as G,zn as H,On as I,Jt as J,qt as K,An as L,Ln as M,In as N,En as O,Fn as P,St as Q,jn as R,tr as S,Sn as T,hn as U,Bn as V,gn as W,Xt as X,Zt as Y,Wt as Z,Qn as _,br as a,Zn as b,hr as c,_r as d,qe as et,mr as f,qn as g,Un as h,Tr as i,Rn as j,Tn as k,gr as l,Wn as m,Sr as n,xr as o,$n as p,Yt as q,Er as r,ur as s,Cr as t,ie as tt,pr as u,Yn as v,$ as w,ar as x,or as y,Mn as z};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-DPpTSio4.js";import{W as t,c as n,o as r}from"./dist-DDeH-1ER.js";import{At as i,Dt as a,Gn as o,Mn as s,Tr as c,Tt as l,fr as u,ft as d,gt as f,ir as p,j as m,jr as h,kt as g,mr as _,n as v,r as y,rr as b,s as x,tr as S,tt as C,w,wt as T,z as E}from"./attribute-changes-C6H-fRVP.js";import{d as D,k as O,n as k,o as A}from"./dist-xTushGCp.js";var j=e({getHookByToken:()=>U,resumeHook:()=>W,resumeWebhook:()=>K});const M=r();async function N(e){let t=await crypto.subtle.digest(`SHA-256`,e),n=new Uint8Array(t),r=``;for(let e of n)r+=e.toString(16).padStart(2,`0`);return r}const P=[25,100];function F(e,t){if(t?.(e))return!1;let n=e??{},r=n.status??n.statusCode;if(typeof r==`number`)return r>=500||r===408||r===429;let i=e?.name;return i!==`BadRequestError`&&i!==`UnauthorizedError`&&i!==`ForbiddenError`}async function I(e,t){let n;for(let r=0;r<=P.length;r++)try{await e();return}catch(e){if(n=e,!F(e,t))break;let i=P[r];i!==void 0&&await new Promise(e=>setTimeout(e,i))}throw A.is(n)?new O(`The hook resume was committed, but its workflow wake could not be published`,{cause:n}):n}function L(e){let t=e.executionContext?.workflowCoreVersion,n=e.executionContext?.traceCarrier,r=e.executionContext?.hookResumeInputVersion;return{deploymentId:e.deploymentId,workflowName:e.workflowName,runSpecVersion:e.specVersion,workflowCoreVersion:typeof t==`string`?t:void 0,traceCarrier:n&&typeof n==`object`?n:void 0,encryptionPublicKey:e.encryptionPublicKey,hookResumeInputVersion:typeof r==`number`?r:void 0}}async function R(e){if(e.resumeContext)return{resumeContext:e.resumeContext,source:`hook`};let t=await(await _()).runs.get(e.runId);return{resumeContext:L(t),source:`run_fallback`,run:t}}async function z(e,t){let n=await _(),r=t.run?await n.getEncryptionKeyForRun?.(t.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:t.resumeContext.deploymentId});return r?await h(r):void 0}function B(e){let t=Object.getOwnPropertyDescriptor(e,`metadata`);return t!==void 0&&typeof t.get==`function`}function V(e){let t=e.metadata,n,r,i=async()=>{let n=await _(),i=await R(e),a=i.run?await n.getEncryptionKeyForRun?.(i.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:i.resumeContext.deploymentId});return r=a?await S(a):void 0,await E(t,e.runId,r)},a=e;return Object.defineProperty(a,"metadata",{get:()=>n??=t===void 0?Promise.resolve(void 0):i(),enumerable:!1,configurable:!0}),{hook:a,metadataEncryptionKey:()=>r}}function H(e){return B(e)?e:V(e).hook}async function U(e){return V(await(await _()).hooks.getByToken(e)).hook}async function W(e,t,n){return G(e,t,n,!1,Date.now())}async function G(e,r,c,h,S){return await y(()=>f(`hook.resume`,async f=>{let y=await _();try{let _=typeof e==`string`,T=_?await y.hooks.getByToken(e):e,E=_||h,O=await R(T),{resumeContext:k}=O;if(f?.setAttributes({...g(T.token),...l(T.hookId),...o(T.runId),"workflow.hook.resume_context_source":O.source}),O.run&&t(O.run.status))throw new A(T.token);let j=w(k.workflowCoreVersion),P,F=c?void 0:u(k.encryptionPublicKey);if(F)P=b(F);else{let e=c??await z(T,O);j.supportedFormats.has(p.ENCRYPTED)||(e=void 0),P=e}let L=(k.runSpecVersion??0)>=5&&j.supportedFormats.has(p.GZIP),B=[],V=[],U=n(T.specVersion),W=await m(r,T.runId,P,B,globalThis,U,j.framedByteStreams,L,void 0,V);await Promise.all(B.map(e=>e.catch(e=>{if(e!==void 0)throw e}))),v(Promise.all(V),e=>{e!==void 0&&C.warn(`Background readback of hook payload failed`,{workflowRunId:T.runId,hookId:T.hookId,error:e instanceof Error?e.message:String(e)})}),f?.setAttributes({...s(k.workflowName)});let G=await d(k.traceCarrier);G&&f?.addLink?.(G);let K=x(k.workflowName),q={deploymentId:k.deploymentId,specVersion:k.runSpecVersion??1},J=((E?T.resumeCapabilities?.hookResumeDedupVersion??0:0)>=1||y.capabilities?.hookResumeDedup===!0)&&!U&&W instanceof Uint8Array;f?.setAttributes({"workflow.hook.resume_strategy":`sequential`});let Y=J?M():void 0,X=J?await N(W):void 0;Y&&f?.setAttributes({"workflow.hook.resume_id":Y});let Z=e=>A.is(e)||D.is(e);try{await y.events.create(T.runId,{eventType:`hook_received`,specVersion:7,correlationId:T.hookId,eventData:{...U?{}:{token:T.token},payload:W}},{v1Compat:U,...Y&&X?{resumeId:Y,resumePayloadDigest:X}:{}})}catch(e){throw Z(e)?new A(T.token):e}f?.setAttributes(a(!0));let Q=Date.now();return await I(()=>y.queue(K,{runId:T.runId,traceCarrier:k.traceCarrier??void 0,hookResumeTiming:{resumeRequestedAtMs:S,queuePublishRequestedAtMs:Q,strategy:`sequential`}},{...q,...Y?{idempotencyKey:`hook-${Y}`}:{}}),y.isDeploymentUnavailableError?.bind(y)),f?.setAttributes(i(!0)),H(T)}catch(t){throw f?.setAttributes({...g(typeof e==`string`?e:e.token),...T(!1)}),t}}))}async function K(e,t){let n=Date.now(),{hook:r,metadataEncryptionKey:i}=V(await(await _()).hooks.getByToken(e));if(r.isWebhook===!1)throw new A(e);let a=await r.metadata,o,s;if(a&&typeof a==`object`&&`respondWith`in a){if(a.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;s=e,t[c]=n}else if(a.respondWith instanceof Response)o=a.respondWith;else throw new O(`Invalid \`respondWith\` value: ${a.respondWith}`,{slug:k.WEBHOOK_INVALID_RESPOND_WITH_VALUE})}else o=new Response(null,{status:202});if(await G(r,t,i(),!0,n),s){let e=s.getReader(),t=await e.read();t.value&&(o=t.value),e.cancel()}if(!o)throw new O(`Workflow run did not send a response`,{slug:k.WEBHOOK_RESPONSE_NOT_SENT});return o}export{j as i,W as n,K as r,U as t};