eve 0.38.0 → 0.38.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +5 -5
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +97 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +35 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +127 -93
- package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +8 -9
- package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/runtime/resume-latency.d.ts +143 -0
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +27 -12
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +39 -8
- package/dist/src/compiled/@workflow/core/runtime/world-compatibility.d.ts +6 -5
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +81 -0
- package/dist/src/compiled/@workflow/core/test-support/orchestrator-context.d.ts +25 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +18 -2
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +9 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +76 -87
- package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +45 -45
- package/dist/src/compiled/@workflow/world/queue.d.ts +86 -0
- package/dist/src/compiled/@workflow/world/slot-identity.d.ts +15 -0
- package/dist/src/compiled/@workflow/world/spec-version.d.ts +30 -18
- package/dist/src/compiled/@workflow/world/test-support/duplicate-event-fixtures.d.ts +41 -0
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-DZtQkszH.js → attribute-changes-B8K0pwpH.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-CPlyFOVo.js → dist-BRGbNjhD.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-xQXN70ED.js → dist-CqvWKNQv.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/frames-DoexhtxJ.js +3 -0
- package/dist/src/compiled/_chunks/workflow/private-z_2Kcwee.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-DO_MuJlY.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-lq7-eG0l.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-7TgF3i-e.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-BPSgt1Wg.js +15 -0
- package/dist/src/compiled/_chunks/workflow/ws-transport-TYZ9zwoZ.js +1 -0
- package/dist/src/compiler/extension-compatibility.d.ts +5 -0
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/model-catalog.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-extension.d.ts +10 -1
- package/dist/src/compiler/normalize-extension.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-subagent.d.ts +1 -0
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/discover-subagent.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +1 -0
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/session-callback-step.d.ts +8 -0
- package/dist/src/execution/session-callback-step.js +1 -1
- package/dist/src/execution/session.d.ts +2 -0
- package/dist/src/execution/session.js +1 -1
- package/dist/src/execution/task-event-callback.d.ts +5 -6
- package/dist/src/execution/task-event-callback.js +1 -1
- package/dist/src/execution/tasks/child/instructions.d.ts +3 -0
- package/dist/src/execution/tasks/child/instructions.js +1 -0
- package/dist/src/execution/tasks/child/steps.d.ts +7 -1
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/update.d.ts +10 -0
- package/dist/src/execution/tasks/child/update.js +1 -0
- package/dist/src/execution/tasks/child/workflow.d.ts +3 -3
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/agent-views.js +1 -1
- package/dist/src/execution/tasks/parent/control-shared.d.ts +1 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +1 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +5 -3
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +3 -0
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/public/channels/mcp.d.ts +2 -2
- package/dist/src/public/channels/mcp.js +1 -1
- package/dist/src/runtime/framework-tools/index.js +1 -1
- package/dist/src/runtime/framework-tools/tasks.d.ts +6 -7
- package/dist/src/runtime/framework-tools/tasks.js +1 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/session-callback-route.js +1 -1
- package/dist/src/setup/scaffold/create/extension.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/tasks/task-id.d.ts +1 -2
- package/dist/src/tasks/task-id.js +1 -1
- package/dist/src/tasks/task-inbox-token.d.ts +2 -0
- package/dist/src/tasks/task-inbox-token.js +1 -0
- package/dist/src/tasks/types.d.ts +9 -1
- package/dist/src/tasks/wire.d.ts +2 -3
- package/docs/channels/custom.mdx +1 -0
- package/docs/channels/mcp.mdx +185 -0
- package/docs/channels/meta.json +1 -0
- package/docs/channels/overview.mdx +6 -1
- package/docs/extensions.md +14 -6
- package/docs/guides/auth-and-route-protection.md +1 -0
- package/docs/guides/dev-tui.md +1 -0
- package/docs/instructions.mdx +1 -0
- package/docs/subagents/index.mdx +3 -1
- package/package.json +6 -6
- package/dist/src/compiled/_chunks/workflow/frames-BBs-9k1d.js +0 -3
- package/dist/src/compiled/_chunks/workflow/private-UQtz8ZcW.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-CYtSorp6.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-Cjo0A3NO.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-C1P0OWBm.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wait-until-CT1ve8qB.js +0 -15
- package/dist/src/compiled/_chunks/workflow/ws-transport-beXxD0s_.js +0 -1
- package/dist/src/execution/tasks/parent/send.d.ts +0 -25
- package/dist/src/execution/tasks/parent/send.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Cr as e,Er as t,Tr as n,wr as r}from"./wait-until-BPSgt1Wg.js";import{i}from"./dist-CqvWKNQv.js";import{$ as a,Y as o}from"./dist-BRGbNjhD.js";function s(e,t){let n=Error.captureStackTrace;n?.(e,t)}const c=Symbol.for(`nodejs.util.inspect.custom`);function l(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function u(t){return`code`in t?e(t.code):`dim`in t?r(t.dim):t.text}function d(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(l).join(``)}function f(e){return e.type===`docs`?n(e.url):e.segments.map(u).join(``)}function p(e){let t=[e.title.map(l).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;d(n).split(`
|
|
2
2
|
`).forEach((e,n)=>{t.push(`${n===0?a:o}${e}`)})}),t.join(`
|
|
3
3
|
`)}function m(e){return t(e.title.map(u).join(``),e.details.map(f))}var h=class extends Error{fatal=!0;#e;constructor(e){super(p(e)),this.#e=e}[c](){let e=m(this.#e),t=this.message.split(`
|
|
4
4
|
`).length,n=(this.stack??``).split(`
|
|
@@ -37,4 +37,4 @@ import{r as e}from"./rolldown-runtime-8V8biNmG.js";import t from"node:crypto";co
|
|
|
37
37
|
|
|
38
38
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=be,c=!s.jitless,l=c&&xe.value,u=t.catchall,ee;e._zod.parse=(s,te)=>{ee??=r.value;let ne=s.value;return o(ne)?c&&l&&te?.async===!1&&te.jitless!==!0?(a||=i(t.shape),s=a(s,te),u?ii([],ne,s,te,ee,e):s):n(s,te):(s.issues.push({expected:`object`,code:`invalid_type`,input:ne,inst:e}),s)}});function si(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=>!Be(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=>v(e,r,c())))}),t)}const ci=r(`$ZodUnion`,(e,t)=>{x.init(e,t),d(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),d(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),d(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),d(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>le(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>si(t,i,e,a)):si(s,i,e,a)}});function li(e,t,n,r){let i=e.filter(e=>e.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>v(e,r,c())))}):t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:[],inclusive:!1}),t)}const ui=r(`$ZodXor`,(e,t)=>{ci.init(e,t),t.inclusive=!1;let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);t instanceof Promise?(s.push(t),o=!0):s.push(t)}return o?Promise.all(s).then(t=>li(t,i,e,a)):li(s,i,e,a)}}),di=r(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ci.init(e,t);let n=e._zod.parse;d(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=se(()=>{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(!be(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?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),fi=r(`$ZodIntersection`,(e,t)=>{x.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])=>mi(e,t,n)):mi(e,i,a)}});function pi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Se(e)&&Se(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pi(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=pi(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 mi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Be(e))return e;let o=pi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const hi=r(`$ZodTuple`,(e,t)=>{x.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=[...n].reverse().findIndex(e=>e._zod.optin!==`optional`),c=s===-1?0:n.length-s;if(!t.rest){let t=a.length>n.length,i=a.length<c-1;if(t||i)return r.issues.push({...t?{code:`too_big`,maximum:n.length,inclusive:!0}:{code:`too_small`,minimum:n.length},input:a,inst:e,origin:`array`}),r}let l=-1;for(let e of n){if(l++,l>=a.length&&l>=c)continue;let t=e._zod.run({value:a[l],issues:[]},i);t instanceof Promise?o.push(t.then(e=>gi(e,r,l))):gi(t,r,l)}if(t.rest){let e=a.slice(n.length);for(let n of e){l++;let e=t.rest._zod.run({value:n,issues:[]},i);e instanceof Promise?o.push(e.then(e=>gi(e,r,l))):gi(e,r,l)}}return o.length?Promise.all(o).then(()=>r):r}});function gi(e,t,n){e.issues.length&&t.issues.push(..._(n,e.issues)),t.value[n]=e.value}const _i=r(`$ZodRecord`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Se(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(..._(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(..._(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&_n.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>v(e,r,c())),input:o,path:[o],inst:e});continue}let l=t.valueType._zod.run({value:i[o],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(..._(o,e.issues)),n.value[s.value]=e.value})):(l.issues.length&&n.issues.push(..._(o,l.issues)),n.value[s.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),vi=r(`$ZodMap`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Map))return n.issues.push({expected:`map`,code:`invalid_type`,input:i,inst:e}),n;let a=[];n.value=new Map;for(let[o,s]of i){let c=t.keyType._zod.run({value:o,issues:[]},r),l=t.valueType._zod.run({value:s,issues:[]},r);c instanceof Promise||l instanceof Promise?a.push(Promise.all([c,l]).then(([t,a])=>{yi(t,a,n,o,i,e,r)})):yi(c,l,n,o,i,e,r)}return a.length?Promise.all(a).then(()=>n):n}});function yi(e,t,n,r,i,a,o){e.issues.length&&(Ee.has(typeof r)?n.issues.push(..._(r,e.issues)):n.issues.push({code:`invalid_key`,origin:`map`,input:i,inst:a,issues:e.issues.map(e=>v(e,o,c()))})),t.issues.length&&(Ee.has(typeof r)?n.issues.push(..._(r,t.issues)):n.issues.push({origin:`map`,code:`invalid_element`,input:i,inst:a,key:r,issues:t.issues.map(e=>v(e,o,c()))})),n.value.set(e.value,t.value)}const bi=r(`$ZodSet`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Set))return n.issues.push({input:i,inst:e,expected:`set`,code:`invalid_type`}),n;let a=[];n.value=new Set;for(let e of i){let i=t.valueType._zod.run({value:e,issues:[]},r);i instanceof Promise?a.push(i.then(e=>xi(e,n))):xi(i,n)}return a.length?Promise.all(a).then(()=>n):n}});function xi(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Si=r(`$ZodEnum`,(e,t)=>{x.init(e,t);let n=ie(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Ee.has(typeof e)).map(e=>typeof e==`string`?m(e):e.toString()).join(`|`)})$`),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}}),Ci=r(`$ZodLiteral`,(e,t)=>{if(x.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?m(e):e?m(e.toString()):String(e)).join(`|`)})$`),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}}),wi=r(`$ZodFile`,(e,t)=>{x.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:`file`,code:`invalid_type`,input:r,inst:e}),t}}),Ti=r(`$ZodTransform`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new o(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 a;return n.value=i,n}});function Ei(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Di=r(`$ZodOptional`,(e,t)=>{x.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,d(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),d(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${le(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Ei(t,e.value)):Ei(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Oi=r(`$ZodExactOptional`,(e,t)=>{Di.init(e,t),d(e._zod,`values`,()=>t.innerType._zod.values),d(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ki=r(`$ZodNullable`,(e,t)=>{x.init(e,t),d(e._zod,`optin`,()=>t.innerType._zod.optin),d(e._zod,`optout`,()=>t.innerType._zod.optout),d(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${le(e.source)}|null)$`):void 0}),d(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ai=r(`$ZodDefault`,(e,t)=>{x.init(e,t),e._zod.optin=`optional`,d(e._zod,`values`,()=>t.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=>ji(e,t)):ji(r,t)}});function ji(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Mi=r(`$ZodPrefault`,(e,t)=>{x.init(e,t),e._zod.optin=`optional`,d(e._zod,`values`,()=>t.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))}),Ni=r(`$ZodNonOptional`,(e,t)=>{x.init(e,t),d(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].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=>Pi(t,e)):Pi(i,e)}});function Pi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Fi=r(`$ZodSuccess`,(e,t)=>{x.init(e,t),e._zod.parse=(e,n)=>{if(n.direction===`backward`)throw new o(`ZodSuccess`);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=t.issues.length===0,e)):(e.value=r.issues.length===0,e)}}),Ii=r(`$ZodCatch`,(e,t)=>{x.init(e,t),d(e._zod,`optin`,()=>t.innerType._zod.optin),d(e._zod,`optout`,()=>t.innerType._zod.optout),d(e._zod,`values`,()=>t.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(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,c()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,c()))},input:e.value}),e.issues=[]),e)}}),Li=r(`$ZodNaN`,(e,t)=>{x.init(e,t),e._zod.parse=(t,n)=>((typeof t.value!=`number`||!Number.isNaN(t.value))&&t.issues.push({input:t.value,inst:e,expected:`nan`,code:`invalid_type`}),t)}),Ri=r(`$ZodPipe`,(e,t)=>{x.init(e,t),d(e._zod,`values`,()=>t.in._zod.values),d(e._zod,`optin`,()=>t.in._zod.optin),d(e._zod,`optout`,()=>t.out._zod.optout),d(e._zod,`propValues`,()=>t.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=>zi(e,t.in,n)):zi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>zi(e,t.out,n)):zi(r,t.out,n)}});function zi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Bi=r(`$ZodCodec`,(e,t)=>{x.init(e,t),d(e._zod,`values`,()=>t.in._zod.values),d(e._zod,`optin`,()=>t.in._zod.optin),d(e._zod,`optout`,()=>t.out._zod.optout),d(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Vi(e,t,n)):Vi(r,t,n)}else{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Vi(e,t,n)):Vi(r,t,n)}}});function Vi(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>Hi(e,r,t.out,n)):Hi(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>Hi(e,r,t.in,n)):Hi(e,r,t.in,n)}}function Hi(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Ui=r(`$ZodReadonly`,(e,t)=>{x.init(e,t),d(e._zod,`propValues`,()=>t.innerType._zod.propValues),d(e._zod,`values`,()=>t.innerType._zod.values),d(e._zod,`optin`,()=>t.innerType?._zod?.optin),d(e._zod,`optout`,()=>t.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(Wi):Wi(r)}});function Wi(e){return e.value=Object.freeze(e.value),e}const Gi=r(`$ZodTemplateLiteral`,(e,t)=>{x.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw Error(`Invalid template literal part: ${e._zod.traits}`);let r=+!!t.startsWith(`^`),i=t.endsWith(`$`)?t.length-1:t.length;n.push(t.slice(r,i))}else if(e===null||De.has(typeof e))n.push(m(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),Ki=r(`$ZodFunction`,(e,t)=>(x.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return function(...n){let r=e._def.input?ct(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?ct(e._def.output,i):i}},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...n){let r=e._def.input?await ut(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await ut(e._def.output,i):i}},e._zod.parse=(t,n)=>typeof t.value==`function`?(e._def.output&&e._def.output._zod.def.type===`promise`?t.value=e.implementAsync(t.value):t.value=e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new hi({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),qi=r(`$ZodPromise`,(e,t)=>{x.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),Ji=r(`$ZodLazy`,(e,t)=>{x.init(e,t),d(e._zod,`innerType`,()=>t.getter()),d(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),d(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),d(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),d(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Yi=r(`$ZodCustom`,(e,t)=>{b.init(e,t),x.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=>Xi(t,n,r,e));Xi(i,n,r,e)}});function Xi(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(Ge(e))}}var Zi;const Qi=Symbol(`ZodOutput`),$i=Symbol(`ZodInput`);var ea=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 ta(){return new ea}(Zi=globalThis).__zod_globalRegistry??(Zi.__zod_globalRegistry=ta());const C=globalThis.__zod_globalRegistry;function na(e,t){return new e({type:`string`,...g(t)})}function ra(e,t){return new e({type:`string`,coerce:!0,...g(t)})}function ia(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...g(t)})}function aa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...g(t)})}function oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...g(t)})}function sa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...g(t)})}function ca(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...g(t)})}function la(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...g(t)})}function ua(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...g(t)})}function da(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...g(t)})}function fa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...g(t)})}function pa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...g(t)})}function ma(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...g(t)})}function ha(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...g(t)})}function ga(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...g(t)})}function _a(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...g(t)})}function va(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...g(t)})}function ya(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...g(t)})}function ba(e,t){return new e({type:`string`,format:`mac`,check:`string_format`,abort:!1,...g(t)})}function xa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...g(t)})}function Sa(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...g(t)})}function Ca(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...g(t)})}function wa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...g(t)})}function Ta(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...g(t)})}function Ea(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...g(t)})}const Da={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Oa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...g(t)})}function ka(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...g(t)})}function Aa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...g(t)})}function ja(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...g(t)})}function Ma(e,t){return new e({type:`number`,checks:[],...g(t)})}function Na(e,t){return new e({type:`number`,coerce:!0,checks:[],...g(t)})}function Pa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...g(t)})}function Fa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float32`,...g(t)})}function Ia(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float64`,...g(t)})}function La(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`int32`,...g(t)})}function Ra(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`uint32`,...g(t)})}function za(e,t){return new e({type:`boolean`,...g(t)})}function Ba(e,t){return new e({type:`boolean`,coerce:!0,...g(t)})}function Va(e,t){return new e({type:`bigint`,...g(t)})}function Ha(e,t){return new e({type:`bigint`,coerce:!0,...g(t)})}function Ua(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`int64`,...g(t)})}function Wa(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`uint64`,...g(t)})}function Ga(e,t){return new e({type:`symbol`,...g(t)})}function Ka(e,t){return new e({type:`undefined`,...g(t)})}function qa(e,t){return new e({type:`null`,...g(t)})}function Ja(e){return new e({type:`any`})}function Ya(e){return new e({type:`unknown`})}function Xa(e,t){return new e({type:`never`,...g(t)})}function Za(e,t){return new e({type:`void`,...g(t)})}function Qa(e,t){return new e({type:`date`,...g(t)})}function $a(e,t){return new e({type:`date`,coerce:!0,...g(t)})}function eo(e,t){return new e({type:`nan`,...g(t)})}function to(e,t){return new Hn({check:`less_than`,...g(t),value:e,inclusive:!1})}function w(e,t){return new Hn({check:`less_than`,...g(t),value:e,inclusive:!0})}function no(e,t){return new Un({check:`greater_than`,...g(t),value:e,inclusive:!1})}function T(e,t){return new Un({check:`greater_than`,...g(t),value:e,inclusive:!0})}function ro(e){return no(0,e)}function io(e){return to(0,e)}function ao(e){return w(0,e)}function oo(e){return T(0,e)}function so(e,t){return new Wn({check:`multiple_of`,...g(t),value:e})}function co(e,t){return new qn({check:`max_size`,...g(t),maximum:e})}function lo(e,t){return new Jn({check:`min_size`,...g(t),minimum:e})}function uo(e,t){return new Yn({check:`size_equals`,...g(t),size:e})}function fo(e,t){return new Xn({check:`max_length`,...g(t),maximum:e})}function po(e,t){return new Zn({check:`min_length`,...g(t),minimum:e})}function mo(e,t){return new Qn({check:`length_equals`,...g(t),length:e})}function ho(e,t){return new er({check:`string_format`,format:`regex`,...g(t),pattern:e})}function go(e){return new tr({check:`string_format`,format:`lowercase`,...g(e)})}function _o(e){return new nr({check:`string_format`,format:`uppercase`,...g(e)})}function vo(e,t){return new rr({check:`string_format`,format:`includes`,...g(t),includes:e})}function yo(e,t){return new ir({check:`string_format`,format:`starts_with`,...g(t),prefix:e})}function bo(e,t){return new ar({check:`string_format`,format:`ends_with`,...g(t),suffix:e})}function xo(e,t,n){return new sr({check:`property`,property:e,schema:t,...g(n)})}function So(e,t){return new cr({check:`mime_type`,mime:e,...g(t)})}function Co(e){return new lr({check:`overwrite`,tx:e})}function wo(e){return Co(t=>t.normalize(e))}function To(){return Co(e=>e.trim())}function Eo(){return Co(e=>e.toLowerCase())}function Do(){return Co(e=>e.toUpperCase())}function Oo(){return Co(e=>ve(e))}function ko(e,t,n){return new e({type:`array`,element:t,...g(n)})}function Ao(e,t,n){return new e({type:`union`,options:t,...g(n)})}function jo(e,t,n){return new e({type:`union`,options:t,inclusive:!1,...g(n)})}function Mo(e,t,n,r){return new e({type:`union`,options:n,discriminator:t,...g(r)})}function No(e,t,n){return new e({type:`intersection`,left:t,right:n})}function Po(e,t,n,r){let i=n instanceof x;return new e({type:`tuple`,items:t,rest:i?n:null,...g(i?r:n)})}function Fo(e,t,n,r){return new e({type:`record`,keyType:t,valueType:n,...g(r)})}function Io(e,t,n,r){return new e({type:`map`,keyType:t,valueType:n,...g(r)})}function Lo(e,t,n){return new e({type:`set`,valueType:t,...g(n)})}function Ro(e,t,n){return new e({type:`enum`,entries:Array.isArray(t)?Object.fromEntries(t.map(e=>[e,e])):t,...g(n)})}function zo(e,t,n){return new e({type:`enum`,entries:t,...g(n)})}function Bo(e,t,n){return new e({type:`literal`,values:Array.isArray(t)?t:[t],...g(n)})}function Vo(e,t){return new e({type:`file`,...g(t)})}function Ho(e,t){return new e({type:`transform`,transform:t})}function Uo(e,t){return new e({type:`optional`,innerType:t})}function Wo(e,t){return new e({type:`nullable`,innerType:t})}function Go(e,t,n){return new e({type:`default`,innerType:t,get defaultValue(){return typeof n==`function`?n():Ce(n)}})}function Ko(e,t,n){return new e({type:`nonoptional`,innerType:t,...g(n)})}function qo(e,t){return new e({type:`success`,innerType:t})}function Jo(e,t,n){return new e({type:`catch`,innerType:t,catchValue:typeof n==`function`?n:()=>n})}function Yo(e,t,n){return new e({type:`pipe`,in:t,out:n})}function Xo(e,t){return new e({type:`readonly`,innerType:t})}function Zo(e,t,n){return new e({type:`template_literal`,parts:t,...g(n)})}function Qo(e,t){return new e({type:`lazy`,getter:t})}function $o(e,t){return new e({type:`promise`,innerType:t})}function es(e,t,n){let r=g(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ts(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...g(n)})}function ns(e){let t=rs(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Ge(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Ge(r))}},e(n.value,n)));return t}function rs(e,t){let n=new b({check:`custom`,...g(t)});return n._zod.check=e,n}function is(e){let t=new b({check:`describe`});return t._zod.onattach=[t=>{let n=C.get(t)??{};C.add(t,{...n,description:e})}],t._zod.check=()=>{},t}function as(e){let t=new b({check:`meta`});return t._zod.onattach=[t=>{let n=C.get(t)??{};C.add(t,{...n,...e})}],t._zod.check=()=>{},t}function os(e,t){let n=g(t),r=n.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],i=n.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];n.case!==`sensitive`&&(r=r.map(e=>typeof e==`string`?e.toLowerCase():e),i=i.map(e=>typeof e==`string`?e.toLowerCase():e));let a=new Set(r),o=new Set(i),s=e.Codec??Bi,c=e.Boolean??Ur,l=new s({type:`pipe`,in:new(e.String??fr)({type:`string`,error:n.error}),out:new c({type:`boolean`,error:n.error}),transform:((e,t)=>{let r=e;return n.case!==`sensitive`&&(r=r.toLowerCase()),a.has(r)?!0:o.has(r)?!1:(t.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...a,...o],input:t.value,inst:l,continue:!1}),{})}),reverseTransform:((e,t)=>e===!0?r[0]||`true`:i[0]||`false`),error:n.error});return l}function ss(e,t,n,r={}){let i=g(r),a={...g(r),check:`string_format`,type:`string`,format:t,fn:typeof n==`function`?n:e=>n.test(e),...i};return n instanceof RegExp&&(a.pattern=n),new e(a)}function cs(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??C,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function E(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);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,E(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&D(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ls(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);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}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+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>
|
|
39
39
|
|
|
40
|
-
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}}}function us(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)):Object.assign(i,s),Object.assign(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??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);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)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:fs(t,`input`,e.processors),output:fs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function D(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 D(r.element,n);if(r.type===`set`)return D(r.valueType,n);if(r.type===`lazy`)return D(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`)return D(r.innerType,n);if(r.type===`intersection`)return D(r.left,n)||D(r.right,n);if(r.type===`record`||r.type===`map`)return D(r.keyType,n)||D(r.valueType,n);if(r.type===`pipe`)return D(r.in,n)||D(r.out,n);if(r.type===`object`){for(let e in r.shape)if(D(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(D(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(D(e,n))return!0;return!!(r.rest&&D(r.rest,n))}return!1}const ds=(e,t={})=>n=>{let r=cs({...n,processors:t});return E(e,r),ls(r,e),us(r,e)},fs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=cs({...i??{},target:a,io:t,processors:n});return E(e,o),ls(o,e),us(o,e)},ps={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ms=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ps[s]??s,i.format===``&&delete i.format,s===`time`&&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}))])}},hs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},gs=(e,t,n,r)=>{n.type=`boolean`},_s=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},vs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},ys=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},bs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},xs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Ss=(e,t,n,r)=>{n.not={}},Cs=(e,t,n,r)=>{},ws=(e,t,n,r)=>{},Ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Es=(e,t,n,r)=>{let i=e._zod.def,a=ie(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ds=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);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},Os=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},ks=(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},As=(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)},js=(e,t,n,r)=>{n.type=`boolean`},Ms=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ps=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Fs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Is=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Ls=(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=E(a.element,t,{...r,path:[...r.path,`items`]})},Rs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=E(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]._zod;return t.io===`input`?n.optin===void 0:n.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=E(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},zs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>E(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Bs=(e,t,n,r)=>{let i=e._zod.def,a=E(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=E(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Vs=(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)=>E(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?E(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:ee}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof ee==`number`&&(i.maxItems=ee)},Hs=(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=E(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=E(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=E(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Us=(e,t,n,r)=>{let i=e._zod.def,a=E(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`}]},Ws=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Gs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ks=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},qs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Js=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;E(a,t,r);let o=t.seen.get(e);o.ref=a},Ys=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Xs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qs=(e,t,n,r)=>{let i=e._zod.innerType;E(i,t,r);let a=t.seen.get(e);a.ref=i},$s={string:ms,number:hs,boolean:gs,bigint:_s,symbol:vs,null:ys,undefined:bs,void:xs,never:Ss,any:Cs,unknown:ws,date:Ts,enum:Es,literal:Ds,nan:Os,template_literal:ks,file:As,success:js,custom:Ms,function:Ns,transform:Ps,map:Fs,set:Is,array:Ls,object:Rs,union:zs,intersection:Bs,tuple:Vs,record:Hs,nullable:Us,nonoptional:Ws,default:Gs,prefault:Ks,catch:qs,pipe:Js,readonly:Ys,promise:Xs,optional:Zs,lazy:Qs};function ec(e,t){if(`_idmap`in e){let n=e,r=cs({...t,processors:$s}),i={};for(let e of n._idmap.entries()){let[t,n]=e;E(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;ls(r,n),a[t]=us(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=cs({...t,processors:$s});return E(e,n),ls(n,e),us(n,e)}var tc=e({ZodISODate:()=>ic,ZodISODateTime:()=>nc,ZodISODuration:()=>cc,ZodISOTime:()=>oc,date:()=>ac,datetime:()=>rc,duration:()=>lc,time:()=>sc});const nc=r(`ZodISODateTime`,(e,t)=>{wr.init(e,t),j.init(e,t)});function rc(e){return Oa(nc,e)}const ic=r(`ZodISODate`,(e,t)=>{Tr.init(e,t),j.init(e,t)});function ac(e){return ka(ic,e)}const oc=r(`ZodISOTime`,(e,t)=>{Er.init(e,t),j.init(e,t)});function sc(e){return Aa(oc,e)}const cc=r(`ZodISODuration`,(e,t)=>{Dr.init(e,t),j.init(e,t)});function lc(e){return ja(cc,e)}const uc=(e,t)=>{tt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>rt(e,t)},flatten:{value:t=>nt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,oe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,oe,2)}},isEmpty:{get(){return e.issues.length===0}}})},dc=r(`ZodError`,uc),O=r(`ZodError`,uc,{Parent:Error}),fc=st(O),pc=lt(O),mc=dt(O),hc=pt(O),gc=ht(O),_c=_t(O),vc=yt(O),yc=xt(O),bc=Ct(O),xc=Tt(O),Sc=Dt(O),Cc=kt(O);var wc=e({ZodAny:()=>zl,ZodArray:()=>Jl,ZodBase64:()=>cl,ZodBase64URL:()=>ul,ZodBigInt:()=>kl,ZodBigIntFormat:()=>jl,ZodBoolean:()=>Ol,ZodCIDRv4:()=>il,ZodCIDRv6:()=>ol,ZodCUID:()=>Hc,ZodCUID2:()=>Wc,ZodCatch:()=>Lu,ZodCodec:()=>Uu,ZodCustom:()=>td,ZodCustomStringFormat:()=>gl,ZodDate:()=>Kl,ZodDefault:()=>ku,ZodDiscriminatedUnion:()=>nu,ZodE164:()=>fl,ZodEmail:()=>Dc,ZodEmoji:()=>Rc,ZodEnum:()=>hu,ZodExactOptional:()=>wu,ZodFile:()=>vu,ZodFunction:()=>$u,ZodGUID:()=>kc,ZodIPv4:()=>Qc,ZodIPv6:()=>nl,ZodIntersection:()=>iu,ZodJWT:()=>ml,ZodKSUID:()=>Xc,ZodLazy:()=>Yu,ZodLiteral:()=>_u,ZodMAC:()=>el,ZodMap:()=>du,ZodNaN:()=>zu,ZodNanoID:()=>Bc,ZodNever:()=>Hl,ZodNonOptional:()=>Nu,ZodNull:()=>Ll,ZodNullable:()=>Eu,ZodNumber:()=>xl,ZodNumberFormat:()=>Sl,ZodObject:()=>Xl,ZodOptional:()=>Su,ZodPipe:()=>Vu,ZodPrefault:()=>ju,ZodPromise:()=>Zu,ZodReadonly:()=>Gu,ZodRecord:()=>cu,ZodSet:()=>pu,ZodString:()=>Ec,ZodStringFormat:()=>j,ZodSuccess:()=>Fu,ZodSymbol:()=>Pl,ZodTemplateLiteral:()=>qu,ZodTransform:()=>bu,ZodTuple:()=>ou,ZodType:()=>k,ZodULID:()=>Kc,ZodURL:()=>Fc,ZodUUID:()=>M,ZodUndefined:()=>Il,ZodUnion:()=>$l,ZodUnknown:()=>Vl,ZodVoid:()=>Wl,ZodXID:()=>Jc,ZodXor:()=>eu,_ZodString:()=>Tc,_default:()=>Au,_function:()=>ed,any:()=>Bl,array:()=>L,base64:()=>ll,base64url:()=>dl,bigint:()=>Al,boolean:()=>P,catch:()=>Ru,check:()=>nd,cidrv4:()=>al,cidrv6:()=>sl,codec:()=>Wu,cuid:()=>Uc,cuid2:()=>Gc,custom:()=>rd,date:()=>ql,describe:()=>od,discriminatedUnion:()=>ru,e164:()=>pl,email:()=>Oc,emoji:()=>zc,enum:()=>V,exactOptional:()=>Tu,file:()=>yu,float32:()=>wl,float64:()=>Tl,function:()=>ed,guid:()=>Ac,hash:()=>bl,hex:()=>yl,hostname:()=>vl,httpUrl:()=>Lc,instanceof:()=>cd,int:()=>Cl,int32:()=>El,int64:()=>Ml,intersection:()=>au,ipv4:()=>$c,ipv6:()=>rl,json:()=>ud,jwt:()=>hl,keyof:()=>Yl,ksuid:()=>Zc,lazy:()=>Xu,literal:()=>H,looseObject:()=>Ql,looseRecord:()=>uu,mac:()=>tl,map:()=>fu,meta:()=>sd,nan:()=>Bu,nanoid:()=>Vc,nativeEnum:()=>gu,never:()=>Ul,nonoptional:()=>Pu,null:()=>Rl,nullable:()=>Du,nullish:()=>Ou,number:()=>N,object:()=>R,optional:()=>Cu,partialRecord:()=>lu,pipe:()=>Hu,prefault:()=>Mu,preprocess:()=>dd,promise:()=>Qu,readonly:()=>Ku,record:()=>B,refine:()=>id,set:()=>mu,strictObject:()=>Zl,string:()=>A,stringFormat:()=>_l,stringbool:()=>ld,success:()=>Iu,superRefine:()=>ad,symbol:()=>Fl,templateLiteral:()=>Ju,transform:()=>xu,tuple:()=>su,uint32:()=>Dl,uint64:()=>Nl,ulid:()=>qc,undefined:()=>F,union:()=>z,unknown:()=>I,url:()=>Ic,uuid:()=>jc,uuidv4:()=>Mc,uuidv6:()=>Nc,uuidv7:()=>Pc,void:()=>Gl,xid:()=>Yc,xor:()=>tu});const k=r(`ZodType`,(e,t)=>(x.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:fs(e,`input`),output:fs(e,`output`)}}),e.toJSONSchema=ds(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(p(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>h(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>fc(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mc(e,t,n),e.parseAsync=async(t,n)=>pc(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>hc(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>gc(e,t,n),e.decode=(t,n)=>_c(e,t,n),e.encodeAsync=async(t,n)=>vc(e,t,n),e.decodeAsync=async(t,n)=>yc(e,t,n),e.safeEncode=(t,n)=>bc(e,t,n),e.safeDecode=(t,n)=>xc(e,t,n),e.safeEncodeAsync=async(t,n)=>Sc(e,t,n),e.safeDecodeAsync=async(t,n)=>Cc(e,t,n),e.refine=(t,n)=>e.check(id(t,n)),e.superRefine=t=>e.check(ad(t)),e.overwrite=t=>e.check(Co(t)),e.optional=()=>Cu(e),e.exactOptional=()=>Tu(e),e.nullable=()=>Du(e),e.nullish=()=>Cu(Du(e)),e.nonoptional=t=>Pu(e,t),e.array=()=>L(e),e.or=t=>z([e,t]),e.and=t=>au(e,t),e.transform=t=>Hu(e,xu(t)),e.default=t=>Au(e,t),e.prefault=t=>Mu(e,t),e.catch=t=>Ru(e,t),e.pipe=t=>Hu(e,t),e.readonly=()=>Ku(e),e.describe=t=>{let n=e.clone();return C.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return C.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return C.get(e);let n=e.clone();return C.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Tc=r(`_ZodString`,(e,t)=>{fr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ho(...t)),e.includes=(...t)=>e.check(vo(...t)),e.startsWith=(...t)=>e.check(yo(...t)),e.endsWith=(...t)=>e.check(bo(...t)),e.min=(...t)=>e.check(po(...t)),e.max=(...t)=>e.check(fo(...t)),e.length=(...t)=>e.check(mo(...t)),e.nonempty=(...t)=>e.check(po(1,...t)),e.lowercase=t=>e.check(go(t)),e.uppercase=t=>e.check(_o(t)),e.trim=()=>e.check(To()),e.normalize=(...t)=>e.check(wo(...t)),e.toLowerCase=()=>e.check(Eo()),e.toUpperCase=()=>e.check(Do()),e.slugify=()=>e.check(Oo())}),Ec=r(`ZodString`,(e,t)=>{fr.init(e,t),Tc.init(e,t),e.email=t=>e.check(ia(Dc,t)),e.url=t=>e.check(ua(Fc,t)),e.jwt=t=>e.check(Ea(ml,t)),e.emoji=t=>e.check(da(Rc,t)),e.guid=t=>e.check(aa(kc,t)),e.uuid=t=>e.check(oa(M,t)),e.uuidv4=t=>e.check(sa(M,t)),e.uuidv6=t=>e.check(ca(M,t)),e.uuidv7=t=>e.check(la(M,t)),e.nanoid=t=>e.check(fa(Bc,t)),e.guid=t=>e.check(aa(kc,t)),e.cuid=t=>e.check(pa(Hc,t)),e.cuid2=t=>e.check(ma(Wc,t)),e.ulid=t=>e.check(ha(Kc,t)),e.base64=t=>e.check(Ca(cl,t)),e.base64url=t=>e.check(wa(ul,t)),e.xid=t=>e.check(ga(Jc,t)),e.ksuid=t=>e.check(_a(Xc,t)),e.ipv4=t=>e.check(va(Qc,t)),e.ipv6=t=>e.check(ya(nl,t)),e.cidrv4=t=>e.check(xa(il,t)),e.cidrv6=t=>e.check(Sa(ol,t)),e.e164=t=>e.check(Ta(fl,t)),e.datetime=t=>e.check(rc(t)),e.date=t=>e.check(ac(t)),e.time=t=>e.check(sc(t)),e.duration=t=>e.check(lc(t))});function A(e){return na(Ec,e)}const j=r(`ZodStringFormat`,(e,t)=>{S.init(e,t),Tc.init(e,t)}),Dc=r(`ZodEmail`,(e,t)=>{hr.init(e,t),j.init(e,t)});function Oc(e){return ia(Dc,e)}const kc=r(`ZodGUID`,(e,t)=>{pr.init(e,t),j.init(e,t)});function Ac(e){return aa(kc,e)}const M=r(`ZodUUID`,(e,t)=>{mr.init(e,t),j.init(e,t)});function jc(e){return oa(M,e)}function Mc(e){return sa(M,e)}function Nc(e){return ca(M,e)}function Pc(e){return la(M,e)}const Fc=r(`ZodURL`,(e,t)=>{gr.init(e,t),j.init(e,t)});function Ic(e){return ua(Fc,e)}function Lc(e){return ua(Fc,{protocol:/^https?$/,hostname:sn,...g(e)})}const Rc=r(`ZodEmoji`,(e,t)=>{_r.init(e,t),j.init(e,t)});function zc(e){return da(Rc,e)}const Bc=r(`ZodNanoID`,(e,t)=>{vr.init(e,t),j.init(e,t)});function Vc(e){return fa(Bc,e)}const Hc=r(`ZodCUID`,(e,t)=>{yr.init(e,t),j.init(e,t)});function Uc(e){return pa(Hc,e)}const Wc=r(`ZodCUID2`,(e,t)=>{br.init(e,t),j.init(e,t)});function Gc(e){return ma(Wc,e)}const Kc=r(`ZodULID`,(e,t)=>{xr.init(e,t),j.init(e,t)});function qc(e){return ha(Kc,e)}const Jc=r(`ZodXID`,(e,t)=>{Sr.init(e,t),j.init(e,t)});function Yc(e){return ga(Jc,e)}const Xc=r(`ZodKSUID`,(e,t)=>{Cr.init(e,t),j.init(e,t)});function Zc(e){return _a(Xc,e)}const Qc=r(`ZodIPv4`,(e,t)=>{Or.init(e,t),j.init(e,t)});function $c(e){return va(Qc,e)}const el=r(`ZodMAC`,(e,t)=>{Ar.init(e,t),j.init(e,t)});function tl(e){return ba(el,e)}const nl=r(`ZodIPv6`,(e,t)=>{kr.init(e,t),j.init(e,t)});function rl(e){return ya(nl,e)}const il=r(`ZodCIDRv4`,(e,t)=>{jr.init(e,t),j.init(e,t)});function al(e){return xa(il,e)}const ol=r(`ZodCIDRv6`,(e,t)=>{Mr.init(e,t),j.init(e,t)});function sl(e){return Sa(ol,e)}const cl=r(`ZodBase64`,(e,t)=>{Pr.init(e,t),j.init(e,t)});function ll(e){return Ca(cl,e)}const ul=r(`ZodBase64URL`,(e,t)=>{Ir.init(e,t),j.init(e,t)});function dl(e){return wa(ul,e)}const fl=r(`ZodE164`,(e,t)=>{Lr.init(e,t),j.init(e,t)});function pl(e){return Ta(fl,e)}const ml=r(`ZodJWT`,(e,t)=>{zr.init(e,t),j.init(e,t)});function hl(e){return Ea(ml,e)}const gl=r(`ZodCustomStringFormat`,(e,t)=>{Br.init(e,t),j.init(e,t)});function _l(e,t,n={}){return ss(gl,e,t,n)}function vl(e){return ss(gl,`hostname`,on,e)}function yl(e){return ss(gl,`hex`,Cn,e)}function bl(e,t){let n=`${e}_${t?.enc??`hex`}`,r=jt[n];if(!r)throw Error(`Unrecognized hash format: ${n}`);return ss(gl,n,r,t)}const xl=r(`ZodNumber`,(e,t)=>{Vr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.int=t=>e.check(Cl(t)),e.safe=t=>e.check(Cl(t)),e.positive=t=>e.check(no(0,t)),e.nonnegative=t=>e.check(T(0,t)),e.negative=t=>e.check(to(0,t)),e.nonpositive=t=>e.check(w(0,t)),e.multipleOf=(t,n)=>e.check(so(t,n)),e.step=(t,n)=>e.check(so(t,n)),e.finite=()=>e;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});function N(e){return Ma(xl,e)}const Sl=r(`ZodNumberFormat`,(e,t)=>{Hr.init(e,t),xl.init(e,t)});function Cl(e){return Pa(Sl,e)}function wl(e){return Fa(Sl,e)}function Tl(e){return Ia(Sl,e)}function El(e){return La(Sl,e)}function Dl(e){return Ra(Sl,e)}const Ol=r(`ZodBoolean`,(e,t)=>{Ur.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r)});function P(e){return za(Ol,e)}const kl=r(`ZodBigInt`,(e,t)=>{Wr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.positive=t=>e.check(no(BigInt(0),t)),e.negative=t=>e.check(to(BigInt(0),t)),e.nonpositive=t=>e.check(w(BigInt(0),t)),e.nonnegative=t=>e.check(T(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(so(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function Al(e){return Va(kl,e)}const jl=r(`ZodBigIntFormat`,(e,t)=>{Gr.init(e,t),kl.init(e,t)});function Ml(e){return Ua(jl,e)}function Nl(e){return Wa(jl,e)}const Pl=r(`ZodSymbol`,(e,t)=>{Kr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r)});function Fl(e){return Ga(Pl,e)}const Il=r(`ZodUndefined`,(e,t)=>{qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function F(e){return Ka(Il,e)}const Ll=r(`ZodNull`,(e,t)=>{Jr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r)});function Rl(e){return qa(Ll,e)}const zl=r(`ZodAny`,(e,t)=>{Yr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Bl(){return Ja(zl)}const Vl=r(`ZodUnknown`,(e,t)=>{Xr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function I(){return Ya(Vl)}const Hl=r(`ZodNever`,(e,t)=>{Zr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r)});function Ul(e){return Xa(Hl,e)}const Wl=r(`ZodVoid`,(e,t)=>{Qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Gl(e){return Za(Wl,e)}const Kl=r(`ZodDate`,(e,t)=>{$r.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.min=(t,n)=>e.check(T(t,n)),e.max=(t,n)=>e.check(w(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function ql(e){return Qa(Kl,e)}const Jl=r(`ZodArray`,(e,t)=>{ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(po(t,n)),e.nonempty=t=>e.check(po(1,t)),e.max=(t,n)=>e.check(fo(t,n)),e.length=(t,n)=>e.check(mo(t,n)),e.unwrap=()=>e.element});function L(e,t){return ko(Jl,e,t)}function Yl(e){let t=e._zod.def.shape;return V(Object.keys(t))}const Xl=r(`ZodObject`,(e,t)=>{oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rs(e,t,n,r),d(e,`shape`,()=>t.shape),e.keyof=()=>V(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:I()}),e.loose=()=>e.clone({...e._zod.def,catchall:I()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ul()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Fe(e,t),e.safeExtend=t=>Ie(e,t),e.merge=t=>Le(e,t),e.pick=t=>Ne(e,t),e.omit=t=>Pe(e,t),e.partial=(...t)=>Re(Su,e,t[0]),e.required=(...t)=>ze(Nu,e,t[0])});function R(e,t){let n={type:`object`,shape:e??{},...g(t)};return new Xl(n)}function Zl(e,t){return new Xl({type:`object`,shape:e,catchall:Ul(),...g(t)})}function Ql(e,t){return new Xl({type:`object`,shape:e,catchall:I(),...g(t)})}const $l=r(`ZodUnion`,(e,t)=>{ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function z(e,t){return new $l({type:`union`,options:e,...g(t)})}const eu=r(`ZodXor`,(e,t)=>{$l.init(e,t),ui.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function tu(e,t){return new eu({type:`union`,options:e,inclusive:!1,...g(t)})}const nu=r(`ZodDiscriminatedUnion`,(e,t)=>{$l.init(e,t),di.init(e,t)});function ru(e,t,n){return new nu({type:`union`,options:t,discriminator:e,...g(n)})}const iu=r(`ZodIntersection`,(e,t)=>{fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bs(e,t,n,r)});function au(e,t){return new iu({type:`intersection`,left:e,right:t})}const ou=r(`ZodTuple`,(e,t)=>{hi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function su(e,t,n){let r=t instanceof x;return new ou({type:`tuple`,items:e,rest:r?t:null,...g(r?n:t)})}const cu=r(`ZodRecord`,(e,t)=>{_i.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function B(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,...g(n)})}function lu(e,t,n){let r=h(e);return r._zod.values=void 0,new cu({type:`record`,keyType:r,valueType:t,...g(n)})}function uu(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,mode:`loose`,...g(n)})}const du=r(`ZodMap`,(e,t)=>{vi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function fu(e,t,n){return new du({type:`map`,keyType:e,valueType:t,...g(n)})}const pu=r(`ZodSet`,(e,t)=>{bi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function mu(e,t){return new pu({type:`set`,valueType:e,...g(t)})}const hu=r(`ZodEnum`,(e,t)=>{Si.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(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 hu({...t,checks:[],...g(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 hu({...t,checks:[],...g(r),entries:i})}});function V(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new hu({type:`enum`,entries:n,...g(t)})}function gu(e,t){return new hu({type:`enum`,entries:e,...g(t)})}const _u=r(`ZodLiteral`,(e,t)=>{Ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(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 H(e,t){return new _u({type:`literal`,values:Array.isArray(e)?e:[e],...g(t)})}const vu=r(`ZodFile`,(e,t)=>{wi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.min=(t,n)=>e.check(lo(t,n)),e.max=(t,n)=>e.check(co(t,n)),e.mime=(t,n)=>e.check(So(Array.isArray(t)?t:[t],n))});function yu(e){return Vo(vu,e)}const bu=r(`ZodTransform`,(e,t)=>{Ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new o(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ge(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ge(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function xu(e){return new bu({type:`transform`,transform:e})}const Su=r(`ZodOptional`,(e,t)=>{Di.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cu(e){return new Su({type:`optional`,innerType:e})}const wu=r(`ZodExactOptional`,(e,t)=>{Oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tu(e){return new wu({type:`optional`,innerType:e})}const Eu=r(`ZodNullable`,(e,t)=>{ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new Eu({type:`nullable`,innerType:e})}function Ou(e){return Cu(Du(e))}const ku=r(`ZodDefault`,(e,t)=>{Ai.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Au(e,t){return new ku({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const ju=r(`ZodPrefault`,(e,t)=>{Mi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e,t){return new ju({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const Nu=r(`ZodNonOptional`,(e,t)=>{Ni.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pu(e,t){return new Nu({type:`nonoptional`,innerType:e,...g(t)})}const Fu=r(`ZodSuccess`,(e,t)=>{Fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e){return new Fu({type:`success`,innerType:e})}const Lu=r(`ZodCatch`,(e,t)=>{Ii.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ru(e,t){return new Lu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const zu=r(`ZodNaN`,(e,t)=>{Li.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r)});function Bu(e){return eo(zu,e)}const Vu=r(`ZodPipe`,(e,t)=>{Ri.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r),e.in=t.in,e.out=t.out});function Hu(e,t){return new Vu({type:`pipe`,in:e,out:t})}const Uu=r(`ZodCodec`,(e,t)=>{Vu.init(e,t),Bi.init(e,t)});function Wu(e,t,n){return new Uu({type:`pipe`,in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const Gu=r(`ZodReadonly`,(e,t)=>{Ui.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ku(e){return new Gu({type:`readonly`,innerType:e})}const qu=r(`ZodTemplateLiteral`,(e,t)=>{Gi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r)});function Ju(e,t){return new qu({type:`template_literal`,parts:e,...g(t)})}const Yu=r(`ZodLazy`,(e,t)=>{Ji.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Xu(e){return new Yu({type:`lazy`,getter:e})}const Zu=r(`ZodPromise`,(e,t)=>{qi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qu(e){return new Zu({type:`promise`,innerType:e})}const $u=r(`ZodFunction`,(e,t)=>{Ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r)});function ed(e){return new $u({type:`function`,input:Array.isArray(e?.input)?su(e?.input):e?.input??L(I()),output:e?.output??I()})}const td=r(`ZodCustom`,(e,t)=>{Yi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r)});function nd(e){let t=new b({check:`custom`});return t._zod.check=e,t}function rd(e,t){return es(td,e??(()=>!0),t)}function id(e,t={}){return ts(td,e,t)}function ad(e){return ns(e)}const od=is,sd=as;function cd(e,t={}){let n=new td({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...g(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}const ld=(...e)=>os({Codec:Uu,Boolean:Ol,String:Ec},...e);function ud(e){let t=Xu(()=>z([A(e),N(),P(),Rl(),L(t),B(A(),t)]));return t}function dd(e,t){return Hu(xu(e),t)}var fd=e({bigint:()=>gd,boolean:()=>hd,date:()=>U,number:()=>md,string:()=>pd});function pd(e){return ra(Ec,e)}function md(e){return Na(xl,e)}function hd(e){return Ba(Ol,e)}function gd(e){return Ha(kl,e)}function U(e){return $a(Kl,e)}const _d=`$rootRunId`,vd=`$parentRunId`,yd=L(R({key:A(),value:z([A(),Rl()])}));var W=class extends Error{constructor(e){super(e),this.name=`AttributeValidationError`}};const bd=e=>new TextEncoder().encode(e).length;function xd(e,t={}){return typeof e==`string`?e.length===0?new W(`Attribute key must not be empty`):e.length>256?new W(`Attribute key length ${e.length} exceeds limit 256: ${JSON.stringify(e.slice(0,32))}…`):!t.allowReservedAttributes&&e.startsWith(`$`)?new W(`Attribute key ${JSON.stringify(e)} starts with reserved prefix "\$" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`):null:new W(`Attribute key must be a string, got ${typeof e}`)}function Sd(e){if(e===null)return null;if(typeof e!=`string`)return new W(`Attribute value must be a string or null, got ${typeof e}`);let t=bd(e);return t>256?new W(`Attribute value byte length ${t} exceeds limit 256`):null}function Cd(e,t={}){let n=new Set,r=t.existingKeys===void 0?void 0:t.existingKeys instanceof Set?t.existingKeys:new Set(t.existingKeys),i=0,a=0;for(let o of e){let e=xd(o.key,{allowReservedAttributes:t.allowReservedAttributes});if(e)throw e;let s=Sd(o.value);if(s)throw s;if(n.has(o.key))throw new W(`Attribute key ${JSON.stringify(o.key)} appears more than once in the same batch`);n.add(o.key),o.value===null?(r===void 0||r.has(o.key))&&(a+=1):(r===void 0||!r.has(o.key))&&(i+=1)}let o=(r===void 0?0:r.size)+i-a;if(o>64)throw new W(`Run attribute count would exceed limit 64 (post-merge ${o})`)}function wd(e,t){let n={...e??{}};for(let{key:e,value:r}of t)r===null?delete n[e]:n[e]=r;return n}const G=z([cd(Uint8Array),Bl()]),K=V([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`,`attr_set`,`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`,`hook_created`,`hook_received`,`hook_disposed`,`hook_conflict`,`wait_created`,`wait_completed`]);K.extract([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`]).options;const Td=K.extract([`run_completed`,`run_failed`,`run_cancelled`]).options;function Ed(e){return Td.includes(e)}const Dd=K.extract([`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`]).options;function Od(e){return Dd.includes(e)}K.extract([`step_completed`,`step_failed`]).options;const kd=K.extract([`hook_created`,`hook_received`,`hook_disposed`]).options;function Ad(e){return kd.includes(e)}const jd=K.extract([`hook_disposed`,`hook_received`]).options;function Md(e){return jd.includes(e)}K.extract([`wait_created`,`wait_completed`]).options;const Nd=K.extract([`step_created`,`hook_created`,`wait_created`]).options;function Pd(e){return Nd.includes(e)}const Fd={run_created:`input`,run_started:`input`,run_completed:`output`,run_failed:`error`,step_created:`input`,step_started:`input`,step_completed:`result`,step_failed:`error`,step_retrying:`error`,hook_created:`metadata`,hook_received:`payload`},Id=Object.fromEntries(Object.entries(Fd).map(([e,t])=>[e,[t]]));function Ld(e){return Id[e]??[]}function Rd(e){return Fd[e]}function zd(e,t){if(t!==`none`||!(`eventData`in e))return e;let n=e.eventData;if(!n||typeof n!=`object`){let{eventData:t,...n}=e;return n}let r=Ld(e.eventType);if(r.length===0)return e;let i={...n};for(let e of r)delete i[e];let{eventData:a,...o}=e;return{...o,...Object.keys(i).length>0?{eventData:i}:{}}}const q=R({eventType:K,correlationId:A().optional(),specVersion:N().optional()}),Bd={ttfs:N().optional(),stso:N().optional(),stepCount:N().int().positive().optional(),eventCount:N().int().positive().optional(),rsfs:N().optional(),finalSchedulingReplay:N().optional(),optimizations:L(A()).optional()},Vd=q.extend({eventType:H(`step_completed`),correlationId:A(),eventData:R({stepName:A().optional(),workflowName:A().optional(),result:G,...Bd})}),Hd=q.extend({eventType:H(`step_failed`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,...Bd})}),Ud=q.extend({eventType:H(`step_retrying`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,retryAfter:U().optional()})}),Wd=q.extend({eventType:H(`step_started`),correlationId:A(),eventData:R({stepName:A().optional(),attempt:N().optional(),workflowName:A().optional(),input:G.optional(),ownerMessageId:A().optional()}).optional()}),Gd=q.extend({eventType:H(`step_created`),correlationId:A(),eventData:R({stepName:A(),workflowName:A().optional(),input:G})}),Kd=q.extend({eventType:H(`hook_created`),correlationId:A(),eventData:R({token:A(),tokenRetentionUntil:U().optional(),metadata:G.optional(),isWebhook:P().optional(),isSystem:P().optional()})}),qd=q.extend({eventType:H(`hook_received`),correlationId:A(),eventData:R({token:A().optional(),payload:G})}),Jd=q.extend({eventType:H(`hook_disposed`),correlationId:A(),eventData:R({token:A().optional()}).optional()}),Yd=q.extend({eventType:H(`hook_conflict`),correlationId:A(),eventData:R({token:A(),conflictingRunId:A().optional()})}),Xd=q.extend({eventType:H(`wait_created`),correlationId:A(),eventData:R({resumeAt:U()})}),Zd=q.extend({eventType:H(`wait_completed`),correlationId:A(),eventData:R({resumeAt:U().optional()}).optional()}),Qd=ru(`type`,[R({type:H(`workflow`)}),R({type:H(`step`),stepId:A(),attempt:N()})]),$d=q.extend({eventType:H(`attr_set`),correlationId:A().optional(),eventData:R({changes:yd,writer:Qd,allowReservedAttributes:H(!0).optional()})}),ef=q.extend({eventType:H(`run_created`),eventData:R({deploymentId:A(),workflowName:A(),input:G,executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()})}),tf=q.extend({eventType:H(`run_started`),eventData:R({input:G.optional(),deploymentId:A().optional(),workflowName:A().optional(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()}).optional()}),nf=q.extend({eventType:H(`run_completed`),eventData:R({output:G.optional()})}),rf=q.extend({eventType:H(`run_failed`),eventData:R({error:G,errorCode:A().optional()})}),af=q.extend({eventType:H(`run_cancelled`),eventData:R({cancelReason:A().max(512).optional()}).optional()});ru(`eventType`,[ef,tf,nf,rf,af,$d,Gd,Vd,Hd,Ud,Wd,Kd,qd,Jd,Xd,Zd]);const of=ru(`eventType`,[ef,tf,nf,rf,af,$d,Gd,Vd,Hd,Ud,Wd,Kd,qd,Jd,Yd,Xd,Zd]).and(R({runId:A(),eventId:A(),createdAt:U(),occurredAt:U().optional(),specVersion:N().optional(),resumeId:A().optional()}));function sf(e){return Pd(e.eventType)?!0:e.eventType===`step_started`&&typeof e.eventData?.stepName==`string`&&e.eventData.input!==void 0}const cf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),lf=cf.extract([`completed`,`failed`,`cancelled`]).options;function uf(e){return lf.includes(e)}const df=R({runId:A(),status:cf,deploymentId:A(),workflowName:A(),specVersion:N().optional(),executionContext:B(A(),Bl()).optional(),input:G.optional(),output:G.optional(),error:G.optional(),errorCode:A().optional(),attributes:B(A(),A()).default({}),encryptionPublicKey:A().optional(),expiredAt:U().optional(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U()}),ff=ru(`status`,[df.extend({status:V([`pending`,`running`]),output:F().optional(),error:F().optional(),completedAt:F().optional()}),df.extend({status:H(`cancelled`),output:F().optional(),error:F().optional(),completedAt:U()}),df.extend({status:H(`completed`),output:G,error:F().optional(),completedAt:U()}),df.extend({status:H(`failed`),output:F().optional(),error:G,completedAt:U()})]),pf=R({runIds:L(A()).min(1).max(500).refine(e=>new Set(e).size===e.length,{message:`runIds must not contain duplicates`}),cancelReason:A().max(512).optional()}),mf=ru(`outcome`,[R({runId:A(),outcome:H(`cancelled`)}),R({runId:A(),outcome:H(`already_cancelled`)}),R({runId:A(),outcome:H(`not_cancellable`),status:A()}),R({runId:A(),outcome:H(`not_found`)}),R({runId:A(),outcome:H(`failed`),code:A(),retryable:P()})]),hf=R({summary:R({requested:N(),cancelled:N(),alreadyCancelled:N(),notCancellable:N(),notFound:N(),failed:N()}),results:L(mf)}),gf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),_f=R({runId:A(),stepId:A(),stepName:A(),status:gf,input:G.optional(),output:G.optional(),error:G.optional(),attempt:N(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),retryAfter:U().optional(),specVersion:N().optional()}),vf=gf.extract([`completed`,`failed`,`cancelled`]).options;function yf(e){return vf.includes(e)}const bf=V([`waiting`,`completed`]),xf=R({waitId:A(),runId:A(),status:bf,resumeAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),specVersion:N().optional()}),Sf=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,J=dd(e=>typeof e==`string`&&Sf.test(e)?`${e.replace(` `,`T`)}Z`:e,U()),Y=J.nullable().optional(),X=A().nullable().optional(),Z=P().nullable().optional(),Cf=R({runId:A(),status:cf,deploymentId:A(),workflowName:A(),specVersion:md().optional(),attributes:B(A(),A()).default({}),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),wf=R({runId:A(),stepId:A(),stepName:X,status:gf,attempt:N().optional(),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z,computeInstanceId:X}),Tf=R({runId:A(),eventId:A(),eventType:K,correlationId:X,entityId:X,stepName:X,workflowName:A(),deploymentId:A(),specVersion:md().optional(),runCreatedAt:J,createdAt:J,region:X,vercelId:X,requestId:X,computeInstanceId:X,resumeAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,isWebhook:Z,isSystem:Z,workflowEncryptionEnabled:Z}),Ef=R({runId:A(),hookId:A(),status:V([`created`,`received`,`disposed`,`conflict`]),createdAt:J,updatedAt:J,receivedAt:Y,disposedAt:Y,isWebhook:Z,isSystem:Z,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Df=R({runId:A(),waitId:A(),status:bf,resumeAt:Y,createdAt:J,updatedAt:J,completedAt:Y,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Of=R({key:A(),runCount:md(),firstSeenAt:U(),lastSeenAt:U()}),kf=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/,`Must match __wkf_workflow_ or __{namespace}_wkf_workflow_`),Af=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/,`Must be a valid queue name with a recognized prefix`),jf=A().regex(/^[a-z][a-z0-9]*$/,`Must be lowercase alphanumeric, starting with a letter`);function Mf(e){return e??process.env.WORKFLOW_QUEUE_NAMESPACE??void 0}function Nf(e,t){if(e!==`workflow`)throw Error(`Unsupported queue kind: ${e}`);return t===void 0?`__wkf_workflow_`:(jf.parse(t),`__${t}_wkf_workflow_`)}function Pf(e){let t=e.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);if(!t)throw Error(`Invalid queue name: ${e}`);return{prefix:kf.parse(t[1]),id:t[2]}}const Ff=A().brand().describe(`A stored queue message ID`),If=B(A(),A()),Lf=R({input:I(),deploymentId:A(),workflowName:A(),specVersion:N(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),environment:A().optional()}),Rf=R({resumeId:A(),hookId:A(),token:A(),payload:I(),payloadDigest:A(),deploymentId:A().optional()}),zf=R({runId:A(),traceCarrier:If.optional(),requestedAt:U().optional(),replayDivergence:R({eventId:A(),count:N().int().positive()}).optional(),preconditionReinvocations:N().int().positive().optional(),serverErrorRetryCount:N().int().optional(),deploymentMismatchRetryCount:N().int().nonnegative().optional(),stepId:A().optional(),stepName:A().optional(),runInput:Lf.optional(),hookInput:Rf.optional()}),Bf=R({__healthCheck:H(!0),correlationId:A(),runId:A().optional()}),Vf=z([Bf,zf]),Hf=R({deploymentId:A(),workflowName:A(),runSpecVersion:N().optional(),workflowCoreVersion:A().optional(),traceCarrier:If.optional(),encryptionPublicKey:A().optional(),hookResumeInputVersion:N().optional()}),Uf=R({hookResumeDedupVersion:N()}),Wf=R({runId:A(),hookId:A(),token:A(),ownerId:A(),projectId:A(),environment:A(),metadata:G.optional(),createdAt:U(),specVersion:N().optional(),isWebhook:P().optional(),isSystem:P().optional(),tokenRetentionUntil:U().optional(),resumeContext:Hf.optional(),resumeCapabilities:Uf.optional()});async function Gf(e,t,n,r){let i=Nf(`workflow`,Mf(r)),a=0;for(let r of[`pending`,`running`]){let o,s=!0;for(;s;){let c=await e.list({status:r,resolveData:`none`,pagination:{cursor:o}});for(let e of c.data)try{await t(`${i}${e.workflowName}`,{runId:e.runId}),a++}catch(t){console.warn(`[${n}] Failed to re-enqueue run ${e.runId}: ${t}`)}s=c.hasMore,o=c.cursor??void 0}}a>0&&console.log(`[${n}] Re-enqueued ${a} active run(s) on startup`)}const Kf=Xu(()=>z([A(),N(),P(),Rl(),L(Kf),B(A(),Kf)])),qf=R({currentLookbackDays:N(),maxLookbackDays:N(),currentWindowStart:U(),maxWindowStart:U(),upgradeAvailable:P()}),Jf=e=>R({data:L(e),cursor:A().nullable(),hasMore:P(),pageInfo:qf.optional()}),Yf=R({message:A(),stack:A().optional(),code:A().optional()}),Xf=`evnt_`;function Zf(e){if(e.length!==26)return!1;for(let t=0;t<10;t++)if(e[t]!==`0`)return!1;for(let t=10;t<26;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function Qf(e){let t=e.indexOf(`_`);return t===-1?e:e.slice(t+1)}function $f(e){return Zf(Qf(e))}function ep(e){if(!Number.isSafeInteger(e)||e<1)throw RangeError(`Invalid event slot: ${e}`);return`${Xf}${String(e).padStart(26,`0`)}`}function tp(e){let t=Qf(e);if(!Zf(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=1?n:null}const np=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;var Q;(function(e){e.Base32IncorrectEncoding=`B32_ENC_INVALID`,e.DecodeTimeInvalidCharacter=`DEC_TIME_CHAR`,e.DecodeTimeValueMalformed=`DEC_TIME_MALFORMED`,e.EncodeTimeNegative=`ENC_TIME_NEG`,e.EncodeTimeSizeExceeded=`ENC_TIME_SIZE_EXCEED`,e.EncodeTimeValueMalformed=`ENC_TIME_MALFORMED`,e.PRNGDetectFailure=`PRNG_DETECT`,e.ULIDInvalid=`ULID_INVALID`,e.Unexpected=`UNEXPECTED`,e.UUIDInvalid=`UUID_INVALID`})(Q||={});var $=class extends Error{constructor(e,t){super(`${t} (${e})`),this.name=`ULIDError`,this.code=e}};function rp(e){let t=Math.floor(e()*32)%32;return np.charAt(t)}function ip(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function ap(e){let t,n=e.length,r,i,a=e;for(;!t&&n-->=0;){if(r=a[n],i=np.indexOf(r),i===-1)throw new $(Q.Base32IncorrectEncoding,`Incorrectly encoded string`);if(i===31){a=ip(a,n,np[0]);continue}t=ip(a,n,np[i+1])}if(typeof t==`string`)return t;throw new $(Q.Base32IncorrectEncoding,`Failed incrementing string`)}function op(e){if(e.length!==26)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID`);let t=e.substr(0,10).toUpperCase().split(``).reverse().reduce((e,t,n)=>{let r=np.indexOf(t);if(r===-1)throw new $(Q.DecodeTimeInvalidCharacter,`Time decode error: Invalid character: ${t}`);return e+=r*32**n},0);if(t>0xffffffffffff)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID: timestamp too large: ${t}`);return t}function sp(e){let n=cp(),r=n&&(n.crypto||n.msCrypto)||(t===void 0?null:t);if(typeof r?.getRandomValues==`function`)return()=>{let e=new Uint8Array(1);return r.getRandomValues(e),e[0]/256};if(typeof r?.randomBytes==`function`)return()=>r.randomBytes(1).readUInt8()/256;if(t?.randomBytes)return()=>t.randomBytes(1).readUInt8()/256;throw new $(Q.PRNGDetectFailure,`Failed to find a reliable PRNG`)}function cp(){return dp()?self:typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:null}function lp(e,t){let n=``;for(;e>0;e--)n=rp(t)+n;return n}function up(e,t=10){if(isNaN(e))throw new $(Q.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>0xffffffffffff)throw new $(Q.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${e}`);if(e<0)throw new $(Q.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new $(Q.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,r=``;for(let i=t;i>0;i--)n=e%32,r=np.charAt(n)+r,e=(e-n)/32;return r}function dp(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function fp(e){let t=e||sp(),n=0,r;return function(e){let i=!e||isNaN(e)?Date.now():e;if(i<=n){let e=r=ap(r);return up(n,10)+e}n=i;let a=r=lp(16,t);return up(i,10)+a}}function pp(e,t){let n=t||sp();return up(!e||isNaN(e)?Date.now():e,10)+lp(16,n)}const mp=A().ulid(),hp=Ju([`wrun_`,qc()]),gp=1440*60*1e3,_p=300*1e3;function vp(e){if(Zf(e))return null;let t=mp.safeParse(e);return t.success?new Date(op(t.data)):null}function yp(e,t,n=gp,r=_p){let i=vp(e.startsWith(t)?e.slice(t.length):e);if(!i)return`Invalid runId: "${e}" is not a valid ULID`;let a=new Date().getTime()-i.getTime();return a>0&&a<=n||a<=0&&-a<=r?null:`Invalid runId timestamp: embedded timestamp is ${Math.round(Math.abs(a)/1e3)}s in the ${a>0?`past`:`future`} (threshold: ${Math.round((a>0?n:r)/1e3)}s)`}var bp=e({ATTRIBUTE_KEY_MAX_LENGTH:()=>256,ATTRIBUTE_MAX_PER_RUN:()=>64,ATTRIBUTE_VALUE_MAX_BYTES:()=>256,BULK_CANCEL_MAX_RUN_IDS:()=>500,DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS:()=>_p,DEFAULT_TIMESTAMP_THRESHOLD_MS:()=>DEFAULT_TIMESTAMP_THRESHOLD_MS,DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS:()=>gp,EVENT_ID_BODY_LENGTH:()=>26,EVENT_ID_PREFIX:()=>Xf,FIRST_EVENT_SLOT:()=>1,HOOK_RESUME_DEDUP_VERSION:()=>1,HOOK_RESUME_INPUT_VERSION:()=>1,HookSchema:()=>Wf,RESERVED_ATTRIBUTE_KEY_PREFIX:()=>`$`,SPEC_VERSION_CURRENT:()=>5,SPEC_VERSION_LEGACY:()=>1,SPEC_VERSION_MAX_SUPPORTED:()=>6,SPEC_VERSION_SUPPORTS_ATTRIBUTES:()=>4,SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT:()=>3,SPEC_VERSION_SUPPORTS_COMPRESSION:()=>5,SPEC_VERSION_SUPPORTS_EVENT_SOURCING:()=>2,SPEC_VERSION_SUPPORTS_SLOT_IDENTITY:()=>6});export{U as $,xo as $a,Et as $c,ia as $i,El as $n,Ii as $o,Nc as $r,gr as $s,j as $t,_f as A,fo as Aa,Yn as Ac,Da as Ai,nd as An,ca as Ao,Ku as Ar,Ni as As,ml as At,sf as B,Xa as Ba,lt as Bc,Sa as Bi,pl as Bn,C as Bo,ad as Br,qi as Bs,Ll as Bt,Of as C,mo as Ca,Zn as Cc,ec as Ci,s as Cl,Gl as Cn,Ka as Co,R as Cr,Ji as Cs,wu as Ct,wf as D,w as Da,lr as Dc,us as Di,dl as Dn,ua as Do,Mu as Dr,Li as Ds,Qc as Dt,Cf as E,to as Ea,Gn as Ec,ls as Ei,ll as En,_o as Eo,Hu as Er,vi as Es,kc as Et,ff as F,so as Fa,_t as Fc,Va as Fi,Gc as Fn,is as Fo,Zl as Fr,ai as Fs,du as Ft,zd as G,qa as Ga,dt as Gc,ra as Gi,wl as Gn,Ir as Go,Dl as Gr,S as Gs,Su as Gt,Ad as H,Ko as Ha,kt as Hc,Ba as Hi,zc as Hn,Yr as Ho,Ju as Hr,_i as Hs,xl as Ht,uf as I,eo as Ia,xt as Ic,za as Ii,rd as In,as as Io,A as Ir,oi as Is,zu as It,vd as J,Uo as Ja,St as Jc,es as Ji,bl as Jn,Ur as Jo,z as Jr,Gi as Js,Zu as Jt,G as K,Wo as Ka,pt as Kc,pa as Ki,Tl as Kn,Wr as Ko,Nl as Kr,Fi as Ks,Vu as Kt,of as L,fa as La,ht as Lc,Jo as Li,ql as Ln,ea as Lo,_l as Lr,Di as Ls,Bc as Lt,pf as M,So as Ma,$n as Mc,ko as Mi,sl as Mn,Za as Mo,id as Mr,ki as Ms,Yu as Mt,hf as N,po as Na,nr as Nc,Ca as Ni,Wu as Nn,ga as No,wc as Nr,Vr as Ns,_u as Nt,Df as O,ba as Oa,sr as Oc,cs as Oi,Al as On,oa as Oo,dd as Or,vr as Os,nl as Ot,df as P,lo as Pa,jt as Pc,wa as Pi,Uc as Pn,jo as Po,mu as Pr,Hr as Ps,el as Pt,fd as Q,$o as Qa,ut as Qc,Ta as Qi,Cl as Qn,br as Qo,Mc as Qr,xr as Qs,Ec as Qt,K as R,zo as Ra,yt as Rc,rs as Ri,od as Rn,$i as Ro,ld as Rr,Ri as Rs,Hl as Rt,Mf as S,Qo as Sa,cr as Sc,$s as Si,c as Sl,F as Sn,ha as So,N as Sr,Cr as Ss,hu as St,Ef as T,go as Ta,Wn as Tc,ds as Ti,L as Tn,Ya as To,lu as Tr,Ar as Ts,$u as Tt,Od as U,ao as Ua,Ct as Uc,$a as Ui,Tu as Un,ti as Uo,xu as Ur,bi as Us,Sl as Ut,Md as V,oo as Va,Tt as Vc,Ha as Vi,Oc as Vn,ta as Vo,Fl as Vr,Ui as Vs,Eu as Vt,Ed as W,wo as Wa,Dt as Wc,Na as Wi,yu as Wn,Pr as Wo,su as Wr,fr as Ws,Xl as Wt,wd as X,Yo as Xa,bt as Xc,Go as Xi,vl as Xn,Mr as Xo,Ic as Xr,hi as Xs,cu as Xt,_d as Y,Co as Ya,gt as Yc,Qa as Yi,yl as Yn,jr as Yo,I as Yr,Ti as Ys,Gu as Yt,Cd as Z,ro as Za,ct as Zc,Mo as Zi,Lc as Zn,yr as Zo,jc as Zr,x as Zs,pu as Zt,Vf as _,Oa as _a,Qn as _c,ic as _i,a as _l,Au as _n,Ho as _o,gu as _r,wr as _s,ku as _t,op as a,Ia as aa,Sr as ac,gc as ai,tt as al,k as an,uo as ao,hl as ar,di as as,kl as at,Nf as b,Ea as ba,Xn as bc,oc as bi,r as bl,cd as bn,Ra as bo,Du as br,fi as bs,Dc as bt,tp as c,aa as ca,Fr as cc,pc as ci,rt as cl,M as cn,na as co,Xu as cr,_r as cs,il as ct,Jf as d,La as da,ur as dc,bc as di,it as dl,Vl as dn,qo as do,uu as dr,wi as ds,Wc as dt,da as ea,mr as ec,Pc as ei,At as el,Fu as en,Xo as eo,Ml as er,Bi as es,md as et,Yf as f,Ua as fa,b as fc,Sc as fi,h as fl,Wl as fn,ns as fo,tl as fr,Ki as fs,Lu as ft,Ff as g,ka as ga,rr as gc,O as gi,l as gl,Ru as gn,Do as go,Vc as gr,Tr as gs,Kl as gt,Bf as h,ya as ha,Un as hc,dc as hi,ke as hl,Tc as hn,Eo as ho,Bu as hr,kr as hs,gl as ht,hp as i,Fa as ia,Qr as ic,yc as ii,mt as il,ou as in,Lo as io,ud as ir,Ai as is,ul as it,yf as j,co as ja,ir as jc,Ja as ji,al as jn,la as jo,B as jr,Jr as js,Xc as jt,xf as k,Io as ka,er as kc,E as ki,P as kn,sa as ko,Qu as kr,Zr as ks,iu as kt,$f as l,vo as la,Rr as lc,xc as li,ot as ll,Il as ln,ss as lo,H as lr,Si as ls,ol as lt,Wf as m,va as ma,ar as mc,hc as mi,We as ml,eu as mn,Zo as mo,sd as mr,Or as ms,td as mt,vp as n,Ro as na,ci as nc,tu as ni,Ot as nl,qu as nn,ts as no,$c as nr,Br as ns,Jl as nt,fp as o,no as oa,ui as oc,vc as oi,y as ol,Kc as on,Oo as oo,Yl as or,Lr as os,jl as ot,Gf as p,No as pa,Kn as pc,mc as pi,ae as pl,Jc as pn,Ga as po,fu as pr,pr as ps,Uu as pt,W as q,Ma as qa,vt as qc,ma as qi,Ac as qn,Gr as qo,qc as qr,Kr as qs,ju as qt,yp as r,Vo as ra,Xr as rc,_c as ri,ft as rl,bu as rn,ho as ro,rl as rr,$r as rs,cl as rt,pp as s,T as sa,Nr as sc,fc as si,nt as sl,Fc as sn,yo as so,Zc as sr,hr as ss,Ol as st,bp as t,bo as ta,qr as tc,Yc as ti,wt as tl,Pl as tn,Fo as to,au as tr,Yi as ts,zl as tt,ep as u,Pa as ua,dr as uc,Cc as ui,at as ul,$l as un,os as uo,Ql as ur,Oi as us,Hc as ut,Af as v,ja as va,Hn as vc,nc as vi,o as vl,V as vn,To as vo,Ul as vr,Dr as vs,nu as vt,Tf as w,Bo as wa,Jn as wc,fs as wi,Bl as wn,Ao as wo,Cu as wr,Ci as ws,vu as wt,Pf as x,_a as xa,qn as xc,tc as xi,n as xl,Rl as xn,Wa as xo,Ou as xr,zr as xs,Rc as xt,zf as y,Aa as ya,tr as yc,cc as yi,i as yl,ed as yn,Po as yo,Pu as yr,Er as ys,fl as yt,Rd as z,io as za,st as zc,xa as zi,ru as zn,Qi as zo,Iu as zr,Mi as zs,Nu as zt};
|
|
40
|
+
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}}}function us(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)):Object.assign(i,s),Object.assign(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??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);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)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:fs(t,`input`,e.processors),output:fs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function D(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 D(r.element,n);if(r.type===`set`)return D(r.valueType,n);if(r.type===`lazy`)return D(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`)return D(r.innerType,n);if(r.type===`intersection`)return D(r.left,n)||D(r.right,n);if(r.type===`record`||r.type===`map`)return D(r.keyType,n)||D(r.valueType,n);if(r.type===`pipe`)return D(r.in,n)||D(r.out,n);if(r.type===`object`){for(let e in r.shape)if(D(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(D(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(D(e,n))return!0;return!!(r.rest&&D(r.rest,n))}return!1}const ds=(e,t={})=>n=>{let r=cs({...n,processors:t});return E(e,r),ls(r,e),us(r,e)},fs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=cs({...i??{},target:a,io:t,processors:n});return E(e,o),ls(o,e),us(o,e)},ps={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ms=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ps[s]??s,i.format===``&&delete i.format,s===`time`&&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}))])}},hs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},gs=(e,t,n,r)=>{n.type=`boolean`},_s=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},vs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},ys=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},bs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},xs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Ss=(e,t,n,r)=>{n.not={}},Cs=(e,t,n,r)=>{},ws=(e,t,n,r)=>{},Ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Es=(e,t,n,r)=>{let i=e._zod.def,a=ie(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ds=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);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},Os=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},ks=(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},As=(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)},js=(e,t,n,r)=>{n.type=`boolean`},Ms=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ps=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Fs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Is=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Ls=(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=E(a.element,t,{...r,path:[...r.path,`items`]})},Rs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=E(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]._zod;return t.io===`input`?n.optin===void 0:n.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=E(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},zs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>E(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Bs=(e,t,n,r)=>{let i=e._zod.def,a=E(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=E(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Vs=(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)=>E(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?E(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:ee}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof ee==`number`&&(i.maxItems=ee)},Hs=(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=E(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=E(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=E(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Us=(e,t,n,r)=>{let i=e._zod.def,a=E(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`}]},Ws=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Gs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ks=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},qs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Js=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;E(a,t,r);let o=t.seen.get(e);o.ref=a},Ys=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Xs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qs=(e,t,n,r)=>{let i=e._zod.innerType;E(i,t,r);let a=t.seen.get(e);a.ref=i},$s={string:ms,number:hs,boolean:gs,bigint:_s,symbol:vs,null:ys,undefined:bs,void:xs,never:Ss,any:Cs,unknown:ws,date:Ts,enum:Es,literal:Ds,nan:Os,template_literal:ks,file:As,success:js,custom:Ms,function:Ns,transform:Ps,map:Fs,set:Is,array:Ls,object:Rs,union:zs,intersection:Bs,tuple:Vs,record:Hs,nullable:Us,nonoptional:Ws,default:Gs,prefault:Ks,catch:qs,pipe:Js,readonly:Ys,promise:Xs,optional:Zs,lazy:Qs};function ec(e,t){if(`_idmap`in e){let n=e,r=cs({...t,processors:$s}),i={};for(let e of n._idmap.entries()){let[t,n]=e;E(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;ls(r,n),a[t]=us(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=cs({...t,processors:$s});return E(e,n),ls(n,e),us(n,e)}var tc=e({ZodISODate:()=>ic,ZodISODateTime:()=>nc,ZodISODuration:()=>cc,ZodISOTime:()=>oc,date:()=>ac,datetime:()=>rc,duration:()=>lc,time:()=>sc});const nc=r(`ZodISODateTime`,(e,t)=>{wr.init(e,t),j.init(e,t)});function rc(e){return Oa(nc,e)}const ic=r(`ZodISODate`,(e,t)=>{Tr.init(e,t),j.init(e,t)});function ac(e){return ka(ic,e)}const oc=r(`ZodISOTime`,(e,t)=>{Er.init(e,t),j.init(e,t)});function sc(e){return Aa(oc,e)}const cc=r(`ZodISODuration`,(e,t)=>{Dr.init(e,t),j.init(e,t)});function lc(e){return ja(cc,e)}const uc=(e,t)=>{tt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>rt(e,t)},flatten:{value:t=>nt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,oe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,oe,2)}},isEmpty:{get(){return e.issues.length===0}}})},dc=r(`ZodError`,uc),O=r(`ZodError`,uc,{Parent:Error}),fc=st(O),pc=lt(O),mc=dt(O),hc=pt(O),gc=ht(O),_c=_t(O),vc=yt(O),yc=xt(O),bc=Ct(O),xc=Tt(O),Sc=Dt(O),Cc=kt(O);var wc=e({ZodAny:()=>zl,ZodArray:()=>Jl,ZodBase64:()=>cl,ZodBase64URL:()=>ul,ZodBigInt:()=>kl,ZodBigIntFormat:()=>jl,ZodBoolean:()=>Ol,ZodCIDRv4:()=>il,ZodCIDRv6:()=>ol,ZodCUID:()=>Hc,ZodCUID2:()=>Wc,ZodCatch:()=>Lu,ZodCodec:()=>Uu,ZodCustom:()=>td,ZodCustomStringFormat:()=>gl,ZodDate:()=>Kl,ZodDefault:()=>ku,ZodDiscriminatedUnion:()=>nu,ZodE164:()=>fl,ZodEmail:()=>Dc,ZodEmoji:()=>Rc,ZodEnum:()=>hu,ZodExactOptional:()=>wu,ZodFile:()=>vu,ZodFunction:()=>$u,ZodGUID:()=>kc,ZodIPv4:()=>Qc,ZodIPv6:()=>nl,ZodIntersection:()=>iu,ZodJWT:()=>ml,ZodKSUID:()=>Xc,ZodLazy:()=>Yu,ZodLiteral:()=>_u,ZodMAC:()=>el,ZodMap:()=>du,ZodNaN:()=>zu,ZodNanoID:()=>Bc,ZodNever:()=>Hl,ZodNonOptional:()=>Nu,ZodNull:()=>Ll,ZodNullable:()=>Eu,ZodNumber:()=>xl,ZodNumberFormat:()=>Sl,ZodObject:()=>Xl,ZodOptional:()=>Su,ZodPipe:()=>Vu,ZodPrefault:()=>ju,ZodPromise:()=>Zu,ZodReadonly:()=>Gu,ZodRecord:()=>cu,ZodSet:()=>pu,ZodString:()=>Ec,ZodStringFormat:()=>j,ZodSuccess:()=>Fu,ZodSymbol:()=>Pl,ZodTemplateLiteral:()=>qu,ZodTransform:()=>bu,ZodTuple:()=>ou,ZodType:()=>k,ZodULID:()=>Kc,ZodURL:()=>Fc,ZodUUID:()=>M,ZodUndefined:()=>Il,ZodUnion:()=>$l,ZodUnknown:()=>Vl,ZodVoid:()=>Wl,ZodXID:()=>Jc,ZodXor:()=>eu,_ZodString:()=>Tc,_default:()=>Au,_function:()=>ed,any:()=>Bl,array:()=>L,base64:()=>ll,base64url:()=>dl,bigint:()=>Al,boolean:()=>P,catch:()=>Ru,check:()=>nd,cidrv4:()=>al,cidrv6:()=>sl,codec:()=>Wu,cuid:()=>Uc,cuid2:()=>Gc,custom:()=>rd,date:()=>ql,describe:()=>od,discriminatedUnion:()=>ru,e164:()=>pl,email:()=>Oc,emoji:()=>zc,enum:()=>V,exactOptional:()=>Tu,file:()=>yu,float32:()=>wl,float64:()=>Tl,function:()=>ed,guid:()=>Ac,hash:()=>bl,hex:()=>yl,hostname:()=>vl,httpUrl:()=>Lc,instanceof:()=>cd,int:()=>Cl,int32:()=>El,int64:()=>Ml,intersection:()=>au,ipv4:()=>$c,ipv6:()=>rl,json:()=>ud,jwt:()=>hl,keyof:()=>Yl,ksuid:()=>Zc,lazy:()=>Xu,literal:()=>H,looseObject:()=>Ql,looseRecord:()=>uu,mac:()=>tl,map:()=>fu,meta:()=>sd,nan:()=>Bu,nanoid:()=>Vc,nativeEnum:()=>gu,never:()=>Ul,nonoptional:()=>Pu,null:()=>Rl,nullable:()=>Du,nullish:()=>Ou,number:()=>N,object:()=>R,optional:()=>Cu,partialRecord:()=>lu,pipe:()=>Hu,prefault:()=>Mu,preprocess:()=>dd,promise:()=>Qu,readonly:()=>Ku,record:()=>B,refine:()=>id,set:()=>mu,strictObject:()=>Zl,string:()=>A,stringFormat:()=>_l,stringbool:()=>ld,success:()=>Iu,superRefine:()=>ad,symbol:()=>Fl,templateLiteral:()=>Ju,transform:()=>xu,tuple:()=>su,uint32:()=>Dl,uint64:()=>Nl,ulid:()=>qc,undefined:()=>F,union:()=>z,unknown:()=>I,url:()=>Ic,uuid:()=>jc,uuidv4:()=>Mc,uuidv6:()=>Nc,uuidv7:()=>Pc,void:()=>Gl,xid:()=>Yc,xor:()=>tu});const k=r(`ZodType`,(e,t)=>(x.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:fs(e,`input`),output:fs(e,`output`)}}),e.toJSONSchema=ds(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(p(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>h(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>fc(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mc(e,t,n),e.parseAsync=async(t,n)=>pc(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>hc(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>gc(e,t,n),e.decode=(t,n)=>_c(e,t,n),e.encodeAsync=async(t,n)=>vc(e,t,n),e.decodeAsync=async(t,n)=>yc(e,t,n),e.safeEncode=(t,n)=>bc(e,t,n),e.safeDecode=(t,n)=>xc(e,t,n),e.safeEncodeAsync=async(t,n)=>Sc(e,t,n),e.safeDecodeAsync=async(t,n)=>Cc(e,t,n),e.refine=(t,n)=>e.check(id(t,n)),e.superRefine=t=>e.check(ad(t)),e.overwrite=t=>e.check(Co(t)),e.optional=()=>Cu(e),e.exactOptional=()=>Tu(e),e.nullable=()=>Du(e),e.nullish=()=>Cu(Du(e)),e.nonoptional=t=>Pu(e,t),e.array=()=>L(e),e.or=t=>z([e,t]),e.and=t=>au(e,t),e.transform=t=>Hu(e,xu(t)),e.default=t=>Au(e,t),e.prefault=t=>Mu(e,t),e.catch=t=>Ru(e,t),e.pipe=t=>Hu(e,t),e.readonly=()=>Ku(e),e.describe=t=>{let n=e.clone();return C.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return C.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return C.get(e);let n=e.clone();return C.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Tc=r(`_ZodString`,(e,t)=>{fr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ho(...t)),e.includes=(...t)=>e.check(vo(...t)),e.startsWith=(...t)=>e.check(yo(...t)),e.endsWith=(...t)=>e.check(bo(...t)),e.min=(...t)=>e.check(po(...t)),e.max=(...t)=>e.check(fo(...t)),e.length=(...t)=>e.check(mo(...t)),e.nonempty=(...t)=>e.check(po(1,...t)),e.lowercase=t=>e.check(go(t)),e.uppercase=t=>e.check(_o(t)),e.trim=()=>e.check(To()),e.normalize=(...t)=>e.check(wo(...t)),e.toLowerCase=()=>e.check(Eo()),e.toUpperCase=()=>e.check(Do()),e.slugify=()=>e.check(Oo())}),Ec=r(`ZodString`,(e,t)=>{fr.init(e,t),Tc.init(e,t),e.email=t=>e.check(ia(Dc,t)),e.url=t=>e.check(ua(Fc,t)),e.jwt=t=>e.check(Ea(ml,t)),e.emoji=t=>e.check(da(Rc,t)),e.guid=t=>e.check(aa(kc,t)),e.uuid=t=>e.check(oa(M,t)),e.uuidv4=t=>e.check(sa(M,t)),e.uuidv6=t=>e.check(ca(M,t)),e.uuidv7=t=>e.check(la(M,t)),e.nanoid=t=>e.check(fa(Bc,t)),e.guid=t=>e.check(aa(kc,t)),e.cuid=t=>e.check(pa(Hc,t)),e.cuid2=t=>e.check(ma(Wc,t)),e.ulid=t=>e.check(ha(Kc,t)),e.base64=t=>e.check(Ca(cl,t)),e.base64url=t=>e.check(wa(ul,t)),e.xid=t=>e.check(ga(Jc,t)),e.ksuid=t=>e.check(_a(Xc,t)),e.ipv4=t=>e.check(va(Qc,t)),e.ipv6=t=>e.check(ya(nl,t)),e.cidrv4=t=>e.check(xa(il,t)),e.cidrv6=t=>e.check(Sa(ol,t)),e.e164=t=>e.check(Ta(fl,t)),e.datetime=t=>e.check(rc(t)),e.date=t=>e.check(ac(t)),e.time=t=>e.check(sc(t)),e.duration=t=>e.check(lc(t))});function A(e){return na(Ec,e)}const j=r(`ZodStringFormat`,(e,t)=>{S.init(e,t),Tc.init(e,t)}),Dc=r(`ZodEmail`,(e,t)=>{hr.init(e,t),j.init(e,t)});function Oc(e){return ia(Dc,e)}const kc=r(`ZodGUID`,(e,t)=>{pr.init(e,t),j.init(e,t)});function Ac(e){return aa(kc,e)}const M=r(`ZodUUID`,(e,t)=>{mr.init(e,t),j.init(e,t)});function jc(e){return oa(M,e)}function Mc(e){return sa(M,e)}function Nc(e){return ca(M,e)}function Pc(e){return la(M,e)}const Fc=r(`ZodURL`,(e,t)=>{gr.init(e,t),j.init(e,t)});function Ic(e){return ua(Fc,e)}function Lc(e){return ua(Fc,{protocol:/^https?$/,hostname:sn,...g(e)})}const Rc=r(`ZodEmoji`,(e,t)=>{_r.init(e,t),j.init(e,t)});function zc(e){return da(Rc,e)}const Bc=r(`ZodNanoID`,(e,t)=>{vr.init(e,t),j.init(e,t)});function Vc(e){return fa(Bc,e)}const Hc=r(`ZodCUID`,(e,t)=>{yr.init(e,t),j.init(e,t)});function Uc(e){return pa(Hc,e)}const Wc=r(`ZodCUID2`,(e,t)=>{br.init(e,t),j.init(e,t)});function Gc(e){return ma(Wc,e)}const Kc=r(`ZodULID`,(e,t)=>{xr.init(e,t),j.init(e,t)});function qc(e){return ha(Kc,e)}const Jc=r(`ZodXID`,(e,t)=>{Sr.init(e,t),j.init(e,t)});function Yc(e){return ga(Jc,e)}const Xc=r(`ZodKSUID`,(e,t)=>{Cr.init(e,t),j.init(e,t)});function Zc(e){return _a(Xc,e)}const Qc=r(`ZodIPv4`,(e,t)=>{Or.init(e,t),j.init(e,t)});function $c(e){return va(Qc,e)}const el=r(`ZodMAC`,(e,t)=>{Ar.init(e,t),j.init(e,t)});function tl(e){return ba(el,e)}const nl=r(`ZodIPv6`,(e,t)=>{kr.init(e,t),j.init(e,t)});function rl(e){return ya(nl,e)}const il=r(`ZodCIDRv4`,(e,t)=>{jr.init(e,t),j.init(e,t)});function al(e){return xa(il,e)}const ol=r(`ZodCIDRv6`,(e,t)=>{Mr.init(e,t),j.init(e,t)});function sl(e){return Sa(ol,e)}const cl=r(`ZodBase64`,(e,t)=>{Pr.init(e,t),j.init(e,t)});function ll(e){return Ca(cl,e)}const ul=r(`ZodBase64URL`,(e,t)=>{Ir.init(e,t),j.init(e,t)});function dl(e){return wa(ul,e)}const fl=r(`ZodE164`,(e,t)=>{Lr.init(e,t),j.init(e,t)});function pl(e){return Ta(fl,e)}const ml=r(`ZodJWT`,(e,t)=>{zr.init(e,t),j.init(e,t)});function hl(e){return Ea(ml,e)}const gl=r(`ZodCustomStringFormat`,(e,t)=>{Br.init(e,t),j.init(e,t)});function _l(e,t,n={}){return ss(gl,e,t,n)}function vl(e){return ss(gl,`hostname`,on,e)}function yl(e){return ss(gl,`hex`,Cn,e)}function bl(e,t){let n=`${e}_${t?.enc??`hex`}`,r=jt[n];if(!r)throw Error(`Unrecognized hash format: ${n}`);return ss(gl,n,r,t)}const xl=r(`ZodNumber`,(e,t)=>{Vr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.int=t=>e.check(Cl(t)),e.safe=t=>e.check(Cl(t)),e.positive=t=>e.check(no(0,t)),e.nonnegative=t=>e.check(T(0,t)),e.negative=t=>e.check(to(0,t)),e.nonpositive=t=>e.check(w(0,t)),e.multipleOf=(t,n)=>e.check(so(t,n)),e.step=(t,n)=>e.check(so(t,n)),e.finite=()=>e;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});function N(e){return Ma(xl,e)}const Sl=r(`ZodNumberFormat`,(e,t)=>{Hr.init(e,t),xl.init(e,t)});function Cl(e){return Pa(Sl,e)}function wl(e){return Fa(Sl,e)}function Tl(e){return Ia(Sl,e)}function El(e){return La(Sl,e)}function Dl(e){return Ra(Sl,e)}const Ol=r(`ZodBoolean`,(e,t)=>{Ur.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r)});function P(e){return za(Ol,e)}const kl=r(`ZodBigInt`,(e,t)=>{Wr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.positive=t=>e.check(no(BigInt(0),t)),e.negative=t=>e.check(to(BigInt(0),t)),e.nonpositive=t=>e.check(w(BigInt(0),t)),e.nonnegative=t=>e.check(T(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(so(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function Al(e){return Va(kl,e)}const jl=r(`ZodBigIntFormat`,(e,t)=>{Gr.init(e,t),kl.init(e,t)});function Ml(e){return Ua(jl,e)}function Nl(e){return Wa(jl,e)}const Pl=r(`ZodSymbol`,(e,t)=>{Kr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r)});function Fl(e){return Ga(Pl,e)}const Il=r(`ZodUndefined`,(e,t)=>{qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function F(e){return Ka(Il,e)}const Ll=r(`ZodNull`,(e,t)=>{Jr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r)});function Rl(e){return qa(Ll,e)}const zl=r(`ZodAny`,(e,t)=>{Yr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Bl(){return Ja(zl)}const Vl=r(`ZodUnknown`,(e,t)=>{Xr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function I(){return Ya(Vl)}const Hl=r(`ZodNever`,(e,t)=>{Zr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r)});function Ul(e){return Xa(Hl,e)}const Wl=r(`ZodVoid`,(e,t)=>{Qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Gl(e){return Za(Wl,e)}const Kl=r(`ZodDate`,(e,t)=>{$r.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.min=(t,n)=>e.check(T(t,n)),e.max=(t,n)=>e.check(w(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function ql(e){return Qa(Kl,e)}const Jl=r(`ZodArray`,(e,t)=>{ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(po(t,n)),e.nonempty=t=>e.check(po(1,t)),e.max=(t,n)=>e.check(fo(t,n)),e.length=(t,n)=>e.check(mo(t,n)),e.unwrap=()=>e.element});function L(e,t){return ko(Jl,e,t)}function Yl(e){let t=e._zod.def.shape;return V(Object.keys(t))}const Xl=r(`ZodObject`,(e,t)=>{oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rs(e,t,n,r),d(e,`shape`,()=>t.shape),e.keyof=()=>V(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:I()}),e.loose=()=>e.clone({...e._zod.def,catchall:I()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ul()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Fe(e,t),e.safeExtend=t=>Ie(e,t),e.merge=t=>Le(e,t),e.pick=t=>Ne(e,t),e.omit=t=>Pe(e,t),e.partial=(...t)=>Re(Su,e,t[0]),e.required=(...t)=>ze(Nu,e,t[0])});function R(e,t){let n={type:`object`,shape:e??{},...g(t)};return new Xl(n)}function Zl(e,t){return new Xl({type:`object`,shape:e,catchall:Ul(),...g(t)})}function Ql(e,t){return new Xl({type:`object`,shape:e,catchall:I(),...g(t)})}const $l=r(`ZodUnion`,(e,t)=>{ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function z(e,t){return new $l({type:`union`,options:e,...g(t)})}const eu=r(`ZodXor`,(e,t)=>{$l.init(e,t),ui.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function tu(e,t){return new eu({type:`union`,options:e,inclusive:!1,...g(t)})}const nu=r(`ZodDiscriminatedUnion`,(e,t)=>{$l.init(e,t),di.init(e,t)});function ru(e,t,n){return new nu({type:`union`,options:t,discriminator:e,...g(n)})}const iu=r(`ZodIntersection`,(e,t)=>{fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bs(e,t,n,r)});function au(e,t){return new iu({type:`intersection`,left:e,right:t})}const ou=r(`ZodTuple`,(e,t)=>{hi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function su(e,t,n){let r=t instanceof x;return new ou({type:`tuple`,items:e,rest:r?t:null,...g(r?n:t)})}const cu=r(`ZodRecord`,(e,t)=>{_i.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function B(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,...g(n)})}function lu(e,t,n){let r=h(e);return r._zod.values=void 0,new cu({type:`record`,keyType:r,valueType:t,...g(n)})}function uu(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,mode:`loose`,...g(n)})}const du=r(`ZodMap`,(e,t)=>{vi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function fu(e,t,n){return new du({type:`map`,keyType:e,valueType:t,...g(n)})}const pu=r(`ZodSet`,(e,t)=>{bi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function mu(e,t){return new pu({type:`set`,valueType:e,...g(t)})}const hu=r(`ZodEnum`,(e,t)=>{Si.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(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 hu({...t,checks:[],...g(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 hu({...t,checks:[],...g(r),entries:i})}});function V(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new hu({type:`enum`,entries:n,...g(t)})}function gu(e,t){return new hu({type:`enum`,entries:e,...g(t)})}const _u=r(`ZodLiteral`,(e,t)=>{Ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(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 H(e,t){return new _u({type:`literal`,values:Array.isArray(e)?e:[e],...g(t)})}const vu=r(`ZodFile`,(e,t)=>{wi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.min=(t,n)=>e.check(lo(t,n)),e.max=(t,n)=>e.check(co(t,n)),e.mime=(t,n)=>e.check(So(Array.isArray(t)?t:[t],n))});function yu(e){return Vo(vu,e)}const bu=r(`ZodTransform`,(e,t)=>{Ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new o(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ge(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ge(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function xu(e){return new bu({type:`transform`,transform:e})}const Su=r(`ZodOptional`,(e,t)=>{Di.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cu(e){return new Su({type:`optional`,innerType:e})}const wu=r(`ZodExactOptional`,(e,t)=>{Oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tu(e){return new wu({type:`optional`,innerType:e})}const Eu=r(`ZodNullable`,(e,t)=>{ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new Eu({type:`nullable`,innerType:e})}function Ou(e){return Cu(Du(e))}const ku=r(`ZodDefault`,(e,t)=>{Ai.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Au(e,t){return new ku({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const ju=r(`ZodPrefault`,(e,t)=>{Mi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e,t){return new ju({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const Nu=r(`ZodNonOptional`,(e,t)=>{Ni.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pu(e,t){return new Nu({type:`nonoptional`,innerType:e,...g(t)})}const Fu=r(`ZodSuccess`,(e,t)=>{Fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e){return new Fu({type:`success`,innerType:e})}const Lu=r(`ZodCatch`,(e,t)=>{Ii.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ru(e,t){return new Lu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const zu=r(`ZodNaN`,(e,t)=>{Li.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r)});function Bu(e){return eo(zu,e)}const Vu=r(`ZodPipe`,(e,t)=>{Ri.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r),e.in=t.in,e.out=t.out});function Hu(e,t){return new Vu({type:`pipe`,in:e,out:t})}const Uu=r(`ZodCodec`,(e,t)=>{Vu.init(e,t),Bi.init(e,t)});function Wu(e,t,n){return new Uu({type:`pipe`,in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const Gu=r(`ZodReadonly`,(e,t)=>{Ui.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ku(e){return new Gu({type:`readonly`,innerType:e})}const qu=r(`ZodTemplateLiteral`,(e,t)=>{Gi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r)});function Ju(e,t){return new qu({type:`template_literal`,parts:e,...g(t)})}const Yu=r(`ZodLazy`,(e,t)=>{Ji.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Xu(e){return new Yu({type:`lazy`,getter:e})}const Zu=r(`ZodPromise`,(e,t)=>{qi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qu(e){return new Zu({type:`promise`,innerType:e})}const $u=r(`ZodFunction`,(e,t)=>{Ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r)});function ed(e){return new $u({type:`function`,input:Array.isArray(e?.input)?su(e?.input):e?.input??L(I()),output:e?.output??I()})}const td=r(`ZodCustom`,(e,t)=>{Yi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r)});function nd(e){let t=new b({check:`custom`});return t._zod.check=e,t}function rd(e,t){return es(td,e??(()=>!0),t)}function id(e,t={}){return ts(td,e,t)}function ad(e){return ns(e)}const od=is,sd=as;function cd(e,t={}){let n=new td({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...g(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}const ld=(...e)=>os({Codec:Uu,Boolean:Ol,String:Ec},...e);function ud(e){let t=Xu(()=>z([A(e),N(),P(),Rl(),L(t),B(A(),t)]));return t}function dd(e,t){return Hu(xu(e),t)}var fd=e({bigint:()=>gd,boolean:()=>hd,date:()=>U,number:()=>md,string:()=>pd});function pd(e){return ra(Ec,e)}function md(e){return Na(xl,e)}function hd(e){return Ba(Ol,e)}function gd(e){return Ha(kl,e)}function U(e){return $a(Kl,e)}const _d=`$rootRunId`,vd=`$parentRunId`,yd=L(R({key:A(),value:z([A(),Rl()])}));var W=class extends Error{constructor(e){super(e),this.name=`AttributeValidationError`}};const bd=e=>new TextEncoder().encode(e).length;function xd(e,t={}){return typeof e==`string`?e.length===0?new W(`Attribute key must not be empty`):e.length>256?new W(`Attribute key length ${e.length} exceeds limit 256: ${JSON.stringify(e.slice(0,32))}…`):!t.allowReservedAttributes&&e.startsWith(`$`)?new W(`Attribute key ${JSON.stringify(e)} starts with reserved prefix "\$" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`):null:new W(`Attribute key must be a string, got ${typeof e}`)}function Sd(e){if(e===null)return null;if(typeof e!=`string`)return new W(`Attribute value must be a string or null, got ${typeof e}`);let t=bd(e);return t>256?new W(`Attribute value byte length ${t} exceeds limit 256`):null}function Cd(e,t={}){let n=new Set,r=t.existingKeys===void 0?void 0:t.existingKeys instanceof Set?t.existingKeys:new Set(t.existingKeys),i=0,a=0;for(let o of e){let e=xd(o.key,{allowReservedAttributes:t.allowReservedAttributes});if(e)throw e;let s=Sd(o.value);if(s)throw s;if(n.has(o.key))throw new W(`Attribute key ${JSON.stringify(o.key)} appears more than once in the same batch`);n.add(o.key),o.value===null?(r===void 0||r.has(o.key))&&(a+=1):(r===void 0||!r.has(o.key))&&(i+=1)}let o=(r===void 0?0:r.size)+i-a;if(o>64)throw new W(`Run attribute count would exceed limit 64 (post-merge ${o})`)}function wd(e,t){let n={...e??{}};for(let{key:e,value:r}of t)r===null?delete n[e]:n[e]=r;return n}const G=z([cd(Uint8Array),Bl()]),K=V([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`,`attr_set`,`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`,`hook_created`,`hook_received`,`hook_disposed`,`hook_conflict`,`wait_created`,`wait_completed`]);K.extract([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`]).options;const Td=K.extract([`run_completed`,`run_failed`,`run_cancelled`]).options;function Ed(e){return Td.includes(e)}const Dd=K.extract([`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`]).options;function Od(e){return Dd.includes(e)}K.extract([`step_completed`,`step_failed`]).options;const kd={step_created:`step_created`,step_started:`step_started`,step_retrying:`step_retrying`,step_completed:`step_terminal`,step_failed:`step_terminal`,wait_created:`wait_created`,wait_completed:`wait_completed`,hook_created:`hook_created`,hook_disposed:`hook_disposed`,run_started:`run_started`};function Ad(e){return kd[e]}const jd=K.extract([`hook_created`,`hook_received`,`hook_disposed`]).options;function Md(e){return jd.includes(e)}const Nd=K.extract([`hook_disposed`,`hook_received`]).options;function Pd(e){return Nd.includes(e)}K.extract([`wait_created`,`wait_completed`]).options;const Fd=K.extract([`step_created`,`hook_created`,`wait_created`]).options;function Id(e){return Fd.includes(e)}const Ld={run_created:`input`,run_started:`input`,run_completed:`output`,run_failed:`error`,step_created:`input`,step_started:`input`,step_completed:`result`,step_failed:`error`,step_retrying:`error`,hook_created:`metadata`,hook_received:`payload`},Rd=Object.fromEntries(Object.entries(Ld).map(([e,t])=>[e,[t]]));function zd(e){return Rd[e]??[]}function Bd(e){return Ld[e]}function Vd(e,t){if(t!==`none`||!(`eventData`in e))return e;let n=e.eventData;if(!n||typeof n!=`object`){let{eventData:t,...n}=e;return n}let r=zd(e.eventType);if(r.length===0)return e;let i={...n};for(let e of r)delete i[e];let{eventData:a,...o}=e;return{...o,...Object.keys(i).length>0?{eventData:i}:{}}}const q=R({eventType:K,correlationId:A().optional(),specVersion:N().optional()}),Hd={ttfs:N().optional(),stso:N().optional(),stepCount:N().int().positive().optional(),eventCount:N().int().positive().optional(),rsfs:N().optional(),finalSchedulingReplay:N().optional(),optimizations:L(A()).optional()},Ud=q.extend({eventType:H(`step_completed`),correlationId:A(),eventData:R({stepName:A().optional(),workflowName:A().optional(),result:G,...Hd})}),Wd=q.extend({eventType:H(`step_failed`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,...Hd})}),Gd=q.extend({eventType:H(`step_retrying`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,retryAfter:U().optional()})}),Kd=q.extend({eventType:H(`step_started`),correlationId:A(),eventData:R({stepName:A().optional(),attempt:N().optional(),workflowName:A().optional(),input:G.optional(),ownerMessageId:A().optional()}).optional()}),qd=q.extend({eventType:H(`step_created`),correlationId:A(),eventData:R({stepName:A(),workflowName:A().optional(),input:G})}),Jd=q.extend({eventType:H(`hook_created`),correlationId:A(),eventData:R({token:A(),tokenRetentionUntil:U().optional(),metadata:G.optional(),isWebhook:P().optional(),isSystem:P().optional()})}),Yd=q.extend({eventType:H(`hook_received`),correlationId:A(),eventData:R({token:A().optional(),payload:G})}),Xd=q.extend({eventType:H(`hook_disposed`),correlationId:A(),eventData:R({token:A().optional()}).optional()}),Zd=q.extend({eventType:H(`hook_conflict`),correlationId:A(),eventData:R({token:A(),conflictingRunId:A().optional()})}),Qd=q.extend({eventType:H(`wait_created`),correlationId:A(),eventData:R({resumeAt:U()})}),$d=q.extend({eventType:H(`wait_completed`),correlationId:A(),eventData:R({resumeAt:U().optional()}).optional()}),ef=ru(`type`,[R({type:H(`workflow`)}),R({type:H(`step`),stepId:A(),attempt:N()})]),tf=q.extend({eventType:H(`attr_set`),correlationId:A().optional(),eventData:R({changes:yd,writer:ef,allowReservedAttributes:H(!0).optional()})}),nf=q.extend({eventType:H(`run_created`),eventData:R({deploymentId:A(),workflowName:A(),input:G,executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()})}),rf=q.extend({eventType:H(`run_started`),eventData:R({input:G.optional(),deploymentId:A().optional(),workflowName:A().optional(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()}).optional()}),af=q.extend({eventType:H(`run_completed`),eventData:R({output:G.optional()})}),of=q.extend({eventType:H(`run_failed`),eventData:R({error:G,errorCode:A().optional()})}),sf=q.extend({eventType:H(`run_cancelled`),eventData:R({cancelReason:A().max(512).optional()}).optional()});ru(`eventType`,[nf,rf,af,of,sf,tf,qd,Ud,Wd,Gd,Kd,Jd,Yd,Xd,Qd,$d]);const cf=ru(`eventType`,[nf,rf,af,of,sf,tf,qd,Ud,Wd,Gd,Kd,Jd,Yd,Xd,Zd,Qd,$d]).and(R({runId:A(),eventId:A(),createdAt:U(),occurredAt:U().optional(),specVersion:N().optional(),resumeId:A().optional()}));function lf(e){return Id(e.eventType)?!0:e.eventType===`step_started`&&typeof e.eventData?.stepName==`string`&&e.eventData.input!==void 0}const uf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),df=uf.extract([`completed`,`failed`,`cancelled`]).options;function ff(e){return df.includes(e)}const pf=R({runId:A(),status:uf,deploymentId:A(),workflowName:A(),specVersion:N().optional(),executionContext:B(A(),Bl()).optional(),input:G.optional(),output:G.optional(),error:G.optional(),errorCode:A().optional(),attributes:B(A(),A()).default({}),encryptionPublicKey:A().optional(),expiredAt:U().optional(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U()}),mf=ru(`status`,[pf.extend({status:V([`pending`,`running`]),output:F().optional(),error:F().optional(),completedAt:F().optional()}),pf.extend({status:H(`cancelled`),output:F().optional(),error:F().optional(),completedAt:U()}),pf.extend({status:H(`completed`),output:G,error:F().optional(),completedAt:U()}),pf.extend({status:H(`failed`),output:F().optional(),error:G,completedAt:U()})]),hf=R({runIds:L(A()).min(1).max(500).refine(e=>new Set(e).size===e.length,{message:`runIds must not contain duplicates`}),cancelReason:A().max(512).optional()}),gf=ru(`outcome`,[R({runId:A(),outcome:H(`cancelled`)}),R({runId:A(),outcome:H(`already_cancelled`)}),R({runId:A(),outcome:H(`not_cancellable`),status:A()}),R({runId:A(),outcome:H(`not_found`)}),R({runId:A(),outcome:H(`failed`),code:A(),retryable:P()})]),_f=R({summary:R({requested:N(),cancelled:N(),alreadyCancelled:N(),notCancellable:N(),notFound:N(),failed:N()}),results:L(gf)}),vf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),yf=R({runId:A(),stepId:A(),stepName:A(),status:vf,input:G.optional(),output:G.optional(),error:G.optional(),attempt:N(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),retryAfter:U().optional(),specVersion:N().optional()}),bf=vf.extract([`completed`,`failed`,`cancelled`]).options;function xf(e){return bf.includes(e)}const Sf=V([`waiting`,`completed`]),Cf=R({waitId:A(),runId:A(),status:Sf,resumeAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),specVersion:N().optional()}),wf=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,J=dd(e=>typeof e==`string`&&wf.test(e)?`${e.replace(` `,`T`)}Z`:e,U()),Y=J.nullable().optional(),X=A().nullable().optional(),Z=P().nullable().optional(),Tf=R({runId:A(),status:uf,deploymentId:A(),workflowName:A(),specVersion:md().optional(),attributes:B(A(),A()).default({}),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Ef=R({runId:A(),stepId:A(),stepName:X,status:vf,attempt:N().optional(),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z,computeInstanceId:X}),Df=R({runId:A(),eventId:A(),eventType:K,correlationId:X,entityId:X,stepName:X,workflowName:A(),deploymentId:A(),specVersion:md().optional(),runCreatedAt:J,createdAt:J,region:X,vercelId:X,requestId:X,computeInstanceId:X,resumeAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,isWebhook:Z,isSystem:Z,workflowEncryptionEnabled:Z}),Of=R({runId:A(),hookId:A(),status:V([`created`,`received`,`disposed`,`conflict`]),createdAt:J,updatedAt:J,receivedAt:Y,disposedAt:Y,isWebhook:Z,isSystem:Z,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),kf=R({runId:A(),waitId:A(),status:Sf,resumeAt:Y,createdAt:J,updatedAt:J,completedAt:Y,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Af=R({key:A(),runCount:md(),firstSeenAt:U(),lastSeenAt:U()}),jf=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/,`Must match __wkf_workflow_ or __{namespace}_wkf_workflow_`),Mf=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/,`Must be a valid queue name with a recognized prefix`),Nf=A().regex(/^[a-z][a-z0-9]*$/,`Must be lowercase alphanumeric, starting with a letter`);function Pf(e){return e??process.env.WORKFLOW_QUEUE_NAMESPACE??void 0}function Ff(e,t){if(e!==`workflow`)throw Error(`Unsupported queue kind: ${e}`);return t===void 0?`__wkf_workflow_`:(Nf.parse(t),`__${t}_wkf_workflow_`)}function If(e){let t=e.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);if(!t)throw Error(`Invalid queue name: ${e}`);return{prefix:jf.parse(t[1]),id:t[2]}}const Lf=A().brand().describe(`A stored queue message ID`),Rf=B(A(),A()),zf=R({input:I(),deploymentId:A(),workflowName:A(),specVersion:N(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),environment:A().optional()}),Bf=R({input:rd(e=>e instanceof Uint8Array,{message:`stepInput.input must be a Uint8Array`})}),Vf=R({resumeId:A(),hookId:A(),token:A(),payload:I(),payloadDigest:A(),deploymentId:A().optional()}),Hf=R({resumeRequestedAtMs:N(),queuePublishRequestedAtMs:N(),strategy:A().optional(),consumerStartedAtMs:N().optional(),replayStartedAtMs:N().optional(),nextStepEncounteredAtMs:N().optional(),setupSource:A().optional()}),Uf=R({runId:A(),traceCarrier:Rf.optional(),requestedAt:U().optional(),replayDivergence:R({eventId:A(),count:N().int().positive()}).optional(),preconditionReinvocations:N().int().positive().optional(),serverErrorRetryCount:N().int().optional(),deploymentMismatchRetryCount:N().int().nonnegative().optional(),stepId:A().optional(),stepName:A().optional(),runInput:zf.optional(),hookInput:Vf.optional(),stepInput:Bf.optional(),hookResumeTiming:Hf.optional().catch(void 0)}),Wf=R({__healthCheck:H(!0),correlationId:A(),runId:A().optional()}),Gf=z([Wf,Uf]),Kf=R({deploymentId:A(),workflowName:A(),runSpecVersion:N().optional(),workflowCoreVersion:A().optional(),traceCarrier:Rf.optional(),encryptionPublicKey:A().optional(),hookResumeInputVersion:N().optional()}),qf=R({hookResumeDedupVersion:N()}),Jf=R({runId:A(),hookId:A(),token:A(),ownerId:A(),projectId:A(),environment:A(),metadata:G.optional(),createdAt:U(),specVersion:N().optional(),isWebhook:P().optional(),isSystem:P().optional(),tokenRetentionUntil:U().optional(),resumeContext:Kf.optional(),resumeCapabilities:qf.optional()});async function Yf(e,t,n,r){let i=Ff(`workflow`,Pf(r)),a=0;for(let r of[`pending`,`running`]){let o,s=!0;for(;s;){let c=await e.list({status:r,resolveData:`none`,pagination:{cursor:o}});for(let e of c.data)try{await t(`${i}${e.workflowName}`,{runId:e.runId}),a++}catch(t){console.warn(`[${n}] Failed to re-enqueue run ${e.runId}: ${t}`)}s=c.hasMore,o=c.cursor??void 0}}a>0&&console.log(`[${n}] Re-enqueued ${a} active run(s) on startup`)}const Xf=Xu(()=>z([A(),N(),P(),Rl(),L(Xf),B(A(),Xf)])),Zf=R({currentLookbackDays:N(),maxLookbackDays:N(),currentWindowStart:U(),maxWindowStart:U(),upgradeAvailable:P()}),Qf=e=>R({data:L(e),cursor:A().nullable(),hasMore:P(),pageInfo:Zf.optional()}),$f=R({message:A(),stack:A().optional(),code:A().optional()}),ep=`evnt_`;function tp(e){if(e.length!==26)return!1;for(let t=0;t<10;t++)if(e[t]!==`0`)return!1;for(let t=10;t<26;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function np(e){let t=e.indexOf(`_`);return t===-1?e:e.slice(t+1)}function rp(e){return tp(np(e))}function ip(e){if(!Number.isSafeInteger(e)||e<1)throw RangeError(`Invalid event slot: ${e}`);return`${ep}${String(e).padStart(26,`0`)}`}function ap(e){let t=np(e);if(!tp(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=1?n:null}function op(e){let t=ap(e);if(t===null)throw Error(`Event id is not slot-numbered: ${e}. This World allocates event positions the runtime cannot read.`);return t}const sp=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;var Q;(function(e){e.Base32IncorrectEncoding=`B32_ENC_INVALID`,e.DecodeTimeInvalidCharacter=`DEC_TIME_CHAR`,e.DecodeTimeValueMalformed=`DEC_TIME_MALFORMED`,e.EncodeTimeNegative=`ENC_TIME_NEG`,e.EncodeTimeSizeExceeded=`ENC_TIME_SIZE_EXCEED`,e.EncodeTimeValueMalformed=`ENC_TIME_MALFORMED`,e.PRNGDetectFailure=`PRNG_DETECT`,e.ULIDInvalid=`ULID_INVALID`,e.Unexpected=`UNEXPECTED`,e.UUIDInvalid=`UUID_INVALID`})(Q||={});var $=class extends Error{constructor(e,t){super(`${t} (${e})`),this.name=`ULIDError`,this.code=e}};function cp(e){let t=Math.floor(e()*32)%32;return sp.charAt(t)}function lp(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function up(e){let t,n=e.length,r,i,a=e;for(;!t&&n-->=0;){if(r=a[n],i=sp.indexOf(r),i===-1)throw new $(Q.Base32IncorrectEncoding,`Incorrectly encoded string`);if(i===31){a=lp(a,n,sp[0]);continue}t=lp(a,n,sp[i+1])}if(typeof t==`string`)return t;throw new $(Q.Base32IncorrectEncoding,`Failed incrementing string`)}function dp(e){if(e.length!==26)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID`);let t=e.substr(0,10).toUpperCase().split(``).reverse().reduce((e,t,n)=>{let r=sp.indexOf(t);if(r===-1)throw new $(Q.DecodeTimeInvalidCharacter,`Time decode error: Invalid character: ${t}`);return e+=r*32**n},0);if(t>0xffffffffffff)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID: timestamp too large: ${t}`);return t}function fp(e){let n=pp(),r=n&&(n.crypto||n.msCrypto)||(t===void 0?null:t);if(typeof r?.getRandomValues==`function`)return()=>{let e=new Uint8Array(1);return r.getRandomValues(e),e[0]/256};if(typeof r?.randomBytes==`function`)return()=>r.randomBytes(1).readUInt8()/256;if(t?.randomBytes)return()=>t.randomBytes(1).readUInt8()/256;throw new $(Q.PRNGDetectFailure,`Failed to find a reliable PRNG`)}function pp(){return gp()?self:typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:null}function mp(e,t){let n=``;for(;e>0;e--)n=cp(t)+n;return n}function hp(e,t=10){if(isNaN(e))throw new $(Q.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>0xffffffffffff)throw new $(Q.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${e}`);if(e<0)throw new $(Q.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new $(Q.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,r=``;for(let i=t;i>0;i--)n=e%32,r=sp.charAt(n)+r,e=(e-n)/32;return r}function gp(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function _p(e){let t=e||fp(),n=0,r;return function(e){let i=!e||isNaN(e)?Date.now():e;if(i<=n){let e=r=up(r);return hp(n,10)+e}n=i;let a=r=mp(16,t);return hp(i,10)+a}}function vp(e,t){let n=t||fp();return hp(!e||isNaN(e)?Date.now():e,10)+mp(16,n)}const yp=A().ulid(),bp=Ju([`wrun_`,qc()]),xp=1440*60*1e3,Sp=300*1e3;function Cp(e){if(tp(e))return null;let t=yp.safeParse(e);return t.success?new Date(dp(t.data)):null}function wp(e,t,n=xp,r=Sp){let i=Cp(e.startsWith(t)?e.slice(t.length):e);if(!i)return`Invalid runId: "${e}" is not a valid ULID`;let a=new Date().getTime()-i.getTime();return a>0&&a<=n||a<=0&&-a<=r?null:`Invalid runId timestamp: embedded timestamp is ${Math.round(Math.abs(a)/1e3)}s in the ${a>0?`past`:`future`} (threshold: ${Math.round((a>0?n:r)/1e3)}s)`}var Tp=e({ANALYTICS_EVENTS_GET_MANY_LIMIT:()=>100,ATTRIBUTE_KEY_MAX_LENGTH:()=>256,ATTRIBUTE_MAX_PER_RUN:()=>64,ATTRIBUTE_VALUE_MAX_BYTES:()=>256,BULK_CANCEL_MAX_RUN_IDS:()=>500,DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS:()=>Sp,DEFAULT_TIMESTAMP_THRESHOLD_MS:()=>DEFAULT_TIMESTAMP_THRESHOLD_MS,DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS:()=>xp,EVENT_ID_BODY_LENGTH:()=>26,EVENT_ID_PREFIX:()=>ep,FIRST_EVENT_SLOT:()=>1,HOOK_RESUME_DEDUP_VERSION:()=>1,HOOK_RESUME_INPUT_VERSION:()=>1,HookSchema:()=>Jf,RESERVED_ATTRIBUTE_KEY_PREFIX:()=>`$`,SPEC_VERSION_CURRENT:()=>6,SPEC_VERSION_LEGACY:()=>1,SPEC_VERSION_MAX_SUPPORTED:()=>6,SPEC_VERSION_SUPPORTS_ATTRIBUTES:()=>4,SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT:()=>3,SPEC_VERSION_SUPPORTS_COMPRESSION:()=>5,SPEC_VERSION_SUPPORTS_EVENT_SOURCING:()=>2,SPEC_VERSION_SUPPORTS_SLOT_IDENTITY:()=>6});export{Cd as $,ro as $a,ct as $c,Mo as $i,Lc as $n,yr as $o,jc as $r,x as $s,pu as $t,Cf as A,ba as Aa,sr as Ac,cs as Ai,Al as An,oa as Ao,dd as Ar,vr as As,nl as At,Ad as B,zo as Ba,yt as Bc,rs as Bi,od as Bn,$i as Bo,ld as Br,Ri as Bs,Hl as Bt,Pf as C,_a as Ca,qn as Cc,tc as Ci,n as Cl,Rl as Cn,Wa as Co,Ou as Cr,zr as Cs,Rc as Ct,Tf as D,go as Da,Wn as Dc,ds as Di,L as Dn,Ya as Do,lu as Dr,Ar as Ds,$u as Dt,Of as E,Bo as Ea,Jn as Ec,fs as Ei,Bl as En,Ao as Eo,Cu as Er,Ci as Es,vu as Et,pf as F,po as Fa,nr as Fc,Ca as Fi,Wu as Fn,ga as Fo,wc as Fr,Vr as Fs,_u as Ft,Od as G,ao as Ga,Ct as Gc,$a as Gi,Tu as Gn,ti as Go,xu as Gr,bi as Gs,Sl as Gt,lf as H,Xa as Ha,lt as Hc,Sa as Hi,pl as Hn,C as Ho,ad as Hr,qi as Hs,Ll as Ht,mf as I,lo as Ia,jt as Ic,wa as Ii,Uc as In,jo as Io,mu as Ir,Hr as Is,el as It,G as J,Wo as Ja,pt as Jc,pa as Ji,Tl as Jn,Wr as Jo,Nl as Jr,Fi as Js,Vu as Jt,Ed as K,wo as Ka,Dt as Kc,Na as Ki,yu as Kn,Pr as Ko,su as Kr,fr as Ks,Xl as Kt,ff as L,so as La,_t as Lc,Va as Li,Gc as Ln,is as Lo,Zl as Lr,ai as Ls,du as Lt,xf as M,fo as Ma,Yn as Mc,Da as Mi,nd as Mn,ca as Mo,Ku as Mr,Ni as Ms,ml as Mt,hf as N,co as Na,ir as Nc,Ja as Ni,al as Nn,la as No,B as Nr,Jr as Ns,Xc as Nt,Ef as O,to as Oa,Gn as Oc,ls as Oi,ll as On,_o as Oo,Hu as Or,vi as Os,kc as Ot,_f as P,So as Pa,$n as Pc,ko as Pi,sl as Pn,Za as Po,id as Pr,ki as Ps,Yu as Pt,wd as Q,Yo as Qa,bt as Qc,Go as Qi,vl as Qn,Mr as Qo,Ic as Qr,hi as Qs,cu as Qt,cf as R,eo as Ra,xt as Rc,za as Ri,rd as Rn,as as Ro,A as Rr,oi as Rs,zu as Rt,If as S,Ea as Sa,Xn as Sc,oc as Si,r as Sl,cd as Sn,Ra as So,Du as Sr,fi as Ss,Dc as St,Df as T,mo as Ta,Zn as Tc,ec as Ti,s as Tl,Gl as Tn,Ka as To,R as Tr,Ji as Ts,wu as Tt,Pd as U,oo as Ua,Tt as Uc,Ha as Ui,Oc as Un,ta as Uo,Fl as Ur,Ui as Us,Eu as Ut,Bd as V,io as Va,st as Vc,xa as Vi,ru as Vn,Qi as Vo,Iu as Vr,Mi as Vs,Nu as Vt,Md as W,Ko as Wa,kt as Wc,Ba as Wi,zc as Wn,Yr as Wo,Ju as Wr,_i as Ws,xl as Wt,vd as X,Uo as Xa,St as Xc,es as Xi,bl as Xn,Ur as Xo,z as Xr,Gi as Xs,Zu as Xt,W as Y,Ma as Ya,vt as Yc,ma as Yi,Ac as Yn,Gr as Yo,qc as Yr,Kr as Ys,ju as Yt,_d as Z,Co as Za,gt as Zc,Qa as Zi,yl as Zn,jr as Zo,I as Zr,Ti as Zs,Gu as Zt,Lf as _,ya as _a,Un as _c,dc as _i,ke as _l,Tc as _n,Eo as _o,Bu as _r,kr as _s,gl as _t,dp as a,Vo as aa,Xr as ac,_c as ai,ft as al,bu as an,ho as ao,rl as ar,$r as as,cl as at,Uf as b,ja as ba,Hn as bc,nc as bi,o as bl,V as bn,To as bo,Ul as br,Dr as bs,nu as bt,ap as c,no as ca,ui as cc,vc as ci,y as cl,Kc as cn,Oo as co,Yl as cr,Lr as cs,jl as ct,ip as d,vo as da,Rr as dc,xc as di,ot as dl,Il as dn,ss as do,H as dr,Si as ds,ol as dt,Ta as ea,xr as ec,Mc as ei,ut as el,Ec as en,$o as eo,Cl as er,br as es,fd as et,Qf as f,Pa as fa,dr as fc,Cc as fi,at as fl,$l as fn,os as fo,Ql as fr,Oi as fs,Hc as ft,Wf as g,va as ga,ar as gc,hc as gi,We as gl,eu as gn,Zo as go,sd as gr,Or as gs,td as gt,Jf as h,No as ha,Kn as hc,mc as hi,ae as hl,Jc as hn,Ga as ho,fu as hr,pr as hs,Uu as ht,bp as i,Ro as ia,ci as ic,tu as ii,Ot as il,qu as in,ts as io,$c as ir,Br as is,Jl as it,yf as j,Io as ja,er as jc,E as ji,P as jn,sa as jo,Qu as jr,Zr as js,iu as jt,kf as k,w as ka,lr as kc,us as ki,dl as kn,ua as ko,Mu as kr,Li as ks,Qc as kt,rp as l,T as la,Nr as lc,fc as li,nt as ll,Fc as ln,yo as lo,Zc as lr,hr as ls,Ol as lt,Yf as m,Ua as ma,b as mc,Sc as mi,h as ml,Wl as mn,ns as mo,tl as mr,Ki as ms,Lu as mt,Cp as n,da as na,mr as nc,Pc as ni,At as nl,Fu as nn,Xo as no,Ml as nr,Bi as ns,md as nt,_p as o,Fa as oa,Qr as oc,yc as oi,mt as ol,ou as on,Lo as oo,ud as or,Ai as os,ul as ot,$f as p,La as pa,ur as pc,bc as pi,it as pl,Vl as pn,qo as po,uu as pr,wi as ps,Wc as pt,Vd as q,qa,dt as qc,ra as qi,wl as qn,Ir as qo,Dl as qr,S as qs,Su as qt,wp as r,bo as ra,qr as rc,Yc as ri,wt as rl,Pl as rn,Fo as ro,au as rr,Yi as rs,zl as rt,vp as s,Ia as sa,Sr as sc,gc as si,tt as sl,k as sn,uo as so,hl as sr,di as ss,kl as st,Tp as t,ia as ta,gr as tc,Nc as ti,Et as tl,j as tn,xo as to,El as tr,Ii as ts,U as tt,op as u,aa as ua,Fr as uc,pc as ui,rt as ul,M as un,na as uo,Xu as ur,_r as us,il as ut,Gf as v,ka as va,rr as vc,O as vi,l as vl,Ru as vn,Do as vo,Vc as vr,Tr as vs,Kl as vt,Af as w,Qo as wa,cr as wc,$s as wi,c as wl,F as wn,ha as wo,N as wr,Cr as ws,hu as wt,Ff as x,Aa as xa,tr as xc,cc as xi,i as xl,ed as xn,Po as xo,Pu as xr,Er as xs,fl as xt,Mf as y,Oa as ya,Qn as yc,ic as yi,a as yl,Au as yn,Ho as yo,gu as yr,wr as ys,ku as yt,K as z,fa as za,ht as zc,Jo as zi,ql as zn,ea as zo,_l as zr,Di as zs,Bc as zt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{t as e}from"./dist-DpYyXbJv.js";function t(e,t,n){return n===1?e:t}const n={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,REPLAY_DIVERGENCE:`REPLAY_DIVERGENCE`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,MAX_EVENTS_EXCEEDED:`MAX_EVENTS_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`,DEPLOYMENT_MISMATCH:`DEPLOYMENT_MISMATCH`};function r(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function i(e,t){if(t.length===0)return e;let n=[e];return t.forEach((e,r)=>{let i=r===t.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;`${e.label}: ${e.value}`.split(`
|
|
2
2
|
`).forEach((e,t)=>{n.push(`${t===0?a:o}${e}`)})}),n.join(`
|
|
3
|
-
`)}function a(e,t){let n=[];return e&&n.push({label:`hint`,value:e}),t&&n.push({label:`docs`,value:`https://workflow-sdk.dev/err/${t}`}),n}const o={NODE_JS_MODULE_IN_WORKFLOW:`node-js-module-in-workflow`,START_INVALID_WORKFLOW_FUNCTION:`start-invalid-workflow-function`,SERIALIZATION_FAILED:`serialization-failed`,WEBHOOK_INVALID_RESPOND_WITH_VALUE:`webhook-invalid-respond-with-value`,WEBHOOK_RESPONSE_NOT_SENT:`webhook-response-not-sent`,FETCH_IN_WORKFLOW_FUNCTION:`fetch-in-workflow`,TIMEOUT_FUNCTIONS_IN_WORKFLOW:`timeout-in-workflow`,HOOK_CONFLICT:`hook-conflict`,CORRUPTED_EVENT_LOG:`corrupted-event-log`,REPLAY_DIVERGENCE:`replay-divergence`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`,DEPLOYMENT_MISMATCH:`deployment-mismatch`};var s=class extends Error{cause;constructor(e,t){let n=i(e,a(void 0,t?.slug));super(n,{cause:t?.cause}),t?.cause!==void 0&&(this.cause=t.cause),t?.cause instanceof Error&&(this.stack=`${this.stack}\nCaused by: ${t.cause.stack}`)}static is(e){return r(e)&&e.name===`WorkflowError`}},c=class extends s{status;code;url;retryAfter;constructor(e,t){super(e,{cause:t?.cause}),this.name=`WorkflowWorldError`,this.status=t?.status,this.code=t?.code,this.url=t?.url,this.retryAfter=t?.retryAfter}static is(e){return r(e)&&e.name===`WorkflowWorldError`}},l=class extends s{runId;errorCode;constructor(e,t,n={}){let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?String(t.message):`Unknown error`;super(`Workflow run "${e}" failed: ${r}`,{cause:t}),this.name=`WorkflowRunFailedError`,this.runId=e,n.errorCode!==void 0&&(this.errorCode=n.errorCode)}static is(e){return r(e)&&e.name===`WorkflowRunFailedError`}},u=class extends s{runId;status;constructor(e,t){super(`Workflow run "${e}" has not completed`,{}),this.name=`WorkflowRunNotCompletedError`,this.runId=e,this.status=t}static is(e){return r(e)&&e.name===`WorkflowRunNotCompletedError`}},d=class extends s{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return r(e)&&e.name===`WorkflowRuntimeError`}},f=class extends d{constructor(e,t){super(e,{...t,slug:o.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return r(e)&&e.name===`CorruptedEventLogError`}},p=class extends d{eventId;constructor(e,t){super(e,{...t,slug:o.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return r(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},m=class extends s{eventCount;limit;constructor(e,t,n){super(`Workflow exceeded the maximum of ${t} events per run`,n),this.name=`MaxEventsExceededError`,this.eventCount=e,this.limit=t}static is(e){return r(e)&&e.name===`MaxEventsExceededError`}},h=class extends d{constructor(e,t){super(e,{cause:t?.cause,slug:o.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return r(e)&&e.name===`RuntimeDecryptionError`}},g=class extends s{hint;constructor(e,t){let n=i(e,a(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return r(e)&&e.name===`WorkflowBuildError`}},_=class extends s{hint;fatal=!0;constructor(e,t){let n=i(e,a(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return r(e)&&e.name===`SerializationError`}},v=class extends d{stepName;constructor(e){super(`Step "${e}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`,{slug:o.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return r(e)&&e.name===`StepNotRegisteredError`}},y=class extends d{workflowName;constructor(e){super(`Workflow "${e}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`,{slug:o.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return r(e)&&e.name===`WorkflowNotRegisteredError`}},b=class extends d{runId;expectedDeploymentId;actualDeploymentId;recoveryAttempts;constructor(e,n,r,i){let a=i?.recoveryAttempts??0,s=a>0?` The runtime re-routed the message to "${n}" ${a} ${t(`time`,`times`,a)} and it kept arriving elsewhere, so the run was stopped to protect against code-skew errors.`:` The run was stopped to protect against code-skew errors.`;super(`Workflow run "${e}" is pinned to deployment "${n}", but was received by deployment "${r}".${s} Verify that the run's deployment is still available and that queue callbacks are routed to it.`,{slug:o.DEPLOYMENT_MISMATCH,cause:i?.cause}),this.name=`WorkflowDeploymentMismatchError`,this.runId=e,this.expectedDeploymentId=n,this.actualDeploymentId=r,this.recoveryAttempts=a}static is(e){return r(e)&&e.name===`WorkflowDeploymentMismatchError`}},x=class extends s{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return r(e)&&e.name===`WorkflowRunNotFoundError`}},S=class extends s{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:o.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return r(e)&&e.name===`HookConflictError`}},C=class extends s{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return r(e)&&e.name===`HookNotFoundError`}},w=class extends c{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return r(e)&&e.name===`EntityConflictError`}},T=class extends c{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return r(e)&&e.name===`RunExpiredError`}},E=class extends c{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return r(e)&&e.name===`TooEarlyError`}},
|
|
3
|
+
`)}function a(e,t){let n=[];return e&&n.push({label:`hint`,value:e}),t&&n.push({label:`docs`,value:`https://workflow-sdk.dev/err/${t}`}),n}const o={NODE_JS_MODULE_IN_WORKFLOW:`node-js-module-in-workflow`,START_INVALID_WORKFLOW_FUNCTION:`start-invalid-workflow-function`,SERIALIZATION_FAILED:`serialization-failed`,WEBHOOK_INVALID_RESPOND_WITH_VALUE:`webhook-invalid-respond-with-value`,WEBHOOK_RESPONSE_NOT_SENT:`webhook-response-not-sent`,FETCH_IN_WORKFLOW_FUNCTION:`fetch-in-workflow`,TIMEOUT_FUNCTIONS_IN_WORKFLOW:`timeout-in-workflow`,HOOK_CONFLICT:`hook-conflict`,CORRUPTED_EVENT_LOG:`corrupted-event-log`,REPLAY_DIVERGENCE:`replay-divergence`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`,DEPLOYMENT_MISMATCH:`deployment-mismatch`};var s=class extends Error{cause;constructor(e,t){let n=i(e,a(void 0,t?.slug));super(n,{cause:t?.cause}),t?.cause!==void 0&&(this.cause=t.cause),t?.cause instanceof Error&&(this.stack=`${this.stack}\nCaused by: ${t.cause.stack}`)}static is(e){return r(e)&&e.name===`WorkflowError`}},c=class extends s{status;code;url;retryAfter;constructor(e,t){super(e,{cause:t?.cause}),this.name=`WorkflowWorldError`,this.status=t?.status,this.code=t?.code,this.url=t?.url,this.retryAfter=t?.retryAfter}static is(e){return r(e)&&e.name===`WorkflowWorldError`}},l=class extends s{runId;errorCode;constructor(e,t,n={}){let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?String(t.message):`Unknown error`;super(`Workflow run "${e}" failed: ${r}`,{cause:t}),this.name=`WorkflowRunFailedError`,this.runId=e,n.errorCode!==void 0&&(this.errorCode=n.errorCode)}static is(e){return r(e)&&e.name===`WorkflowRunFailedError`}},u=class extends s{runId;status;constructor(e,t){super(`Workflow run "${e}" has not completed`,{}),this.name=`WorkflowRunNotCompletedError`,this.runId=e,this.status=t}static is(e){return r(e)&&e.name===`WorkflowRunNotCompletedError`}},d=class extends s{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return r(e)&&e.name===`WorkflowRuntimeError`}},f=class extends d{constructor(e,t){super(e,{...t,slug:o.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return r(e)&&e.name===`CorruptedEventLogError`}},p=class extends d{eventId;constructor(e,t){super(e,{...t,slug:o.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return r(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},m=class extends s{eventCount;limit;constructor(e,t,n){super(`Workflow exceeded the maximum of ${t} events per run`,n),this.name=`MaxEventsExceededError`,this.eventCount=e,this.limit=t}static is(e){return r(e)&&e.name===`MaxEventsExceededError`}},h=class extends d{constructor(e,t){super(e,{cause:t?.cause,slug:o.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return r(e)&&e.name===`RuntimeDecryptionError`}},g=class extends s{hint;constructor(e,t){let n=i(e,a(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return r(e)&&e.name===`WorkflowBuildError`}},_=class extends s{hint;fatal=!0;constructor(e,t){let n=i(e,a(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return r(e)&&e.name===`SerializationError`}},v=class extends d{stepName;constructor(e){super(`Step "${e}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`,{slug:o.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return r(e)&&e.name===`StepNotRegisteredError`}},y=class extends d{workflowName;constructor(e){super(`Workflow "${e}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`,{slug:o.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return r(e)&&e.name===`WorkflowNotRegisteredError`}},b=class extends d{runId;expectedDeploymentId;actualDeploymentId;recoveryAttempts;constructor(e,n,r,i){let a=i?.recoveryAttempts??0,s=a>0?` The runtime re-routed the message to "${n}" ${a} ${t(`time`,`times`,a)} and it kept arriving elsewhere, so the run was stopped to protect against code-skew errors.`:` The run was stopped to protect against code-skew errors.`;super(`Workflow run "${e}" is pinned to deployment "${n}", but was received by deployment "${r}".${s} Verify that the run's deployment is still available and that queue callbacks are routed to it.`,{slug:o.DEPLOYMENT_MISMATCH,cause:i?.cause}),this.name=`WorkflowDeploymentMismatchError`,this.runId=e,this.expectedDeploymentId=n,this.actualDeploymentId=r,this.recoveryAttempts=a}static is(e){return r(e)&&e.name===`WorkflowDeploymentMismatchError`}},x=class extends s{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return r(e)&&e.name===`WorkflowRunNotFoundError`}},S=class extends s{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:o.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return r(e)&&e.name===`HookConflictError`}},C=class extends s{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return r(e)&&e.name===`HookNotFoundError`}},w=class extends c{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return r(e)&&e.name===`EntityConflictError`}},T=class extends c{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return r(e)&&e.name===`RunExpiredError`}},E=class extends c{runId;streamId;expiredAt;constructor(e,t,n,r){super(e,{status:410,code:`stream-expired`}),this.runId=t,this.streamId=n,this.expiredAt=r,this.name=`StreamExpiredError`}static is(e){return r(e)&&e.name===`StreamExpiredError`}},D=class extends c{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return r(e)&&e.name===`TooEarlyError`}},O=class extends c{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return r(e)&&e.name===`ThrottleError`}},k=class extends c{details;constructor(e,t){super(e,{status:412,retryAfter:t?.retryAfter}),this.name=`PreconditionFailedError`,this.details=t?.details}static is(e){return r(e)&&e.name===`PreconditionFailedError`}},A=class extends s{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return r(e)&&e.name===`WorkflowRunCancelledError`}},j=class extends s{runSpecVersion;worldSpecVersion;constructor(e,t){super(`Run requires spec version ${e}, but world supports version ${t}. Please upgrade 'workflow' package.`),this.name=`RunNotSupportedError`,this.runSpecVersion=e,this.worldSpecVersion=t}static is(e){return r(e)&&e.name===`RunNotSupportedError`}},M=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return r(e)?e.name===`FatalError`||e.fatal===!0:!1}},N=class extends Error{retryAfter;constructor(t,n={}){super(t),this.name=`RetryableError`,n.retryAfter===void 0?this.retryAfter=new Date(Date.now()+1e3):this.retryAfter=e(n.retryAfter)}static is(e){return r(e)&&e.name===`RetryableError`}};const P="Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.",F=Symbol.for(`@workflow/errors//FatalError`),I=Symbol.for(`@workflow/errors//RetryableError`),L=Symbol.for(`@workflow/errors//HookConflictError`),R=Symbol.for(`@workflow/errors//RuntimeDecryptionError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,F)||Object.defineProperty(globalThis,F,{value:M,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,I)||Object.defineProperty(globalThis,I,{value:N,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,L)||Object.defineProperty(globalThis,L,{value:S,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,R)||Object.defineProperty(globalThis,R,{value:h,writable:!1,enumerable:!1,configurable:!1}));export{n as A,y as C,x as D,u as E,d as O,s as S,l as T,O as _,S as a,g as b,k as c,T as d,j as f,E as g,v as h,M as i,t as j,c as k,p as l,_ as m,o as n,C as o,h as p,w as r,m as s,f as t,N as u,D as v,A as w,b as x,P as y};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e,i as t,t as n}from"./rolldown-runtime-8V8biNmG.js";import{_ as r,c as i,d as a,g as o,k as s,r as c,v as l}from"./dist-CqvWKNQv.js";import{Nr as u,Rr as d,Zr as f}from"./dist-BRGbNjhD.js";import{t as p}from"./env-config-DxamfI7T.js";import{t as m}from"./undici-BBG5cZTy.js";import{n as h,r as g,t as _}from"./token-util-DjMgNdXS.js";import{createRequire as v}from"module";import{inspect as y}from"node:util";import b from"node:os";var x=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})})),ee=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=x(),f=g();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-DjMgNdXS.js`).then(t=>e(t.t())),await import(`./token-DGzfw-Vb.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})})),S=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=ee(),d=x(),f=h(),p=_();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})})),te=S();let C;try{C=new TextDecoder}catch{}let w,T,E=0;const ne=[],re=57337,ie={};let ae=11281e4,D=1681e4,O=ne,oe=0,k={},A,se,ce=0,j=0,M,N,P=[],le=[],F,I,ue,de={useRecords:!1,mapsAsObjects:!0},fe=!1,pe=2;try{Function(``)}catch{pe=1/0}var me=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 Ie(()=>(Le(),this?this.decode(t,n):e.prototype.decode.call(de,t,n)));T=n>-1?n:t.length,E=0,oe=0,j=0,se=null,O=ne,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,he();(!A||A.length>0)&&(A=[])}else k=de,(!A||A.length>0)&&(A=[]),F=null;return he()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;fe=!0;let a=this?this.decode(e,i):ze.decode(e,i);if(t){if(t(a)===!1)return;for(;E<i;)if(r=E,t(he())===!1)return}else{for(n=[a];E<i;)r=E,n.push(he());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{fe=!1,Le()}}};function he(){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(!fe)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw Le(),(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 Ee();e=I.getUint16(E),E+=2;break;case 26:if(t==7){let e=I.getFloat32(E);if(k.useFloat32>2){let t=Re[(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())!=ie;){if(r>=ae)throw Error(`Array length exceeds ${ae}`);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())!=ie;){if(t++>=D)throw Error(`Property count exceeds ${D}`);e[R(k.decodeKey(i))]=L()}else for(;(i=L())!=ie;){if(t++>=D)throw Error(`Property count exceeds ${D}`);e[R(i)]=L()}return e}else{ue&&=(k.mapsAsObjects=!0,!1);let e=new Map;if(k.keyMap){let t=0;for(;(i=L())!=ie;){if(t++>=D)throw Error(`Map size exceeds ${D}`);e.set(k.decodeKey(i),L())}}else{let t=0;for(;(i=L())!=ie;){if(t++>=D)throw Error(`Map size exceeds ${D}`);e.set(i,L())}}return e}case 7:return ie;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 Ce(e);case 3:if(j>=E)return se.slice(E-ce,(E+=e)-ce);if(j==0&&T<140&&e<32){let t=e<16?Se(e):xe(e);if(t!=null)return t}return ve(e);case 4:if(e>=ae)throw Error(`Array length exceeds ${ae}`);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 ${ae}`);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}else{ue&&=(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>=re){let t=A[e&8191];if(t)return t.read||=_e(t),t.read();if(e<65536){if(e==57343){let e=U(),t=L(),n=L();De(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}else if(e==57342){let e=U(),t=L();for(let n=2;n<e;n++)De(t++,L());return L()}else if(e==re)return Pe();if(k.getShared&&(Fe(),t=A[e&8191],t))return t.read||=_e(t),t.read()}}let n=P[e];if(n)return n.handlesRead?n(L):n(L());{let t=L();for(let n=0;n<le.length;n++){let r=le[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||H())[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 ge=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function _e(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++>=pe){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=>ge.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>ge.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 ve=be;function ye(e){ve=t(1);function t(t){return function(t){let n=O[oe++];if(n==null){if(M)return be(t);let r=e(E,T,t,w);if(typeof r==`string`)n=r,O=ne;else if(O=r,oe=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):(se=n,ce=E,j=E+r,E+=t,n.slice(0,t))}}}function be(e){let t;if(e<16&&(t=Se(e)))return t;if(e>64&&C)return C.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 xe(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 Se(e){if(e<4)if(e<2){if(e===0)return``;{let e=w[E++];if((e&128)>1){--E;return}return z(e)}}else{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)}else{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)}}else 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)}else{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)}}else 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)}else{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)}}else{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 Ce(e){return k.copyBuffers?Uint8Array.prototype.slice.call(w,E,E+=e):w.subarray(E,E+=e)}let we=new Float32Array(1),Te=new Uint8Array(we.buffer,0,4);function Ee(){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 Te[3]=e&128|(n>>1)+56,Te[2]=(e&7)<<5|t>>3,Te[1]=t<<5,Te[0]=0,we[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 De=(e,t)=>{e-=57344;let n=A[e];n&&n.isShared&&((A.restoreStructures||=[])[e]=n),A[e]=t,t.read=_e(t)};P[105]=e=>{let t=e.length,n=e[1];De(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 Oe={Error,RegExp};P[27]=e=>(Oe[e[0]]||Error)(e[1],e[2]);const ke=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()};ke.handlesRead=!0,P[51]=ke,P[6]=e=>{if(!F)if(k.getShared)Fe();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,ue=!0),e())).handlesRead=!0;function V(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function H(){if(!F)if(k.getShared)Fe();else throw Error(`No packed values available`);return F}le.push((e,t)=>{if(e>=225&&e<=255)return V(H().prefixes[e-224],t);if(e>=28704&&e<=32767)return V(H().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return V(H().prefixes[e-1879048192],t);if(e>=216&&e<=223)return V(t,H().suffixes[e-216]);if(e>=27647&&e<=28671)return V(t,H().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return V(t,H().suffixes[e-1811939328]);if(e==1399353956)return{packedValues:F,structures:A.slice(0),version:t};if(e==55799)return t});const Ae=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,je=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],Me=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<je.length;e++)Ne(je[e],Me[e]);function Ne(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==Ae?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 Pe(){let e=U(),t=E+L();for(let t=2;t<e;t++){let e=U();E+=e}let n=E;return E=t,M=[be(U()),be(U())],M.position0=0,M.position1=0,M.postBundlePosition=E,E=n,L()}function U(){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;break}return e}function Fe(){if(k.getShared){let e=Ie(()=>(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 Ie(e){let t=T,n=E,r=oe,i=ce,a=j,o=se,s=O,c=N,l=M,u=new Uint8Array(w.slice(0,T)),d=A,f=k,p=fe,m=e();return T=t,E=n,oe=r,ce=i,j=a,se=o,O=s,N=c,M=l,w=u,fe=p,A=d,k=f,I=new DataView(w.buffer,w.byteOffset,w.byteLength),m}function Le(){w=null,N=null,A=null}const Re=Array(147);for(let e=0;e<256;e++)Re[e]=+(`1e`+Math.floor(45.15-e*.30103));let ze=new me({useRecords:!1});const Be=ze.decode;ze.decodeMultiple;const Ve={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let He;try{He=new TextEncoder}catch{}let Ue,We;const Ge=typeof globalThis==`object`&&globalThis.Buffer,Ke=Ge!==void 0,qe=Ke?Ge.allocUnsafeSlow:Uint8Array,Je=Ke?Ge:Uint8Array,Ye=Ke?4294967296:2144337920;let Xe,W,G,K=0,q,J=null;const Ze=/[\u0080-\uFFFF]/,Y=Symbol(`record-id`);var Qe=class extends me{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=Je.prototype.utf8Write?function(e,t,n){return W.utf8Write(e,t,n)}:He&&He.encodeInto?function(e,t){return He.encodeInto(e,W.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,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e));break}return this.encode(e,t)},this.encode=function(o,c){if(W||(W=new qe(8192),G=new DataView(W.buffer,0,8192),K=0),q=W.length-10,q-K<2048?(W=new qe(W.length),G=new DataView(W.buffer,0,W.length),q=W.length-10,K=0):c===512&&(K=K+7&2147483640),t=K,s.useSelfDescribedHeader&&(G.setUint32(K,3654940416),K+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(J=[],J.size=1/0):J=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[Y]===void 0&&(i[Y]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[Y]=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,rt(o,t),t.values.length>0){W[K++]=216,W[K++]=51,X(4);let e=t.values;v(e),X(0),X(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}Xe=c&mt;try{if(Xe)return;if(v(o),J&&st(t,v),s.offset=K,a&&a.idsToInsert){K+=a.idsToInsert.length*2,K>q&&b(K),s.offset=K;let e=ot(W.subarray(t,K),a.idsToInsert);return a=null,e}return c&512?(W.start=t,W.end=K,W):W.subarray(t,K)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=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][Y]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=W.subarray(t,K);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(K=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 v=n=>{K>q&&(W=b(K));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?W[K++]=t+224:(W[K++]=198,t&1?v(15-t>>1):v(t-16>>1));return}else if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(J&&r>=4&&r<1024){if((J.size+=r)>61440){let e,n=(J[0]?J[0].length*3+J[1].length:0)+10;K+n>q&&(W=b(K+n)),W[K++]=217,W[K++]=223,W[K++]=249,W[K++]=J.position?132:130,W[K++]=26,e=K-t,K+=4,J.position&&st(t,v),J=[``,``],J.size=0,J.position=e}let e=Ze.test(n);J[+!e]+=n,W[K++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(K+s>q&&(W=b(K+s)),r<64||!o){let e,t,o,s=K+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?W[s++]=t:t<2048?(W[s++]=t>>6|192,W[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,W[s++]=t>>18|240,W[s++]=t>>12&63|128,W[s++]=t>>6&63|128,W[s++]=t&63|128):(W[s++]=t>>12|224,W[s++]=t>>6&63|128,W[s++]=t&63|128);i=s-K-a}else i=o(n,K+a,s);i<24?W[K++]=96|i:i<256?(a<2&&W.copyWithin(K+2,K+1,K+1+i),W[K++]=120,W[K++]=i):i<65536?(a<3&&W.copyWithin(K+3,K+2,K+2+i),W[K++]=121,W[K++]=i>>8,W[K++]=i&255):(a<5&&W.copyWithin(K+5,K+3,K+3+i),W[K++]=122,G.setUint32(K,i),K+=4),K+=i}else if(r===`number`)if(!this.alwaysUseFloat&&n>>>0===n)n<24?W[K++]=n:n<256?(W[K++]=24,W[K++]=n):n<65536?(W[K++]=25,W[K++]=n>>8,W[K++]=n&255):(W[K++]=26,G.setUint32(K,n),K+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?W[K++]=31-n:n>=-256?(W[K++]=56,W[K++]=~n):n>=-65536?(W[K++]=57,G.setUint16(K,~n),K+=2):(W[K++]=58,G.setUint32(K,~n),K+=4);else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){W[K++]=250,G.setFloat32(K,n);let t;if(e<4||(t=n*Re[(W[K]&127)<<1|W[K+1]>>7])>>0===t){K+=4;return}else K--}W[K++]=251,G.setFloat64(K,n),K+=8}else if(r===`object`)if(!n)W[K++]=246;else{if(a){let e=a.get(n);if(e){if(W[K++]=216,W[K++]=29,W[K++]=25,!e.references){let t=a.idsToInsert||=[];e.references=[],t.push(e)}e.references.push(K-t),K+=2;return}else a.set(n,{offset:K-t})}let e=n.constructor;if(e===Object)y(n);else if(e===Array){i=n.length,i<24?W[K++]=128|i:X(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(W[K++]=217,W[K++]=1,W[K++]=3),i=n.size,i<24?W[K++]=160|i:i<256?(W[K++]=184,W[K++]=i):i<65536?(W[K++]=185,W[K++]=i>>8,W[K++]=i&255):(W[K++]=186,G.setUint32(K,i),K+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t);else{for(let e=0,t=Ue.length;e<t;e++){let t=We[e];if(n instanceof t){let t=Ue[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?W[K++]=192|r:r<256?(W[K++]=216,W[K++]=r):r<65536?(W[K++]=217,W[K++]=r>>8,W[K++]=r&255):r>-1&&(W[K++]=218,G.setUint32(K,r),K+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(Xe){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}W[K++]=159;for(let e of n)v(e);W[K++]=255;return}if(n[Symbol.asyncIterator]||nt(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 v(e)}y(n)}}else if(r===`boolean`)W[K++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)W[K++]=27,G.setBigUint64(K,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)W[K++]=59,G.setBigUint64(K,-n-BigInt(1));else if(this.largeBigIntToFloat)W[K++]=251,G.setFloat64(K,Number(n));else{n>=BigInt(0)?W[K++]=194:(W[K++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);at(new Uint8Array(e.reverse()),b);return}K+=8}else if(r===`undefined`)W[K++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?W[K++]=160|r:r<256?(W[K++]=184,W[K++]=r):r<65536?(W[K++]=185,W[K++]=r>>8,W[K++]=r&255):(W[K++]=186,G.setUint32(K,r),K+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{W[K++]=185;let n=K-t;K+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);W[n+++t]=r>>8,W[n+t]=r&255}:(e,t)=>{let n,a=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[Y]&1048576&&(c=a[Y]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[Y];if(d!==void 0)d&=65535,W[K++]=217,W[K++]=d>>8|224,W[K++]=d&255;else if(u||=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){W[K++]=217,W[K++]=d>>8|224,W[K++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[Y]===void 0||a[Y]&1048576)&&(a[Y]=d),a=a[u[e]];a[Y]=d|1048576,r=!0}else{if(a[Y]=d,G.setUint32(K,3655335680),K+=3,o&&(g+=_*o),h.length>=256-l&&(h.shift()[Y]=void 0),h.push(a),X(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?W[K++]=128|s:X(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>Ye)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(Ye,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,W.length-1)>>12)+1<<12;let r=new qe(n);return G=new DataView(r.buffer,0,n),W.copy?W.copy(r,0,t,e):r.set(W.slice(t,e)),K-=t,t=0,q=r.length-10,W=r},x=100,ee=1e3;this.encodeAsIterable=function(e,t){return w(e,t,S)},this.encodeAsAsyncIterable=function(e,t){return w(e,t,T)};function*S(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):$e(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*S(i,n[r]):yield*te(i,n,r):v(i)}}else if(i===Array){let r=e.length;X(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||K-t>x)?n.element?yield*S(r,n.element):yield*te(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){W[K++]=159;for(let r of e)r&&(typeof r==`object`||K-t>x)?n.element?yield*S(r,n.element):yield*te(r,n,`element`):v(r);W[K++]=255}else nt(e)?($e(e.size,64),yield W.subarray(t,K),yield e,C()):e[Symbol.asyncIterator]?(W[K++]=159,yield W.subarray(t,K),yield e,C(),W[K++]=255):v(e);r&&K>t?yield W.subarray(t,K):K-t>x&&(yield W.subarray(t,K),C())}function*te(e,n,r){let i=K-t;try{v(e),K-t>x&&(yield W.subarray(t,K),C())}catch(a){if(a.iteratorNotHandled)n[r]={},K=t+i,yield*S.call(this,e,n[r]);else throw a}}function C(){x=ee,s.encode(null,mt)}function w(e,t,n){return x=t&&t.chunkThreshold?ee=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,mt),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*T(e,t){for(let n of S(e,t,!0)){let e=n.constructor;if(e===Je||e===Uint8Array)yield n;else if(nt(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*T(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){W=e,G=new DataView(W.buffer,W.byteOffset,W.byteLength),K=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 et(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 $e(e,t){e<24?W[K++]=t|e:e<256?(W[K++]=t|24,W[K++]=e):e<65536?(W[K++]=t|25,W[K++]=e>>8,W[K++]=e&255):(W[K++]=t|26,G.setUint32(K,e),K+=4)}var et=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function X(e){e<24?W[K++]=128|e:e<256?(W[K++]=152,W[K++]=e):e<65536?(W[K++]=153,W[K++]=e>>8,W[K++]=e&255):(W[K++]=154,G.setUint32(K,e),K+=4)}const tt=typeof Blob>`u`?function(){}:Blob;function nt(e){if(e instanceof tt)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function rt(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++)rt(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&rt(n,t),rt(e[n],t))}break;case`function`:console.log(e)}}const it=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;We=[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,et],Ue=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(W[K++]=26,G.setUint32(K,n),K+=4):(W[K++]=251,G.setFloat64(K,n),K+=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){at(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||Ke&&this.tagUint8Array!==!1))return 64},encode(e,t,n){at(e,n)}},Z(68,1),Z(69,2),Z(70,4),Z(71,8),Z(72,1),Z(77,2),Z(78,4),Z(79,8),Z(85,4),Z(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){W[K++]=216,W[K++]=51,X(4);let e=n.values;t(e),X(0),X(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){G.setUint32(K,3655335424),K+=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 Z(e,t){return!it&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(Ke?Ge.from(i,r,n):new Uint8Array(i,r,n))}}}function at(e,t){let n=e.byteLength;n<24?W[K++]=64+n:n<256?(W[K++]=88,W[K++]=n):n<65536?(W[K++]=89,W[K++]=n>>8,W[K++]=n&255):(W[K++]=90,G.setUint32(K,n),K+=4),K+n>=W.length&&t(K+n),W.set(e.buffer?e:new Uint8Array(e),K),K+=n}function ot(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 st(e,t){G.setUint32(J.position+e,K-J.position-e+1);let n=J;J=null,t(n[0]),t(n[1])}let ct=new Qe({useRecords:!1});const lt=ct.encode;ct.encodeAsIterable,ct.encodeAsAsyncIterable;const{NEVER:ut,ALWAYS:dt,DECIMAL_ROUND:ft,DECIMAL_FIT:pt}=Ve,mt=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`):v(import.meta.url)(`cbor-extract`),e&&ye(e.extractStrings)}catch{}}var ht=m();let gt,_t,vt;const yt={connections:8,keepAliveTimeout:1e4},bt={...yt,allowH2:!1,pipelining:1},xt={...yt,allowH2:!0,pipelining:100,initialWindowSize:4194304,connectionWindowSize:16777216},St={...yt,allowH2:!1,pipelining:1},Ct={...yt,allowH2:!0,pipelining:1},wt={retryAfter:!0,statusCodes:[500,502,503,504]},Tt={retryAfter:!0,methods:[`PUT`],statusCodes:[429]},Et={retryAfter:!0,methods:[`PUT`],statusCodes:[429,500,502,503,504]};function Dt(){return process.env.WORKFLOW_H2_MULTIPLEX!==`0`}function Ot(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 kt(e){return(t,n)=>{let r=t.body,i=!!r&&typeof r!=`string`&&!Buffer.isBuffer(r)&&typeof r[Symbol.asyncIterator]==`function`,a=Ot(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 At=new Set([`UND_ERR_INFO`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`]);function jt(e){let t=e;for(let e=0;t&&e<8;e++){let e=t.code;if(typeof e==`string`&&At.has(e))return!0;t=t.cause}return!1}function Mt(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(!jt(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 Nt=Mt(()=>Bt(),`events transport`);function Pt(e,t){Nt.note(e,t)}function Ft(e){return e?.dispatcher??Ut()}function It(e){return e?.dispatcher??Nt.get()}function Lt(e){return e?.dispatcher??Wt()}function Rt(e){return e?.dispatcher??Gt()}function zt(e,t){return new ht.RetryAgent(new ht.Agent(e),t)}function Bt(e){let t=Dt(),n=new ht.RetryAgent(new ht.Agent({...t?xt:St,...e}),wt);return t?Vt(n,n.compose(kt)):n}function Vt(e,t){return new Proxy(t,{get:(t,n)=>n===`close`||n===`destroy`?e[n].bind(e):t[n]})}function Ht(e,t){return new ht.RetryAgent(new ht.Agent({...Ct,...t}),e)}function Ut(){return gt??=zt(bt,wt),gt}function Wt(){return _t??=Ht(Tt),_t}function Gt(){return vt??=Ht(Et),vt}let Kt=null;async function qt(){return Kt||=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)),Kt}let Jt=null;function Yt(){return typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)}let Xt=!1;function Zt(e,t){if(!(Xt||!Yt())){Xt=!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 Qt(){return Jt||=qt().then(e=>{if(!e)return null;let t=e.trace.getTracer(`workflow`);return Zt(e,t),t}),Jt}async function $t(e,...t){let[n,r]=await Promise.all([Qt(),qt()]),{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 en(e){let t=await qt();if(t)return t.SpanKind[e]}async function tn(e){let t=await qt();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 nn=Q(`http.request.method`),rn=Q(`url.full`),an=Q(`server.address`),on=Q(`server.port`),sn=Q(`http.response.status_code`),$=Q(`error.type`),cn=Q(`network.protocol.name`),ln=Q(`workflow.world.parse.format`),un=Q(`peer.service`),dn=Q(`rpc.system`),fn=Q(`rpc.service`),pn=Q(`rpc.method`),mn=Q(`workflow.run.id`),hn=Q(`step.id`),gn=Q(`workflow.stream.name`),_n=Q(`workflow.stream.operation`),vn=Q(`workflow.stream.start_index`),yn=Q(`workflow.events.transport`),bn=Q(`workflow.event.type`),xn=Q(`workflow.client.version`),Sn=Q(`step.stso_ms`),Cn=Q(`step.latency_optimizations`),wn=Q(`workflow.events.ws.url`),Tn=Q(`workflow.events.ws.req_id`),En=Q(`workflow.events.ws.reconnect_attempt`),Dn=()=>p(`WORKFLOW_REQUEST_TIMEOUT_MS`,6e4,{integer:!0,min:1}),On=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 An(e){return kn.flatMap(t=>{let n=e.get(t);return n?[`${t}=${n}`]:[]})}function jn(e){let t=An(e);return t.length>0?` (${t.join(`; `)})`:``}function Mn(e,t,n,r){if(!On)return;let i=An(n.headers),a=i.length>0?`; ${i.join(`; `)}`:``;console.debug(`[workflow:world-vercel:http] ${e} ${t} -> ${n.status} (${r}ms${a})`)}function Nn(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 Pn(e){if(!e)return;let t=parseInt(e,10);return Number.isNaN(t)?void 0:t}function Fn(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function In(e,t,n={}){let{retryAfter:u,code:d,url:f,mitigated:p,details:m}=n;if(e===409)return new c(t);if(e===410){if(d===`stream-expired`){let e=m&&typeof m==`object`?m:void 0,n=typeof e?.expiredAt==`string`?new Date(e.expiredAt):void 0;return new o(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 a(t)}return e===412?new i(t,{retryAfter:u,details:m}):e===425?new l(t,{retryAfter:u}):e===429?Ln(e,p)?new s(`${t} (x-vercel-mitigated=challenge)`,{url:f,status:e,code:`TRANSPORT`,retryAfter:u}):new r(t,{retryAfter:u}):new s(t,{url:f,status:e,code:d,retryAfter:u})}function Ln(e,t){return e===429&&t===`challenge`}async function Rn(e){return e?.token??process.env.VERCEL_TOKEN??await(0,te.getVercelOidcToken)().catch(()=>null)}function zn(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 Bn(e){let{method:t,url:n,peerService:r}=e,{serverAddress:i,serverPort:a}=zn(n);return{...nn(t),...rn(n),...i?an(i):{},...a?on(a):{},...un(r),...dn(`http`),...fn(r)}}async function Vn(e,t){let{method:n,url:r,peerService:i=`workflow-server`,spanName:a,attributes:o}=e;return $t(a??`http ${n}`,{kind:await en(`CLIENT`)},async e=>{if(a&&On&&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(Bn({method:n,url:r,peerService:i})),o&&e?.setAttributes(o),t(e)})}function Hn(e,t){e?.setAttributes({...sn(t)}),(t<200||t>=300)&&e?.setAttributes({...$(`HTTP ${t}`)})}async function Un(e){let{method:t,url:n,headers:r,body:i,dispatcher:a,peerService:o,timeoutMs:c=Dn(),signal:l,injectTraceContext:u=!0,cacheBust:d=!0,logLabel:f,buildError:p,spanName:m,attributes:h,durationAttribute:g,onTransportOutcome:_}=e,v=f??n;return Vn({method:t,url:n,peerService:o,spanName:m,attributes:h},async e=>{u&&await tn(r),d&&r.set(`X-Request-Time`,Date.now().toString());let o=c==null?void 0:AbortSignal.timeout(c),f=l&&o?AbortSignal.any([l,o]):l??o,m=Date.now(),h;try{h=await fetch(n,{method:t,headers:r,body:i,signal:f,dispatcher:a})}catch(r){let i=Date.now()-m;if(_?.(r),r instanceof Error&&(r.name===`TimeoutError`||r.name===`AbortError`)){let a=new s(`${t} ${v} timed out after ${i}ms`,{url:n,cause:r});throw e?.setAttributes({...$(`TIMEOUT`)}),e?.recordException?.(a),a}throw r}let y=Date.now()-m;if(_?.(),Mn(t,v,h,y),Hn(e,h.status),g&&e?.setAttributes({[g]:y}),!h.ok){if(Nn(t,n,r),p){let t=await p(h);throw e?.recordException?.(t),t}let i=await h.text().catch(()=>``),a=In(h.status,`${t} ${v} -> HTTP ${h.status}: ${h.statusText}${i?` ${i}`:``}${jn(h.headers)}`,{url:n,retryAfter:Pn(h.headers.get(`Retry-After`))});throw e?.recordException?.(a),a}return h})}const Wn=`5.0.0-beta.38`,Gn=new Set([`GET`,`HEAD`]),Kn=new Set([`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`]);function qn(e){let t=e;for(let e=0;t!=null&&e<5;e++){if(typeof t==`object`&&`code`in t){let e=t.code;if(typeof e==`string`&&Kn.has(e))return e}t=t?.cause}}const Jn=()=>process.env.VERCEL_WORKFLOW_SERVER_URL||``,Yn=()=>process.env.WORKFLOW_TEST_LIMIT_OVERRIDES?.trim()||``;function Xn(e){return e}const Zn=(...e)=>e.filter(Boolean).join(` `),Qn=()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;return e?`@workflow/world-vercel/${Wn} node-${process.version} ${b.platform()} (${b.arch()}) ${e}`:`@workflow/world-vercel/${Wn} node-${process.version} ${b.platform()} (${b.arch()})`},$n=e=>{let t=e?.projectConfig,n=Jn()||`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}},er=e=>{let t=e?.projectConfig;return t?t.environment||`production`:process.env.VERCEL_TARGET_ENV||process.env.VERCEL_ENV||void 0},tr=(e,t)=>{let n=e?.projectConfig,r=new Headers(e?.headers);r.set(`User-Agent`,Zn(Qn(),r.get(`User-Agent`)));let i=Yn();i&&r.set(`x-workflow-test-limit-overrides`,i),n&&(r.set(`x-vercel-environment`,er(e)),n.projectId&&r.set(`x-vercel-project-id`,n.projectId),n.teamId&&r.set(`x-vercel-team-id`,n.teamId));let a=Jn();return a&&t.usingProxy&&r.set(`x-vercel-workflow-api-url`,a),r};async function nr(e){let{baseUrl:t,usingProxy:n}=$n(e),r=tr(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,te.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 rr({endpoint:e,options:t={},config:n={},schema:r,data:i,onResponse:a,retryConnectTimeout:o=!1}){let c=t.method||`GET`,{baseUrl:l,headers:u}=await nr(n),d=`${l}${e}`;return $t(`http ${c}`,{kind:await en(`CLIENT`)},async l=>{l?.setAttributes(Bn({method:c,url:d,peerService:`workflow-server`})),u.set(`Accept`,`application/cbor`),await tn(u);let f;i!==void 0&&(u.set(`Content-Type`,`application/cbor`),f=lt(i));let p=Gn.has(c.toUpperCase()),m,h=``;for(let r=0;;r++){u.set(`X-Request-Time`,Date.now().toString());let i=AbortSignal.timeout(Dn()),g=t.signal?AbortSignal.any([t.signal,i]):i,_=new Request(d,{...t,body:f,headers:u,signal:g}),v=Date.now(),y;try{y=await fetch(_,{dispatcher:Ft(n)})}catch(t){let n=Date.now()-v;if(t instanceof Error&&(t.name===`TimeoutError`||t.name===`AbortError`)){let r=new s(`${c} ${e} timed out after ${n}ms`,{url:d,code:`TIMEOUT`,cause:t});throw l?.setAttributes({...$(`TIMEOUT`)}),l?.recordException?.(r),r}let i=qn(t);if(i){if(o&&p&&i===`UND_ERR_CONNECT_TIMEOUT`&&r===0){await new Promise(e=>setTimeout(e,100));continue}let a=new s(`${c} ${e} transport failure after ${n}ms (${i})`,{url:d,code:`TRANSPORT`,cause:t});throw l?.setAttributes({...$(`TRANSPORT`)}),l?.recordException?.(a),a}throw t}let b=Date.now()-v;if(h=jn(y.headers),Mn(c,e,y,b),l?.setAttributes({...sn(y.status)}),!y.ok){let t=await ar(y).then(e=>e.data).catch(()=>({})),n=t.code??t.error;Nn(_.method,d,u);let r=Pn(y.headers.get(`Retry-After`)),i=(t.message||`${_.method} ${e} -> HTTP ${y.status}: ${y.statusText}`)+h,a=In(y.status,i,{url:d,code:n,retryAfter:r,mitigated:y.headers.get(`x-vercel-mitigated`),details:t.details});throw l?.setAttributes({...$(n||`HTTP ${y.status}`)}),l?.recordException?.(a),a}a?.(y);try{m=await $t(`world.parse`,async e=>{let t=await ar(y),n=(y.headers.get(`Content-Type`)||``).includes(`application/cbor`);return e?.setAttributes({...ln(n?`cbor`:`json`)}),t});break}catch(t){if(p&&r<2){let n=100*2**r;l?.setAttributes({...$(`PARSE_ERROR_RETRYING`)}),On&&console.debug(`[workflow:world-vercel:http] ${c} ${e} body parse failed (attempt ${r+1}/3); retrying in ${n}ms: ${t}`),await new Promise(e=>setTimeout(e,n));continue}let n=y.headers.get(`Content-Type`)||`unknown`;throw new s(`Failed to parse response body for ${c} ${e}${h} (Content-Type: ${n}):\n\n${t}`,{url:d,code:`PARSE_ERROR`,cause:t})}}return await $t(`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 s(`Schema validation failed for ${c} ${e}${h}:\n${n}${r}`,{url:d,code:`SCHEMA_VALIDATION`,cause:t.error})}return t.data})})}function ir(e){let t=y(e,{depth:3,maxArrayLength:10,breakLength:120});return t.length>500?`${t.slice(0,500)}...`:t}async function ar(e){let t=e.headers.get(`Content-Type`)||``;if(t.includes(`application/cbor`)){let n=await e.arrayBuffer(),r=Be(new Uint8Array(n));return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.byteLength} bytes (CBOR), preview: ${ir(r)}`}}let n=await e.text(),r=JSON.parse(n);return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.length} bytes, preview: ${ir(r)}`}}function or(){return process.env.WORKFLOW_EVENTS_TRANSPORT===`ws`}const sr=`application/vnd.workflow.v4-frames`,cr=u(d(),f());function lr(e,t){let n=new Uint8Array(lt(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*ur(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():fr(e.getReader()),n=new Uint8Array,r=async e=>{for(;n.byteLength<e;){let{done:e,value:r}=await t.next();if(e)return!1;if(!r||r.byteLength===0)continue;let i=new Uint8Array(n.byteLength+r.byteLength);i.set(n,0),i.set(r,n.byteLength),n=i}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 Error(`decodeFrames: truncated meta block`);let t=cr.parse(Be(i(e)));if(!await r(4))throw Error(`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 Error(`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*fr(e){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{dr(()=>e.cancel())}}export{Sn as A,wn as B,cn as C,dn as D,fn as E,gn as F,It as G,tn as H,_n as I,Pt as J,Rt as K,vn as L,bn as M,yn as N,hn as O,mn as P,En as R,$ as S,pn as T,$t as U,en as V,Ft as W,Be as X,lt as Y,S as Z,Un as _,Xn as a,Rn as b,$n as c,Wn as d,In as f,Mn as g,Fn as h,or as i,xn as j,Cn as k,rr as l,An as m,ur as n,tr as o,Dn as p,Lt as q,lr as r,nr as s,sr as t,er as u,Pn as v,un as w,Vn as x,Hn as y,Tn as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./dist-DpYyXbJv.js";function e(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function t(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}const n=Symbol.for(`@workflow/core//registeredSteps`),r=globalThis,i=r[n]??=new Map,a=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function o(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function s(e){if(a.has(e)){for(let[t,n]of i.entries())if(t.endsWith(`//${e}`))return n}}function c(e,t){i.set(e,t),t.stepId=e}function l(e){let t=i.get(e);if(t)return t;for(let t of o(e)){let e=i.get(t);if(e)return e}let n=s(e);if(n)return n}const u={hook:[`hook`,`wait`,`step`],wait:[`hook`,`step`],step:[`wait`,`hook`,`step`]};function d(e,t,n,r){return n>=t||!u[e].includes(r.kind)?!1:!(e===`step`&&!r.armed)}function f(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=p(e,t,n,r);return r.set(t,a),a}function p(e,t,n,r){if(!n.armed)return!1;for(let[i,a]of e)if(d(n.kind,t,i,a)&&!f(e,i,a,r))return!1;return!0}async function m(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)return;let r=e.pendingDeliveryBarriers,i=[];for(let[e,a]of r)d(n,t,e,a)&&i.push(a.delivered);i.length>0&&(await Promise.all(i),await new Promise(e=>setTimeout(e,0)))}function h(t,n,r,i={}){let a=t.pendingDeliveryBarriers;if(!a||n===void 0)return{markDelivered:()=>{},arm:()=>{}};let o=!1,{promise:s,resolve:c}=e(),l={kind:r,delivered:s,armed:i.armed??!0};a.set(n,l);let u=()=>{o||(o=!0,a.get(n)===l&&a.delete(n),c())};return v(t,u),{markDelivered:u,arm:()=>{l.armed=!0}}}function g(e){let t=e.pendingDeliveryBarriers;if(!t||t.size===0)return!1;let n=new Map;for(let[e,r]of t)if(f(t,e,r,n))return!0;return!1}function _(e){return e.pendingDeliveries===0&&!g(e)}function v(e,t){let n=()=>{_(e)?t():e.promiseQueue.then(()=>{setTimeout(n,0)})};setTimeout(n,0)}export{h as a,t as c,_ as i,e as l,l as n,c as o,g as r,v as s,m as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-8V8biNmG.js";import{C as t,Cn as n,Fn as r,Jn as i,Kn as a,Q as o,R as s,Sr as c,St as l,T as ee,Yn as u,_t as d,ar as f,gr as p,j as m,lt as h,n as g,o as te,rr as _,st as v,t as y,vt as b,yt as x}from"./wait-until-BPSgt1Wg.js";import{O as S,d as C,n as w,o as T,r as E}from"./dist-CqvWKNQv.js";import{L as D,o as O}from"./dist-BRGbNjhD.js";import{t as k}from"./spec-version-DBUVfF_R.js";var A=e({getHookByToken:()=>I,resumeHook:()=>L,resumeWebhook:()=>z});const ne=O();async function j(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}function M(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 N(e){if(e.resumeContext)return{resumeContext:e.resumeContext,source:`hook`};let t=await(await f()).runs.get(e.runId);return{resumeContext:M(t),source:`run_fallback`,run:t}}async function P(e,t){let n=await f(),r=t.run?await n.getEncryptionKeyForRun?.(t.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:t.resumeContext.deploymentId});return r?await c(r):void 0}async function F(e){let t=await f(),n=await t.hooks.getByToken(e),r;if(n.metadata!==void 0){let e=await N(n),i=e.run?await t.getEncryptionKeyForRun?.(e.run):await t.getEncryptionKeyForRun?.(n.runId,{deploymentId:e.resumeContext.deploymentId});r=i?await a(i):void 0,n.metadata=await s(n.metadata,n.runId,r)}return{hook:n,encryptionKey:r}}async function I(e){let{hook:t}=await F(e);return t}async function L(e,t,n){return R(e,t,n,!1,Date.now())}async function R(e,a,s,c,p){return await g(()=>h(`hook.resume`,async h=>{let g=await f();try{let d=typeof e==`string`,f=d?await g.hooks.getByToken(e):e,S=d||c,w=await N(f),{resumeContext:O}=w;if(h?.setAttributes({...l(f.token),...b(f.hookId),...r(f.runId),"workflow.hook.resume_context_source":w.source}),w.run&&D(w.run.status))throw new T(f.token);let A=ee(O.workflowCoreVersion),M,F=s?void 0:_(O.encryptionPublicKey);if(F)M=i(F);else{let e=s??await P(f,w);A.supportedFormats.has(u.ENCRYPTED)||(e=void 0),M=e}let I=(O.runSpecVersion??0)>=5&&A.supportedFormats.has(u.GZIP),L=[],R=k(f.specVersion),z=await m(a,f.runId,M,L,globalThis,R,A.framedByteStreams,I);y(Promise.all(L),e=>{e!==void 0&&o.warn(`Background flush of hook payload ops failed`,{workflowRunId:f.runId,hookId:f.hookId,error:e instanceof Error?e.message:String(e)})}),h?.setAttributes({...n(O.workflowName)});let B=await v(O.traceCarrier);B&&h?.addLink?.(B);let V={...R?{}:{token:f.token},payload:z},H=te(O.workflowName),U={deploymentId:O.deploymentId,specVersion:O.runSpecVersion??1},W=process.env.WORKFLOW_DISABLE_LAZY_HOOK_RESUME===`1`,G=(S?f.resumeCapabilities?.hookResumeDedupVersion??0:0)>=1||g.capabilities?.hookResumeDedup===!0,K=W?`disabled`:G?(O.hookResumeInputVersion??0)<1?`consumer_unsupported`:R?`legacy`:(O.runSpecVersion??0)<3?`non_cbor_transport`:z instanceof Uint8Array?z.byteLength>131072?`oversized`:null:`non_bytes`:`backend_unsupported`,q=K===null;h?.setAttributes({"workflow.hook.resume_strategy":q?`parallel`:`sequential`,...K?{"workflow.hook.resume_fallback_reason":K}:{}});let J=e=>T.is(e)||E.is(e)||C.is(e);if(!q){try{await g.events.create(f.runId,{eventType:`hook_received`,specVersion:6,correlationId:f.hookId,eventData:V},{v1Compat:R})}catch(e){throw J(e)?new T(f.token):e}let e=Date.now();return await g.queue(H,{runId:f.runId,traceCarrier:O.traceCarrier??void 0,hookResumeTiming:{resumeRequestedAtMs:p,queuePublishRequestedAtMs:e,strategy:`sequential`}},U),f}let Y=ne(),X=await j(z);h?.setAttributes({"workflow.hook.resume_id":Y});let[Z,Q]=await Promise.allSettled([g.events.create(f.runId,{eventType:`hook_received`,specVersion:6,correlationId:f.hookId,eventData:V},{v1Compat:R,resumeId:Y,resumePayloadDigest:X}),(()=>{let e=Date.now();return g.queue(H,{runId:f.runId,traceCarrier:O.traceCarrier??void 0,hookInput:{resumeId:Y,hookId:f.hookId,token:f.token,payload:z,payloadDigest:X,deploymentId:O.deploymentId},hookResumeTiming:{resumeRequestedAtMs:p,queuePublishRequestedAtMs:e,strategy:`parallel`}},U)})()]);if(Q.status===`rejected`)throw Q.reason;let $=!1;if(Z.status===`rejected`){let e=Z.reason;if(T.is(e)||C.is(e))throw new T(f.token);if(E.is(e)||t(e))$=!0,h?.setAttributes({...x(!0),"workflow.hook.resume_event_write_recovered":!0,"workflow.hook.resume_event_write_error":e instanceof Error?e.name:`unknown`}),o.warn(`Hook resume event write failed, but the run was re-triggered via the queue. The hook_received event will be ensured by the queue consumer.`,{workflowRunId:f.runId,hookId:f.hookId,resumeId:Y,error:e instanceof Error?e.message:String(e)});else throw e}return $?{...f,resilientResume:!0}:f}catch(t){throw h?.setAttributes({...l(typeof e==`string`?e:e.token),...d(!1)}),t}}))}async function z(e,t){let n=Date.now(),{hook:r,encryptionKey:i}=await F(e);if(r.isWebhook===!1)throw new T(e);let a,o;if(r.metadata&&typeof r.metadata==`object`&&`respondWith`in r.metadata)if(r.metadata.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;o=e,t[p]=n}else if(r.metadata.respondWith instanceof Response)a=r.metadata.respondWith;else throw new S(`Invalid \`respondWith\` value: ${r.metadata.respondWith}`,{slug:w.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else a=new Response(null,{status:202});if(await R(r,t,i,!0,n),o){let e=o.getReader(),t=await e.read();t.value&&(a=t.value),e.cancel()}if(!a)throw new S(`Workflow run did not send a response`,{slug:w.WEBHOOK_RESPONSE_NOT_SENT});return a}export{A as i,L as n,z as r,I as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$n as e,C as t,Cn as n,F as r,Fn as i,H as a,Jn as o,Kn as s,L as c,Ln as l,M as u,Q as d,Sr as ee,T as te,V as f,X as p,Yn as m,Z as h,ar as g,c as ne,ct as re,er as _,ft as ie,ir as ae,kr as v,lt as y,n as b,nr as oe,o as x,or as S,pn as C,rr as w,t as se,wn as ce,x as le}from"./wait-until-BPSgt1Wg.js";import{D as T,E,O as D,T as O,r as k,w as A}from"./dist-CqvWKNQv.js";import{t as ue}from"./attribute-changes-B8K0pwpH.js";import{X as j,Z as M,i as de,o as N}from"./dist-BRGbNjhD.js";import{t as P}from"./env-config-DxamfI7T.js";import{t as F}from"./spec-version-DBUVfF_R.js";const I=[`node`,`quickjs`];function L(e=process.env){let t=e.WORKFLOW_VM;if(!(t===void 0||t===``)){if(I.includes(t))return t;throw new D(`Invalid WORKFLOW_VM value: "${t}". Expected one of: ${I.join(`, `)}.`)}}function R(e){let t=e.executionContext?.workflowVm;if(t!==void 0){if(!I.includes(t))throw new D(`Invalid executionContext.workflowVm value: "${t}". Expected one of: ${I.join(`, `)}.`);return t===`quickjs`}return L()===`quickjs`}const z=N();function B(){let e=h.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[M]:e.rootRunId??t,[j]:t}}let V=!1;async function H(e,r,a){"use step";return await b(()=>{let s=e?.workflowId;if(!s)throw new D(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return y(`workflow.start ${v(s)}`,async e=>{e?.setAttributes({...n(s),...ce(`start`)});let c=[],f=a??{};Array.isArray(r)?c=r:typeof r==`object`&&(f=r),e?.setAttributes({...C(c.length)});let p=f.world??await g();S(p);let h=await p.getDeploymentId(),_=f.deploymentId??h;_===`latest`&&(p.resolveLatestDeploymentId?_=await p.resolveLatestDeploymentId():(V||(V=!0,d.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:h})),_=h));let v=`wrun_${p.createRunId?p.createRunId(f):z()}`,y,b,T,E;if(_===h)y=!0,b=!0,T=1;else if(typeof p.streams?.get!=`function`)y=!1,b=!1,T=void 0;else{let e=await ne(p,{deploymentId:_,runId:v,timeout:2e3,namespace:f.namespace}).catch(()=>void 0);E=e?.encryptionPublicKey;let t=te(e?.workflowCoreVersion);y=t.framedByteStreams,b=t.supportedFormats.has(m.GZIP),T=e?.hookResumeInputVersion}let O=[],A=await re(),j=f.specVersion??p.specVersion,M=F(j),N=f.allowReservedAttributes===!0,P;if(f.attributes&&Object.keys(f.attributes).length>0){if(j<4)throw new D(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(f.attributes))if(typeof t!=`string`)throw new D(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=ue(f.attributes,{allowReservedAttributes:N});P=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let I=j>=4?B():void 0,R=I?{...I,...P}:P,H=R?{attributes:R,...N||I!=null?{allowReservedAttributes:!0}:{}}:{};if(f.replayedFromRunId!==void 0&&!de.safeParse(f.replayedFromRunId).success)throw new D(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(f.replayedFromRunId).slice(0,64))}.`);let U=w(E),W,G;if(U)W=o(U),G=E;else{let e=await p.getEncryptionKeyForRun?.(v,{...f,deploymentId:_});W=e?await ee(e):void 0,G=e?oe((await ae(e)).publicKey):void 0}let K=await u(c,v,W,O,globalThis,M,y,b&&j>=5),q=p.getEnvironment?.(),J=L(),Y={traceCarrier:A,workflowCoreVersion:le,features:{encryption:!!W},...T===void 0?{}:{hookResumeInputVersion:T},...J?{workflowVm:J}:{},...f.replayedFromRunId?{replayedFromRunId:f.replayedFromRunId}:{}},[X,Z]=await Promise.allSettled([p.events.create(v,{eventType:`run_created`,specVersion:j,eventData:{deploymentId:_,workflowName:s,input:K,executionContext:Y,...G?{encryptionPublicKey:G}:{},...H}},{v1Compat:M}),p.queue(x(s,f.namespace),{runId:v,traceCarrier:A,...j>=3?{runInput:{input:K,deploymentId:_,workflowName:s,specVersion:j,executionContext:Y,...G?{encryptionPublicKey:G}:{},...q===void 0?{}:{environment:q},...H}}:{}},{deploymentId:_,specVersion:j,...f.region===void 0?{}:{region:f.region}})]);if(Z.status===`rejected`)throw Z.reason;let $=!1;if(X.status===`rejected`){let e=X.reason;if(!k.is(e))if(t(e))$=!0,d.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:v,error:e.message});else throw e}else{let e=X.value;if(!M&&e.run.runId!==v)throw new D(`Server returned different runId than requested: expected ${v}, got ${e.run.runId}`)}return se(Promise.all(O),e=>{d.warn(`Background flush of workflow argument streams failed`,{workflowRunId:v,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...i(v),...ie(_),...X.status===`fulfilled`?l(X.value.run.status):{}}),new Q(v,{resilientStart:$})})})}const U=e=>Array.isArray(e)?e:[e];async function W(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await s(i):void 0,o=U(await f(r.input,t,a,globalThis)),c=n.specVersion??r.specVersion??1,l=n.deploymentId??r.deploymentId;return(await H({workflowId:r.workflowName},o,{deploymentId:l,world:e,specVersion:c,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function G(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=F(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function K(e,t,n){if(t.length===0)throw Error(`cancelRuns requires at least one run ID.`);if(t.length>500)throw Error(`cancelRuns accepts at most 500 run IDs (received ${t.length}).`);if(new Set(t).size!==t.length)throw Error(`cancelRuns requires unique run IDs (duplicates found).`);if(e.runs.cancelMany)return e.runs.cancelMany({runIds:t,...n?.cancelReason===void 0?{}:{cancelReason:n.cancelReason}});let r=Array(t.length),i=0,a=async()=>{for(;;){let a=i++;if(a>=t.length)return;let o=t[a];try{await G(e,o,n),r[a]={runId:o,outcome:`cancelled`}}catch{r[a]={runId:o,outcome:`failed`,code:`internal_error`,retryable:!0}}}},o=Math.min(20,t.length);await Promise.all(Array.from({length:o},()=>a()));let s={requested:t.length,cancelled:0,alreadyCancelled:0,notCancellable:0,notFound:0,failed:0};for(let e of r)switch(e.outcome){case`cancelled`:s.cancelled++;break;case`already_cancelled`:s.alreadyCancelled++;break;case`not_cancellable`:s.notCancellable++;break;case`not_found`:s.notFound++;break;case`failed`:s.failed++;break}return{summary:s,results:r}}async function q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(x(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function J(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=F(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{sortOrder:`asc`,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),l=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);l=l.filter(t=>t.correlationId&&e.has(t.correlationId))}let u=[],d=0;for(let n of l){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),d++}catch(e){k.is(e)?d++:u.push(e instanceof Error?e:Error(String(e)))}}if(d>0&&await e.queue(x(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),u.length>0)throw AggregateError(u,`Failed to complete ${u.length}/${l.length} pending wait(s) for run ${t}`);return{stoppedCount:d}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Y(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function X(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}function Z(){return P(`WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS`,1e3,{integer:!0,min:1})}var Q=class t{static[_](e){return{runId:e.runId,resilientStart:e.#r}}static[e](e){return new t(e.runId,{resilientStart:e.resilientStart})}runId;#e;get#t(){return this.#e||=g(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await s(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return J(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:6,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(T.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:i,namespace:a}=e,o=p(this.runId,a),s=this.#a(),c=r(n,t,this.runId,s).ReadableStream({name:o,startIndex:i}),l=this.#t,u=this.runId;return Object.assign(c,{getTailIndex:async()=>(await(await l).streams.getInfo(u,o)).tailIndex})}async#o(){let e=await this.#t,t=0,n=this.#r?3:0,r=[1e3,3e3,6e3];for(;;)try{let t=await e.runs.get(this.runId);if(t.status===`completed`){let e=await this.#i();return await a(t.output,this.runId,e)}if(t.status===`cancelled`)throw new A(this.runId);if(t.status===`failed`){let e=await this.#i(),n;try{n=await c(t.error,this.runId,e)}catch{n=Error(`Failed to hydrate workflow run error`)}throw new O(this.runId,n,{errorCode:t.errorCode})}throw new E(this.runId,t.status)}catch(e){if(E.is(e)){await new Promise(e=>setTimeout(e,Z()));continue}if(T.is(e)&&t<n){let e=r[t];t++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function $(e){return new Q(e)}export{X as a,q as c,R as d,K as i,J as l,$ as n,Y as o,G as r,W as s,Q as t,H as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{br as e}from"./wait-until-BPSgt1Wg.js";import{i as t}from"./attribute-changes-B8K0pwpH.js";async function n(r){let i=globalThis[e];return i||t(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
|