eve 0.26.2 → 0.27.1
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 +33 -0
- package/dist/src/channel/resolve-active-session.d.ts +4 -0
- package/dist/src/channel/resolve-active-session.js +1 -0
- package/dist/src/channel/routes.d.ts +11 -0
- package/dist/src/cli/dev/tui/vercel-trusted-sources-policy.d.ts +1 -1
- package/dist/src/cli/dev/tui/vercel-trusted-sources.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +16 -16
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/google/index.d.ts +9 -2
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +18 -3
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.d.ts +285 -24
- package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +7 -3
- package/dist/src/compiled/@vercel/oidc/index.js +28 -2
- package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +11 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +7 -0
- package/dist/src/compiled/@vercel/sandbox/command.d.ts +8 -0
- package/dist/src/compiled/@vercel/sandbox/execution-context.d.ts +116 -0
- package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +20 -19
- package/dist/src/compiled/@vercel/sandbox/network-policy.d.ts +13 -5
- package/dist/src/compiled/@vercel/sandbox/sandbox-user.d.ts +212 -0
- package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +133 -2
- package/dist/src/compiled/@vercel/sandbox/session.d.ts +2 -1
- package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +41 -22
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +29 -0
- package/dist/src/compiled/@workflow/core/global.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.d.ts +6 -17
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +56 -0
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +6 -4
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +4 -1
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +39 -0
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization.d.ts +44 -4
- package/dist/src/compiled/@workflow/core/symbols.d.ts +13 -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/error-codes.d.ts +2 -0
- package/dist/src/compiled/@workflow/errors/index.d.ts +14 -0
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/events.d.ts +15 -0
- package/dist/src/compiled/@workflow/world/hooks.d.ts +2 -1
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +77 -4
- package/dist/src/compiled/@workflow/world-local/index.js +4 -4
- package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
- package/dist/src/compiled/_chunks/node/{auth-BuQkq4Gr.js → auth-l7F2PF2b.js} +2 -2
- package/dist/src/compiled/_chunks/node/{version-DD-FX9rK.js → version-CjHTLx2a.js} +1 -1
- package/dist/src/compiled/_chunks/node/virtual-loader-Cwgujv7l.js +1 -0
- package/dist/src/compiled/_chunks/workflow/attribute-changes-Dk1fP6vt.js +20 -0
- package/dist/src/compiled/_chunks/workflow/{chunk-BHKSVoKr.js → chunk-BTyA9uPd.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-B3qkUnLJ.js +3 -0
- package/dist/src/compiled/_chunks/workflow/{dist-CSfKNxQW.js → dist-BX517Nmz.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-zLevmMyU.js → dist-C_VDTghO.js} +10 -10
- package/dist/src/compiled/_chunks/workflow/{dist-CttsoN4D.js → dist-CrxV2rsR.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{functions-PT9ri9Hu.js → functions-Dv8dc_-I.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-czpG5xnP.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-6zaMjFY6.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-B2u06FWc.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{src-CQuMexnO.js → src-D1EltLDA.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{token-CaY0nA5J.js → token-Cz223z3C.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/token-DWqA5-DA.js +1 -0
- package/dist/src/compiled/_chunks/workflow/token-util-B6qBs3-0.js +27 -0
- package/dist/src/compiled/_chunks/workflow/{undici-fb54XL8i.js → undici-C2ZhYnV9.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/wrapper-Cc2otuUR.js +6 -0
- package/dist/src/compiled/env-runner/index.js +1 -1
- package/dist/src/compiled/env-runner/node-worker.js +1 -1
- package/dist/src/compiled/eventsource-parser/stream/index.d.ts +16 -3
- package/dist/src/compiled/jose/index.js +1 -1
- package/dist/src/compiler/compile-from-memory.d.ts +5 -0
- package/dist/src/compiler/compile-from-memory.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +10 -10
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/execution/deliver-payloads.d.ts +1 -1
- package/dist/src/execution/deliver-payloads.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/compaction-prompt.d.ts +19 -1
- package/dist/src/harness/compaction-prompt.js +7 -5
- package/dist/src/harness/compaction.d.ts +4 -11
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/prompt-cache.d.ts +16 -5
- package/dist/src/harness/prompt-cache.js +1 -1
- package/dist/src/harness/session-limit-continuation.d.ts +8 -0
- package/dist/src/harness/session-limit-continuation.js +1 -1
- package/dist/src/harness/session-limit-enforcement.d.ts +9 -6
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/stale-input-responses.d.ts +21 -3
- package/dist/src/harness/stale-input-responses.js +2 -2
- package/dist/src/harness/token-estimate.d.ts +9 -0
- package/dist/src/harness/token-estimate.js +1 -0
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/turn-cancellation.d.ts +13 -0
- package/dist/src/harness/turn-cancellation.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/copy-host-middleware.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
- package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.8/node_modules/@vercel/sdk/esm/models/updateprojectblock.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.8/node_modules/@vercel/sdk/esm/models/updateprojectprojectsbranchmatcher.js +1 -0
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/public/channels/auth.d.ts +59 -9
- package/dist/src/public/channels/auth.js +1 -1
- package/dist/src/public/channels/discord/defaults.js +1 -1
- package/dist/src/public/channels/linear/api.d.ts +2 -0
- package/dist/src/public/channels/linear/api.js +3 -1
- package/dist/src/public/channels/linear/defaults.js +2 -2
- package/dist/src/public/channels/linear/hitl.d.ts +8 -13
- package/dist/src/public/channels/linear/hitl.js +3 -3
- package/dist/src/public/channels/linear/index.d.ts +1 -1
- package/dist/src/public/channels/linear/index.js +1 -1
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +20 -0
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +31 -0
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/index.d.ts +2 -2
- package/dist/src/public/channels/slack/slackChannel.d.ts +72 -4
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/defaults.js +2 -2
- package/dist/src/public/channels/teams/index.d.ts +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +7 -2
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/defaults.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/nuxt/index.d.ts +1 -1
- package/dist/src/public/nuxt/index.js +1 -1
- package/dist/src/public/nuxt/module.d.ts +10 -24
- package/dist/src/public/nuxt/module.js +1 -1
- package/dist/src/public/nuxt/routing.d.ts +5 -39
- package/dist/src/public/nuxt/routing.js +1 -1
- package/dist/src/public/nuxt/vercel-services.d.ts +117 -0
- package/dist/src/public/nuxt/vercel-services.js +1 -0
- package/dist/src/runtime/framework-tools/connection-search-dynamic.js +2 -1
- package/dist/src/runtime/framework-tools/todo.js +1 -1
- package/dist/src/runtime/governance/auth/http-basic.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +90 -5
- package/dist/src/setup/scaffold/update/channels.js +2 -2
- package/dist/src/setup/scaffold/update/connections.js +1 -1
- package/dist/src/{public/next → shared}/resolve-eve-binary.d.ts +1 -1
- package/docs/agent-config.md +10 -5
- package/docs/channels/slack.mdx +76 -10
- package/docs/channels/teams.mdx +10 -3
- package/docs/extensions.md +115 -77
- package/docs/guides/auth-and-route-protection.md +14 -1
- package/docs/guides/deployment/vercel.mdx +1 -1
- package/docs/guides/frontend/nuxt.mdx +22 -1
- package/docs/guides/frontend/overview.mdx +2 -0
- package/docs/meta.json +1 -0
- package/package.json +22 -22
- package/dist/src/compiled/@workflow/core/step-hydration-cache.d.ts +0 -148
- package/dist/src/compiled/_chunks/node/virtual-loader-B8K8w9cr.js +0 -1
- package/dist/src/compiled/_chunks/workflow/attribute-changes-CXiYB8h9.js +0 -20
- package/dist/src/compiled/_chunks/workflow/dist-BYo8Gno2.js +0 -3
- package/dist/src/compiled/_chunks/workflow/resume-hook-CHXbXuRZ.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-BjtAGa3_.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-BJAv0MFP.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-D4VIwGlD.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wrapper-ulTvoTdW.js +0 -6
- package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.1/node_modules/@vercel/sdk/esm/models/updateprojectprojectsaction.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_sdk@1.28.1/node_modules/@vercel/sdk/esm/models/updateprojectprojectsoptionsallowlist.js +0 -1
- package/dist/src/public/nuxt/vercel-json.d.ts +0 -17
- package/dist/src/public/nuxt/vercel-json.js +0 -1
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/lib/primitives.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/lib/schemas.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/models/aclaction.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/models/sdkvalidationerror.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/defaultToZeroValue.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/fp.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/primitives.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/rfcdate.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/smartUnion.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@vercel_sdk@1.28.1 → @vercel_sdk@1.28.8}/node_modules/@vercel/sdk/esm/types/unrecognized.js +0 -0
- /package/dist/src/{public/next → shared}/resolve-eve-binary.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-BTyA9uPd.js";import{c as r,d as i,h as a,i as o,l as s,m as c,n as l,p as u,s as d,t as f}from"./version-
|
|
2
|
-
`)}const A=`${
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-BTyA9uPd.js";import{c as r,d as i,h as a,i as o,l as s,m as c,n as l,p as u,s as d,t as f}from"./version-CjHTLx2a.js";import*as p from"node:path";import m from"node:path";import{homedir as h}from"node:os";import g from"node:fs";import*as _ from"node:fs/promises";import v from"os";import{setTimeout as y}from"node:timers/promises";const ee={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var b;b||={};const x=i().transform((e,t)=>{try{return JSON.parse(e)}catch(e){return t.addIssue({code:ee.custom,message:`Invalid JSON: ${e.message}`}),a}});var S=n(((t,n)=>{let r=e(`os`),i=e(`path`),a=/^win/i.test(process.platform);function o(e){return i.normalize(i.join(e,`.`))}let s=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TMPDIR||e.TEMP||e.TMP),t},c=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.USERPROFILE||i.join(e.HOMEDRIVE,e.HOMEPATH)||e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TEMP||e.TMP||i.join(e.LOCALAPPDATA||e.SystemRoot||e.windir,`Temp`)),t};n.exports=new class e{constructor(){let t=function(){return new e};this._fn=t;let n=a?c():s();return Object.keys(n).forEach(e=>{this._fn[e]=n[e]}),this._fn}}})),C=n(((t,n)=>{let r=e(`path`),i=S(),a=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(i.home()||i.temp(),`.cache`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(i.home()||i.temp(),`.config`),e.data=()=>process.env.XDG_DATA_HOME||r.join(i.home()||i.temp(),`.local`,`share`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(i.home()||i.temp(),`.local`,`state`),e},o=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Caches`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Preferences`),e.data=()=>process.env.XDG_DATA_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Application Support`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`State`),e},s=()=>{let e={};return e.cache=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_CACHE_HOME||r.join(e,`xdg.cache`)},e.config=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_CONFIG_HOME||r.join(e,`xdg.config`)},e.data=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_DATA_HOME||r.join(e,`xdg.data`)},e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_STATE_HOME||r.join(e,`xdg.state`)},e},c=()=>{let e=function(){return c()},t={};return t=/^darwin$/i.test(process.platform)?o():/^win/i.test(process.platform)?s():a(),t.configDirs=()=>{let e=[];return e.push(t.config()),process.env.XDG_CONFIG_DIRS&&e.push(...process.env.XDG_CONFIG_DIRS.split(r.delimiter)),e},t.dataDirs=()=>{let e=[];return e.push(t.data()),process.env.XDG_DATA_DIRS&&e.push(...process.env.XDG_DATA_DIRS.split(r.delimiter)),e},Object.keys(t).forEach(n=>{e[n]=t[n]}),e};n.exports=c()})),w=t(n(((t,n)=>{let r=e(`path`),i=e(`os`),a=C(),o=/^win/i.test(process.platform);function s(e,t){if(e||={},typeof e!=`object`&&(e={isolated:e}),e.isolated=e.isolated===void 0||e.isolated===null?t:e.isolated,typeof e.isolated!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof e.isolated}`);return e}let c=(e,t)=>{let n={};return n.cache=(n={isolated:null})=>(n=s(n,t),r.join(a.cache(),n.isolated?e:``)),n.config=(n={isolated:null})=>(n=s(n,t),r.join(a.config(),n.isolated?e:``)),n.data=(n={isolated:null})=>(n=s(n,t),r.join(a.data(),n.isolated?e:``)),n.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),n.state=(n={isolated:null})=>(n=s(n,t),r.join(a.state(),n.isolated?e:``)),n.configDirs=(n={isolated:null})=>(n=s(n,t),a.configDirs().map(t=>r.join(t,n.isolated?e:``))),n.dataDirs=(n={isolated:null})=>(n=s(n,t),a.dataDirs().map(t=>r.join(t,n.isolated?e:``))),n},l=(e,t)=>{let{env:n}=process,o=i.homedir(),c=i.tmpdir(),l=n.APPDATA||r.join(o||c,`AppData`,`Roaming`),u=n.LOCALAPPDATA||r.join(o||c,`AppData`,`Local`),d={};return d.cache=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CACHE_HOME?r.join(a.cache(),i.isolated?e:``):r.join(u,i.isolated?e:``,`Cache`)),d.config=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CONFIG_HOME?r.join(a.config(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Config`)),d.data=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_DATA_HOME?r.join(a.data(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Data`)),d.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),d.state=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_STATE_HOME?r.join(a.state(),i.isolated?e:``):r.join(u,i.isolated?e:``,`State`)),d.configDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.config(i)];return n.XDG_CONFIG_DIRS&&a.push(...n.XDG_CONFIG_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d.dataDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.data(i)];return n.XDG_DATA_DIRS&&a.push(...n.XDG_DATA_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d};n.exports=new class t{constructor(n={name:null,suffix:null,isolated:!0}){let i=function(e={name:null,suffix:null,isolated:!0}){return new t(e)};this._fn=i,n||={},typeof n!=`object`&&(n={name:n});let a=n.name||``;if(typeof a!=`string`)throw TypeError(`Expected string for "name" argument, got ${typeof a}`);let s=n.suffix||``;if(typeof s!=`string`)throw TypeError(`Expected string for "suffix" argument, got ${typeof s}`);let u=n.isolated===void 0||n.isolated===null?!0:n.isolated;if(typeof u!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof u}`);a||=r.parse(process.pkg?process.execPath:e.main?e.main.filename:process.argv[0]).name,s&&(a+=s),this._fn.$name=()=>a,this._fn.$isolated=()=>u;let d=o?l(a,u):c(a,u);return Object.keys(d).forEach(e=>{this._fn[e]=d[e]}),this._fn}}}))(),1);const T=r().transform(e=>new Date(e*1e3)),E=s({token:i().min(1).optional(),refreshToken:i().min(1).optional(),expiresAt:T.optional()}),D=x.pipe(E),te=e=>{try{return g.lstatSync(e).isDirectory()}catch{return!1}},O=()=>{if(process.env.VERCEL_AUTH_CONFIG_DIR)return process.env.VERCEL_AUTH_CONFIG_DIR;let e=(0,w.default)(`com.vercel.cli`).dataDirs();return[...e,m.join(h(),`.now`),...(0,w.default)(`now`).dataDirs()].find(e=>te(e))||e[0]},ne=()=>{try{let e=m.join(O(),`auth.json`);return D.parse(g.readFileSync(e,`utf8`))}catch{return null}};function k(e){let t=m.join(O(),`auth.json`);g.mkdirSync(m.dirname(t),{recursive:!0});let n={token:e.token,expiresAt:e.expiresAt&&Math.round(e.expiresAt.getTime()/1e3),refreshToken:e.refreshToken};g.writeFileSync(t,JSON.stringify(n)+`
|
|
2
|
+
`)}const A=`${v.hostname()} @ vercel/sandbox/${f} node-${process.version} ${v.platform()} (${v.arch()})`,j=new URL(`https://vercel.com`),M=`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,N=s({issuer:i().url(),device_authorization_endpoint:i().url(),token_endpoint:i().url(),revocation_endpoint:i().url(),jwks_uri:i().url(),introspection_endpoint:i().url()});let P;const F=s({device_code:i(),user_code:i(),verification_uri:i().url(),verification_uri_complete:i().url(),expires_in:r(),interval:r()}),I=s({active:d(!0),client_id:i(),session_id:i()}).or(s({active:d(!1)}));async function L(){if(P)return P;let e=await fetch(new URL(`.well-known/openid-configuration`,j),{headers:{"Content-Type":`application/json`,"user-agent":A}});return P=N.parse(await e.json()),P}async function R(){let e=await L();return{async deviceAuthorizationRequest(){let t=await(await fetch(e.device_authorization_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({client_id:M,scope:`openid offline_access`})})).json(),n=F.safeParse(t);if(!n.success)throw new H(`Failed to parse device authorization response from the Vercel authorization server.`,t);return{device_code:n.data.device_code,user_code:n.data.user_code,verification_uri:n.data.verification_uri,verification_uri_complete:n.data.verification_uri_complete,expiresAt:Date.now()+n.data.expires_in*1e3,interval:n.data.interval}},async deviceAccessTokenRequest(t){try{return[null,await fetch(e.token_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({client_id:M,grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t}),signal:AbortSignal.timeout(10*1e3)})]}catch(e){return e instanceof Error?[e]:[Error(`An unknown error occurred. See the logs for details.`,{cause:e})]}},async processTokenResponse(e){let t=await e.json(),n=z.safeParse(t);return n.success?[null,n.data]:[new H(`Failed to parse token response from the Vercel authorization server.`,t)]},async revokeToken(t){let n=await fetch(e.revocation_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({token:t,client_id:M})});if(!n.ok)return new H(`Revocation request failed`,await n.json())},async refreshToken(t){let n=await fetch(e.token_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({client_id:M,grant_type:`refresh_token`,refresh_token:t})}),[r,i]=await this.processTokenResponse(n);if(r)throw r;return i},async introspectToken(t){let n=await(await fetch(e.introspection_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({token:t})})).json(),r=I.safeParse(n);if(!r.success)throw new H(`Failed to parse introspection response from the Vercel authorization server.`,n);return r.data}}}const z=s({access_token:i(),token_type:d(`Bearer`),expires_in:r(),refresh_token:i().optional(),scope:i().optional()}),B=s({error:l([`invalid_request`,`invalid_client`,`invalid_grant`,`unauthorized_client`,`unsupported_grant_type`,`invalid_scope`,`server_error`,`authorization_pending`,`slow_down`,`access_denied`,`expired_token`,`unsupported_token_type`]),error_description:i().optional(),error_uri:i().optional()});function V(e){try{return B.parse(e)}catch(e){return e instanceof c?TypeError(`Invalid OAuth error response: ${e.message}`):TypeError(`Failed to parse OAuth error response`)}}var H=class extends Error{constructor(e,t){super(e),this.name=`OAuthError`;let n=V(t);if(n instanceof TypeError){this.cause=Error(`Unexpected response from the Vercel authorization server.`),this.code=`server_error`;return}let r=n.error;n.error_description&&(r+=`: ${n.error_description}`),n.error_uri&&(r+=` (${n.error_uri})`),this.cause=Error(r),this.code=n.error}};function U(e){return e instanceof H}async function*W({request:e,oauth:t}){let n=new AbortController;try{let r=e.interval*1e3;for(;Date.now()<e.expiresAt;){let[i,a]=await t.deviceAccessTokenRequest(e.device_code);if(i){if(i.message.includes(`timeout`)){r*=2,yield{_tag:`Timeout`,newInterval:r},await y(r,{signal:n.signal});continue}yield{_tag:`Error`,error:i};return}yield{_tag:`Response`,response:a.clone()};let[o,s]=await t.processTokenResponse(a);if(U(o)){let{code:e}=o;switch(e){case`authorization_pending`:await y(r,{signal:n.signal});continue;case`slow_down`:r+=5*1e3,yield{_tag:`SlowDown`,newInterval:r},await y(r,{signal:n.signal});continue;default:yield{_tag:`Error`,error:o.cause};return}}if(o){yield{_tag:`Error`,error:o};return}k({token:s.access_token,expiresAt:new Date(Date.now()+s.expires_in*1e3),refreshToken:s.refresh_token});return}yield{_tag:`Error`,error:Error(`Timed out waiting for authentication. Please try again.`)};return}finally{n.abort()}}var G=class extends Error{constructor(e){super(`HTTP ${e.statusCode}: ${e.responseText}`),this.name=`NotOk`,this.response=e}};async function K(e){let t=await fetch(`https://vercel.com/api${e.endpoint}`,{method:e.method,body:e.body,headers:{Authorization:`Bearer ${e.token}`,"Content-Type":`application/json`}});if(!t.ok){let e=await t.text();try{let{error:t}=JSON.parse(e);e=`${t.code.toUpperCase()}: ${t.message}`}catch{}throw new G({responseText:e,statusCode:t.status})}return await t.json()}const q=x.pipe(s({projectId:i(),orgId:i()}));async function J(e){let t=p.join(e,`.vercel`,`project.json`),n;try{n=await _.readFile(t,`utf-8`)}catch{return null}let r=q.safeParse(n);return r.success?{projectId:r.data.projectId,teamId:r.data.orgId}:null}const Y=s({user:s({defaultTeamId:i().nullable(),username:i()})}),X=s({id:i(),slug:i(),updatedAt:r().optional(),membership:s({role:i()}),billing:s({plan:i()})}),re=s({teams:o(u()).transform(e=>e.flatMap(e=>{let t=X.safeParse(e);return t.success?[t.data]:[]})),pagination:s({count:r(),next:r().nullable()})}),Z=`vercel-sandbox-default-project`;function Q(e){return e instanceof G&&(e.response.statusCode===402||e.response.statusCode===403)}async function ie(e){let t=await J(e.cwd??process.cwd());if(t){let n=await ae(e.token,t.teamId,t.projectId);return{...t,created:!1,...n}}if(e.teamId)return $(e.token,e.teamId);let{defaultTeamId:n,username:r}=(await K({token:e.token,endpoint:`/v2/user`}).then(Y.parse)).user;if(n)try{let t=await $(e.token,n);try{let r=await K({token:e.token,endpoint:`/v2/teams/${encodeURIComponent(n)}`}).then(s({slug:i()}).parse);return{...t,teamSlug:r.slug}}catch{return t}}catch(e){if(!Q(e))throw e}let a=null;do{let t=a===null?`/v2/teams?limit=20`:`/v2/teams?limit=20&until=${a}`,i=await K({token:e.token,endpoint:t}).then(re.parse);a=i.pagination.next;let o=i.teams.filter(e=>e.membership.role===`OWNER`&&e.billing.plan===`hobby`);if(o.length===0)continue;let s=o.find(e=>e.slug===r)??o.sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))[0];if(s&&s.id!==n)try{return{...await $(e.token,s.id),teamSlug:s.slug}}catch(e){if(!Q(e))throw e}}while(a!==null);try{return{...await $(e.token,r),teamSlug:r}}catch(e){if(!Q(e))throw e}throw new G({statusCode:403,responseText:`Authenticated as "${r}" but none of the available teams allow sandbox creation.`})}async function $(e,t){let n=t.startsWith(`team_`)?`teamId=${encodeURIComponent(t)}`:`slug=${encodeURIComponent(t)}`,r=!1;try{await K({token:e,endpoint:`/v2/projects/vercel-sandbox-default-project?${n}`})}catch(t){if(!(t instanceof G)||t.response.statusCode!==404)throw t;await K({token:e,endpoint:`/v11/projects?${n}`,method:`POST`,body:JSON.stringify({name:Z})}),r=!0}return{projectId:Z,teamId:t,created:r}}async function ae(e,t,n){try{let r=t.startsWith(`team_`)?`teamId=${encodeURIComponent(t)}`:`slug=${encodeURIComponent(t)}`,[a,o]=await Promise.all([K({token:e,endpoint:`/v2/teams/${encodeURIComponent(t)}`}).then(s({slug:i()}).parse),K({token:e,endpoint:`/v2/projects/${encodeURIComponent(n)}?${r}`}).then(s({name:i()}).parse)]);return{teamSlug:a.slug,projectSlug:o.name}}catch{return{}}}export{G as NotOk,R as OAuth,ne as getAuth,ie as inferScope,U as isOAuthError,W as pollForToken,k as updateAuthConfig};
|
|
@@ -61,4 +61,4 @@ var e;const t=Object.freeze({status:`aborted`});function n(e,t,n){function r(n,r
|
|
|
61
61
|
|
|
62
62
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,s=_,c=!a.jitless,u=c&&re.value,d=t.catchall,f;e._zod.parse=(a,l)=>{f??=r.value;let p=a.value;return s(p)?c&&u&&l?.async===!1&&l.jitless!==!0?(o||=i(t.shape),a=o(a,l),d?on([],p,a,l,f,e):a):n(a,l):(a.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),a)}});function ln(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=>!S(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=>T(e,r,o())))}),t)}const un=n(`$ZodUnion`,(e,t)=>{P.init(e,t),m(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),m(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),m(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),m(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=>d(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ln(t,r,e,i)):ln(o,r,e,i)}}),dn=n(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,un.init(e,t);let n=e._zod.parse;m(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=l(()=>{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(!_(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),fn=n(`$ZodIntersection`,(e,t)=>{P.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])=>pn(e,t,n)):pn(e,i,a)}});function R(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(v(e)&&v(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=R(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=R(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 pn(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}),S(e))return e;let o=R(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const mn=n(`$ZodRecord`,(e,t)=>{P.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!v(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],s=t.keyType._zod.values;if(s){n.value={};let c=new Set;for(let l of s)if(typeof l==`string`||typeof l==`number`||typeof l==`symbol`){c.add(typeof l==`number`?l.toString():l);let s=t.keyType._zod.run({value:l,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>T(e,r,o())),input:l,path:[l],inst:e});continue}let u=s.value,d=t.valueType._zod.run({value:i[l],issues:[]},r);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&n.issues.push(...C(l,e.issues)),n.value[u]=e.value})):(d.issues.length&&n.issues.push(...C(l,d.issues)),n.value[u]=d.value)}let l;for(let e in i)c.has(e)||(l??=[],l.push(e));l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let s of Reflect.ownKeys(i)){if(s===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&&rt.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=i[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>T(e,r,o())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:i[s],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(...C(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...C(s,l.issues)),n.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),hn=n(`$ZodEnum`,(e,t)=>{P.init(e,t);let n=s(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?y(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}}),gn=n(`$ZodLiteral`,(e,t)=>{if(P.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`?y(e):e?y(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}}),_n=n(`$ZodTransform`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,a)=>{if(a.direction===`backward`)throw new i(e.constructor.name);let o=t.transform(n.value,n);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new r;return n.value=o,n.fallback=!0,n}});function vn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const yn=n(`$ZodOptional`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,m(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),m(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${d(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>vn(e,r)):vn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),bn=n(`$ZodExactOptional`,(e,t)=>{yn.init(e,t),m(e._zod,`values`,()=>t.innerType._zod.values),m(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xn=n(`$ZodNullable`,(e,t)=>{P.init(e,t),m(e._zod,`optin`,()=>t.innerType._zod.optin),m(e._zod,`optout`,()=>t.innerType._zod.optout),m(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${d(e.source)}|null)$`):void 0}),m(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)}),Sn=n(`$ZodDefault`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,m(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=>Cn(e,t)):Cn(r,t)}});function Cn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const wn=n(`$ZodPrefault`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,m(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))}),Tn=n(`$ZodNonOptional`,(e,t)=>{P.init(e,t),m(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=>En(t,e)):En(i,e)}});function En(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 Dn=n(`$ZodCatch`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,m(e._zod,`optout`,()=>t.innerType._zod.optout),m(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=>T(e,n,o()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>T(e,n,o()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),On=n(`$ZodPipe`,(e,t)=>{P.init(e,t),m(e._zod,`values`,()=>t.in._zod.values),m(e._zod,`optin`,()=>t.in._zod.optin),m(e._zod,`optout`,()=>t.out._zod.optout),m(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=>z(e,t.in,n)):z(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>z(e,t.out,n)):z(r,t.out,n)}});function z(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const kn=n(`$ZodReadonly`,(e,t)=>{P.init(e,t),m(e._zod,`propValues`,()=>t.innerType._zod.propValues),m(e._zod,`values`,()=>t.innerType._zod.values),m(e._zod,`optin`,()=>t.innerType?._zod?.optin),m(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(An):An(r)}});function An(e){return e.value=Object.freeze(e.value),e}const jn=n(`$ZodCustom`,(e,t)=>{M.init(e,t),P.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=>Mn(t,n,r,e));Mn(i,n,r,e)}});function Mn(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(D(e))}}var Nn,Pn=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 Fn(){return new Pn}(Nn=globalThis).__zod_globalRegistry??(Nn.__zod_globalRegistry=Fn());const B=globalThis.__zod_globalRegistry;function In(e,t){return new e({type:`string`,...x(t)})}function Ln(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...x(t)})}function Rn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...x(t)})}function zn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...x(t)})}function Bn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...x(t)})}function Vn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...x(t)})}function Hn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...x(t)})}function Un(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...x(t)})}function Wn(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...x(t)})}function Gn(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...x(t)})}function Kn(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...x(t)})}function qn(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...x(t)})}function Jn(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...x(t)})}function Yn(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...x(t)})}function Xn(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...x(t)})}function Zn(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...x(t)})}function Qn(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...x(t)})}function $n(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...x(t)})}function er(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...x(t)})}function tr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...x(t)})}function nr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...x(t)})}function rr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...x(t)})}function ir(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...x(t)})}function ar(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...x(t)})}function or(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...x(t)})}function sr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...x(t)})}function cr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...x(t)})}function lr(e,t){return new e({type:`number`,checks:[],...x(t)})}function ur(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...x(t)})}function dr(e,t){return new e({type:`boolean`,...x(t)})}function fr(e){return new e({type:`any`})}function pr(e){return new e({type:`unknown`})}function mr(e,t){return new e({type:`never`,...x(t)})}function hr(e,t){return new ct({check:`less_than`,...x(t),value:e,inclusive:!1})}function V(e,t){return new ct({check:`less_than`,...x(t),value:e,inclusive:!0})}function gr(e,t){return new lt({check:`greater_than`,...x(t),value:e,inclusive:!1})}function H(e,t){return new lt({check:`greater_than`,...x(t),value:e,inclusive:!0})}function _r(e,t){return new ut({check:`multiple_of`,...x(t),value:e})}function vr(e,t){return new ft({check:`max_length`,...x(t),maximum:e})}function U(e,t){return new pt({check:`min_length`,...x(t),minimum:e})}function yr(e,t){return new mt({check:`length_equals`,...x(t),length:e})}function br(e,t){return new ht({check:`string_format`,format:`regex`,...x(t),pattern:e})}function xr(e){return new gt({check:`string_format`,format:`lowercase`,...x(e)})}function Sr(e){return new _t({check:`string_format`,format:`uppercase`,...x(e)})}function Cr(e,t){return new vt({check:`string_format`,format:`includes`,...x(t),includes:e})}function wr(e,t){return new yt({check:`string_format`,format:`starts_with`,...x(t),prefix:e})}function Tr(e,t){return new bt({check:`string_format`,format:`ends_with`,...x(t),suffix:e})}function W(e){return new xt({check:`overwrite`,tx:e})}function Er(e){return W(t=>t.normalize(e))}function Dr(){return W(e=>e.trim())}function Or(){return W(e=>e.toLowerCase())}function kr(){return W(e=>e.toUpperCase())}function Ar(){return W(e=>te(e))}function jr(e,t,n){return new e({type:`array`,element:t,...x(n)})}function Mr(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...x(n)})}function Nr(e,t){let n=Pr(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(D(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(D(r))}},e(t.value,t)),t);return n}function Pr(e,t){let n=new M({check:`custom`,...x(t)});return n._zod.check=e,n}function Fr(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??B,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 G(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,G(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`&&K(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ir(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>
|
|
63
63
|
|
|
64
|
-
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 Lr(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.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:q(t,`input`,e.processors),output:q(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function K(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 K(r.element,n);if(r.type===`set`)return K(r.valueType,n);if(r.type===`lazy`)return K(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 K(r.innerType,n);if(r.type===`intersection`)return K(r.left,n)||K(r.right,n);if(r.type===`record`||r.type===`map`)return K(r.keyType,n)||K(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:K(r.in,n)||K(r.out,n);if(r.type===`object`){for(let e in r.shape)if(K(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(K(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(K(e,n))return!0;return!!(r.rest&&K(r.rest,n))}return!1}const Rr=(e,t={})=>n=>{let r=Fr({...n,processors:t});return G(e,r),Ir(r,e),Lr(r,e)},q=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Fr({...i??{},target:a,io:t,processors:n});return G(e,o),Ir(o,e),Lr(o,e)},zr={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Br=(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=zr[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}))])}},Vr=(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`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Hr=(e,t,n,r)=>{n.type=`boolean`},Ur=(e,t,n,r)=>{n.not={}},Wr=(e,t,n,r)=>{let i=e._zod.def,a=s(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Gr=(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},Kr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},qr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Jr=(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=G(a.element,t,{...r,path:[...r.path,`items`]})},Yr=(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]=G(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=G(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Xr=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>G(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Zr=(e,t,n,r)=>{let i=e._zod.def,a=G(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=G(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]]},Qr=(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=G(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=G(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=G(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)}},$r=(e,t,n,r)=>{let i=e._zod.def,a=G(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`}]},ei=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ti=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ni=(e,t,n,r)=>{let i=e._zod.def;G(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)))},ri=(e,t,n,r)=>{let i=e._zod.def;G(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},ii=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;G(o,t,r);let s=t.seen.get(e);s.ref=o},ai=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},oi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},si=n(`ZodISODateTime`,(e,t)=>{Ft.init(e,t),Z.init(e,t)});function ci(e){return ar(si,e)}const li=n(`ZodISODate`,(e,t)=>{It.init(e,t),Z.init(e,t)});function ui(e){return or(li,e)}const di=n(`ZodISOTime`,(e,t)=>{Lt.init(e,t),Z.init(e,t)});function fi(e){return sr(di,e)}const pi=n(`ZodISODuration`,(e,t)=>{Rt.init(e,t),Z.init(e,t)});function mi(e){return cr(pi,e)}const hi=(e,t)=>{_e.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>be(e,t)},flatten:{value:t=>ye(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,c,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,c,2)}},isEmpty:{get(){return e.issues.length===0}}})},gi=n(`ZodError`,hi),J=n(`ZodError`,hi,{Parent:Error}),_i=O(J),vi=k(J),yi=A(J),bi=j(J),xi=Ce(J),Si=we(J),Ci=Te(J),wi=Ee(J),Ti=De(J),Ei=Oe(J),Di=ke(J),Oi=Ae(J),ki=new WeakMap;function Y(e,t,n){let r=Object.getPrototypeOf(e),i=ki.get(r);if(i||(i=new Set,ki.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const X=n(`ZodType`,(e,t)=>(P.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:q(e,`input`),output:q(e,`output`)}}),e.toJSONSchema=Rr(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>_i(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>yi(e,t,n),e.parseAsync=async(t,n)=>vi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>bi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>xi(e,t,n),e.decode=(t,n)=>Si(e,t,n),e.encodeAsync=async(t,n)=>Ci(e,t,n),e.decodeAsync=async(t,n)=>wi(e,t,n),e.safeEncode=(t,n)=>Ti(e,t,n),e.safeDecode=(t,n)=>Ei(e,t,n),e.safeEncodeAsync=async(t,n)=>Di(e,t,n),e.safeDecodeAsync=async(t,n)=>Oi(e,t,n),Y(e,`ZodType`,{check(...e){let t=this.def;return this.clone(g(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return b(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ga(e,t))},superRefine(e,t){return this.check(Ka(e,t))},overwrite(e){return this.check(W(e))},optional(){return Da(this)},exactOptional(){return ka(this)},nullable(){return ja(this)},nullish(){return Da(ja(this))},nonoptional(e){return La(this,e)},array(){return la(this)},or(e){return pa([this,e])},and(e){return _a(this,e)},transform(e){return Va(this,Ta(e))},default(e){return Na(this,e)},prefault(e){return Fa(this,e)},catch(e){return za(this,e)},pipe(e){return Va(this,e)},readonly(){return Ua(this)},describe(e){let t=this.clone();return B.add(t,{description:e}),t},meta(...e){if(e.length===0)return B.get(this);let t=this.clone();return B.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e)),Ai=n(`_ZodString`,(e,t)=>{F.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Br(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Y(e,`_ZodString`,{regex(...e){return this.check(br(...e))},includes(...e){return this.check(Cr(...e))},startsWith(...e){return this.check(wr(...e))},endsWith(...e){return this.check(Tr(...e))},min(...e){return this.check(U(...e))},max(...e){return this.check(vr(...e))},length(...e){return this.check(yr(...e))},nonempty(...e){return this.check(U(1,...e))},lowercase(e){return this.check(xr(e))},uppercase(e){return this.check(Sr(e))},trim(){return this.check(Dr())},normalize(...e){return this.check(Er(...e))},toLowerCase(){return this.check(Or())},toUpperCase(){return this.check(kr())},slugify(){return this.check(Ar())}})}),ji=n(`ZodString`,(e,t)=>{F.init(e,t),Ai.init(e,t),e.email=t=>e.check(Ln(Ni,t)),e.url=t=>e.check(Un(Fi,t)),e.jwt=t=>e.check(ir(Xi,t)),e.emoji=t=>e.check(Wn(Ii,t)),e.guid=t=>e.check(Rn(Pi,t)),e.uuid=t=>e.check(zn(Q,t)),e.uuidv4=t=>e.check(Bn(Q,t)),e.uuidv6=t=>e.check(Vn(Q,t)),e.uuidv7=t=>e.check(Hn(Q,t)),e.nanoid=t=>e.check(Gn(Li,t)),e.guid=t=>e.check(Rn(Pi,t)),e.cuid=t=>e.check(Kn(Ri,t)),e.cuid2=t=>e.check(qn(zi,t)),e.ulid=t=>e.check(Jn(Bi,t)),e.base64=t=>e.check(tr(qi,t)),e.base64url=t=>e.check(nr(Ji,t)),e.xid=t=>e.check(Yn(Vi,t)),e.ksuid=t=>e.check(Xn(Hi,t)),e.ipv4=t=>e.check(Zn(Ui,t)),e.ipv6=t=>e.check(Qn(Wi,t)),e.cidrv4=t=>e.check($n(Gi,t)),e.cidrv6=t=>e.check(er(Ki,t)),e.e164=t=>e.check(rr(Yi,t)),e.datetime=t=>e.check(ci(t)),e.date=t=>e.check(ui(t)),e.time=t=>e.check(fi(t)),e.duration=t=>e.check(mi(t))});function Mi(e){return In(ji,e)}const Z=n(`ZodStringFormat`,(e,t)=>{I.init(e,t),Ai.init(e,t)}),Ni=n(`ZodEmail`,(e,t)=>{Et.init(e,t),Z.init(e,t)}),Pi=n(`ZodGUID`,(e,t)=>{wt.init(e,t),Z.init(e,t)}),Q=n(`ZodUUID`,(e,t)=>{Tt.init(e,t),Z.init(e,t)}),Fi=n(`ZodURL`,(e,t)=>{Dt.init(e,t),Z.init(e,t)}),Ii=n(`ZodEmoji`,(e,t)=>{Ot.init(e,t),Z.init(e,t)}),Li=n(`ZodNanoID`,(e,t)=>{kt.init(e,t),Z.init(e,t)}),Ri=n(`ZodCUID`,(e,t)=>{At.init(e,t),Z.init(e,t)}),zi=n(`ZodCUID2`,(e,t)=>{jt.init(e,t),Z.init(e,t)}),Bi=n(`ZodULID`,(e,t)=>{Mt.init(e,t),Z.init(e,t)}),Vi=n(`ZodXID`,(e,t)=>{Nt.init(e,t),Z.init(e,t)}),Hi=n(`ZodKSUID`,(e,t)=>{Pt.init(e,t),Z.init(e,t)}),Ui=n(`ZodIPv4`,(e,t)=>{zt.init(e,t),Z.init(e,t)}),Wi=n(`ZodIPv6`,(e,t)=>{Bt.init(e,t),Z.init(e,t)}),Gi=n(`ZodCIDRv4`,(e,t)=>{Vt.init(e,t),Z.init(e,t)}),Ki=n(`ZodCIDRv6`,(e,t)=>{Ht.init(e,t),Z.init(e,t)}),qi=n(`ZodBase64`,(e,t)=>{Wt.init(e,t),Z.init(e,t)}),Ji=n(`ZodBase64URL`,(e,t)=>{Kt.init(e,t),Z.init(e,t)}),Yi=n(`ZodE164`,(e,t)=>{qt.init(e,t),Z.init(e,t)}),Xi=n(`ZodJWT`,(e,t)=>{Yt.init(e,t),Z.init(e,t)}),Zi=n(`ZodNumber`,(e,t)=>{Xt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vr(e,t,n,r),Y(e,`ZodNumber`,{gt(e,t){return this.check(gr(e,t))},gte(e,t){return this.check(H(e,t))},min(e,t){return this.check(H(e,t))},lt(e,t){return this.check(hr(e,t))},lte(e,t){return this.check(V(e,t))},max(e,t){return this.check(V(e,t))},int(e){return this.check(ea(e))},safe(e){return this.check(ea(e))},positive(e){return this.check(gr(0,e))},nonnegative(e){return this.check(H(0,e))},negative(e){return this.check(hr(0,e))},nonpositive(e){return this.check(V(0,e))},multipleOf(e,t){return this.check(_r(e,t))},step(e,t){return this.check(_r(e,t))},finite(){return this}});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 Qi(e){return lr(Zi,e)}const $i=n(`ZodNumberFormat`,(e,t)=>{Zt.init(e,t),Zi.init(e,t)});function ea(e){return ur($i,e)}const ta=n(`ZodBoolean`,(e,t)=>{Qt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hr(e,t,n,r)});function na(e){return dr(ta,e)}const ra=n(`ZodAny`,(e,t)=>{$t.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ia(){return fr(ra)}const aa=n(`ZodUnknown`,(e,t)=>{en.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function $(){return pr(aa)}const oa=n(`ZodNever`,(e,t)=>{tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ur(e,t,n,r)});function sa(e){return mr(oa,e)}const ca=n(`ZodArray`,(e,t)=>{rn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jr(e,t,n,r),e.element=t.element,Y(e,`ZodArray`,{min(e,t){return this.check(U(e,t))},nonempty(e){return this.check(U(1,e))},max(e,t){return this.check(vr(e,t))},length(e,t){return this.check(yr(e,t))},unwrap(){return this.element}})});function la(e,t){return jr(ca,e,t)}const ua=n(`ZodObject`,(e,t)=>{cn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yr(e,t,n,r),m(e,`shape`,()=>t.shape),Y(e,`ZodObject`,{keyof(){return xa(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:$()})},loose(){return this.clone({...this._zod.def,catchall:$()})},strict(){return this.clone({...this._zod.def,catchall:sa()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ue(this,e)},safeExtend(e){return de(this,e)},merge(e){return fe(this,e)},pick(e){return ce(this,e)},omit(e){return le(this,e)},partial(...e){return pe(Ea,this,e[0])},required(...e){return me(Ia,this,e[0])}})});function da(e,t){return new ua({type:`object`,shape:e??{},...x(t)})}const fa=n(`ZodUnion`,(e,t)=>{un.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xr(e,t,n,r),e.options=t.options});function pa(e,t){return new fa({type:`union`,options:e,...x(t)})}const ma=n(`ZodDiscriminatedUnion`,(e,t)=>{fa.init(e,t),dn.init(e,t)});function ha(e,t,n){return new ma({type:`union`,options:t,discriminator:e,...x(n)})}const ga=n(`ZodIntersection`,(e,t)=>{fn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zr(e,t,n,r)});function _a(e,t){return new ga({type:`intersection`,left:e,right:t})}const va=n(`ZodRecord`,(e,t)=>{mn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qr(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ya(e,t,n){return!t||!t._zod?new va({type:`record`,keyType:Mi(),valueType:e,...x(t)}):new va({type:`record`,keyType:e,valueType:t,...x(n)})}const ba=n(`ZodEnum`,(e,t)=>{hn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wr(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 ba({...t,checks:[],...x(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 ba({...t,checks:[],...x(r),entries:i})}});function xa(e,t){return new ba({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...x(t)})}const Sa=n(`ZodLiteral`,(e,t)=>{gn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gr(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 Ca(e,t){return new Sa({type:`literal`,values:Array.isArray(e)?e:[e],...x(t)})}const wa=n(`ZodTransform`,(e,t)=>{_n.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qr(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new i(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(D(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(D(t))}};let a=t.transform(n.value,n);return a instanceof Promise?a.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Ta(e){return new wa({type:`transform`,transform:e})}const Ea=n(`ZodOptional`,(e,t)=>{yn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Da(e){return new Ea({type:`optional`,innerType:e})}const Oa=n(`ZodExactOptional`,(e,t)=>{bn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ka(e){return new Oa({type:`optional`,innerType:e})}const Aa=n(`ZodNullable`,(e,t)=>{xn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$r(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ja(e){return new Aa({type:`nullable`,innerType:e})}const Ma=n(`ZodDefault`,(e,t)=>{Sn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Na(e,t){return new Ma({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Pa=n(`ZodPrefault`,(e,t)=>{wn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fa(e,t){return new Pa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Ia=n(`ZodNonOptional`,(e,t)=>{Tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ei(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function La(e,t){return new Ia({type:`nonoptional`,innerType:e,...x(t)})}const Ra=n(`ZodCatch`,(e,t)=>{Dn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function za(e,t){return new Ra({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Ba=n(`ZodPipe`,(e,t)=>{On.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r),e.in=t.in,e.out=t.out});function Va(e,t){return new Ba({type:`pipe`,in:e,out:t})}const Ha=n(`ZodReadonly`,(e,t)=>{kn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ua(e){return new Ha({type:`readonly`,innerType:e})}const Wa=n(`ZodCustom`,(e,t)=>{jn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,n,r)});function Ga(e,t={}){return Mr(Wa,e,t)}function Ka(e,t){return Nr(e,t)}const qa=`2.3.0`;export{na as a,Qi as c,Mi as d,pa as f,t as h,la as i,da as l,gi as m,xa as n,ha as o,$ as p,ia as r,Ca as s,qa as t,ya as u};
|
|
64
|
+
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 Lr(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.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:q(t,`input`,e.processors),output:q(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function K(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 K(r.element,n);if(r.type===`set`)return K(r.valueType,n);if(r.type===`lazy`)return K(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 K(r.innerType,n);if(r.type===`intersection`)return K(r.left,n)||K(r.right,n);if(r.type===`record`||r.type===`map`)return K(r.keyType,n)||K(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:K(r.in,n)||K(r.out,n);if(r.type===`object`){for(let e in r.shape)if(K(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(K(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(K(e,n))return!0;return!!(r.rest&&K(r.rest,n))}return!1}const Rr=(e,t={})=>n=>{let r=Fr({...n,processors:t});return G(e,r),Ir(r,e),Lr(r,e)},q=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Fr({...i??{},target:a,io:t,processors:n});return G(e,o),Ir(o,e),Lr(o,e)},zr={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Br=(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=zr[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}))])}},Vr=(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`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Hr=(e,t,n,r)=>{n.type=`boolean`},Ur=(e,t,n,r)=>{n.not={}},Wr=(e,t,n,r)=>{let i=e._zod.def,a=s(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Gr=(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},Kr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},qr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Jr=(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=G(a.element,t,{...r,path:[...r.path,`items`]})},Yr=(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]=G(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=G(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Xr=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>G(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Zr=(e,t,n,r)=>{let i=e._zod.def,a=G(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=G(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]]},Qr=(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=G(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=G(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=G(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)}},$r=(e,t,n,r)=>{let i=e._zod.def,a=G(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`}]},ei=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ti=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ni=(e,t,n,r)=>{let i=e._zod.def;G(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)))},ri=(e,t,n,r)=>{let i=e._zod.def;G(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},ii=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;G(o,t,r);let s=t.seen.get(e);s.ref=o},ai=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},oi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},si=n(`ZodISODateTime`,(e,t)=>{Ft.init(e,t),Z.init(e,t)});function ci(e){return ar(si,e)}const li=n(`ZodISODate`,(e,t)=>{It.init(e,t),Z.init(e,t)});function ui(e){return or(li,e)}const di=n(`ZodISOTime`,(e,t)=>{Lt.init(e,t),Z.init(e,t)});function fi(e){return sr(di,e)}const pi=n(`ZodISODuration`,(e,t)=>{Rt.init(e,t),Z.init(e,t)});function mi(e){return cr(pi,e)}const hi=(e,t)=>{_e.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>be(e,t)},flatten:{value:t=>ye(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,c,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,c,2)}},isEmpty:{get(){return e.issues.length===0}}})},gi=n(`ZodError`,hi),J=n(`ZodError`,hi,{Parent:Error}),_i=O(J),vi=k(J),yi=A(J),bi=j(J),xi=Ce(J),Si=we(J),Ci=Te(J),wi=Ee(J),Ti=De(J),Ei=Oe(J),Di=ke(J),Oi=Ae(J),ki=new WeakMap;function Y(e,t,n){let r=Object.getPrototypeOf(e),i=ki.get(r);if(i||(i=new Set,ki.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const X=n(`ZodType`,(e,t)=>(P.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:q(e,`input`),output:q(e,`output`)}}),e.toJSONSchema=Rr(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>_i(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>yi(e,t,n),e.parseAsync=async(t,n)=>vi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>bi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>xi(e,t,n),e.decode=(t,n)=>Si(e,t,n),e.encodeAsync=async(t,n)=>Ci(e,t,n),e.decodeAsync=async(t,n)=>wi(e,t,n),e.safeEncode=(t,n)=>Ti(e,t,n),e.safeDecode=(t,n)=>Ei(e,t,n),e.safeEncodeAsync=async(t,n)=>Di(e,t,n),e.safeDecodeAsync=async(t,n)=>Oi(e,t,n),Y(e,`ZodType`,{check(...e){let t=this.def;return this.clone(g(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return b(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ga(e,t))},superRefine(e,t){return this.check(Ka(e,t))},overwrite(e){return this.check(W(e))},optional(){return Da(this)},exactOptional(){return ka(this)},nullable(){return ja(this)},nullish(){return Da(ja(this))},nonoptional(e){return La(this,e)},array(){return la(this)},or(e){return pa([this,e])},and(e){return _a(this,e)},transform(e){return Va(this,Ta(e))},default(e){return Na(this,e)},prefault(e){return Fa(this,e)},catch(e){return za(this,e)},pipe(e){return Va(this,e)},readonly(){return Ua(this)},describe(e){let t=this.clone();return B.add(t,{description:e}),t},meta(...e){if(e.length===0)return B.get(this);let t=this.clone();return B.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e)),Ai=n(`_ZodString`,(e,t)=>{F.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Br(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Y(e,`_ZodString`,{regex(...e){return this.check(br(...e))},includes(...e){return this.check(Cr(...e))},startsWith(...e){return this.check(wr(...e))},endsWith(...e){return this.check(Tr(...e))},min(...e){return this.check(U(...e))},max(...e){return this.check(vr(...e))},length(...e){return this.check(yr(...e))},nonempty(...e){return this.check(U(1,...e))},lowercase(e){return this.check(xr(e))},uppercase(e){return this.check(Sr(e))},trim(){return this.check(Dr())},normalize(...e){return this.check(Er(...e))},toLowerCase(){return this.check(Or())},toUpperCase(){return this.check(kr())},slugify(){return this.check(Ar())}})}),ji=n(`ZodString`,(e,t)=>{F.init(e,t),Ai.init(e,t),e.email=t=>e.check(Ln(Ni,t)),e.url=t=>e.check(Un(Fi,t)),e.jwt=t=>e.check(ir(Xi,t)),e.emoji=t=>e.check(Wn(Ii,t)),e.guid=t=>e.check(Rn(Pi,t)),e.uuid=t=>e.check(zn(Q,t)),e.uuidv4=t=>e.check(Bn(Q,t)),e.uuidv6=t=>e.check(Vn(Q,t)),e.uuidv7=t=>e.check(Hn(Q,t)),e.nanoid=t=>e.check(Gn(Li,t)),e.guid=t=>e.check(Rn(Pi,t)),e.cuid=t=>e.check(Kn(Ri,t)),e.cuid2=t=>e.check(qn(zi,t)),e.ulid=t=>e.check(Jn(Bi,t)),e.base64=t=>e.check(tr(qi,t)),e.base64url=t=>e.check(nr(Ji,t)),e.xid=t=>e.check(Yn(Vi,t)),e.ksuid=t=>e.check(Xn(Hi,t)),e.ipv4=t=>e.check(Zn(Ui,t)),e.ipv6=t=>e.check(Qn(Wi,t)),e.cidrv4=t=>e.check($n(Gi,t)),e.cidrv6=t=>e.check(er(Ki,t)),e.e164=t=>e.check(rr(Yi,t)),e.datetime=t=>e.check(ci(t)),e.date=t=>e.check(ui(t)),e.time=t=>e.check(fi(t)),e.duration=t=>e.check(mi(t))});function Mi(e){return In(ji,e)}const Z=n(`ZodStringFormat`,(e,t)=>{I.init(e,t),Ai.init(e,t)}),Ni=n(`ZodEmail`,(e,t)=>{Et.init(e,t),Z.init(e,t)}),Pi=n(`ZodGUID`,(e,t)=>{wt.init(e,t),Z.init(e,t)}),Q=n(`ZodUUID`,(e,t)=>{Tt.init(e,t),Z.init(e,t)}),Fi=n(`ZodURL`,(e,t)=>{Dt.init(e,t),Z.init(e,t)}),Ii=n(`ZodEmoji`,(e,t)=>{Ot.init(e,t),Z.init(e,t)}),Li=n(`ZodNanoID`,(e,t)=>{kt.init(e,t),Z.init(e,t)}),Ri=n(`ZodCUID`,(e,t)=>{At.init(e,t),Z.init(e,t)}),zi=n(`ZodCUID2`,(e,t)=>{jt.init(e,t),Z.init(e,t)}),Bi=n(`ZodULID`,(e,t)=>{Mt.init(e,t),Z.init(e,t)}),Vi=n(`ZodXID`,(e,t)=>{Nt.init(e,t),Z.init(e,t)}),Hi=n(`ZodKSUID`,(e,t)=>{Pt.init(e,t),Z.init(e,t)}),Ui=n(`ZodIPv4`,(e,t)=>{zt.init(e,t),Z.init(e,t)}),Wi=n(`ZodIPv6`,(e,t)=>{Bt.init(e,t),Z.init(e,t)}),Gi=n(`ZodCIDRv4`,(e,t)=>{Vt.init(e,t),Z.init(e,t)}),Ki=n(`ZodCIDRv6`,(e,t)=>{Ht.init(e,t),Z.init(e,t)}),qi=n(`ZodBase64`,(e,t)=>{Wt.init(e,t),Z.init(e,t)}),Ji=n(`ZodBase64URL`,(e,t)=>{Kt.init(e,t),Z.init(e,t)}),Yi=n(`ZodE164`,(e,t)=>{qt.init(e,t),Z.init(e,t)}),Xi=n(`ZodJWT`,(e,t)=>{Yt.init(e,t),Z.init(e,t)}),Zi=n(`ZodNumber`,(e,t)=>{Xt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vr(e,t,n,r),Y(e,`ZodNumber`,{gt(e,t){return this.check(gr(e,t))},gte(e,t){return this.check(H(e,t))},min(e,t){return this.check(H(e,t))},lt(e,t){return this.check(hr(e,t))},lte(e,t){return this.check(V(e,t))},max(e,t){return this.check(V(e,t))},int(e){return this.check(ea(e))},safe(e){return this.check(ea(e))},positive(e){return this.check(gr(0,e))},nonnegative(e){return this.check(H(0,e))},negative(e){return this.check(hr(0,e))},nonpositive(e){return this.check(V(0,e))},multipleOf(e,t){return this.check(_r(e,t))},step(e,t){return this.check(_r(e,t))},finite(){return this}});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 Qi(e){return lr(Zi,e)}const $i=n(`ZodNumberFormat`,(e,t)=>{Zt.init(e,t),Zi.init(e,t)});function ea(e){return ur($i,e)}const ta=n(`ZodBoolean`,(e,t)=>{Qt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hr(e,t,n,r)});function na(e){return dr(ta,e)}const ra=n(`ZodAny`,(e,t)=>{$t.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ia(){return fr(ra)}const aa=n(`ZodUnknown`,(e,t)=>{en.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function $(){return pr(aa)}const oa=n(`ZodNever`,(e,t)=>{tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ur(e,t,n,r)});function sa(e){return mr(oa,e)}const ca=n(`ZodArray`,(e,t)=>{rn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jr(e,t,n,r),e.element=t.element,Y(e,`ZodArray`,{min(e,t){return this.check(U(e,t))},nonempty(e){return this.check(U(1,e))},max(e,t){return this.check(vr(e,t))},length(e,t){return this.check(yr(e,t))},unwrap(){return this.element}})});function la(e,t){return jr(ca,e,t)}const ua=n(`ZodObject`,(e,t)=>{cn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yr(e,t,n,r),m(e,`shape`,()=>t.shape),Y(e,`ZodObject`,{keyof(){return xa(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:$()})},loose(){return this.clone({...this._zod.def,catchall:$()})},strict(){return this.clone({...this._zod.def,catchall:sa()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ue(this,e)},safeExtend(e){return de(this,e)},merge(e){return fe(this,e)},pick(e){return ce(this,e)},omit(e){return le(this,e)},partial(...e){return pe(Ea,this,e[0])},required(...e){return me(Ia,this,e[0])}})});function da(e,t){return new ua({type:`object`,shape:e??{},...x(t)})}const fa=n(`ZodUnion`,(e,t)=>{un.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xr(e,t,n,r),e.options=t.options});function pa(e,t){return new fa({type:`union`,options:e,...x(t)})}const ma=n(`ZodDiscriminatedUnion`,(e,t)=>{fa.init(e,t),dn.init(e,t)});function ha(e,t,n){return new ma({type:`union`,options:t,discriminator:e,...x(n)})}const ga=n(`ZodIntersection`,(e,t)=>{fn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zr(e,t,n,r)});function _a(e,t){return new ga({type:`intersection`,left:e,right:t})}const va=n(`ZodRecord`,(e,t)=>{mn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qr(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ya(e,t,n){return!t||!t._zod?new va({type:`record`,keyType:Mi(),valueType:e,...x(t)}):new va({type:`record`,keyType:e,valueType:t,...x(n)})}const ba=n(`ZodEnum`,(e,t)=>{hn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wr(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 ba({...t,checks:[],...x(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 ba({...t,checks:[],...x(r),entries:i})}});function xa(e,t){return new ba({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...x(t)})}const Sa=n(`ZodLiteral`,(e,t)=>{gn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gr(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 Ca(e,t){return new Sa({type:`literal`,values:Array.isArray(e)?e:[e],...x(t)})}const wa=n(`ZodTransform`,(e,t)=>{_n.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qr(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new i(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(D(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(D(t))}};let a=t.transform(n.value,n);return a instanceof Promise?a.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Ta(e){return new wa({type:`transform`,transform:e})}const Ea=n(`ZodOptional`,(e,t)=>{yn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Da(e){return new Ea({type:`optional`,innerType:e})}const Oa=n(`ZodExactOptional`,(e,t)=>{bn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ka(e){return new Oa({type:`optional`,innerType:e})}const Aa=n(`ZodNullable`,(e,t)=>{xn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$r(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ja(e){return new Aa({type:`nullable`,innerType:e})}const Ma=n(`ZodDefault`,(e,t)=>{Sn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Na(e,t){return new Ma({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Pa=n(`ZodPrefault`,(e,t)=>{wn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fa(e,t){return new Pa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Ia=n(`ZodNonOptional`,(e,t)=>{Tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ei(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function La(e,t){return new Ia({type:`nonoptional`,innerType:e,...x(t)})}const Ra=n(`ZodCatch`,(e,t)=>{Dn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function za(e,t){return new Ra({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Ba=n(`ZodPipe`,(e,t)=>{On.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r),e.in=t.in,e.out=t.out});function Va(e,t){return new Ba({type:`pipe`,in:e,out:t})}const Ha=n(`ZodReadonly`,(e,t)=>{kn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ua(e){return new Ha({type:`readonly`,innerType:e})}const Wa=n(`ZodCustom`,(e,t)=>{jn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,n,r)});function Ga(e,t={}){return Mr(Wa,e,t)}function Ka(e,t){return Nr(e,t)}const qa=`2.8.0`;export{na as a,Qi as c,Mi as d,pa as f,t as h,la as i,da as l,gi as m,xa as n,ha as o,$ as p,ia as r,Ca as s,qa as t,ya as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pathToFileURL as e}from"node:url";async function t(e){let t=await Promise.all(Object.entries(e).map(async([e,t])=>[e,typeof t==`function`?await t():t]));return Object.fromEntries(t)}const n=`virtual:`;function r(e,t,r=c(),a=!1){return{resolve:(i,a,o)=>{let c=s(i);if(Object.hasOwn(e,c)){let e=t?.get(c);return{url:n+encodeURIComponent(i)+(e?`?v=${e}`:``),shortCircuit:!0}}return a.parentURL?.startsWith(n)?o(i,{...a,parentURL:r}):o(i,a)},load:(t,r,o)=>{if(t.startsWith(n)){let n=s(decodeURIComponent(t.slice(8)));if(Object.hasOwn(e,n))return{format:a?`module`:i(n),source:e[n],shortCircuit:!0}}return o(t,r)}}}function i(e){return e.endsWith(`.json`)?`json`:e.endsWith(`.ts`)||e.endsWith(`.mts`)?`module-typescript`:`module`}function a(e,t,n,r){if(typeof n!=`function`)throw TypeError(`[env-runner] virtual TypeScript module "${e}" requires \`module.stripTypeScriptTypes\` ${r.requirement}; ${r.remedy} or provide a pre-transpiled JavaScript source instead.`);return n(t)}function o(e,t){let n=[t],r=new Set(n);for(let t of n){let i=[`"${t}"`,`'${t}'`,"`"+t+"`"];for(let[t,a]of Object.entries(e))!r.has(t)&&i.some(e=>a.includes(e))&&(r.add(t),n.push(t))}return n}function s(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}function c(){return e(process.cwd()+`/`).href}export{i as a,a as i,o as n,t as r,r as t};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{o as e,t}from"./chunk-BTyA9uPd.js";import{c as n,d as r,f as i,l as a,p as o,s,u as c}from"./dist-CrxV2rsR.js";import{D as l,E as u,O as d,a as f,c as p,i as m,l as h,m as g,p as _,u as v}from"./dist-B3qkUnLJ.js";import{K as y,X as ee,_ as te,f as ne,n as re,o as ie,x as b,y as ae}from"./dist-BX517Nmz.js";import{getStepFunction as oe}from"../../@workflow/core/private.js";import{types as se}from"node:util";import{AsyncLocalStorage as ce}from"node:async_hooks";function le(e,t){let n=Error.captureStackTrace;n?.(e,t)}const ue=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:e.env.NO_COLOR?!1:!!e.stdout?.isTTY:!1})(),x=(e,t)=>n=>ue?`\x1b[${e}m${n}\x1b[${t}m`:n,S={bold:x(1,22),dim:x(2,22),italic:x(3,23),red:x(31,39),blue:x(34,39),cyan:x(36,39),yellow:x(33,39),magenta:x(35,39)},de={info:S.blue,help:S.cyan,warn:S.yellow,error:S.red};function fe(e){let t=Array.isArray(e)?e.join(`
|
|
2
|
+
`):e;return de.info(`${S.bold(`hint:`)} ${t}`)}function pe(e){return de.info(`${S.bold(`docs:`)} ${e}`)}function me(e){return S.italic(`${S.dim("`")}${e}${S.dim("`")}`)}function C(e){return S.dim(e)}function he(e){return S.bold(e)}function ge(e){return S.red(e)}function _e(e){return S.magenta(e)}function ve(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
|
|
3
|
+
`),a=r===t.length-1,o=a?`╰▶ `:`├▶ `,s=a?` `:`│ `,c=i.map((e,t)=>`${t===0?o:s}${e}`);n.push(...c)}),n.join(`
|
|
4
|
+
`)}const ye=Symbol.for(`nodejs.util.inspect.custom`);function be(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function xe(e){return`code`in e?me(e.code):`dim`in e?C(e.dim):e.text}function Se(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(be).join(``)}function Ce(e){return e.type===`docs`?pe(e.url):e.segments.map(xe).join(``)}function we(e){let t=[e.title.map(be).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;Se(n).split(`
|
|
5
|
+
`).forEach((e,n)=>t.push(`${n===0?a:o}${e}`))}),t.join(`
|
|
6
|
+
`)}function Te(e){return ve(e.title.map(xe).join(``),e.details.map(Ce))}var Ee=class extends Error{fatal=!0;#e;constructor(e){super(we(e)),this.#e=e}[ye](){let e=Te(this.#e),t=this.message.split(`
|
|
7
|
+
`).length,n=(this.stack??``).split(`
|
|
8
|
+
`).slice(t).join(`
|
|
9
|
+
`);return n?`${this.name}: ${e}\n${n}`:`${this.name}: ${e}`}toString(){return`${this.name}: ${Te(this.#e)}`}},De=class extends Ee{name=`NotInWorkflowContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow function`}],details:[{type:`docs`,url:t}]})}},Oe=class extends Ee{name=`NotInStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a step function`}],details:[{type:`docs`,url:t}]})}},ke=class extends Ee{name=`NotInWorkflowOrStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow or step function`}],details:[{type:`docs`,url:t}]})}};const Ae=Symbol.for(`WORKFLOW_CONTEXT`);function je(){let e=globalThis[Ae];if(!e){let e=new ke(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`);throw le(e,je),e}return e}var Me=class extends Ee{name=`UnavailableInWorkflowContextError`;constructor(e,t){let n=globalThis[Ae]?.workflowName,r=(()=>{if(!n)return null;let e=n.match(/^(workflow\/|step\/)(.*)$/);return e?[{dim:e[1]},{text:e[2]}]:[{text:n}]})(),i=r?{type:`plain`,segments:[{text:`this call was made from the `},...r,{text:` workflow context.`}]}:{type:`plain`,segments:[{text:`this call was made from a workflow context.`}]};super({title:[{code:e},{text:` cannot be called from a workflow context.`}],details:[{type:`plain`,segments:[{text:`calling this in a workflow context can cause determinism issues.`}]},i,{type:`docs`,url:t}]})}};function Ne(e,t,n){let r=new De(e,t);throw le(r,n),r}function Pe(e,t,n){let r=new Oe(e,t);throw le(r,n),r}function Fe(e,t,n){let r=new ke(e,t);throw le(r,n),r}function Ie(e,t,n){let r=new Me(e,t);throw le(r,n),r}var Le=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),Re=t(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),ze=t(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=Le(),a=Re();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),Be=t(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),Ve=t(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),w=t(((e,t)=>{let n=Re(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=Le(),{safeRe:a,t:o}=ze(),s=Be(),{compareIdentifiers:c}=Ve();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),He=t(((e,t)=>{let n=w();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),Ue=t(((e,t)=>{let n=He();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),We=t(((e,t)=>{let n=He();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Ge=t(((e,t)=>{let n=w();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),Ke=t(((e,t)=>{let n=He();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),qe=t(((e,t)=>{let n=w();t.exports=(e,t)=>new n(e,t).major})),Je=t(((e,t)=>{let n=w();t.exports=(e,t)=>new n(e,t).minor})),Ye=t(((e,t)=>{let n=w();t.exports=(e,t)=>new n(e,t).patch})),Xe=t(((e,t)=>{let n=He();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),T=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Ze=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>n(t,e,r)})),Qe=t(((e,t)=>{let n=T();t.exports=(e,t)=>n(e,t,!0)})),$e=t(((e,t)=>{let n=w();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),et=t(((e,t)=>{let n=$e();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),tt=t(((e,t)=>{let n=$e();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),nt=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>n(e,t,r)>0})),rt=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>n(e,t,r)<0})),it=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>n(e,t,r)===0})),at=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>n(e,t,r)!==0})),ot=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>n(e,t,r)>=0})),st=t(((e,t)=>{let n=T();t.exports=(e,t,r)=>n(e,t,r)<=0})),ct=t(((e,t)=>{let n=it(),r=at(),i=nt(),a=ot(),o=rt(),s=st();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),lt=t(((e,t)=>{let n=w(),r=He(),{safeRe:i,t:a}=ze();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),ut=t(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),E=t(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,se(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>oe(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let ee=[..._.values()];return r.set(t,ee),ee}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(ce(this.set[t],e,this.options))return!0;return!1}};let r=new(ut()),i=Be(),a=dt(),o=Re(),s=w(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=ze(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=Le(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=ne(e,t),o(`caret`,e),e=ee(e,t),o(`tildes`,e),e=ie(e,t),o(`xrange`,e),e=ae(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,ee=(e,t)=>e.trim().split(/\s+/).map(e=>te(e,t)).join(` `),te=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},ne=(e,t)=>e.trim().split(/\s+/).map(e=>re(e,t)).join(` `),re=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},ie=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>b(e,t)).join(` `)),b=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},ae=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),oe=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),se=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),ce=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),dt=t(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=Be(),{safeRe:i,t:a}=ze(),o=ct(),s=Re(),c=w(),l=E()})),ft=t(((e,t)=>{let n=E();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),pt=t(((e,t)=>{let n=E();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),mt=t(((e,t)=>{let n=w(),r=E();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),ht=t(((e,t)=>{let n=w(),r=E();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),gt=t(((e,t)=>{let n=w(),r=E(),i=nt();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),_t=t(((e,t)=>{let n=E();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),vt=t(((e,t)=>{let n=w(),r=dt(),{ANY:i}=r,a=E(),o=ft(),s=nt(),c=rt(),l=st(),u=ot();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),yt=t(((e,t)=>{let n=vt();t.exports=(e,t,r)=>n(e,t,`>`,r)})),bt=t(((e,t)=>{let n=vt();t.exports=(e,t,r)=>n(e,t,`<`,r)})),xt=t(((e,t)=>{let n=E();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),St=t(((e,t)=>{let n=ft(),r=T();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),Ct=t(((e,t)=>{let n=E(),r=dt(),{ANY:i}=r,a=ft(),o=T(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),wt=t(((e,t)=>{let n=ze(),r=Le(),i=w(),a=Ve();t.exports={parse:He(),valid:Ue(),clean:We(),inc:Ge(),diff:Ke(),major:qe(),minor:Je(),patch:Ye(),prerelease:Xe(),compare:T(),rcompare:Ze(),compareLoose:Qe(),compareBuild:$e(),sort:et(),rsort:tt(),gt:nt(),lt:rt(),eq:it(),neq:at(),gte:ot(),lte:st(),cmp:ct(),coerce:lt(),Comparator:dt(),Range:E(),satisfies:ft(),toComparators:pt(),maxSatisfying:mt(),minSatisfying:ht(),minVersion:gt(),validRange:_t(),outside:vt(),gtr:yt(),ltr:bt(),intersects:xt(),simplifyRange:St(),subset:Ct(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));function Tt(e){return new Uint8Array(e).toBase64()}function Et(e){return Uint8Array.fromBase64(e).buffer}function Dt(e){return Buffer.from(e).toString(`base64`)}function Ot(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function kt(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function At(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}const jt=typeof Uint8Array.fromBase64==`function`,Mt=typeof process==`object`&&process.versions?.node!==void 0,Nt=jt?Tt:Mt?Dt:kt,Pt=jt?Et:Mt?Ot:At,Ft=2**32-1,It=Ft-1;var D=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};function Lt(e){return e===null||typeof e!=`object`&&typeof e!=`function`}const Rt=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function zt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===Rt}function Bt(e){return Object.prototype.toString.call(e).slice(8,-1)}function Vt(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
|
|
10
|
+
`:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;case`\b`:return`\\b`;case`\f`:return`\\f`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:return e<` `?`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}function O(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=Vt(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function Ht(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const Ut=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Wt(e){return Ut.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Gt(e){return!(!Number.isInteger(e)||e<0||e>It)}function Kt(e){return!(!Number.isInteger(e)||e<0||e>Ft)}function qt(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return Gt(+e)}function Jt(e){let t=Object.keys(e);for(var n=t.length-1;n>=0&&!qt(t[n]);n--);return t.length=n+1,t}function Yt(e,t){return Xt(JSON.parse(e),t)}function Xt(e,t){if(typeof e==`number`)return a(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let n=e,r=Array(n.length),i=null;function a(e,o=!1){if(e===-1)return;if(e===-3)return NaN;if(e===-4)return 1/0;if(e===-5)return-1/0;if(e===-6)return-0;if(o||typeof e!=`number`)throw Error(`Invalid input`);if(e in r)return r[e];let s=n[e];if(!s||typeof s!=`object`)r[e]=s;else if(Array.isArray(s))if(typeof s[0]==`string`){let o=s[0],c=t&&Object.hasOwn(t,o)?t[o]:void 0;if(c){let t=s[1];if(typeof t!=`number`&&(t=n.push(s[1])-1),i??=new Set,i.has(t))throw Error(`Invalid circular reference`);return i.add(t),r[e]=c(a(t)),i.delete(t),r[e]}switch(o){case`Date`:r[e]=new Date(s[1]);break;case`Set`:let t=new Set;r[e]=t;for(let e=1;e<s.length;e+=1)t.add(a(s[e]));break;case`Map`:let i=new Map;r[e]=i;for(let e=1;e<s.length;e+=2)i.set(a(s[e]),a(s[e+1]));break;case`RegExp`:r[e]=new RegExp(s[1],s[2]);break;case`Object`:{let t=s[1];if(typeof n[t]==`object`&&n[t][0]!==`BigInt`)throw Error(`Invalid input`);r[e]=Object(a(t));break}case`BigInt`:r[e]=BigInt(s[1]);break;case`null`:let c=Object.create(null);r[e]=c;for(let e=1;e<s.length;e+=2){if(s[e]===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");c[s[e]]=a(s[e+1])}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{if(n[s[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=globalThis[o],i=a(s[1]);r[e]=s[2]===void 0?new t(i):new t(i,s[2],s[3]);break}case`ArrayBuffer`:{let t=s[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);r[e]=Pt(t);break}case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:{let t=o.slice(9);r[e]=Temporal[t].from(s[1]);break}case`URL`:r[e]=new URL(s[1]);break;case`URLSearchParams`:r[e]=new URLSearchParams(s[1]);break;default:throw Error(`Unknown type ${o}`)}}else if(s[0]===-7){let t=s[1];if(!Kt(t))throw Error(`Invalid input`);let n=[];r[e]=n,n[It]=void 0,delete n[It];for(let e=2;e<s.length;e+=2){let r=s[e];if(!Gt(r)||r>=t)throw Error(`Invalid input`);n[r]=a(s[e+1])}n.length=t}else{let t=Array(s.length);r[e]=t;for(let e=0;e<s.length;e+=1){let n=s[e];n!==-2&&(t[e]=a(n))}}else{let t={};r[e]=t;for(let e of Object.keys(s)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");let n=s[e];t[e]=a(n)}}return r[e]}return a(0)}function k(e,t){let n=Zt(!1,e,t);return typeof n==`string`?n:`[${n.join(`,`)}]`}function Zt(e,t,n){let r=[],i=new Map,a=[];if(n)for(let e of Object.getOwnPropertyNames(n))a.push({key:e,fn:n[e]});let o=[],s=0;function c(n,l){if(n===void 0)return-1;if(Number.isNaN(n))return-3;if(n===1/0)return-4;if(n===-1/0)return-5;if(n===0&&1/n<0)return-6;if(i.has(n))return i.get(n);l??=s++,i.set(n,l);for(let{key:e,fn:t}of a){let i=t(n);if(i)return r[l]=`["${e}",${c(i)}]`,l}if(typeof n==`function`)throw new D(`Cannot stringify a function`,o,n,t);if(typeof n==`symbol`)throw new D(`Cannot stringify a Symbol primitive`,o,n,t);let u=``;if(Lt(n))u=Qt(n);else if(typeof n.then==`function`){if(!e)throw new D(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,o,n,t);u=Promise.resolve(n).then(e=>{let t=c(e,l);t<0&&(r[l]=t)})}else{let e=Bt(n);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:u=`["Object",${c(n.valueOf())}]`;break;case`Date`:u=`["Date","${isNaN(n.getDate())?``:n.toISOString()}"]`;break;case`URL`:u=`["URL",${O(n.toString())}]`;break;case`URLSearchParams`:u=`["URLSearchParams",${O(n.toString())}]`;break;case`RegExp`:let{source:r,flags:i}=n;u=i?`["RegExp",${O(r)},"${i}"]`:`["RegExp",${O(r)}]`;break;case`Array`:{let e=!1;u=`[`;for(let t=0;t<n.length;t+=1)if(t>0&&(u+=`,`),Object.hasOwn(n,t))o.push(`[${t}]`),u+=c(n[t]),o.pop();else if(e)u+=-2;else{let t=Jt(n),r=t.length,i=String(n.length).length;if((n.length-r)*3>4+i+r*(i+1)){u=`[-7,`+n.length;for(let e=0;e<t.length;e++){let r=t[e];o.push(`[${r}]`),u+=`,`+r+`,`+c(n[r]),o.pop()}break}else e=!0,u+=-2}u+=`]`;break}case`Set`:u=`["Set"`;for(let e of n)u+=`,${c(e)}`;u+=`]`;break;case`Map`:u=`["Map"`;for(let[e,t]of n)o.push(`.get(${Lt(e)?Qt(e):`...`})`),u+=`,${c(e)},${c(t)}`,o.pop();u+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{let t=n;u=`["`+e+`",`+c(t.buffer),t.byteLength!==t.buffer.byteLength&&(u+=`,${t.byteOffset},${t.length}`),u+=`]`;break}case`ArrayBuffer`:u=`["ArrayBuffer","${Nt(n)}"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:u=`["${e}",${O(n.toString())}]`;break;default:if(!zt(n))throw new D(`Cannot stringify arbitrary non-POJOs`,o,n,t);if(Ht(n).length>0)throw new D(`Cannot stringify POJOs with symbolic keys`,o,n,t);if(Object.getPrototypeOf(n)===null){u=`["null"`;for(let e of Object.keys(n)){if(e===`__proto__`)throw new D(`Cannot stringify objects with __proto__ keys`,o,n,t);o.push(Wt(e)),u+=`,${O(e)},${c(n[e])}`,o.pop()}u+=`]`}else{u=`{`;let e=!1;for(let r of Object.keys(n)){if(r===`__proto__`)throw new D(`Cannot stringify objects with __proto__ keys`,o,n,t);e&&(u+=`,`),e=!0,o.push(Wt(r)),u+=`${O(r)}:${c(n[r])}`,o.pop()}u+=`}`}}}return r[l]=u,l}let l=c(t);return l<0?`${l}`:r}function Qt(e){let t=typeof e;return t===`string`?O(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var $t=e(wt(),1);async function en(e,t=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new u(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,t)}async function tn(e,t){let n=globalThis.crypto.getRandomValues(new Uint8Array(12)),r;try{r=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:n,tagLength:128},e,t)}catch(e){throw new _(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let i=new Uint8Array(12+r.byteLength);return i.set(n,0),i.set(new Uint8Array(r),12),i}async function nn(e,t){if(t.byteLength<28)throw new _(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let n=t.subarray(0,12),r=t.subarray(12),i;try{i=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:n,tagLength:128},e,r)}catch(e){throw new _(`AES-256-GCM decryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(i)}const rn=Symbol.for(`WORKFLOW_USE_STEP`),an=Symbol.for(`WORKFLOW_SET_ATTRIBUTES`),on=Symbol.for(`WORKFLOW_CREATE_HOOK`),sn=Symbol.for(`WORKFLOW_SLEEP`),cn=Symbol.for(`WORKFLOW_GET_STREAM_ID`),ln=Symbol.for(`WORKFLOW_STABLE_ULID`),A=Symbol.for(`WORKFLOW_STREAM_NAME`),un=Symbol.for(`WORKFLOW_STREAM_TYPE`),dn=Symbol.for(`WORKFLOW_STREAM_FRAMING`),j=Symbol.for(`WORKFLOW_STREAM_SERVER_RUN_ID`),M=Symbol.for(`WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID`),fn=Symbol.for(`WORKFLOW_STREAM_WRITE_BATCH`),pn=Symbol.for(`BODY_INIT`),mn=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),hn=Symbol.for(`workflow-class-registry`),N=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),P=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),gn=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),_n=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`),vn=()=>b(`WORKFLOW_STREAM_MAX_INFLIGHT_CHUNKS`,1e3,{integer:!0,min:1}),yn=()=>b(`WORKFLOW_STREAM_MAX_CHUNKS_PER_BATCH`,1e3,{integer:!0,min:1}),bn=()=>b(`WORKFLOW_STREAM_MAX_BYTES_PER_BATCH`,1048576,{integer:!0,min:1}),xn=()=>b(`WORKFLOW_LOCK_POLL_INTERVAL_MS`,10,{integer:!0,min:1});function F(){let e={...n(),pendingOps:0,doneResolved:!1,streamEnded:!1};return e.promise.catch(()=>{}),e}function Sn(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Cn(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function wn(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}Sn(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.writablePollingInterval=void 0)},xn());t.writablePollingInterval=n}function Tn(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}Cn(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.readablePollingInterval=void 0)},xn());t.readablePollingInterval=n}function I(e,t,n){let r=t[fn];return typeof r==`function`?Mn(e,t,n,r):En(e,t,n)}async function En(e,t,n){let r=e.getReader(),i=t.getWriter(),a;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),i.closed.then(()=>{throw new u(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await i.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await i.write(e.value)}finally{n.pendingOps--}}}catch(e){throw n.streamEnded=!0,a=e,n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(a).catch(()=>{}),r.releaseLock(),i.releaseLock()}}function Dn(e,t){let n=e[t];n&&(e[t]=null,n())}function On(e){let t=0,n=0;for(let r of e.queue){if(t>=e.maxChunksPerBatch||t>0&&n+r.byteLength>e.maxBytesPerBatch)break;t++,n+=r.byteLength}return t}async function kn(e){for(;;){if(e.queue.length===0){if(e.sourceDone)return;await new Promise(t=>{e.wakeConsumer=t});continue}let t=On(e),n=e.queue.slice(0,t);e.queue=e.queue.slice(t),await e.batchWrite(n),e.state.pendingOps-=n.length,Dn(e,`wakeProducer`)}}function An(e,t,n){return Promise.race([e.read(),t.closed.then(()=>{throw new u(`Writable stream closed prematurely`)}),n.then(()=>{throw new u(`Stream consumer ended prematurely`)},e=>{throw e})])}async function jn(e,t,n){e.state.pendingOps<n||await Promise.race([new Promise(t=>{e.wakeProducer=t}),t.then(()=>void 0,()=>void 0)])}async function Mn(e,t,n,r){let i=e.getReader(),a=t.getWriter(),o=vn(),s,c={state:n,batchWrite:r,queue:[],sourceDone:!1,wakeConsumer:null,wakeProducer:null,maxChunksPerBatch:yn(),maxBytesPerBatch:bn()},l=kn(c);try{for(;!n.streamEnded;){let e=await An(i,a,l);if(n.streamEnded)return;if(e.done){c.sourceDone=!0,Dn(c,`wakeConsumer`),await l,n.streamEnded=!0,await a.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}c.queue.push(e.value),n.pendingOps++,Dn(c,`wakeConsumer`),await jn(c,l,o)}}catch(e){throw n.streamEnded=!0,s=e,c.sourceDone=!0,Dn(c,`wakeConsumer`),await l.catch(()=>{}),n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{i.cancel(s).catch(()=>{}),i.releaseLock(),a.releaseLock()}}function Nn(e){if(e.specVersion!==5)throw new u(`This Workflow runtime requires a World with matching spec version 5, but the configured World declares spec version ${e.specVersion??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const Pn=Symbol.for(`@workflow/world//cache`),Fn=Symbol.for(`@workflow/world//cachePromise`),In=Symbol.for(`@workflow/world//getWorldFn`);async function L(){let e=globalThis;if(e[Pn])return Nn(e[Pn]),e[Pn];if(e[Fn])return e[Pn]=await e[Fn],Nn(e[Pn]),e[Pn];let t=e[In];if(t){let e=await t();return Nn(e),e}throw Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.")}const Ln=Symbol.for(`workflow-serialize`),Rn=Symbol.for(`workflow-deserialize`);function zn(e=globalThis){let t=e,n=t[hn];return n||(n=new Map,t[hn]=n),n}const Bn=`class//workflow//Run`;function Vn(e,t,n=globalThis){zn(n).set(e,t)}function Hn(e,t){return zn(t).get(e)}function Un(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=e.classId;return typeof t==`string`?{classId:t}:!1},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=e.constructor;if(!t||typeof t!=`function`)return!1;let n=t[Ln];if(typeof n!=`function`)return!1;let r=t.classId;if(typeof r!=`string`)throw Error(`Class "${t.name}" with ${String(Ln)} must have a static "classId" property.`);return{classId:r,data:n.call(t,e)}}}}function Wn(e=globalThis){return{Class:t=>{let n=t.classId,r=Hn(n,e);if(!r)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);return r},Instance:t=>{let n=t.classId,r=t.data,i=Hn(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[Rn];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(Rn)} method.`);return a.call(i,r)}}}function Gn(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function R(e){return Gn(e.buffer,e.byteOffset,e.byteLength)}function z(e,t){let n=e===`.`?``:e,r=Buffer.from(n,`base64`),i=new t.ArrayBuffer(r.length);return new t.Uint8Array(i).set(r),i}function Kn(e){return JSON.parse(e)}function qn(e){if(!se.isNativeError(e))return!1;let t={message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t}function Jn(e,t){return!se.isNativeError(t)||t.name!==e?!1:qn(t)}function B(e){return t=>Jn(e,t)||!1}function Yn(e,t){return n=>{let r=n,i=`cause`in r?{cause:r.cause}:void 0,a=e[t],o=new a(r.message,i);return r.stack!==void 0&&(o.stack=r.stack),o}}function Xn(e=globalThis){return{ArrayBuffer:t=>t instanceof e.ArrayBuffer&&Gn(t,0,t.byteLength),BigInt:e=>typeof e==`bigint`&&e.toString(),BigInt64Array:t=>t instanceof e.BigInt64Array&&R(t),BigUint64Array:t=>t instanceof e.BigUint64Array&&R(t),Date:t=>t instanceof e.Date?Number.isNaN(t.getDate())?`.`:t.toISOString():!1,DOMException:e=>{if(typeof e!=`object`||!e||e.constructor?.name!==`DOMException`)return!1;let t=e,n={message:t.message,name:t.name,stack:t.stack};return`cause`in t&&(n.cause=t.cause),n},EvalError:B(`EvalError`),FatalError:B(`FatalError`),HookConflictError:e=>{let t=Jn(`HookConflictError`,e);if(!t)return!1;let n=e,r={...t,token:n.token};return n.conflictingRunId!==void 0&&(r.conflictingRunId=n.conflictingRunId),r},RangeError:B(`RangeError`),ReferenceError:B(`ReferenceError`),RetryableError:e=>{let t=Jn(`RetryableError`,e);if(!t)return!1;let n=e.retryAfter,r;if(n&&typeof n==`object`&&typeof n.getTime==`function`){let e=n.getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else if(typeof n==`string`||typeof n==`number`){let e=new Date(n).getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else r=Date.now()+1e3;return{...t,retryAfter:r}},RuntimeDecryptionError:e=>{let t=Jn(`RuntimeDecryptionError`,e);if(!t)return!1;let n={...t},r=e.context;return r!==void 0&&(n.context=r),n},SyntaxError:B(`SyntaxError`),TypeError:B(`TypeError`),URIError:B(`URIError`),AggregateError:e=>{let t=Jn(`AggregateError`,e);return t?{...t,errors:e.errors}:!1},Error:e=>{if(!se.isNativeError(e))return!1;let t={name:e.name,message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t},Float32Array:t=>t instanceof e.Float32Array&&R(t),Float64Array:t=>t instanceof e.Float64Array&&R(t),Headers:t=>t instanceof e.Headers&&Array.from(t),Int8Array:t=>t instanceof e.Int8Array&&R(t),Int16Array:t=>t instanceof e.Int16Array&&R(t),Int32Array:t=>t instanceof e.Int32Array&&R(t),Map:t=>t instanceof e.Map&&Array.from(t),RegExp:t=>t instanceof e.RegExp&&{source:t.source,flags:t.flags},Set:t=>t instanceof e.Set&&Array.from(t),URL:t=>t instanceof e.URL&&t.href,WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=e.workflowId;return typeof t==`string`?{workflowId:t}:!1},URLSearchParams:t=>t instanceof e.URLSearchParams?t.size===0?`.`:String(t):!1,Uint8Array:t=>t instanceof e.Uint8Array&&R(t),Uint8ClampedArray:t=>t instanceof e.Uint8ClampedArray&&R(t),Uint16Array:t=>t instanceof e.Uint16Array&&R(t),Uint32Array:t=>t instanceof e.Uint32Array&&R(t)}}function Zn(e=globalThis){return{ArrayBuffer:t=>z(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(z(t,e)),BigUint64Array:t=>new e.BigUint64Array(z(t,e)),Date:t=>new e.Date(t),DOMException:t=>{let n=new e.DOMException(t.message,t.name);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},EvalError:Yn(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??m)(t.message);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},HookConflictError:t=>{let n=new(e[Symbol.for(`@workflow/errors//HookConflictError`)]??f)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:Yn(e,`RangeError`),ReferenceError:Yn(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??v)(t.message,{retryAfter:new e.Date(t.retryAfter)});return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RuntimeDecryptionError:t=>{let n=e[Symbol.for(`@workflow/errors//RuntimeDecryptionError`)]??_,r={};`cause`in t&&(r.cause=t.cause),t.context!==void 0&&(r.context=t.context);let i=new n(t.message,r);return t.stack!==void 0&&(i.stack=t.stack),i},SyntaxError:Yn(e,`SyntaxError`),TypeError:Yn(e,`TypeError`),URIError:Yn(e,`URIError`),AggregateError:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.AggregateError(t.errors,t.message,n);return t.stack!==void 0&&(r.stack=t.stack),r},Error:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.Error(t.message,n);return r.name=t.name,t.stack!==void 0&&(r.stack=t.stack),r},Float32Array:t=>new e.Float32Array(z(t,e)),Float64Array:t=>new e.Float64Array(z(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(z(t,e)),Int16Array:t=>new e.Int16Array(z(t,e)),Int32Array:t=>new e.Int32Array(z(t,e)),Map:t=>new e.Map(t),RegExp:t=>new e.RegExp(t.source,t.flags),Set:t=>new e.Set(t),URL:t=>new e.URL(t),WorkflowFunction:e=>Object.assign(()=>{throw Error(`Workflow functions cannot be called directly. Use start() to invoke them.`)},{workflowId:e.workflowId}),URLSearchParams:t=>new e.URLSearchParams(t===`.`?``:t),Uint8Array:t=>new e.Uint8Array(z(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(z(t,e)),Uint16Array:t=>new e.Uint16Array(z(t,e)),Uint32Array:t=>new e.Uint32Array(z(t,e))}}function Qn(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=e.stepId;if(typeof t!=`string`)return!1;let n=e.__closureVarsFn,r=n&&typeof n==`function`?n():void 0,i=`__boundThis`in e,a=i?e.__boundThis:void 0,o=e.__boundArgs,s={stepId:t};return r!==void 0&&(s.closureVars=r),i&&(s.boundThis=a),Array.isArray(o)&&o.length>0&&(s.boundArgs=o),s}}}function $n(e=globalThis){let t=e[Symbol.for(`WORKFLOW_USE_STEP`)];return{StepFunction:e=>{let n=e.stepId,r=e.closureVars;if(!t)throw Error(`WORKFLOW_USE_STEP not found on global object. Step functions cannot be deserialized outside workflow context.`);let i=r?t(n,()=>r):t(n);if(`boundThis`in e){let t=Array.isArray(e.boundArgs)?e.boundArgs:[];return i.bind(e.boundThis,...t)}return i}}}function er(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const V={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,GZIP:`gzip`,ZSTD:`zstd`},tr=new TextEncoder,nr=new TextDecoder;function rr(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Un(),...Qn(),...Xn(t)};break;case`step`:r={...Un(),...Xn(t)};break;case`client`:r={...Un(),...Xn(t)};break}return n?{...r,...n}:r}function ir(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Wn(t),...$n(t),...Zn(t)};break;case`step`:r={...Wn(t),...Zn(t)};break;case`client`:r={...Wn(t),...Zn(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}};break}return n?{...r,...n}:r}const H={formatPrefix:V.DEVALUE_V1,serialize(e,t,n){let r=k(e,rr(t,n?.global,n?.extraReducers));return tr.encode(r)},deserialize(e,t,n){let r=ir(t,n?.global,n?.extraRevivers);return Yt(nr.decode(e),r)},deserializeLegacy(e,t,n){return Xt(e,ir(t,n?.global,n?.extraRevivers))}},ar=new TextEncoder,or=new TextDecoder;function U(e,t){if(!(t instanceof Uint8Array))return t;let n=ar.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function sr(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=or.decode(t);return er(n)?n:null}function W(e){if(!(e instanceof Uint8Array))return{format:V.DEVALUE_V1,payload:new TextEncoder().encode(JSON.stringify(e))};if(e.length<4)throw Error(`Data too short to contain format prefix: expected at least 4 bytes, got ${e.length}`);let t=e.subarray(0,4),n=or.decode(t);if(!er(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}function cr(){try{return typeof process<`u`&&process.env?.WORKFLOW_DISABLE_COMPRESSION===`1`}catch{return!1}}function lr(){try{let e=process.env?.WORKFLOW_COMPRESSION_CODEC;return e===`gzip`||e===`zstd`?e:void 0}catch{return}}function ur(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function dr(){let e=ur();return typeof e?.zstdCompressSync==`function`&&typeof e?.zstdDecompressSync==`function`}function fr(){return typeof CompressionStream==`function`&&typeof DecompressionStream==`function`}async function pr(e,t){let n=t.writable.getWriter(),r=n.write(e).then(()=>n.close());r.catch(()=>{});let i=[],a=0,o=t.readable.getReader();for(;;){let{done:e,value:t}=await o.read();if(e)break;i.push(t),a+=t.length}await r;let s=new Uint8Array(a),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function mr(e){return pr(e,new CompressionStream(`gzip`))}async function hr(e){return pr(e,new DecompressionStream(`gzip`))}function gr(e){let t=ur(),n=t?.constants?.ZSTD_c_compressionLevel,r=n===void 0?void 0:{params:{[n]:3}};return new Uint8Array(t.zstdCompressSync(e,r))}function _r(e){let t=ur();if(!t?.zstdDecompressSync)throw Error(`Compressed (zstd) workflow data encountered but node:zlib zstd support is not available in this runtime (requires Node.js 22.15+). In the browser, register a zstd decoder via registerZstdDecoder (serialization-format.ts).`);return new Uint8Array(t.zstdDecompressSync(e))}function G(e,t,n,r){e&&(e.recorded=!0,e.compressed=t!==`none`,e.codec=t,e.uncompressedBytes=n,e.storedBytes=r)}function vr(){return lr()===`gzip`?fr()?`gzip`:`none`:dr()?`zstd`:fr()?`gzip`:`none`}async function yr(e,t,n){if(!(e instanceof Uint8Array))return e;if(!t||e.length<1024||cr())return G(n,`none`,e.length,e.length),e;let r=vr();if(r===`none`)return G(n,`none`,e.length,e.length),e;let i=r===`zstd`?gr(e):await mr(e),a=r===`zstd`?V.ZSTD:V.GZIP,o=4+i.length;return o>=e.length*.95?(G(n,`none`,e.length,e.length),e):(G(n,r,e.length,o),U(a,i))}async function br(e,t){if(!(e instanceof Uint8Array))return e;let n=sr(e);if(n===V.ZSTD){let{payload:n}=W(e),r=_r(n);return G(t,`zstd`,r.length,e.length),r}if(n===V.GZIP){if(!fr())throw Error(`Compressed (gzip) workflow data encountered but DecompressionStream is not available in this runtime. Node.js 18+, browsers, and edge runtimes all support it.`);let{payload:n}=W(e),r=await hr(n);return G(t,`gzip`,r.length,e.length),r}return G(t,`none`,e.length,e.length),e}async function xr(e){return typeof e==`function`?e():e}async function Sr(e,t){if(!t||!(e instanceof Uint8Array))return e;let n=await tn(t,e);return U(V.ENCRYPTED,n)}async function Cr(e,t){if(!(e instanceof Uint8Array))return e;let n=sr(e);if(n===V.ENCRYPTED&&!t)throw new _(`Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encr`}});if(n!==V.ENCRYPTED)return e;let{payload:r}=W(e);try{return await nn(t,r)}catch(e){throw _.is(e)&&e.context&&(e.context.formatPrefix=n),e}}function wr(e,t,n){let[r,...i]=t.split(`
|
|
11
|
+
`),a=i.join(`
|
|
12
|
+
`),o=Tr(r??``,n),s=Er(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
|
|
13
|
+
`)}function Tr(e,t){if(!t||Object.keys(t).length===0)return null;let n=new Set;n.add(`errorStack`),typeof t.errorMessage==`string`&&e.includes(t.errorMessage)&&n.add(`errorMessage`);let i=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`hint`,`attempt`,`retryCount`]),a=[],o=K(t,`errorName`),s=K(t,`errorAttribution`);if(o||s){let e=s?s===`sdk`?_e(`sdk error`):ge(`user error`):``,t=o?he(o):``,n=e&&t?C(` · `):``;a.push(` ${e}${n}${t}`)}let l=K(t,`workflowRunId`),u=K(t,`workflowName`);l?a.push(kr(`run`,l,u,r)):u&&a.push(kr(`run`,null,u,r));let d=K(t,`stepId`),f=K(t,`stepName`);if((d||f)&&a.push(kr(`step`,d,f,c)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?a.push(` ${Or(`retry`)} ${e} ${C(`attempts ·`)} ${n} ${C(`max retries`)}`):e!==void 0&&a.push(` ${Or(`retry`)} ${e} ${C(`attempts`)}`)}let p=K(t,`errorCode`);p&&p!==o&&a.push(` ${Or(`code`)} ${C(p)}`);let m=K(t,`hint`);m&&a.push(` ${fe(m)}`);let h=Object.entries(t).filter(([e,t])=>!i.has(e)&&!n.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of h)a.push(` ${Or(e)} ${Ar(t)}`);return a.length?a.join(`
|
|
14
|
+
`):null}function Er(e){if(!e)return null;let t=e.split(`
|
|
15
|
+
`),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(C(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&Dr(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(C(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
|
|
16
|
+
`)}function Dr(e){let t=e.trimStart();return t.startsWith(`at `)?!!(t.includes(`node:internal/`)||t.includes(`node_modules/.pnpm/`)||t.includes(`node_modules__pnpm_`)||t.includes(`_next_dist_`)||t.includes(`node_modules/next/`)||t.includes(`node_modules/@opentelemetry/`)||t.includes(`node_modules/vitest/`)||t.includes(`node_modules/@vitest/`)):!1}function K(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Or(e){return C(e.padEnd(6))}function kr(e,t,n,r){let a=t||C(`—`),s=n&&(e===`run`?o(n):i(n))?`${C(`·`)} ${r(n)}`:``;return` ${Or(e)} ${a}${s?` `+s:``}`}function Ar(e){if(typeof e==`string`)return e.includes(`
|
|
17
|
+
`)?e.split(`
|
|
18
|
+
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
19
|
+
`):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var jr=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,o=0,s=0,c=0,l=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?c++:e.abortRequested?l++:i++:e.type===`wait`?o++:e.type===`attribute`&&s++;let u=[];r>0&&u.push(`${r} ${a(`step`,`steps`,r)}`),i>0&&u.push(`${i} ${a(`hook`,`hooks`,i)}`),o>0&&u.push(`${o} ${a(`wait`,`waits`,o)}`),s>0&&u.push(`${s} ${a(`attribute write`,`attribute writes`,s)}`),c>0&&u.push(`${c} hook ${a(`disposal`,`disposals`,c)}`);let d=a(`has`,`have`,r+i+o+s+c),f=+(r>0)+ +(i>0)+ +(o>0)+ +(s>0)+ +(c>0),p;p=f>1?`processed`:r>0?`run`:i>0||o>0?`created`:s>0?`written`:c>0?`processed`:`received`;let m=u.length>0?`${u.join(` and `)} ${d} not been ${p} yet`:`0 steps have not been run yet`;super(m),this.name=`WorkflowSuspension`,this.steps=n,this.globalThis=t,this.stepCount=r,this.hookCount=i,this.waitCount=o,this.attributeCount=s,this.hookDisposedCount=c,this.abortCount=l}static is(t){return t instanceof e}};function Mr(){throw new u(`This API is not available inside a workflow function. Workflow functions run in a deterministic VM; move the call to a step function for full Node.js access.`)}function q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Nr=q(`workflow.name`),Pr=q(`workflow.operation`),Fr=q(`workflow.run.id`),Ir=q(`workflow.run.status`),Lr=q(`workflow.started_at`),Rr=q(`workflow.events.count`),zr=q(`workflow.arguments.count`),Br=q(`workflow.result.type`),Vr=q(`workflow.trace.propagated`),Hr=q(`workflow.trace.mode`),Ur=q(`workflow.turbo`),Wr=q(`workflow.error.name`),Gr=q(`workflow.error.message`),Kr=q(`workflow.error.code`),qr=q(`workflow.steps.created`),Jr=q(`workflow.hooks.created`),Yr=q(`workflow.waits.created`),Xr=q(`workflow.inline_ownership.owned_recovery_steps`),Zr=q(`workflow.inline_ownership.backstop_wakes_armed`),Qr=q(`workflow.route.type`),$r=q(`workflow.route.handler_cached`),ei=q(`workflow.route.invocation_count`),ti=q(`workflow.route.entrypoint_age_ms`),ni=q(`workflow.route.module_body_init_ms`),ri=q(`step.name`),ii=q(`step.id`),ai=q(`step.attempt`),oi=q(`step.status`),si=q(`step.max_retries`),ci=q(`step.ttfs_ms`),li=q(`step.stso_ms`),ui=q(`step.rsfs_ms`),di=q(`step.final_scheduling_replay_ms`),fi=q(`step.latency_optimizations`),pi=q(`step.skipped`),mi=q(`step.skip_reason`),hi=q(`step.arguments.count`),gi=q(`step.result.type`),_i=q(`step.error.name`),vi=q(`step.error.message`),yi=q(`step.fatal_error`),bi=q(`step.retry.exhausted`),xi=q(`step.retry.timeout_seconds`),Si=q(`step.retry.will_retry`),Ci=q(`messaging.system`),wi=q(`messaging.destination.name`),Ti=q(`messaging.message.id`),Ei=q(`messaging.operation.type`),Di=q(`workflow.queue.overhead_ms`),Oi=q(`deployment.id`),ki=q(`workflow.hook.token`),Ai=q(`workflow.hook.id`),ji=q(`workflow.hook.found`),Mi=q(`workflow.suspension.state`),Ni=q(`workflow.suspension.hook_count`),Pi=q(`workflow.suspension.step_count`),Fi=q(`workflow.suspension.wait_count`),Ii=q(`http.request.method`),Li=q(`http.route`),Ri=q(`http.response.status_code`),zi=q(`error.type`),Bi=q(`workflow.events.pages_loaded`),Vi=q(`workflow.queue.deserialize_time_ms`),Hi=q(`workflow.queue.execution_time_ms`),Ui=q(`workflow.queue.serialize_time_ms`),Wi=q(`workflow.serialization.operation`),Gi=q(`workflow.serialization.compressed`),Ki=q(`workflow.serialization.codec`),qi=q(`workflow.serialization.uncompressed_bytes`),Ji=q(`workflow.serialization.stored_bytes`),Yi=q(`workflow.serialization.compression_ratio`),Xi=q(`peer.service`),Zi=q(`rpc.system`),Qi=q(`rpc.service`),$i=q(`rpc.method`),ea=q(`error.retryable`),ta=q(`error.category`),na=new Set;function ra(){let e=process.env.WORKFLOW_TRACE_MODE;return e===`continuous`?`continuous`:(e&&e!==`linked`&&!na.has(e)&&(na.add(e),Y.warn(`Unrecognized WORKFLOW_TRACE_MODE value "${e}"; expected "linked" or "continuous". Falling back to "linked".`)),`linked`)}function ia(e){return e!==void 0&&Object.keys(e).length>0}function aa(e,t){return e===`linked`&&ia(t)?Promise.resolve(t):sa()}async function oa(e,t){if(e!==`linked`)return ba();let n=await xa(ia(t)?t:void 0);return n?[n]:void 0}async function sa(){let e=await J.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function ca(e){let t=await J.value;if(t)return t.propagation.extract(t.context.active(),e)}async function la(e,t){if(!e)return t();let n=await J.value;if(!n)return t();let r=await ca(e);return r?n.context.with(r,async()=>await t()):t()}const J=s(async()=>{try{return await import(`./src-D1EltLDA.js`).then(t=>e(t.t(),1))}catch{return Y.info(`OpenTelemetry not available, tracing will be disabled`),null}}),ua=s(async()=>{let e=await J.value;if(!e)return null;let t=e.trace.getTracer(`workflow`);return fa(e,t),t});let da=!1;function fa(e,t){let n=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);if(!(da||!n)){da=!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.core`);console.warn(`[workflow:otel-diag] core`,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] core failed:`,e instanceof Error?e.message:e)}}}async function pa(e,...t){let[n,r]=await Promise.all([ua.value,J.value]),{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}),ha(t,r,e),t}finally{e.end()}})}async function ma(e,t,n){let r=await ua.value;r&&r.startSpan(e,{...n,startTime:t}).end()}function ha(e,t,n){!e||!jr.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({...Mi(`suspended`),...Pi(e.stepCount),...Ni(e.hookCount),...Fi(e.waitCount)}))}async function ga(e){let[t,n]=await Promise.all([ca(e),J.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function _a(){return await ya(e=>e.trace.getActiveSpan())}async function va(e){return ya(t=>t.SpanKind[e])}async function ya(e){let t=await J.value;if(t)return await e(t)}function ba(){return ya(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function xa(e){if(!e)return;let[t,n]=await Promise.all([ga(e),J.value]);if(!(!t||!n)&&n.trace.isSpanContextValid(t))return{context:t}}async function Sa(e,t){let n=await J.value;if(!n)return t();let r=n.propagation.createBaggage({"workflow.run_id":{value:e.workflowRunId},"workflow.name":{value:e.workflowName}}),i=n.propagation.setBaggage(n.context.active(),r);return n.context.with(i,()=>t())}function Ca(e,t){if(!t)return!1;let n=!1;for(let r of t.split(`,`)){let t=r.trim();if(!t)continue;let i=t.startsWith(`-`),a=i?t.slice(1):t;RegExp(`^${a.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`)}$`).test(e)&&(n=!i)}return n}function wa(e,t={}){let n=r=>{let i=n=>t.debugNamespace??`workflow:${e}:${n}`,a=t=>{let n=i(t);return(i,a)=>{let o=Object.keys(r).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...r,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(wr(`[workflow-sdk]`,i,c)),Ca(n,process.env.DEBUG)&&(console.debug(`[${n}] ${i}`,c??``),_a().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:a(`debug`),info:a(`info`),warn:a(`warn`),error:a(`error`),child:e=>n({...r,...e}),forRun:(e,t,i)=>n({...r,workflowRunId:e,...t===void 0?{}:{workflowName:t},...i??{}})}};return n({})}const Ta=wa(`step`),Y=wa(`runtime`),Ea=wa(`webhook`),Da=wa(`events`);wa(`adapter`),wa(`build`,{debugNamespace:`workflow:build`});function Oa(e){if(_.is(e))throw e}function X(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof D&&t.path&&(r+=` at path "${t.path}"`);let i=`Ensure you're ${n} workflow serializable types. Check the serialization docs to see what's serializable: https://workflow-sdk.dev/docs/foundations/serialization`;return t instanceof D&&t.value!==void 0&&Y.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function ka(e,t,n){try{let r=H.serialize(e,`client`,n);return Sr(await yr(U(V.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){Oa(e);let{message:t,hint:n}=X(`client value`,e);throw new g(t,{hint:n,cause:e})}}async function Aa(e,t,n){let r=await br(await Cr(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function ja(e,t,n){try{let r=H.serialize(e,`step`,n);return Sr(await yr(U(V.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){Oa(e);let{message:t,hint:n}=X(`step value`,e);throw new g(t,{hint:n,cause:e})}}async function Ma(e,t,n){let r=await br(await Cr(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function Na(e,t){if(!(e instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=W(e);if(n===V.DEVALUE_V1)return H.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const Pa=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),Fa=globalThis[Pa]??(globalThis[Pa]=new ce);function Ia(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${a(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${a(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${a(`timer`,`timers`,n)}`);let i=[];e>0&&i.push(`steps are completed`),t>0&&i.push(`hooks are received`),n>0&&i.push(`timers have elapsed`);let o=i.join(` and `);return`${r.join(` and `)} to be enqueued\n Workflow will suspend and resume when ${o}`}function La(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function Ra(e){return`strm_${e}_system_abort`}function za(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return Ra(e.slice(5))}const Ba=()=>b(`WORKFLOW_DEFERRED_CHECK_DELAY_MS`,100,{integer:!0,min:10});var Z;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Z||={});var Va=class{eventIndex;events=[];callbacks=[];onConsumedEvent;onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,this.onConsumedEvent=t.onConsumedEvent,this.onUnconsumedEvent=t.onUnconsumedEvent,this.getPromiseQueue=t.getPromiseQueue}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}notifyConsumedEvent(e){if(this.onConsumedEvent)try{this.onConsumedEvent(e)}catch(e){Da.error(`onConsumedEvent callback threw an error`,{error:e})}}consume=()=>{for(;;){let e=this.events[this.eventIndex]??null;if(!this.consumeOne(e)){this.handleUnconsumed(e);return}}};consumeOne(e){for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Z.NotConsumed;try{r=n(e)}catch(e){Da.error(`EventConsumer callback threw an error`,{error:e})}if(!(r!==Z.Consumed&&r!==Z.Finished))return e!==null&&this.notifyConsumedEvent(e),this.eventIndex++,r===Z.Finished&&this.callbacks.splice(t,1),e!==null}return!1}handleUnconsumed(e){if(e!==null){let t=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===t&&(this.pendingUnconsumedCheck=null,this.onUnconsumedEvent(e))},Ba())})}}},Ha=class{aborted=!1;reason=void 0;[N];[P];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[N]=e,this[P]=t}_setAborted(e){if(!this.aborted){this.aborted=!0,this.reason=e,this.#t&&this.#t.call(this);for(let e of this.#e)e();this.#e=[]}}addEventListener(e,t){if(e===`abort`){if(this.aborted){t();return}this.#e.push(t)}}removeEventListener(e,t){e===`abort`&&(this.#e=this.#e.filter(e=>e!==t))}throwIfAborted(){if(this.aborted)throw this.reason??new DOMException(`The operation was aborted.`,`AbortError`)}};function Ua(e){return class{signal;[N];[P];constructor(){let t=e.generateUlid(),n=Ra(t),r=`abrt_${t}`;this[N]=n,this[P]=r,this.signal=new Ha(n,r);let i=`hook_${e.generateUlid()}`;e.invocationsQueue.set(i,{type:`hook`,correlationId:i,token:r,isWebhook:!1,isSystem:!0}),e.eventsConsumer.subscribe(t=>{if(!t||t.correlationId!==i)return Z.NotConsumed;let n=`eventData`in t&&t.eventData&&`token`in t.eventData?t.eventData.token:void 0;if(typeof n==`string`&&n!==this[P])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new h(`Replay divergence: abort hook event ${t.eventType} for ${i} belongs to token "${n}", but the current abort hook expects "${this[P]}"`,{eventId:t.eventId}))}),Z.Finished;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(i);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Z.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload;return e.pendingDeliveries++,e.promiseQueue=e.promiseQueue.then(async()=>{let r;try{if(n!==void 0)try{let i=await e.replayPayloadCache.prepareEventPayload(t.eventId,`payload`,n),a=await Ho(n,e.runId,e.encryptionKey,e.globalThis,{},i);a&&typeof a==`object`&&`reason`in a&&(r=a.reason)}catch{}this.signal._setAborted(r)}finally{e.pendingDeliveries--}}),e.invocationsQueue.delete(i),Z.Consumed}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(i),Z.Finished):Z.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[P]){n.abortRequested=!0,n.abortReason=t;break}}}}}function Wa(){return{abort(e){let t=new Ha(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new Ha(``,``),n=Array.from(e);for(let e of n)if(e.aborted)return t._setAborted(e.reason),t;let r=[],i=()=>{for(let{signal:e,listener:t}of r)e.removeEventListener&&e.removeEventListener(`abort`,t);r.length=0};for(let e of n){if(!e.addEventListener)continue;let n=()=>{t.aborted||(t._setAborted(e.reason),i())};r.push({signal:e,listener:n}),e.addEventListener(`abort`,n)}return t},timeout(){throw Error(`AbortSignal.timeout() is not supported in workflow functions. Use sleep() with an AbortController instead. See: /docs/errors/abort-signal-timeout-in-workflow`)}}}const Ga=ie();function Ka(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function qa(e){return Oa(e),e instanceof g&&e.cause!==void 0||e instanceof u&&e.cause!==void 0?e.cause:e}async function Q(e,t){if(e.recorded)try{let n=await _a();if(!n)return;let r=e.uncompressedBytes??0,i=e.storedBytes??0;n.setAttributes({...Wi(t),...Gi(e.compressed??!1),...Ki(e.codec??`none`),...qi(r),...Ji(i),...e.compressed&&r>0?Yi(1-i/r):{}})}catch{}}function Ja(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0};return new TransformStream({async transform(i,a){try{r.resolved||=(r.key=await xr(t),!0);let o=k(i,e),s=n.encode(o),c=U(V.DEVALUE_V1,s);if(r.key){let e=await tn(r.key,c);c=U(V.ENCRYPTED,e)}let l=new Uint8Array(4+c.length);new DataView(l.buffer).setUint32(0,c.length,!1),l.set(c,4),a.enqueue(l)}catch(e){if(_.is(e)){a.error(e);return}let{message:t,hint:n}=X(`stream chunk`,e);a.error(new g(t,{hint:n,cause:e}))}}})}function Ya(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0};function a(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function o(a){for(i.resolved||=(i.key=await xr(t),!0);r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let o=r.slice(4,4+t);r=r.slice(4+t);let{format:s,payload:c}=W(o);if(s===V.ENCRYPTED){if(!i.key){a.error(new _(`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:c.byteLength,formatPrefix:`encr`}}));return}let e;try{e=await nn(i.key,c)}catch(e){throw _.is(e)&&e.context&&(e.context.formatPrefix=s),e}({format:s,payload:c}=W(e))}if(s===V.DEVALUE_V1){let t=n.decode(c);a.enqueue(Yt(t,e))}}}return new TransformStream({async transform(t,i){if(r.length===0&&t.length>=4){let e=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!1);if(e>0&&e<1e8){a(t),await o(i);return}}else if(r.length>0){a(t),await o(i);return}let s=n.decode(t).split(`
|
|
20
|
+
`);for(let t of s)t.length>0&&i.enqueue(Yt(t,e))},async flush(e){r.length>0&&await o(e)}})}const Xa=1e8;function Za(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>Xa){t.error(new u(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${Xa}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function Qa(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>Xa){r.error(new u(`Byte-stream frame length ${t} exceeds maximum (${Xa}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new u(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function $a(e,t,n,r,i){(async()=>{await ma(`workflow.stream.read`,e,{kind:await va(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof i==`number`?{"workflow.stream.read.connect_ms":i}:{},...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}function eo(e,t,n,r,i,a){(async()=>{await ma(`workflow.stream.read.complete`,e,{kind:await va(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read_complete`,"workflow.stream.read.total_ms":Date.now()-e,"workflow.stream.read.chunks":r,"workflow.stream.read.bytes":i,...typeof a==`number`?{"workflow.stream.read.reconnects":a}:{}}})})()}var to=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new u(`"name" is required, got "${t}"`);let r,i=!1,a,o=0,s=0;super({type:`bytes`,pull:async c=>{let l=this.#e;if(!l){r===void 0&&(r=Date.now());let i=await L(),o=Date.now(),s=await i.streams.get(e,t,n);a=Date.now()-o,l=this.#e=s.getReader()}if(!l){c.error(Error(`Failed to get reader`));return}let u=await l.read();u.done?(this.#e=void 0,r!==void 0&&eo(r,e,t,o,s),c.close()):(!i&&u.value.byteLength>0&&r!==void 0&&(i=!0,$a(r,e,t,n,a)),o+=1,s+=u.value.byteLength,c.enqueue(u.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const no=()=>b(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),ro=()=>b(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,1e3,{integer:!0,min:1});function io(e,t,n){let r=n===void 0||n>=0,i=n??0,a=0,o=0,s=0,c,l=new Uint8Array,u,d,f=!1,p=0,m=0;async function h(){let o=await L(),s=r?i+a:n,l=Date.now(),u=await o.streams.get(e,t,s);d===void 0&&(d=Date.now()-l),c=u.getReader()}async function g(){c&&=(await c.cancel().catch(()=>{}),void 0),i+=a,a=0,l=new Uint8Array;let e=no(),n=ro();for(;;){if(o++,s++,o>e)throw Error(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(s>n)throw Error(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{await h();return}catch{}}}return new ReadableStream({pull:async i=>{for(u===void 0&&(u=Date.now());;){if(!c)try{await h()}catch(e){i.error(e);return}let _;try{_=await c.read()}catch(e){if(!r){i.error(e);return}try{await g()}catch(e){i.error(e);return}continue}if(_.done||!_.value){c=void 0,u!==void 0&&eo(u,e,t,p,m,s),i.close();return}let v=_.value;if(v.length>0){let e=new Uint8Array(l.length+v.length);e.set(l,0),e.set(v,l.length),l=e}let y=!1;for(;l.length>=4;){let r=4+new DataView(l.buffer,l.byteOffset,l.byteLength).getUint32(0,!1);if(l.length<r)break;i.enqueue(l.slice(0,r)),l=l.slice(r),a++,p++,m+=r,!f&&u!==void 0&&(f=!0,$a(u,e,t,n,d)),y=!0}if(y){o=0;return}}},cancel:async()=>{c&&=(await c.cancel().catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)}),void 0)}})}const ao=()=>b(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,10,{integer:!0});function oo(e,t,n,r,i,a,o){(async()=>{await ma(`workflow.stream.flush`,e,{kind:await va(`CLIENT`),attributes:{"workflow.run.id":n,"workflow.stream.name":r,"workflow.stream.operation":`flush`,"workflow.stream.flush.buffer_dwell_ms":t-e,"workflow.stream.flush.chunks":i,"workflow.stream.flush.bytes":a,"workflow.stream.write.chunk_rtt":o}})})()}function so(e,t,n){(async()=>{await ma(`workflow.stream.close`,e,{kind:await va(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`close`,"workflow.stream.close.rpc_ms":Date.now()-e}})})()}var $=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new u(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new u(`"name" is required, got "${t}"`);let r=L(),i=n,a=async()=>{if(i){try{await i}catch{}i=void 0}},o=[],s=null,c=null,l,d,f=async()=>{if(s&&=(clearTimeout(s),null),o.length===0)return;await a();let n=o.slice(),i=d;d=void 0;let c=Date.now(),u=await r;l===void 0&&(l=u.streamFlushIntervalMs??ao());let f=Date.now();try{if(typeof u.streams.writeMulti==`function`&&n.length>1)await u.streams.writeMulti(e,t,n);else for(let r of n)await u.streams.write(e,t,r)}catch(e){throw i!==void 0&&(d=d===void 0?i:Math.min(d,i)),e}i!==void 0&&oo(i,c,e,t,n.length,n.reduce((e,t)=>e+t.byteLength,0),Date.now()-f),o=[]},p=[],m=()=>{s||=setTimeout(()=>{s=null;let e=p;p=[],c=f().then(()=>{for(let t of e)t.resolve()},t=>{for(let n of e)n.reject(t)})},l??ao())};super({async write(e){d===void 0&&(d=Date.now()),c&&=(await c,null),o.push(e),m(),await new Promise((e,t)=>{p.push({resolve:e,reject:t})})},async close(){c&&=(await c,null),await f(),await a();let n=await r,i=Date.now();await n.streams.close(e,t),so(i,e,t)},abort(e){s&&=(clearTimeout(s),null),o=[];let t=p;p=[];let n=e??Error(`Stream aborted`);for(let e of t)e.reject(n)}}),Object.defineProperty(this,fn,{value:async e=>{if(e.length!==0){d===void 0&&(d=Date.now());for(let t of e)o.push(t);await f()}},enumerable:!1,writable:!1})}};function co(e=globalThis){return{...Un(),...Qn(),...Xn(e),Request:t=>{if(!(t instanceof e.Request))return!1;let n={method:t.method,url:t.url,headers:t.headers,body:t.body,duplex:t.duplex},r=t[mn];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[N])&&(n.signal=t.signal),n},Response:t=>t instanceof e.Response?{type:t.type,url:t.url,status:t.status,statusText:t.statusText,headers:t.headers,body:t.body,redirected:t.redirected}:!1}}function lo(e,t,n,r,i,a){let o=t[N],s=t[P];if(!o){let e=(n[ln]||Ga)();o=Ra(e),s=`abrt_${e}`,t[N]=o,t[P]=s,t.signal&&(t.signal[N]=o,t.signal[P]=s)}return fo(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function uo(e,t){let n=t[N]??t.signal?.[N],r=t[P]??t.signal?.[P];if(!n)throw Error(`AbortController/AbortSignal stream name is not set`);return{streamName:n,hookToken:r,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function fo(e,t,n,r,i){e.aborted||e[gn]||(e[gn]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await xr(r),a=await Fo({aborted:!0,reason:e.reason},n,i),o=new $(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function po(e=globalThis,t,n,r,i=!1,a){return{...co(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new g(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=`strm_${(e[ln]||Ga)()}`,c=Ka(o),l=new $(n,s,a);c===`bytes`?i?t.push(o.pipeThrough(Za()).pipeTo(l)):t.push(o.pipeTo(l)):t.push(o.pipeThrough(Ja(po(e,t,n,r,i,a),r)).pipeTo(l));let u={name:s};return c&&(u.type=c),c===`bytes`&&i&&(u.framing=`framed-v1`),u},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[A],a=r[j];if(typeof i==`string`&&typeof a==`string`){let e={name:i,runId:a},t=r[M];return typeof t==`string`&&(e.deploymentId=t),e}let o=`strm_${(e[ln]||Ga)()}`,s=new to(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:lo(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:lo(i,i,e,t,n,r)}}function mo(e=globalThis){return{...co(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[pn];if(n!==void 0)return{bodyInit:n};let r=t[A];if(!r)throw new u("ReadableStream `name` is not set");let i={name:r},a=t[un];a&&(i.type=a);let o=t[dn];return o&&(i.framing=o),i},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[A];if(!n)throw new u("WritableStream `name` is not set");let r={name:n},i=t[j];typeof i==`string`&&(r.runId=i);let a=t[M];return typeof a==`string`&&(r.deploymentId=a),r},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[N]??n.signal?.[N],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:uo(t.signal,n)},AbortSignal:t=>{let n=t?.[N],r=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!n&&!r?!1:uo(t,t)}}}function ho(e=globalThis,t,n,r,i=!1,a){return{...co(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new g(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=o[A],c=o[un],l=o[dn];if(!s){s=`strm_${(e[ln]||Ga)()}`,c=Ka(o),l=c===`bytes`&&i?`framed-v1`:l;let u=new $(n,s,a);c===`bytes`?l===`framed-v1`?t.push(o.pipeThrough(Za()).pipeTo(u)):t.push(o.pipeTo(u)):t.push(o.pipeThrough(Ja(ho(e,t,n,r,i,a),r)).pipeTo(u))}let u={name:s};return c&&(u.type=c),l&&(u.framing=l),u},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[A],o=i[j];a||(a=`strm_${(e[ln]||Ga)()}`,t.push(new to(n,a).pipeThrough(Ya(Eo(e,t,n,r),r)).pipeTo(i)));let s={name:a};typeof o==`string`&&(s.runId=o);let c=i[M];return typeof c==`string`&&(s.deploymentId=c),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:lo(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:lo(i,i,e,t,n,r)}}function go(...e){let t=new WeakSet;function n(e){let t=e[_n];t&&!t.signal.aborted&&t.abort()}function r(e){if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function _o(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new to(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=Fa.getStore(),r=await Io(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function vo(e,t,n){let r=e,i=e.signal;r[N]=t.streamName,r[P]=t.hookToken,i[N]=t.streamName,i[P]=t.hookToken,n&&(r[_n]=n,i[_n]=n)}function yo(e,t){let n=e,r=t;n[N]!==void 0&&(r[N]=n[N]),n[P]!==void 0&&(r[P]=n[P]),n[_n]!==void 0&&(r[_n]=n[_n])}function bo(e,t,n){let r=new AbortController;e.aborted?(vo(r,e),r.abort(e.reason)):e.streamName?vo(r,e,_o(r,n,e.streamName,t)):vo(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=Fa.getStore();if(n&&(n.ops.push((async()=>{try{let r=await Fo({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new $(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-czpG5xnP.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function xo(e,t,n){let r=new AbortController;return e.aborted?(vo(r,e),r.abort(e.reason)):e.streamName?vo(r,e,_o(r,n,e.streamName,t)):vo(r,e),r.signal}function So(e=globalThis){return{...Wn(e),...Zn(e)}}async function Co(e,t){let n=await L();if(!n.getEncryptionKeyForRun)return;let r=t?await n.getEncryptionKeyForRun(e,{deploymentId:t}):await n.getEncryptionKeyForRun(await n.runs.get(e));return r?await en(r,[`encrypt`]):void 0}function wo(e=globalThis,t,n,r){return{...So(e),StepFunction:()=>{throw new g(`Step functions cannot be deserialized in client context. Step functions should not be returned from workflows.`,{hint:`A step function reference reached the client. Return a serializable value (e.g. the step result) instead of the step itself.`})},WorkflowFunction:e=>Object.assign(()=>{throw new g(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(n.signal=t.signal);let r=new e.Request(t.url,n);return t.signal&&yo(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}if(i.type===`bytes`){let r=new to(n,i.name,i.startIndex),a=F();t.push(a.promise);let{readable:o,writable:s}=i.framing===`framed-v1`?Qa():new e.TransformStream;return I(r,s,a).catch(()=>{}),Tn(o,a),o}else{let a=io(n,i.name,i.startIndex),o=Ya(wo(e,t,n,r),r),s=F();return t.push(s.promise),I(a,o.writable,s).catch(()=>{}),Tn(o.readable,s),o.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:Co(a,i.deploymentId),s=Ja(po(e,t,a,o),o),c=new $(a,i.name),l=F();return t.push(l.promise),I(s.readable,c,l).catch(()=>{}),wn(s.writable,l),Object.defineProperty(s.writable,A,{value:i.name,writable:!1}),Object.defineProperty(s.writable,j,{value:a,writable:!1}),typeof i.deploymentId==`string`&&Object.defineProperty(s.writable,M,{value:i.deploymentId,writable:!1}),s.writable},AbortController:e=>bo(e,t,n),AbortSignal:e=>xo(e,t,n)}}function To(e=globalThis){return{...So(e),...$n(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[mn]=n,delete t.responseWritable,t.respondWith=()=>{throw new g("`respondWith()` must be called from within a step function.",{hint:'Move the `respondWith(...)` call inside a `"use step"` function — it cannot be invoked from a workflow context.'})}),t},WorkflowFunction:e=>Object.assign(()=>{throw new g(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Response:t=>(Object.setPrototypeOf(t,e.Response.prototype),t),ReadableStream:t=>`bodyInit`in t?Object.create(e.ReadableStream.prototype,{[pn]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[A]:{value:t.name,writable:!1},[un]:{value:t.type,writable:!1},[dn]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[A]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[j]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[M]={value:t.deploymentId,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new Ha(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[N]:e.streamName,[P]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new Ha(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function Eo(e=globalThis,t,n,r,i){return{...So(e),StepFunction:e=>{let t=e.stepId,n=e.closureVars,r=`boundThis`in e,i=r?e.boundThis:void 0,a=Array.isArray(e.boundArgs)?e.boundArgs:[],o=oe(t);if(!o)throw new g(`Step function "${t}" not found. Make sure the step function is registered.`,{hint:`Make sure the step file is included in your build (i.e. it is listed in the workflow manifest), and that the SWC plugin is configured for the file.`});if(!n&&!r&&a.length===0)return o;let s=function(...e){let t=r?i:this,s=a.length>0?[...a,...e]:e;if(n){let e=Fa.getStore();if(!e)throw new u(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return Fa.run(r,()=>o.apply(t,s))}return o.apply(t,s)};return Object.defineProperty(s,"name",{value:o.name}),Object.defineProperty(s,"stepId",{value:t,writable:!1,enumerable:!1,configurable:!1}),o.maxRetries!==void 0&&(s.maxRetries=o.maxRetries),s},WorkflowFunction:e=>Object.assign(()=>{throw new g(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n=t.responseWritable,r={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(r.signal=t.signal);let i=new e.Request(t.url,r);return t.signal&&yo(t.signal,i.signal),n&&(i.respondWith=async e=>{let t=n.getWriter();await t.write(e),await t.close()}),i},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:a=>{if(`bodyInit`in a){let t=a.bodyInit;return new e.Response(t).body}let o=new to(n,a.name);if(a.type===`bytes`){let n=F();t.push(n.promise);let{readable:r,writable:i}=a.framing===`framed-v1`?Qa():new e.TransformStream;return I(o,i,n).catch(()=>{}),Tn(r,n),r}else{let a=Ya(Eo(e,t,n,r,i),r),s=F();return t.push(s.promise),I(o,a.writable,s).catch(()=>{}),Tn(a.readable,s),a.readable}},WritableStream:a=>{let o=typeof a.runId==`string`?a.runId:n,s=typeof a.deploymentId==`string`?a.deploymentId:o===n?i:void 0,c=o===n?r:Co(o,s),l=Ja(ho(e,t,o,c),c),u=new $(o,a.name),d=F();return t.push(d.promise),I(l.readable,u,d).catch(()=>{}),wn(l.writable,d),Object.defineProperty(l.writable,A,{value:a.name,writable:!1}),Object.defineProperty(l.writable,j,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,M,{value:s,writable:!1}),l.writable},AbortController:e=>bo(e,t,n),AbortSignal:e=>xo(e,t,n)}}async function Do(e,t){return await Sr(e,t)}const Oo=async(e,t)=>{let n={},r=await br(await Cr(e,t),n);return await Q(n,`deserialize`),{data:r}};function ko(e,t=globalThis,n={}){return Na(e.data,{global:t,extraRevivers:{...Go(To(t)),...n}})}function Ao(e,t=globalThis,n={}){let{data:r}=e;if(!(r instanceof Uint8Array))return Xt(r,{...To(t),...n});let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return Yt(new TextDecoder().decode(a),{...To(t),...n});throw Error(`Unsupported serialization format: ${i}`)}async function jo(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1){if(a)return Kn(k(e,po(i,r,t,n,o)));try{let a={},c=await ka(e,n,{global:i,extraReducers:Wo(po(i,r,t,n,o)),compression:s,compressionStats:a});return await Q(a,`serialize`),c}catch(e){let t=qa(e),{message:n,hint:r}=X(`workflow arguments`,t);throw new g(n,{hint:r,cause:t})}}async function Mo(e,t,n,r=globalThis,i={},a){return ko(a??await Oo(e,n),r,i)}async function No(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Kn(k(e,mo(r)));try{let t={},i=await ja(e,n,{global:r,extraReducers:Wo(mo(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=qa(e),{message:n,hint:r}=X(`workflow return value`,t);throw new g(n,{hint:r,cause:t})}}async function Po(e,t,n,r=[],i=globalThis,a={}){let o={},s=await Aa(e,n,{global:i,extraRevivers:{...Go(wo(i,r,t,n)),...a},compressionStats:o});return await Q(o,`deserialize`),s}async function Fo(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Kn(k(e,mo(r)));try{let t={},i=await ja(e,n,{global:r,extraReducers:Wo(mo(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=qa(e),{message:n,hint:r}=X(`step arguments`,t);throw new g(n,{hint:r,cause:t})}}async function Io(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await Ma(e,n,{global:i,extraRevivers:{...Go(Eo(i,r,t,n,o)),...a},compressionStats:s});return await Q(s,`deserialize`),c}async function Lo(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c){if(a)return Kn(k(e,ho(i,r,t,n,o,c)));try{let a={},l=await ja(e,n,{global:i,extraReducers:Wo(ho(i,r,t,n,o,c)),compression:s,compressionStats:a});return await Q(a,`serialize`),l}catch(e){let t=qa(e),{message:n,hint:r}=X(`step return value`,t);throw new g(n,{hint:r,cause:t})}}async function Ro(e,t,n,r=[],i=globalThis,a=!1){try{let o=k(e,ho(i,r,t,n)),s=new TextEncoder().encode(o),c=U(V.DEVALUE_V1,s),l={},u=await Do(await yr(c,a,l),n);return await Q(l,`serialize`),u}catch(e){let t=qa(e),{message:n,hint:r}=X(`step error`,t);throw new g(n,{hint:r,cause:t})}}async function zo(e,t,n,r=globalThis,i={},a){return Ao(a??await Oo(e,n),r,i)}async function Bo(e,t,n,r=globalThis,i=!1){try{let t=k(e,mo(r)),a=new TextEncoder().encode(t),o=U(V.DEVALUE_V1,a),s={},c=await Do(await yr(o,i,s),n);return await Q(s,`serialize`),c}catch(e){let t=qa(e),{message:n,hint:r}=X(`run error`,t);throw new g(n,{hint:r,cause:t})}}async function Vo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await br(await Cr(e,n),o);if(await Q(o,`deserialize`),!(s instanceof Uint8Array))return Xt(s,{...wo(i,r,t,n),...a});let{format:c,payload:l}=W(s);if(c===V.DEVALUE_V1)return Yt(new TextDecoder().decode(l),{...wo(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${c}`)}async function Ho(e,t,n,r=globalThis,i={},a){return ko(a??await Oo(e,n),r,i)}const Uo=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function Wo(e){let t={};for(let n of Uo)n in e&&(t[n]=e[n]);return t}function Go(e){let t={};for(let n of Uo)n in e&&(t[n]=e[n]);return t}const Ko=[{format:V.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:V.GZIP,minVersion:`5.0.0-beta.18`},{format:V.ZSTD,minVersion:`5.0.0-beta.18`}],qo=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],Jo=new Set([V.DEVALUE_V1]);function Yo(e){if(!e||!$t.default.valid(e))return{supportedFormats:Jo,framedByteStreams:!1};let t=new Set(Jo);for(let{format:n,minVersion:r}of Ko)$t.default.gte(e,r)&&t.add(n);let n={supportedFormats:t,framedByteStreams:!1};for(let{capability:t,minVersion:r}of qo)$t.default.gte(e,r)&&(n[t]=!0);return n}const Xo=`5.0.0-beta.36`,Zo=/^[a-zA-Z0-9_\-./@]+$/;function Qo(e,t){if(!Zo.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${te(`workflow`,ae(t))}${e}`}const $o=ie();function es(e){return`__health_check__${e}`}function ts(e){let t=ne.safeParse(e);if(t.success)return t.data}function ns(e){return`wrun_hc_${e}`}async function rs(e,t,n){let r=await L(),i=es(e.correlationId),a=JSON.stringify({healthy:!0,endpoint:t,correlationId:e.correlationId,specVersion:n??5,workflowCoreVersion:Xo,timestamp:Date.now()}),o=ns(e.correlationId);await r.streams.write(o,i,a),await r.streams.close(o,i)}function is(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function as(e,t){let n=[],r=!1,i=!1;for(;!r&&!i;){let a=e.read(),o=new Promise(e=>setTimeout(()=>{i=!0,e({done:!0,value:void 0})},t)),s=await Promise.race([a,o]);r=s.done,s.value&&n.push(s.value)}return{chunks:n,timedOut:i}}function os(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),s}async function ss(e,t,n){let r=n?.timeout??3e4,i=e.createRunId?.()??$o(),a=es(i),o=`${te(t,ae(n?.namespace))}health_check`,s=Date.now();try{for(await e.queue(o,{__healthCheck:!0,correlationId:i},{specVersion:1,deploymentId:n?.deploymentId});Date.now()-s<r;)try{let t=r-(Date.now()-s),n=(await is(e.streams.get(ns(i),a),t)).getReader(),{chunks:o,timedOut:c}=await as(n,500);if(c){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=os(o);if(l)return{...l,latencyMs:Date.now()-s};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${r}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}function cs(e,t){return new l(`Event pagination ${t} for workflow run "${e}".`,{code:d.WORLD_CONTRACT_ERROR})}function ls(e,t,n){if(t){if(n.has(t))throw cs(e,`did not advance`);n.add(t)}}function us(e,t,n){for(let r of n)t.has(r.eventId)||(t.add(r.eventId),e.push(r))}function ds(e,t,n,r){if(t){if(n===null)throw cs(e,`returned more pages without a cursor`);if(r.has(n))throw cs(e,`repeated a cursor`)}}function fs(e,t,n){return t!==null&&!n&&l.is(e)&&e.status===400}async function ps(e,t){let n=t!==void 0;return pa(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...Fr(e)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await L(),f=Date.now();for(;c;){let t=Date.now(),r=s;ls(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(fs(t,r,u)){Y.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,u=!0;continue}throw t}us(i,a,f.data),c=f.hasMore,ds(e,c,f.cursor,o),s=f.cursor??s,l++,Y.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return Y.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...Rr(i.length),...Bi(l)}),{events:i,cursor:s}})}function ms(){return process.env.WORKFLOW_PRECONDITION_GUARD!==`0`}function hs(e){let t=e[e.length-1];if(!t)return;let n=t.eventId,r=n.lastIndexOf(`_`),i=re(r===-1?n:n.slice(r+1))?.getTime();if(i===void 0){Y.debug(`Precondition guard: latest event id is not a decodable ULID; sending no snapshot`,{eventId:n});return}return i}function gs(e){return ms()?hs(e):void 0}async function _s(e,t,n){for(let r=0;;r++)try{return await n(gs(t.events))}catch(n){if(!p.is(n)||r>=2)throw n;Y.info(`Event creation rejected as stale; reloading event log and retrying`,{workflowRunId:e,attempt:r+1,maxRetries:2});let i=await ps(e,t.cursor??void 0);us(t.events,new Set(t.events.map(e=>e.eventId)),i.events),t.cursor=i.cursor??t.cursor}}const vs={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function ys(e,t){return async n=>{let r=new URL(n.url);return r.searchParams.has(`__health`)?n.method===`OPTIONS`?new Response(null,{status:204,headers:vs}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??5,workflowCoreVersion:Xo}),{status:200,headers:{"Content-Type":`application/json`,...vs}}):await e(n)}}async function bs(e,...t){let n=t[0];await pa(`queue.publish`,{attributes:{...Ci(`vercel-queue`),...wi(n),...Ei(`publish`),...Xi(`vercel-queue`),...Zi(`vercel-queue`),...Qi(`vqs`),...$i(`publish`)},kind:await va(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(Ti(r))})}function xs(e){if(e.requestedAt)try{return Di(Date.now()-e.requestedAt.getTime())}catch{return}}function Ss(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await en(n):void 0})(),n)}function Cs(t){import(`./functions-Dv8dc_-I.js`).then(t=>e(t.default,1)).then(({waitUntil:e})=>{e(t)})}function ws(e,t){Cs(e.catch(e=>{if(!(e?.name===`AbortError`||e?.name===`ResponseAborted`))try{t(e)}catch{}}))}async function Ts(e){let t=e();return Cs(t.catch(()=>{})),t}function Es(e,t={}){if(typeof e!=`object`||!e||Array.isArray(e))throw new m(`setAttributes requires a plain object, got ${e===null?`null`:Array.isArray(e)?`array`:typeof e}`);let n=Object.entries(e).map(([e,t])=>({key:e,value:t===void 0?null:t}));if(n.length===0)return n;let r=t.allowReservedAttributes===!0;try{ee(n,{allowReservedAttributes:r})}catch(e){throw e instanceof y?new m(e.message):e}return n}export{sa as $,ei as $t,Io as A,cn as An,gi as At,Ia as B,Ae as Bn,zr as Bt,Lo as C,pn as Cn,_i as Ct,wo as D,j as Dn,fi as Dt,po as E,M as En,ii as Et,Oo as F,Me as Fn,mi as Ft,Ta as G,Rr as Gt,La as H,Oe as Hn,Kr as Ht,Wa as I,Pe as In,pi as It,aa as J,Pr as Jt,Ea as K,Jr as Kt,Ua as L,Ne as Ln,oi as Lt,Ho as M,sn as Mn,xi as Mt,Mo as N,rn as Nn,Si as Nt,Ja as O,mn as On,si as Ot,Po as P,en as Pn,ui as Pt,xa as Q,$r as Qt,Z as R,Fe as Rn,li as Rt,Ro as S,wn as Sn,vi as St,No as T,A as Tn,di as Tt,Fa as U,De as Un,Gr as Ut,za as V,je as Vn,Zr as Vt,Y as W,ke as Wn,Wr as Wt,ra as X,Br as Xt,va as Y,Xr as Yt,ia as Z,ti as Zt,Yo as _,Ln as _n,Vi as _t,Qo as a,qr as an,ea as at,Bo as b,F as bn,hi as bt,ms as c,Ur as cn,Ai as ct,ts as d,jr as dn,Ri as dt,ni as en,pa as et,bs as f,V as fn,Li as ft,Xo as g,Rn as gn,Ci as gt,_s as h,Hn as hn,Ei as ht,xs as i,Lr as in,ta as it,zo as j,an as jn,bi as jt,Vo as k,on as kn,ri as kt,ps as l,Yr as ln,ki as lt,ys as m,Vn as mn,Ti as mt,ws as n,Fr as nn,Sa as nt,rs as o,Hr as on,zi as ot,gs as p,Bn as pn,wi as pt,oa as q,Nr as qt,Ts as r,Ir as rn,Oi as rt,ss as s,Vr as sn,ji as st,Es as t,Qr as tn,la as tt,Ss as u,Mr as un,Ii as ut,$ as v,L as vn,Hi as vt,jo as w,ln as wn,yi as wt,Fo as x,I as xn,ai as xt,go as y,Nn as yn,Ui as yt,Va as z,Ie as zn,ci as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(e&&(t=e(e=0)),t),c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),f=e(import.meta.url);export{
|
|
1
|
+
import{createRequire as e}from"node:module";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(e&&(t=e(e=0)),t),c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),f=e=>o.call(e,`module.exports`)?e[`module.exports`]:u(n({},`__esModule`,{value:!0}),e),p=e(import.meta.url);export{f as a,p as i,s as n,d as o,l as r,c as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{o as e}from"./dist-CrxV2rsR.js";const t={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`};function n(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function r(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
|
+
`).forEach((e,t)=>n.push(`${t===0?a:o}${e}`))}),n.join(`
|
|
3
|
+
`)}function i(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 a={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`};var o=class extends Error{cause;constructor(e,t){let n=r(e,i(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 n(e)&&e.name===`WorkflowError`}},s=class extends o{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 n(e)&&e.name===`WorkflowWorldError`}},c=class extends o{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 n(e)&&e.name===`WorkflowRunFailedError`}},l=class extends o{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 n(e)&&e.name===`WorkflowRunNotCompletedError`}},u=class extends o{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return n(e)&&e.name===`WorkflowRuntimeError`}},d=class extends u{constructor(e,t){super(e,{...t,slug:a.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return n(e)&&e.name===`CorruptedEventLogError`}},f=class extends u{eventId;constructor(e,t){super(e,{...t,slug:a.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return n(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},p=class extends o{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 n(e)&&e.name===`MaxEventsExceededError`}},m=class extends u{constructor(e,t){super(e,{cause:t?.cause,slug:a.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return n(e)&&e.name===`RuntimeDecryptionError`}},h=class extends o{hint;constructor(e,t){let n=r(e,i(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return n(e)&&e.name===`WorkflowBuildError`}},g=class extends o{hint;fatal=!0;constructor(e,t){let n=r(e,i(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return n(e)&&e.name===`SerializationError`}},_=class extends u{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:a.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return n(e)&&e.name===`StepNotRegisteredError`}},v=class extends u{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:a.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return n(e)&&e.name===`WorkflowNotRegisteredError`}},y=class extends o{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return n(e)&&e.name===`WorkflowRunNotFoundError`}},b=class extends o{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:a.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return n(e)&&e.name===`HookConflictError`}},x=class extends o{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return n(e)&&e.name===`HookNotFoundError`}},S=class extends s{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return n(e)&&e.name===`EntityConflictError`}},C=class extends s{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return n(e)&&e.name===`RunExpiredError`}},w=class extends s{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return n(e)&&e.name===`TooEarlyError`}},T=class extends s{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return n(e)&&e.name===`ThrottleError`}},E=class extends s{constructor(e,t){super(e,{status:412,retryAfter:t?.retryAfter}),this.name=`PreconditionFailedError`}static is(e){return n(e)&&e.name===`PreconditionFailedError`}},D=class extends o{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return n(e)&&e.name===`WorkflowRunCancelledError`}},O=class extends o{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 n(e)&&e.name===`RunNotSupportedError`}},k=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return n(e)?e.name===`FatalError`?!0:e.fatal===!0:!1}},A=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 n(e)&&e.name===`RetryableError`}};const j="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.",M=Symbol.for(`@workflow/errors//FatalError`),N=Symbol.for(`@workflow/errors//RetryableError`),P=Symbol.for(`@workflow/errors//HookConflictError`),F=Symbol.for(`@workflow/errors//RuntimeDecryptionError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,M)||Object.defineProperty(globalThis,M,{value:k,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,N)||Object.defineProperty(globalThis,N,{value:A,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,P)||Object.defineProperty(globalThis,P,{value:b,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,F)||Object.defineProperty(globalThis,F,{value:m,writable:!1,enumerable:!1,configurable:!1}));export{c as C,s as D,u as E,t as O,D as S,y as T,w as _,b as a,o as b,E as c,C as d,O as f,T as g,_ as h,k as i,f as l,g as m,a as n,x as o,m as p,S as r,p as s,d as t,A as u,j as v,l as w,v as x,h as y};
|