experimental-ash 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/docs/public/advanced/hooks.mdx +8 -2
- package/dist/docs/public/advanced/runs-and-streaming.md +6 -3
- package/dist/docs/public/advanced/typescript-api.md +32 -0
- package/dist/docs/public/channels/custom.mdx +23 -0
- package/dist/docs/public/frontend/README.md +8 -4
- package/dist/docs/public/frontend/meta.json +9 -1
- package/dist/docs/public/frontend/nextjs.md +4 -4
- package/dist/docs/public/frontend/nuxt.md +168 -0
- package/dist/docs/public/frontend/sveltekit.md +177 -0
- package/dist/docs/public/frontend/use-ash-agent-svelte.md +185 -0
- package/dist/docs/public/frontend/use-ash-agent-vue.md +236 -0
- package/dist/docs/public/frontend/use-ash-agent.md +14 -14
- package/dist/docs/public/getting-started.mdx +2 -0
- package/dist/src/channel/websocket-upgrade-server.d.ts +26 -0
- package/dist/src/channel/websocket-upgrade-server.js +1 -0
- package/dist/src/chunks/use-ash-agent-BQJLh7KU.js +1224 -0
- package/dist/src/chunks/use-ash-agent-CRWVA4i-.js +1192 -0
- package/dist/src/client/ash-agent-store.d.ts +61 -0
- package/dist/src/client/ash-agent-store.js +2 -0
- package/dist/src/client/index.d.ts +2 -0
- package/dist/src/client/index.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +3 -3
- package/dist/src/compiled/@chat-adapter/slack/index.js +25 -25
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/runtime.js +29 -29
- 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/queue.d.ts +8 -0
- package/dist/src/compiled/_chunks/workflow/dist-zpK2YVVA.js +3 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-BFK9mgsb.js +12 -0
- package/dist/src/compiled/_chunks/workflow/{sleep-Bg0t23kF.js → sleep-CeJckNg2.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{symbols-u476uwyR.js → symbols-BWCAoPHE.js} +1 -1
- package/dist/src/internal/application/package.d.ts +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/channel-routes.js +2 -2
- package/dist/src/internal/workflow-bundle/ash-service-route-output.js +11 -1
- package/dist/src/packages/ash-scaffold/src/channels.js +1 -1
- package/dist/src/public/channels/index.d.ts +1 -0
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/nuxt/dev-server.d.ts +24 -0
- package/dist/src/public/nuxt/dev-server.js +1 -0
- package/dist/src/public/nuxt/index.d.ts +1 -0
- package/dist/src/public/nuxt/index.js +1 -0
- package/dist/src/public/nuxt/module.d.ts +31 -0
- package/dist/src/public/nuxt/module.js +1 -0
- package/dist/src/public/nuxt/routing.d.ts +55 -0
- package/dist/src/public/nuxt/routing.js +1 -0
- package/dist/src/public/nuxt/vercel-json.d.ts +17 -0
- package/dist/src/public/nuxt/vercel-json.js +1 -0
- package/dist/src/public/sveltekit/dev-server.d.ts +24 -0
- package/dist/src/public/sveltekit/dev-server.js +1 -0
- package/dist/src/public/sveltekit/index.d.ts +39 -0
- package/dist/src/public/sveltekit/index.js +1 -0
- package/dist/src/public/sveltekit/routing.d.ts +32 -0
- package/dist/src/public/sveltekit/routing.js +1 -0
- package/dist/src/public/sveltekit/vercel-json.d.ts +17 -0
- package/dist/src/public/sveltekit/vercel-json.js +1 -0
- package/dist/src/react/use-ash-agent.d.ts +5 -27
- package/dist/src/react/use-ash-agent.js +1 -2
- package/dist/src/svelte/index.d.ts +3 -0
- package/dist/src/svelte/index.js +3 -0
- package/dist/src/svelte/use-ash-agent.d.ts +80 -0
- package/dist/src/svelte/use-ash-agent.js +3 -0
- package/dist/src/vue/index.d.ts +3 -0
- package/dist/src/vue/index.js +3 -0
- package/dist/src/vue/use-ash-agent.d.ts +78 -0
- package/dist/src/vue/use-ash-agent.js +3 -0
- package/package.json +51 -6
- package/dist/src/compiled/_chunks/workflow/dist-C4EHshZE.js +0 -3
- package/dist/src/compiled/_chunks/workflow/resume-hook-BlALLgSA.js +0 -12
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type AshAgentStoreCallbacks, type AshAgentStoreSnapshot, type AshAgentStoreStatus, type PrepareSend } from "#client/ash-agent-store.js";
|
|
2
|
+
import { type AshMessageData } from "#client/message-reducer.js";
|
|
3
|
+
import type { AshAgentReducer } from "#client/reducer.js";
|
|
4
|
+
import type { ClientSession } from "#client/session.js";
|
|
5
|
+
import type { ClientAuth, HeadersValue, SendMessageOptions, SendTurnInput, SessionState } from "#client/types.js";
|
|
6
|
+
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
7
|
+
export type { PrepareSend };
|
|
8
|
+
export type UseAshAgentStatus = AshAgentStoreStatus;
|
|
9
|
+
export type UseAshAgentSnapshot<TData> = AshAgentStoreSnapshot<TData>;
|
|
10
|
+
/**
|
|
11
|
+
* Reactive return value from `useAshAgent`.
|
|
12
|
+
*
|
|
13
|
+
* The state properties are Svelte 5 rune-friendly getters. Read them from a
|
|
14
|
+
* template, `$derived`, or `$effect` and Svelte will update when Ash streams
|
|
15
|
+
* new events.
|
|
16
|
+
*/
|
|
17
|
+
export interface UseAshAgentReturn<TData> {
|
|
18
|
+
/** Projected state built by reducing every stream event through the reducer. */
|
|
19
|
+
readonly data: TData;
|
|
20
|
+
/** Last transport-level error, or `undefined` when healthy. */
|
|
21
|
+
readonly error: Error | undefined;
|
|
22
|
+
/** Raw server events received during this session (authoritative stream). */
|
|
23
|
+
readonly events: readonly HandleMessageStreamEvent[];
|
|
24
|
+
/** Clear all state and start a new session. */
|
|
25
|
+
readonly reset: () => void;
|
|
26
|
+
/** Send a turn with full structured input (message, attachments, input responses). */
|
|
27
|
+
readonly send: (input: SendTurnInput, options?: SendMessageOptions) => Promise<void>;
|
|
28
|
+
/** Shorthand: send a plain text message. */
|
|
29
|
+
readonly sendMessage: (message: string, options?: SendMessageOptions) => Promise<void>;
|
|
30
|
+
/** Current session identity and stream cursor. */
|
|
31
|
+
readonly session: SessionState;
|
|
32
|
+
/** Lifecycle phase: `"ready"` (idle), `"submitted"` (request sent, awaiting first event), `"streaming"` (events arriving), or `"error"`. */
|
|
33
|
+
readonly status: UseAshAgentStatus;
|
|
34
|
+
/** Abort the in-flight request. */
|
|
35
|
+
readonly stop: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Configuration for creating or binding a Svelte Ash agent session.
|
|
39
|
+
*
|
|
40
|
+
* Session configuration is read once when `useAshAgent` creates its internal
|
|
41
|
+
* store. To point the binding at a different host, reducer, or session, create
|
|
42
|
+
* a new binding instance. Lifecycle callbacks are installed on creation.
|
|
43
|
+
*
|
|
44
|
+
* For credentials or headers that must change without recreating the binding,
|
|
45
|
+
* pass function values to `auth` or `headers`; the underlying client resolves
|
|
46
|
+
* those before each HTTP request.
|
|
47
|
+
*/
|
|
48
|
+
export interface UseAshAgentOptions<TData> extends AshAgentStoreCallbacks<TData> {
|
|
49
|
+
readonly auth?: ClientAuth;
|
|
50
|
+
readonly headers?: HeadersValue;
|
|
51
|
+
/**
|
|
52
|
+
* Base URL used for Ash client requests.
|
|
53
|
+
*
|
|
54
|
+
* By default, requests target same-origin Ash routes such as `/ash/v1/...`.
|
|
55
|
+
* Pass a same-origin prefix such as `/api` to use an app-owned proxy, or an
|
|
56
|
+
* absolute origin to talk to an Ash server directly.
|
|
57
|
+
*
|
|
58
|
+
* @default ""
|
|
59
|
+
*/
|
|
60
|
+
readonly host?: string;
|
|
61
|
+
readonly initialEvents?: readonly HandleMessageStreamEvent[];
|
|
62
|
+
readonly initialSession?: SessionState;
|
|
63
|
+
readonly maxReconnectAttempts?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Project submitted user messages before Ash confirms them with a
|
|
66
|
+
* `message.received` stream event.
|
|
67
|
+
*
|
|
68
|
+
* Optimistic events are reducer-facing projection events only. They are not
|
|
69
|
+
* exposed through `events`, which remains the authoritative Ash stream.
|
|
70
|
+
*
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
readonly optimistic?: boolean;
|
|
74
|
+
readonly reducer?: AshAgentReducer<TData>;
|
|
75
|
+
readonly session?: ClientSession;
|
|
76
|
+
}
|
|
77
|
+
export declare function useAshAgent(options?: UseAshAgentOptions<AshMessageData>): UseAshAgentReturn<AshMessageData>;
|
|
78
|
+
export declare function useAshAgent<TData>(options: UseAshAgentOptions<TData> & {
|
|
79
|
+
readonly reducer: AshAgentReducer<TData>;
|
|
80
|
+
}): UseAshAgentReturn<TData>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useAshAgent, type PrepareSend, type UseAshAgentOptions, type UseAshAgentReturn, type UseAshAgentSnapshot, type UseAshAgentStatus, } from "#vue/use-ash-agent.js";
|
|
2
|
+
export { type AshAgentReducer, type AshAgentReducerEvent, type ClientInputRespondedEvent, type ClientMessageFailedEvent, type ClientMessageSubmittedEvent, } from "#client/reducer.js";
|
|
3
|
+
export { defaultMessageReducer, type AshMessageData, type AshDynamicToolPart, type AshMessageInputRequest, type AshMessage, type AshMessageMetadata, type AshMessagePart, type AshMessageToolMetadata, } from "#client/message-reducer.js";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type ComputedRef } from "vue";
|
|
2
|
+
import { type AshAgentStoreCallbacks, type AshAgentStoreSnapshot, type AshAgentStoreStatus, type PrepareSend } from "#client/ash-agent-store.js";
|
|
3
|
+
import type { AshAgentReducer } from "#client/reducer.js";
|
|
4
|
+
import type { ClientSession } from "#client/session.js";
|
|
5
|
+
import { type AshMessageData } from "#client/message-reducer.js";
|
|
6
|
+
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
7
|
+
import type { ClientAuth, HeadersValue, SendMessageOptions, SendTurnInput, SessionState } from "#client/types.js";
|
|
8
|
+
export type { PrepareSend };
|
|
9
|
+
export type UseAshAgentStatus = AshAgentStoreStatus;
|
|
10
|
+
export type UseAshAgentSnapshot<TData> = AshAgentStoreSnapshot<TData>;
|
|
11
|
+
/**
|
|
12
|
+
* Reactive return value from `useAshAgent`.
|
|
13
|
+
*/
|
|
14
|
+
export interface UseAshAgentReturn<TData> {
|
|
15
|
+
/** Projected state built by reducing every stream event through the reducer. */
|
|
16
|
+
readonly data: ComputedRef<TData>;
|
|
17
|
+
/** Last transport-level error, or `undefined` when healthy. */
|
|
18
|
+
readonly error: ComputedRef<Error | undefined>;
|
|
19
|
+
/** Raw server events received during this session (authoritative stream). */
|
|
20
|
+
readonly events: ComputedRef<readonly HandleMessageStreamEvent[]>;
|
|
21
|
+
/** Clear all state and start a new session. */
|
|
22
|
+
readonly reset: () => void;
|
|
23
|
+
/** Send a turn with full structured input (message, attachments, input responses). */
|
|
24
|
+
readonly send: (input: SendTurnInput, options?: SendMessageOptions) => Promise<void>;
|
|
25
|
+
/** Shorthand: send a plain text message. */
|
|
26
|
+
readonly sendMessage: (message: string, options?: SendMessageOptions) => Promise<void>;
|
|
27
|
+
/** Current session identity and stream cursor. */
|
|
28
|
+
readonly session: ComputedRef<SessionState>;
|
|
29
|
+
/** Lifecycle phase: `"ready"` (idle), `"submitted"` (request sent, awaiting first event), `"streaming"` (events arriving), or `"error"`. */
|
|
30
|
+
readonly status: ComputedRef<UseAshAgentStatus>;
|
|
31
|
+
/** Abort the in-flight request. */
|
|
32
|
+
readonly stop: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for creating or binding a Vue Ash agent session.
|
|
36
|
+
*
|
|
37
|
+
* Session configuration is read once when the composable creates its internal
|
|
38
|
+
* store. To point the composable at a different host, reducer, or session,
|
|
39
|
+
* unmount and remount the component that calls it. Lifecycle callbacks are
|
|
40
|
+
* synced on every call to `setCallbacks`.
|
|
41
|
+
*
|
|
42
|
+
* For credentials or headers that must change without remounting, pass function
|
|
43
|
+
* values to `auth` or `headers`; the underlying client resolves those before
|
|
44
|
+
* each HTTP request.
|
|
45
|
+
*/
|
|
46
|
+
export interface UseAshAgentOptions<TData> extends AshAgentStoreCallbacks<TData> {
|
|
47
|
+
readonly auth?: ClientAuth;
|
|
48
|
+
readonly headers?: HeadersValue;
|
|
49
|
+
/**
|
|
50
|
+
* Base URL used for Ash client requests.
|
|
51
|
+
*
|
|
52
|
+
* By default, requests target same-origin Ash routes such as `/ash/v1/...`.
|
|
53
|
+
* Pass a same-origin prefix such as `/api` to use an app-owned proxy, or an
|
|
54
|
+
* absolute origin to talk to an Ash server directly.
|
|
55
|
+
*
|
|
56
|
+
* @default ""
|
|
57
|
+
*/
|
|
58
|
+
readonly host?: string;
|
|
59
|
+
readonly initialEvents?: readonly HandleMessageStreamEvent[];
|
|
60
|
+
readonly initialSession?: SessionState;
|
|
61
|
+
readonly maxReconnectAttempts?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Project submitted user messages before Ash confirms them with a
|
|
64
|
+
* `message.received` stream event.
|
|
65
|
+
*
|
|
66
|
+
* Optimistic events are reducer-facing projection events only. They are not
|
|
67
|
+
* exposed through `events`, which remains the authoritative Ash stream.
|
|
68
|
+
*
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
readonly optimistic?: boolean;
|
|
72
|
+
readonly reducer?: AshAgentReducer<TData>;
|
|
73
|
+
readonly session?: ClientSession;
|
|
74
|
+
}
|
|
75
|
+
export declare function useAshAgent(options?: UseAshAgentOptions<AshMessageData>): UseAshAgentReturn<AshMessageData>;
|
|
76
|
+
export declare function useAshAgent<TData>(options: UseAshAgentOptions<TData> & {
|
|
77
|
+
readonly reducer: AshAgentReducer<TData>;
|
|
78
|
+
}): UseAshAgentReturn<TData>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "experimental-ash",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-framework",
|
|
@@ -60,11 +60,31 @@
|
|
|
60
60
|
"import": "./dist/src/react/index.js",
|
|
61
61
|
"default": "./dist/src/react/index.js"
|
|
62
62
|
},
|
|
63
|
+
"./vue": {
|
|
64
|
+
"types": "./dist/src/vue/index.d.ts",
|
|
65
|
+
"import": "./dist/src/vue/index.js",
|
|
66
|
+
"default": "./dist/src/vue/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./svelte": {
|
|
69
|
+
"types": "./dist/src/svelte/index.d.ts",
|
|
70
|
+
"import": "./dist/src/svelte/index.js",
|
|
71
|
+
"default": "./dist/src/svelte/index.js"
|
|
72
|
+
},
|
|
63
73
|
"./next": {
|
|
64
74
|
"types": "./dist/src/public/next/index.d.ts",
|
|
65
75
|
"import": "./dist/src/public/next/index.js",
|
|
66
76
|
"default": "./dist/src/public/next/index.js"
|
|
67
77
|
},
|
|
78
|
+
"./nuxt": {
|
|
79
|
+
"types": "./dist/src/public/nuxt/index.d.ts",
|
|
80
|
+
"import": "./dist/src/public/nuxt/index.js",
|
|
81
|
+
"default": "./dist/src/public/nuxt/index.js"
|
|
82
|
+
},
|
|
83
|
+
"./sveltekit": {
|
|
84
|
+
"types": "./dist/src/public/sveltekit/index.d.ts",
|
|
85
|
+
"import": "./dist/src/public/sveltekit/index.js",
|
|
86
|
+
"default": "./dist/src/public/sveltekit/index.js"
|
|
87
|
+
},
|
|
68
88
|
"./tools/approval": {
|
|
69
89
|
"types": "./dist/src/public/tools/approval/index.d.ts",
|
|
70
90
|
"import": "./dist/src/public/tools/approval/index.js",
|
|
@@ -212,16 +232,18 @@
|
|
|
212
232
|
"@ai-sdk/provider": "4.0.0-canary.18",
|
|
213
233
|
"@chat-adapter/slack": "4.29.0",
|
|
214
234
|
"@chat-adapter/state-memory": "4.29.0",
|
|
235
|
+
"@nuxt/kit": "^4.0.0",
|
|
215
236
|
"@standard-schema/spec": "1.1.0",
|
|
237
|
+
"@sveltejs/kit": "^2.0.0",
|
|
216
238
|
"@types/json-schema": "7.0.15",
|
|
217
239
|
"@types/react": "19.2.15",
|
|
218
240
|
"@types/react-test-renderer": "19.1.0",
|
|
219
241
|
"@vercel/oidc": "3.5.0",
|
|
220
242
|
"@vercel/sandbox": "2.1.0",
|
|
221
|
-
"@workflow/core": "5.0.0-beta.
|
|
222
|
-
"@workflow/errors": "5.0.0-beta.
|
|
223
|
-
"@workflow/world": "5.0.0-beta.
|
|
224
|
-
"@workflow/world-local": "5.0.0-beta.
|
|
243
|
+
"@workflow/core": "5.0.0-beta.12",
|
|
244
|
+
"@workflow/errors": "5.0.0-beta.7",
|
|
245
|
+
"@workflow/world": "5.0.0-beta.7",
|
|
246
|
+
"@workflow/world-local": "5.0.0-beta.13",
|
|
225
247
|
"ai": "7.0.0-canary.165",
|
|
226
248
|
"autoevals": "0.0.132",
|
|
227
249
|
"chat": "4.29.0",
|
|
@@ -236,30 +258,53 @@
|
|
|
236
258
|
"picocolors": "1.1.1",
|
|
237
259
|
"react": "19.2.6",
|
|
238
260
|
"react-test-renderer": "19.2.6",
|
|
261
|
+
"svelte": "^5.0.0",
|
|
239
262
|
"turndown": "7.2.4",
|
|
263
|
+
"vite": "^8.0.0",
|
|
264
|
+
"vue": "^3.5.0",
|
|
240
265
|
"zod": "4.4.3",
|
|
241
266
|
"zod-validation-error": "5.0.0",
|
|
242
267
|
"@vercel/ash-scaffold": "0.0.0"
|
|
243
268
|
},
|
|
244
269
|
"peerDependencies": {
|
|
245
270
|
"@opentelemetry/api": "^1.0.0",
|
|
271
|
+
"@sveltejs/kit": "^2.0.0",
|
|
246
272
|
"ai": "7.0.0-canary.165",
|
|
247
273
|
"braintrust": "^3.0.0",
|
|
248
274
|
"next": "^16.0.0",
|
|
249
|
-
"
|
|
275
|
+
"nuxt": "^4.0.0",
|
|
276
|
+
"react": "^19.0.0",
|
|
277
|
+
"svelte": "^5.0.0",
|
|
278
|
+
"vite": "^8.0.0",
|
|
279
|
+
"vue": "^3.5.0"
|
|
250
280
|
},
|
|
251
281
|
"peerDependenciesMeta": {
|
|
252
282
|
"@opentelemetry/api": {
|
|
253
283
|
"optional": true
|
|
254
284
|
},
|
|
285
|
+
"@sveltejs/kit": {
|
|
286
|
+
"optional": true
|
|
287
|
+
},
|
|
255
288
|
"braintrust": {
|
|
256
289
|
"optional": true
|
|
257
290
|
},
|
|
258
291
|
"next": {
|
|
259
292
|
"optional": true
|
|
260
293
|
},
|
|
294
|
+
"nuxt": {
|
|
295
|
+
"optional": true
|
|
296
|
+
},
|
|
261
297
|
"react": {
|
|
262
298
|
"optional": true
|
|
299
|
+
},
|
|
300
|
+
"svelte": {
|
|
301
|
+
"optional": true
|
|
302
|
+
},
|
|
303
|
+
"vite": {
|
|
304
|
+
"optional": true
|
|
305
|
+
},
|
|
306
|
+
"vue": {
|
|
307
|
+
"optional": true
|
|
263
308
|
}
|
|
264
309
|
},
|
|
265
310
|
"engines": {
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./chunk-DSjMdhoD.js";function n(e,t,n){return n===1?e:t}function r(e,t){if(typeof t!=`string`)return null;let[n,r,...i]=t.split(`//`);if(n!==e||!r||i.length===0)return null;let a=i.join(`//`),o=a.split(`/`).at(-1)??``,s=``;return s=r.startsWith(`./`)?r.split(`/`).at(-1)??``:(r.split(`@`).slice(0,-1).join(`@`)||r.split(`@`)[0])?.split(`/`).at(-1)??``,[`default`,`__default`].includes(o)&&s&&(o=s),{shortName:o,moduleSpecifier:r,functionName:a}}function i(e){return r(`workflow`,e)}function a(e){return r(`step`,e)}function o(e){return c(a(e),e)}function s(e){return c(i(e),e)}function c(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}function l(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function u(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}var d=e(t(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}))(),1);function f(e){if(typeof e==`string`){let t=(0,d.default)(e);if(typeof t!=`number`||t<0)throw Error(`Invalid duration: "${e}". Expected a valid duration string like "1s", "1m", "1h", etc.`);return new Date(Date.now()+t)}else if(typeof e==`number`){if(e<0||!Number.isFinite(e))throw Error(`Invalid duration: ${e}. Expected a non-negative finite number of milliseconds.`);return new Date(Date.now()+e)}else if(e instanceof Date||e&&typeof e==`object`&&typeof e.getTime==`function`)return e instanceof Date?e:new Date(e.getTime());else throw Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`)}function p(e=process.env){return e.WORKFLOW_TARGET_WORLD||(e.VERCEL_DEPLOYMENT_ID?`vercel`:`local`)}function m(e){return e===`vercel`||e===`@workflow/world-vercel`}const h={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`};function g(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function _(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 v(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 y={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`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`};var b=class extends Error{cause;constructor(e,t){let n=_(e,v(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 g(e)&&e.name===`WorkflowError`}},x=class extends b{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 g(e)&&e.name===`WorkflowWorldError`}},S=class extends b{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 g(e)&&e.name===`WorkflowRunFailedError`}},C=class extends b{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 g(e)&&e.name===`WorkflowRunNotCompletedError`}},w=class extends b{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return g(e)&&e.name===`WorkflowRuntimeError`}},T=class extends w{constructor(e,t){super(e,{...t,slug:y.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return g(e)&&e.name===`CorruptedEventLogError`}},E=class extends w{context;constructor(e,t){super(e,{cause:t?.cause,slug:y.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return g(e)&&e.name===`RuntimeDecryptionError`}},D=class extends b{hint;constructor(e,t){let n=_(e,v(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return g(e)&&e.name===`WorkflowBuildError`}},O=class extends b{hint;fatal=!0;constructor(e,t){let n=_(e,v(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return g(e)&&e.name===`SerializationError`}},k=class extends w{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:y.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return g(e)&&e.name===`StepNotRegisteredError`}},A=class extends w{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:y.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return g(e)&&e.name===`WorkflowNotRegisteredError`}},j=class extends b{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return g(e)&&e.name===`WorkflowRunNotFoundError`}},M=class extends b{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:y.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return g(e)&&e.name===`HookConflictError`}},N=class extends b{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return g(e)&&e.name===`HookNotFoundError`}},P=class extends x{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return g(e)&&e.name===`EntityConflictError`}},F=class extends x{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return g(e)&&e.name===`RunExpiredError`}},I=class extends x{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return g(e)&&e.name===`TooEarlyError`}},L=class extends x{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return g(e)&&e.name===`ThrottleError`}},R=class extends b{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return g(e)&&e.name===`WorkflowRunCancelledError`}},z=class extends b{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 g(e)&&e.name===`RunNotSupportedError`}},B=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return g(e)?e.name===`FatalError`?!0:e.fatal===!0:!1}},V=class extends Error{retryAfter;constructor(e,t={}){super(e),this.name=`RetryableError`,t.retryAfter===void 0?this.retryAfter=new Date(Date.now()+1e3):this.retryAfter=f(t.retryAfter)}static is(e){return g(e)&&e.name===`RetryableError`}};const H="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.",U=Symbol.for(`@workflow/errors//FatalError`),W=Symbol.for(`@workflow/errors//RetryableError`),G=Symbol.for(`@workflow/errors//HookConflictError`),K=Symbol.for(`@workflow/errors//RuntimeDecryptionError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,U)||Object.defineProperty(globalThis,U,{value:B,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,W)||Object.defineProperty(globalThis,W,{value:V,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,G)||Object.defineProperty(globalThis,G,{value:M,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,K)||Object.defineProperty(globalThis,K,{value:E,writable:!1,enumerable:!1,configurable:!1}));export{l as A,w as C,p as D,m as E,n as F,s as M,a as N,f as O,i as P,j as S,h as T,b as _,M as a,S as b,F as c,O as d,k as f,D as g,H as h,B as i,o as j,u as k,z as l,I as m,y as n,N as o,L as p,P as r,V as s,T as t,E as u,A as v,x as w,C as x,R as y};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./chunk-DSjMdhoD.js";import{A as r,C as i,F as a,M as o,N as s,P as c,T as l,a as u,d,i as f,j as p,k as m,n as h,o as g,s as _,t as v,u as y,w as b}from"./dist-C4EHshZE.js";import{C as x,a as S,c as C,d as w,dt as T,f as ee,ft as te,i as E,k as ne,l as D,mt as re,n as ie,o as ae,pt as oe,r as se,s as O,t as k,u as ce,ut as le,x as ue}from"./symbols-u476uwyR.js";import{getStepFunction as de}from"../../@workflow/core/private.js";import{types as fe}from"node:util";import{AsyncLocalStorage as pe}from"node:async_hooks";var me=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>w,ipAddress:()=>S}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function x(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function S(e){return y(`headers`in e?e.headers:e,f)}function C(e){return e?e.split(`:`)[0]:`dev1`}function w(e){return{city:b(e,u),country:y(e.headers,d),flag:x(y(e.headers,d)),countryRegion:y(e.headers,h),region:C(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}0&&(t.exports={CITY_HEADER_NAME:u,COUNTRY_HEADER_NAME:d,EMOJI_FLAG_UNICODE_STARTING_POSITION:v,IP_HEADER_NAME:f,LATITUDE_HEADER_NAME:p,LONGITUDE_HEADER_NAME:m,POSTAL_CODE_HEADER_NAME:g,REGION_HEADER_NAME:h,REQUEST_ID_HEADER_NAME:_,geolocation:w,ipAddress:S})})),he=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n};0&&(t.exports={getEnv:u})})),ge=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),_e=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{waitUntil:()=>d}),t.exports=c(l);var u=ge();let d=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,u.getContext)().waitUntil?.(e)};0&&(t.exports={waitUntil:d})})),ve=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}0&&(t.exports={next:f,rewrite:d})})),ye=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}};0&&(t.exports={InMemoryCache:u})})),be=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{BuildCache:()=>d}),t.exports=c(l);var u=xe(),d=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(u.HEADERS_VERCEL_CACHE_STATE)!==u.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[u.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[u.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[u.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}};0&&(t.exports={BuildCache:d})})),xe=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>T,HEADERS_VERCEL_CACHE_STATE:()=>S,HEADERS_VERCEL_CACHE_TAGS:()=>w,HEADERS_VERCEL_REVALIDATE:()=>C,PkgCacheState:()=>x,getCache:()=>g}),t.exports=c(l);var u=ge(),d=ye(),f=be();let p=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},m=null,h=null,g=e=>v(()=>{let e;return e=(0,u.getContext)().cache?(0,u.getContext)().cache:b(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},_(e));function _(e){let t=e?.keyHashFunction||p;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function v(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,{...i,name:i?.name??n}),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let y=!1;function b(e){if(m||=new d.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),m;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return y||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),m;if(!h){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),m}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}h=new f.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return h}var x=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(x||{});let S=`x-vercel-cache-state`,C=`x-vercel-revalidate`,w=`x-vercel-cache-tags`,T=`x-vercel-cache-item-name`;0&&(t.exports={HEADERS_VERCEL_CACHE_ITEM_NAME:T,HEADERS_VERCEL_CACHE_STATE:S,HEADERS_VERCEL_CACHE_TAGS:w,HEADERS_VERCEL_REVALIDATE:C,PkgCacheState:x,getCache:g})})),Se=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{attachDatabasePool:()=>_,experimental_attachDatabasePool:()=>v}),t.exports=c(l);var u=ge();let d=!!process.env.DEBUG;function f(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let p=null,m=()=>{},h=Date.now();function g(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;p&&(clearTimeout(p),m());let t=new Promise(e=>{m=e}),n=Math.min(f(e)+100,Math.max(100,899e3-(Date.now()-h)));p=setTimeout(()=>{m?.(),d&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,u.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function _(e){if(p&&(m?.(),clearTimeout(p)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{d&&console.log(`Client released from pool`),g(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{d&&console.log(`MySQL client released from pool`),g(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{d&&console.log(`MySQL2/MariaDB client released from pool`),g(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{d&&console.log(`MongoDB connection checked out`),g(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{d&&console.log(`Redis connection ended`),g(e)});return}throw Error(`Unsupported database pool type`)}let v=_;0&&(t.exports={attachDatabasePool:_,experimental_attachDatabasePool:v})})),Ce=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{dangerouslyDeleteBySrcImage:()=>m,dangerouslyDeleteByTag:()=>f,invalidateBySrcImage:()=>p,invalidateByTag:()=>d}),t.exports=c(l);var u=ge();let d=e=>{let t=(0,u.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},f=(e,t)=>{let n=(0,u.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},p=e=>{let t=(0,u.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},m=(e,t)=>{let n=(0,u.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()};0&&(t.exports={dangerouslyDeleteBySrcImage:m,dangerouslyDeleteByTag:f,invalidateBySrcImage:p,invalidateByTag:d})})),we=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{addCacheTag:()=>d}),t.exports=c(l);var u=ge();let d=e=>{let t=(0,u.getContext)().addCacheTag;return t?t(e):Promise.resolve()};0&&(t.exports={addCacheTag:d})})),Te=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{addCacheTag:()=>_.addCacheTag,attachDatabasePool:()=>h.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>g.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>g.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>h.experimental_attachDatabasePool,geolocation:()=>u.geolocation,getCache:()=>m.getCache,getEnv:()=>d.getEnv,invalidateBySrcImage:()=>g.invalidateBySrcImage,invalidateByTag:()=>g.invalidateByTag,ipAddress:()=>u.ipAddress,next:()=>p.next,rewrite:()=>p.rewrite,waitUntil:()=>f.waitUntil}),t.exports=c(l);var u=me(),d=he(),f=_e(),p=ve(),m=xe(),h=Se(),g=Ce(),_=we();0&&(t.exports={addCacheTag,attachDatabasePool,dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag,experimental_attachDatabasePool,geolocation,getCache,getEnv,invalidateBySrcImage,invalidateByTag,ipAddress,next,rewrite,waitUntil})})),Ee=n(((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}})),De=n(((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):()=>{}})),Oe=n(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=Ee(),a=De();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*$`)})),ke=n(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),Ae=n(((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)}})),A=n(((e,t)=>{let n=De(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=Ee(),{safeRe:a,t:o}=Oe(),s=ke(),{compareIdentifiers:c}=Ae();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}}})),j=n(((e,t)=>{let n=A();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}}})),je=n(((e,t)=>{let n=j();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Me=n(((e,t)=>{let n=j();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Ne=n(((e,t)=>{let n=A();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}}})),Pe=n(((e,t)=>{let n=j();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`}})),Fe=n(((e,t)=>{let n=A();t.exports=(e,t)=>new n(e,t).major})),Ie=n(((e,t)=>{let n=A();t.exports=(e,t)=>new n(e,t).minor})),Le=n(((e,t)=>{let n=A();t.exports=(e,t)=>new n(e,t).patch})),Re=n(((e,t)=>{let n=j();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),M=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),ze=n(((e,t)=>{let n=M();t.exports=(e,t,r)=>n(t,e,r)})),Be=n(((e,t)=>{let n=M();t.exports=(e,t)=>n(e,t,!0)})),Ve=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),He=n(((e,t)=>{let n=Ve();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Ue=n(((e,t)=>{let n=Ve();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),We=n(((e,t)=>{let n=M();t.exports=(e,t,r)=>n(e,t,r)>0})),Ge=n(((e,t)=>{let n=M();t.exports=(e,t,r)=>n(e,t,r)<0})),Ke=n(((e,t)=>{let n=M();t.exports=(e,t,r)=>n(e,t,r)===0})),qe=n(((e,t)=>{let n=M();t.exports=(e,t,r)=>n(e,t,r)!==0})),Je=n(((e,t)=>{let n=M();t.exports=(e,t,r)=>n(e,t,r)>=0})),Ye=n(((e,t)=>{let n=M();t.exports=(e,t,r)=>n(e,t,r)<=0})),Xe=n(((e,t)=>{let n=Ke(),r=qe(),i=We(),a=Je(),o=Ge(),s=Ye();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}`)}}})),Ze=n(((e,t)=>{let n=A(),r=j(),{safeRe:i,t:a}=Oe();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)}})),Qe=n(((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}}})),N=n(((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,E(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=>te(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 b=[..._.values()];return r.set(t,b),b}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(ne(this.set[t],e,this.options))return!0;return!1}};let r=new(Qe()),i=ke(),a=$e(),o=De(),s=A(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=Oe(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=Ee(),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=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=w(e,t),o(`xrange`,e),e=ee(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(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})},S=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(` `),C=(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})},w=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>T(e,t)).join(` `)),T=(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})},ee=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),te=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),E=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()),ne=(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}})),$e=n(((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=ke(),{safeRe:i,t:a}=Oe(),o=Xe(),s=De(),c=A(),l=N()})),et=n(((e,t)=>{let n=N();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),tt=n(((e,t)=>{let n=N();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),nt=n(((e,t)=>{let n=A(),r=N();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}})),rt=n(((e,t)=>{let n=A(),r=N();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}})),it=n(((e,t)=>{let n=A(),r=N(),i=We();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}})),at=n(((e,t)=>{let n=N();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),ot=n(((e,t)=>{let n=A(),r=$e(),{ANY:i}=r,a=N(),o=et(),s=We(),c=Ge(),l=Ye(),u=Je();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}})),st=n(((e,t)=>{let n=ot();t.exports=(e,t,r)=>n(e,t,`>`,r)})),ct=n(((e,t)=>{let n=ot();t.exports=(e,t,r)=>n(e,t,`<`,r)})),lt=n(((e,t)=>{let n=N();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),ut=n(((e,t)=>{let n=et(),r=M();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}})),dt=n(((e,t)=>{let n=N(),r=$e(),{ANY:i}=r,a=et(),o=M(),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})),ft=n(((e,t)=>{let n=Oe(),r=Ee(),i=A(),a=Ae();t.exports={parse:j(),valid:je(),clean:Me(),inc:Ne(),diff:Pe(),major:Fe(),minor:Ie(),patch:Le(),prerelease:Re(),compare:M(),rcompare:ze(),compareLoose:Be(),compareBuild:Ve(),sort:He(),rsort:Ue(),gt:We(),lt:Ge(),eq:Ke(),neq:qe(),gte:Je(),lte:Ye(),cmp:Xe(),coerce:Ze(),Comparator:$e(),Range:N(),satisfies:et(),toComparators:tt(),maxSatisfying:nt(),minSatisfying:rt(),minVersion:it(),validRange:at(),outside:ot(),gtr:st(),ltr:ct(),intersects:lt(),simplifyRange:ut(),subset:dt(),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}})),P=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};function pt(e){return Object(e)!==e}const mt=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function ht(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===mt}function gt(e){return Object.prototype.toString.call(e).slice(8,-1)}function _t(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
|
|
2
|
-
`: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 F(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=_t(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function vt(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const yt=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function bt(e){return yt.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function xt(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}let t=+e;return!(t>=2**32-1||t<0)}function St(e){let t=Object.keys(e);for(var n=t.length-1;n>=0&&!xt(t[n]);n--);return t.length=n+1,t}function Ct(e){let t=new DataView(e),n=``;for(let r=0;r<e.byteLength;r++)n+=String.fromCharCode(t.getUint8(r));return Dt(n)}function wt(e){let t=Et(e),n=new ArrayBuffer(t.length),r=new DataView(n);for(let e=0;e<n.byteLength;e++)r.setUint8(e,t.charCodeAt(e));return n}const Tt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Et(e){e.length%4==0&&(e=e.replace(/==?$/,``));let t=``,n=0,r=0;for(let i=0;i<e.length;i++)n<<=6,n|=Tt.indexOf(e[i]),r+=6,r===24&&(t+=String.fromCharCode((n&16711680)>>16),t+=String.fromCharCode((n&65280)>>8),t+=String.fromCharCode(n&255),n=r=0);return r===12?(n>>=4,t+=String.fromCharCode(n)):r===18&&(n>>=2,t+=String.fromCharCode((n&65280)>>8),t+=String.fromCharCode(n&255)),t}function Dt(e){let t=``;for(let n=0;n<e.length;n+=3){let r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(n)>>2,r[1]=(e.charCodeAt(n)&3)<<4,e.length>n+1&&(r[1]|=e.charCodeAt(n+1)>>4,r[2]=(e.charCodeAt(n+1)&15)<<2),e.length>n+2&&(r[2]|=e.charCodeAt(n+2)>>6,r[3]=e.charCodeAt(n+2)&63);for(let e=0;e<r.length;e++)r[e]===void 0?t+=`=`:t+=Tt[r[e]]}return t}function Ot(e,t){return kt(JSON.parse(e),t)}function kt(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`:r[e]=Object(s[1]);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)c[s[e]]=a(s[e+1]);break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{if(n[s[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=globalThis[o],i=new t(a(s[1]));r[e]=s[2]===void 0?i:i.subarray(s[2],s[3]);break}case`ArrayBuffer`:{let t=s[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);r[e]=wt(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],n=Array(t);r[e]=n;for(let e=2;e<s.length;e+=2){let t=s[e];n[t]=a(s[e+1])}}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 I(e,t){let n=[],r=new Map,i=[];if(t)for(let e of Object.getOwnPropertyNames(t))i.push({key:e,fn:t[e]});let a=[],o=0;function s(t){if(t===void 0)return-1;if(Number.isNaN(t))return-3;if(t===1/0)return-4;if(t===-1/0)return-5;if(t===0&&1/t<0)return-6;if(r.has(t))return r.get(t);let c=o++;r.set(t,c);for(let{key:e,fn:r}of i){let i=r(t);if(i)return n[c]=`["${e}",${s(i)}]`,c}if(typeof t==`function`)throw new P(`Cannot stringify a function`,a,t,e);let l=``;if(pt(t))l=At(t);else{let n=gt(t);switch(n){case`Number`:case`String`:case`Boolean`:l=`["Object",${At(t)}]`;break;case`BigInt`:l=`["BigInt",${t}]`;break;case`Date`:l=`["Date","${isNaN(t.getDate())?``:t.toISOString()}"]`;break;case`URL`:l=`["URL",${F(t.toString())}]`;break;case`URLSearchParams`:l=`["URLSearchParams",${F(t.toString())}]`;break;case`RegExp`:let{source:r,flags:i}=t;l=i?`["RegExp",${F(r)},"${i}"]`:`["RegExp",${F(r)}]`;break;case`Array`:{let e=!1;l=`[`;for(let n=0;n<t.length;n+=1)if(n>0&&(l+=`,`),Object.hasOwn(t,n))a.push(`[${n}]`),l+=s(t[n]),a.pop();else if(e)l+=-2;else{let n=St(t),r=n.length,i=String(t.length).length;if((t.length-r)*3>4+i+r*(i+1)){l=`[-7,`+t.length;for(let e=0;e<n.length;e++){let r=n[e];a.push(`[${r}]`),l+=`,`+r+`,`+s(t[r]),a.pop()}break}else e=!0,l+=-2}l+=`]`;break}case`Set`:l=`["Set"`;for(let e of t)l+=`,${s(e)}`;l+=`]`;break;case`Map`:l=`["Map"`;for(let[e,n]of t)a.push(`.get(${pt(e)?At(e):`...`})`),l+=`,${s(e)},${s(n)}`,a.pop();l+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let e=t;l=`["`+n+`",`+s(e.buffer);let r=t.byteOffset,i=r+t.byteLength;if(r>0||i!==e.buffer.byteLength){let e=/(\d+)/.exec(n)[1]/8;l+=`,${r/e},${i/e}`}l+=`]`;break}case`ArrayBuffer`:l=`["ArrayBuffer","${Ct(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`:l=`["${n}",${F(t.toString())}]`;break;default:if(!ht(t))throw new P(`Cannot stringify arbitrary non-POJOs`,a,t,e);if(vt(t).length>0)throw new P(`Cannot stringify POJOs with symbolic keys`,a,t,e);if(Object.getPrototypeOf(t)===null){l=`["null"`;for(let n of Object.keys(t)){if(n===`__proto__`)throw new P(`Cannot stringify objects with __proto__ keys`,a,t,e);a.push(bt(n)),l+=`,${F(n)},${s(t[n])}`,a.pop()}l+=`]`}else{l=`{`;let n=!1;for(let r of Object.keys(t)){if(r===`__proto__`)throw new P(`Cannot stringify objects with __proto__ keys`,a,t,e);n&&(l+=`,`),n=!0,a.push(bt(r)),l+=`${F(r)}:${s(t[r])}`,a.pop()}l+=`}`}}}return n[c]=l,c}let c=s(e);return c<0?`${c}`:`[${n.join(`,`)}]`}function At(e){let t=typeof e;return t===`string`?F(e):e instanceof String?F(e.toString()):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var jt=Te(),Mt=e(ft(),1);async function Nt(e,t=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new i(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,t)}async function Pt(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 y(`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 Ft(e,t){if(t.byteLength<28)throw new y(`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 y(`AES-256-GCM decryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(i)}function L(){let e={...r(),pendingOps:0,doneResolved:!1,streamEnded:!1};return e.promise.catch(()=>{}),e}function It(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Lt(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Rt(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}It(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.writablePollingInterval=void 0)},10);t.writablePollingInterval=n}function zt(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}Lt(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.readablePollingInterval=void 0)},10);t.readablePollingInterval=n}async function R(e,t,n){let r=e.getReader(),a=t.getWriter(),o;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),a.closed.then(()=>{throw new i(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await a.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await a.write(e.value)}finally{n.pendingOps--}}}catch(e){throw n.streamEnded=!0,o=e,n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(o).catch(()=>{}),r.releaseLock(),a.releaseLock()}}const Bt=Symbol.for(`@workflow/world//cache`),Vt=Symbol.for(`@workflow/world//cachePromise`),Ht=Symbol.for(`@workflow/world//getWorldFn`);async function z(){let e=globalThis;if(e[Bt])return e[Bt];if(e[Vt])return e[Bt]=await e[Vt],e[Bt];let t=e[Ht];if(t)return t();let{getWorld:n}=await import([`./world`,`js`].join(`.`));return n()}const Ut=Symbol.for(`workflow-serialize`),Wt=Symbol.for(`workflow-deserialize`);function Gt(e=globalThis){let t=e,n=t[ee];return n||(n=new Map,t[ee]=n),n}function Kt(e,t){return Gt(t).get(e)}function qt(){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[Ut];if(typeof n!=`function`)return!1;let r=t.classId;if(typeof r!=`string`)throw Error(`Class "${t.name}" with ${String(Ut)} must have a static "classId" property.`);return{classId:r,data:n.call(t,e)}}}}function Jt(e=globalThis){return{Class:t=>{let n=t.classId,r=Kt(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=Kt(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[Wt];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(Wt)} method.`);return a.call(i,r)}}}function Yt(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function B(e){return Yt(e.buffer,e.byteOffset,e.byteLength)}function V(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 Xt(e){return JSON.parse(e)}function Zt(e){if(!fe.isNativeError(e))return!1;let t={message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t}function Qt(e,t){return!fe.isNativeError(t)||t.name!==e?!1:Zt(t)}function H(e){return t=>Qt(e,t)||!1}function U(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 $t(e=globalThis){return{ArrayBuffer:t=>t instanceof e.ArrayBuffer&&Yt(t,0,t.byteLength),BigInt:e=>typeof e==`bigint`&&e.toString(),BigInt64Array:t=>t instanceof e.BigInt64Array&&B(t),BigUint64Array:t=>t instanceof e.BigUint64Array&&B(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:H(`EvalError`),FatalError:H(`FatalError`),HookConflictError:e=>{let t=Qt(`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:H(`RangeError`),ReferenceError:H(`ReferenceError`),RetryableError:e=>{let t=Qt(`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=Qt(`RuntimeDecryptionError`,e);if(!t)return!1;let n={...t},r=e.context;return r!==void 0&&(n.context=r),n},SyntaxError:H(`SyntaxError`),TypeError:H(`TypeError`),URIError:H(`URIError`),AggregateError:e=>{let t=Qt(`AggregateError`,e);return t?{...t,errors:e.errors}:!1},Error:e=>{if(!fe.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&&B(t),Float64Array:t=>t instanceof e.Float64Array&&B(t),Headers:t=>t instanceof e.Headers&&Array.from(t),Int8Array:t=>t instanceof e.Int8Array&&B(t),Int16Array:t=>t instanceof e.Int16Array&&B(t),Int32Array:t=>t instanceof e.Int32Array&&B(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&&B(t),Uint8ClampedArray:t=>t instanceof e.Uint8ClampedArray&&B(t),Uint16Array:t=>t instanceof e.Uint16Array&&B(t),Uint32Array:t=>t instanceof e.Uint32Array&&B(t)}}function en(e=globalThis){return{ArrayBuffer:t=>V(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(V(t,e)),BigUint64Array:t=>new e.BigUint64Array(V(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:U(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??f)(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`)]??u)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:U(e,`RangeError`),ReferenceError:U(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??_)(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`)]??y,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:U(e,`SyntaxError`),TypeError:U(e,`TypeError`),URIError:U(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(V(t,e)),Float64Array:t=>new e.Float64Array(V(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(V(t,e)),Int16Array:t=>new e.Int16Array(V(t,e)),Int32Array:t=>new e.Int32Array(V(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(V(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(V(t,e)),Uint16Array:t=>new e.Uint16Array(V(t,e)),Uint32Array:t=>new e.Uint32Array(V(t,e))}}function tn(){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 nn(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 rn(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const W={DEVALUE_V1:`devl`,ENCRYPTED:`encr`},an=new TextEncoder,on=new TextDecoder;function sn(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...qt(),...tn(),...$t(t)};break;case`step`:r={...qt(),...$t(t)};break;case`client`:r={...qt(),...$t(t)};break}return n?{...r,...n}:r}function cn(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Jt(t),...nn(t),...en(t)};break;case`step`:r={...Jt(t),...en(t)};break;case`client`:r={...Jt(t),...en(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}};break}return n?{...r,...n}:r}const G={formatPrefix:W.DEVALUE_V1,serialize(e,t,n){let r=I(e,sn(t,n?.global,n?.extraReducers));return an.encode(r)},deserialize(e,t,n){let r=cn(t,n?.global,n?.extraRevivers);return Ot(on.decode(e),r)},deserializeLegacy(e,t,n){return kt(e,cn(t,n?.global,n?.extraRevivers))}},ln=new TextEncoder,un=new TextDecoder;function K(e,t){if(!(t instanceof Uint8Array))return t;let n=ln.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function dn(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=un.decode(t);return rn(n)?n:null}function q(e){if(!(e instanceof Uint8Array))return{format:W.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=un.decode(t);if(!rn(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}async function fn(e,t){if(!t||!(e instanceof Uint8Array))return e;let n=await Pt(t,e);return K(W.ENCRYPTED,n)}async function pn(e,t){if(!(e instanceof Uint8Array))return e;let n=dn(e);if(n===W.ENCRYPTED&&!t)throw new y(`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!==W.ENCRYPTED)return e;let{payload:r}=q(e);try{return await Ft(t,r)}catch(e){throw y.is(e)&&e.context&&(e.context.formatPrefix=n),e}}function mn(e,t,n){let[r,...i]=t.split(`
|
|
3
|
-
`),a=i.join(`
|
|
4
|
-
`),o=hn(r??``,n),s=gn(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
|
|
5
|
-
`)}function hn(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 r=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`hint`,`attempt`,`retryCount`]),i=[],a=J(t,`errorName`),s=J(t,`errorAttribution`);if(a||s){let e=s?s===`sdk`?oe(`sdk error`):re(`user error`):``,t=a?le(a):``,n=e&&t?T(` · `):``;i.push(` ${e}${n}${t}`)}let c=J(t,`workflowRunId`),l=J(t,`workflowName`);c?i.push(yn(`run`,c,l,o)):l&&i.push(yn(`run`,null,l,o));let u=J(t,`stepId`),d=J(t,`stepName`);if((u||d)&&i.push(yn(`step`,u,d,p)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?i.push(` ${vn(`retry`)} ${e} ${T(`attempts ·`)} ${n} ${T(`max retries`)}`):e!==void 0&&i.push(` ${vn(`retry`)} ${e} ${T(`attempts`)}`)}let f=J(t,`errorCode`);f&&f!==a&&i.push(` ${vn(`code`)} ${T(f)}`);let m=J(t,`hint`);m&&i.push(` ${te(m)}`);let h=Object.entries(t).filter(([e,t])=>!r.has(e)&&!n.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of h)i.push(` ${vn(e)} ${bn(t)}`);return i.length?i.join(`
|
|
6
|
-
`):null}function gn(e){if(!e)return null;let t=e.split(`
|
|
7
|
-
`),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(T(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&_n(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(T(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
|
|
8
|
-
`)}function _n(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 J(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function vn(e){return T(e.padEnd(6))}function yn(e,t,n,r){let i=t||T(`—`),a=n&&(e===`run`?c(n):s(n))?`${T(`·`)} ${r(n)}`:``;return` ${vn(e)} ${i}${a?` `+a:``}`}function bn(e){if(typeof e==`string`)return e.includes(`
|
|
9
|
-
`)?e.split(`
|
|
10
|
-
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
11
|
-
`):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var xn=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,o=0,s=0,c=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?s++:e.abortRequested?c++:i++:e.type===`wait`&&o++;let l=[];r>0&&l.push(`${r} ${a(`step`,`steps`,r)}`),i>0&&l.push(`${i} ${a(`hook`,`hooks`,i)}`),o>0&&l.push(`${o} ${a(`wait`,`waits`,o)}`),s>0&&l.push(`${s} hook ${a(`disposal`,`disposals`,s)}`);let u=a(`has`,`have`,r+i+o+s),d=+(r>0)+ +(i>0)+ +(o>0)+ +(s>0),f;f=d>1?`processed`:r>0?`run`:i>0||o>0?`created`:s>0?`processed`:`received`;let p=l.length>0?`${l.join(` and `)} ${u} not been ${f} yet`:`0 steps have not been run yet`;super(p),this.name=`WorkflowSuspension`,this.steps=n,this.globalThis=t,this.stepCount=r,this.hookCount=i,this.waitCount=o,this.hookDisposedCount=s,this.abortCount=c}static is(t){return t instanceof e}};function Sn(){throw new i(`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 Y(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Cn=Y(`workflow.name`),wn=Y(`workflow.operation`),Tn=Y(`workflow.run.id`),En=Y(`workflow.run.status`),Dn=Y(`workflow.started_at`),On=Y(`workflow.events.count`),kn=Y(`workflow.arguments.count`),An=Y(`workflow.result.type`),jn=Y(`workflow.trace.propagated`),Mn=Y(`workflow.error.name`),Nn=Y(`workflow.error.message`),Pn=Y(`workflow.error.code`),Fn=Y(`workflow.steps.created`),In=Y(`workflow.hooks.created`),Ln=Y(`workflow.waits.created`),Rn=Y(`step.name`),zn=Y(`step.id`),Bn=Y(`step.attempt`),Vn=Y(`step.status`),Hn=Y(`step.max_retries`),Un=Y(`step.skipped`),Wn=Y(`step.skip_reason`),Gn=Y(`step.arguments.count`),Kn=Y(`step.result.type`),qn=Y(`step.error.name`),Jn=Y(`step.error.message`),Yn=Y(`step.fatal_error`),Xn=Y(`step.retry.exhausted`),Zn=Y(`step.retry.timeout_seconds`),Qn=Y(`step.retry.will_retry`),$n=Y(`messaging.system`),er=Y(`messaging.destination.name`),tr=Y(`messaging.message.id`),nr=Y(`messaging.operation.type`),rr=Y(`workflow.queue.overhead_ms`),ir=Y(`deployment.id`),ar=Y(`workflow.hook.token`),or=Y(`workflow.hook.id`),sr=Y(`workflow.hook.found`),cr=Y(`workflow.suspension.state`),lr=Y(`workflow.suspension.hook_count`),ur=Y(`workflow.suspension.step_count`),dr=Y(`workflow.suspension.wait_count`),fr=Y(`error.type`),pr=Y(`workflow.events.pages_loaded`),mr=Y(`workflow.queue.deserialize_time_ms`),hr=Y(`workflow.queue.execution_time_ms`),gr=Y(`workflow.queue.serialize_time_ms`),_r=Y(`peer.service`),vr=Y(`rpc.system`),yr=Y(`rpc.service`),br=Y(`rpc.method`),xr=Y(`error.retryable`),Sr=Y(`error.category`);async function Cr(){let e=await X.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function wr(e){let t=await X.value;if(t)return t.propagation.extract(t.context.active(),e)}async function Tr(e,t){if(!e)return t();let n=await X.value;if(!n)return t();let r=await wr(e);return r?n.context.with(r,async()=>await t()):t()}const X=m(async()=>{try{return await import(`./src-B54rYDvB.js`).then(t=>e(t.t(),1))}catch{return Rr.info(`OpenTelemetry not available, tracing will be disabled`),null}}),Er=m(async()=>{let e=await X.value;return e?e.trace.getTracer(`workflow`):null});async function Dr(e,...t){let[n,r]=await Promise.all([Er.value,X.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}),Or(t,r,e),t}finally{e.end()}})}function Or(e,t,n){!e||!xn.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({...cr(`suspended`),...ur(e.stepCount),...lr(e.hookCount),...dr(e.waitCount)}))}async function kr(e){let[t,n]=await Promise.all([wr(e),X.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function Ar(){return await Mr(e=>e.trace.getActiveSpan())}async function jr(e){return Mr(t=>t.SpanKind[e])}async function Mr(e){let t=await X.value;if(t)return await e(t)}function Nr(){return Mr(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function Pr(e,t){let n=await X.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 Fr(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 Ir(e){let t=n=>{let r=t=>{let r=`workflow:${e}:${t}`;return(i,a)=>{let o=Object.keys(n).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...n,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(mn(`[workflow-sdk]`,i,c)),Fr(r,process.env.DEBUG)&&(console.debug(`[${r}] ${i}`,c??``),Ar().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:r(`debug`),info:r(`info`),warn:r(`warn`),error:r(`error`),child:e=>t({...n,...e}),forRun:(e,r,i)=>t({...n,workflowRunId:e,...r===void 0?{}:{workflowName:r},...i??{}})}};return t({})}const Lr=Ir(`step`),Rr=Ir(`runtime`),zr=Ir(`webhook`),Br=Ir(`events`);Ir(`adapter`);function Vr(e){if(y.is(e))throw e}function Z(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof P&&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 P&&t.value!==void 0&&Rr.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function Hr(e,t,n){try{let r=G.serialize(e,`client`,n);return fn(K(W.DEVALUE_V1,r),t)}catch(e){Vr(e);let{message:t,hint:n}=Z(`client value`,e);throw new d(t,{hint:n,cause:e})}}async function Ur(e,t,n){let r=await pn(e,t);if(!(r instanceof Uint8Array)){if(G.deserializeLegacy)return G.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=q(r);if(i===W.DEVALUE_V1)return G.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function Wr(e,t,n){try{let r=G.serialize(e,`step`,n);return fn(K(W.DEVALUE_V1,r),t)}catch(e){Vr(e);let{message:t,hint:n}=Z(`step value`,e);throw new d(t,{hint:n,cause:e})}}async function Gr(e,t,n){let r=await pn(e,t);if(!(r instanceof Uint8Array)){if(G.deserializeLegacy)return G.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=q(r);if(i===W.DEVALUE_V1)return G.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function Kr(e,t){if(!(e instanceof Uint8Array)){if(G.deserializeLegacy)return G.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=q(e);if(n===W.DEVALUE_V1)return G.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const qr=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),Jr=globalThis[qr]??(globalThis[qr]=new pe);function Yr(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 Xr(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function Zr(e){return`strm_${e}_system_abort`}function Qr(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return Zr(e.slice(5))}async function $r(e){let t=e();return(0,jt.waitUntil)(t.catch(()=>{})),t}var Q;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Q||={});var ei=class{eventIndex;events=[];callbacks=[];onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,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)}consume=()=>{let e=this.events[this.eventIndex]??null;for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Q.NotConsumed;try{r=n(e)}catch(e){Br.error(`EventConsumer callback threw an error`,{error:e})}if(r===Q.Consumed||r===Q.Finished){this.eventIndex++,r===Q.Finished&&this.callbacks.splice(t,1),process.nextTick(this.consume);return}}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))},100)})}}},ti=class{aborted=!1;reason=void 0;[E];[k];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[E]=e,this[k]=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 ni(e){return class{signal;[E];[k];constructor(){let t=e.generateUlid(),n=Zr(t),r=`abrt_${t}`;this[E]=n,this[k]=r,this.signal=new ti(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 Q.NotConsumed;let n=`eventData`in t&&t.eventData&&`token`in t.eventData?t.eventData.token:void 0;if(typeof n==`string`&&n!==this[k])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new v(`Corrupted event log: abort hook event ${t.eventType} for ${i} belongs to token "${n}", but the current abort hook expects "${this[k]}"`))}),Q.Finished;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(i);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Q.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload;return e.promiseQueue=e.promiseQueue.then(async()=>{let t;if(n!==void 0)try{let r=await Bi(n,e.runId,e.encryptionKey,e.globalThis);r&&typeof r==`object`&&`reason`in r&&(t=r.reason)}catch{}this.signal._setAborted(t)}),e.invocationsQueue.delete(i),Q.Consumed}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(i),Q.Finished):Q.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[k]){n.abortRequested=!0,n.abortReason=t;break}}}}}function ri(){return{abort(e){let t=new ti(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new ti(``,``),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 ii=ue();function ai(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function oi(e){return Vr(e),e instanceof d&&e.cause!==void 0||e instanceof i&&e.cause!==void 0?e.cause:e}function si(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 t,!0);let o=I(i,e),s=n.encode(o),c=K(W.DEVALUE_V1,s);if(r.key){let e=await Pt(r.key,c);c=K(W.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(y.is(e)){a.error(e);return}let{message:t,hint:n}=Z(`stream chunk`,e);a.error(new d(t,{hint:n,cause:e}))}}})}function ci(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 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}=q(o);if(s===W.ENCRYPTED){if(!i.key){a.error(new y(`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 Ft(i.key,c)}catch(e){throw y.is(e)&&e.context&&(e.context.formatPrefix=s),e}({format:s,payload:c}=q(e))}if(s===W.DEVALUE_V1){let t=n.decode(c);a.enqueue(Ot(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(`
|
|
12
|
-
`);for(let t of s)t.length>0&&i.enqueue(Ot(t,e))},async flush(e){r.length>0&&await o(e)}})}var li=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new i(`"name" is required, got "${t}"`);super({type:`bytes`,pull:async r=>{let i=this.#e;if(!i){let r=await(await z()).streams.get(e,t,n);i=this.#e=r.getReader()}if(!i){r.error(Error(`Failed to get reader`));return}let a=await i.read();a.done?(this.#e=void 0,r.close()):r.enqueue(a.value)},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}},$=class extends WritableStream{constructor(e,t){if(typeof e!=`string`)throw new i(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new i(`"name" is required, got "${t}"`);let n=z(),r=[],a=null,o=null,s,c=async()=>{if(a&&=(clearTimeout(a),null),r.length===0)return;let i=r.slice(),o=await n;if(s===void 0&&(s=o.streamFlushIntervalMs??10),typeof o.streams.writeMulti==`function`&&i.length>1)await o.streams.writeMulti(e,t,i);else for(let n of i)await o.streams.write(e,t,n);r=[]},l=[],u=()=>{a||=setTimeout(()=>{a=null;let e=l;l=[],o=c().then(()=>{for(let t of e)t.resolve()},t=>{for(let n of e)n.reject(t)})},s??10)};super({async write(e){o&&=(await o,null),r.push(e),u(),await new Promise((e,t)=>{l.push({resolve:e,reject:t})})},async close(){o&&=(await o,null),await c(),await(await n).streams.close(e,t)},abort(e){a&&=(clearTimeout(a),null),r=[];let t=l;l=[];let n=e??Error(`Stream aborted`);for(let e of t)e.reject(n)}})}};function ui(e=globalThis){return{...qt(),...tn(),...$t(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[w];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[E])&&(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 di(e,t,n,r,i,a){let o=t[E],s=t[k];if(!o){let e=(n[ae]||ii)();o=Zr(e),s=`abrt_${e}`,t[E]=o,t[k]=s,t.signal&&(t.signal[E]=o,t.signal[k]=s)}return pi(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function fi(e,t){let n=t[E]??t.signal?.[E],r=t[k]??t.signal?.[k];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 pi(e,t,n,r,i){e.aborted||e[ie]||(e[ie]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await r,a=await Ni({aborted:!0,reason:e.reason},n,i),o=new $(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function mi(e=globalThis,t,n,r){return{...ui(e),ReadableStream:i=>{if(!(i instanceof e.ReadableStream))return!1;if(i.locked)throw new d(`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 a=`strm_${(e[ae]||ii)()}`,o=ai(i),s=new $(n,a);o===`bytes`?t.push(i.pipeTo(s)):t.push(i.pipeThrough(si(mi(e,t,n,r),r)).pipeTo(s));let c={name:a};return o&&(c.type=o),c},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[O],a=r[D];if(typeof i==`string`&&typeof a==`string`){let e={name:i,runId:a},t=r[C];return typeof t==`string`&&(e.deploymentId=t),e}let o=`strm_${(e[ae]||ii)()}`,s=new li(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:di(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:di(i,i,e,t,n,r)}}function hi(e=globalThis){return{...ui(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[S];if(n!==void 0)return{bodyInit:n};let r=t[O];if(!r)throw new i("ReadableStream `name` is not set");let a={name:r},o=t[ce];return o&&(a.type=o),a},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[O];if(!n)throw new i("WritableStream `name` is not set");let r={name:n},a=t[D];typeof a==`string`&&(r.runId=a);let o=t[C];return typeof o==`string`&&(r.deploymentId=o),r},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[E]??n.signal?.[E],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:fi(t.signal,n)},AbortSignal:t=>{let n=t?.[E],r=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!n&&!r?!1:fi(t,t)}}}function gi(e=globalThis,t,n,r){return{...ui(e),ReadableStream:i=>{if(!(i instanceof e.ReadableStream))return!1;if(i.locked)throw new d(`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 a=i[O],o=i[ce];if(!a){a=`strm_${(e[ae]||ii)()}`,o=ai(i);let s=new $(n,a);o===`bytes`?t.push(i.pipeTo(s)):t.push(i.pipeThrough(si(gi(e,t,n,r),r)).pipeTo(s))}let s={name:a};return o&&(s.type=o),s},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[O],o=i[D];a||(a=`strm_${(e[ae]||ii)()}`,t.push(new li(n,a).pipeThrough(ci(Ei(e,t,n,r),r)).pipeTo(i)));let s={name:a};typeof o==`string`&&(s.runId=o);let c=i[C];return typeof c==`string`&&(s.deploymentId=c),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:di(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:di(i,i,e,t,n,r)}}function _i(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new li(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(r.releaseLock(),a.value&&!a.done)try{let n=Jr.getStore(),r=await Pi(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}catch{}})()),i}function vi(e,t,n){let r=e,i=e.signal;r[E]=t.streamName,r[k]=t.hookToken,i[E]=t.streamName,i[k]=t.hookToken,n&&(r[se]=n,i[se]=n)}function yi(e,t){let n=e,r=t;n[E]!==void 0&&(r[E]=n[E]),n[k]!==void 0&&(r[k]=n[k]),n[se]!==void 0&&(r[se]=n[se])}function bi(e,t,n){let r=new AbortController;e.aborted?(vi(r,e),r.abort(e.reason)):e.streamName?vi(r,e,_i(r,n,e.streamName,t)):vi(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=Jr.getStore();n&&(n.ops.push((async()=>{try{let r=await Ni({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&&n.ops.push((async()=>{try{let{resumeHook:n}=await Promise.resolve().then(()=>ha);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})()))},r}function xi(e,t,n){let r=new AbortController;return e.aborted?(vi(r,e),r.abort(e.reason)):e.streamName?vi(r,e,_i(r,n,e.streamName,t)):vi(r,e),r.signal}function Si(e=globalThis){return{...Jt(e),...en(e)}}async function Ci(e,t){let n=await z();if(!n.getEncryptionKeyForRun)return;let r=t?await n.getEncryptionKeyForRun(e,{deploymentId:t}):await n.getEncryptionKeyForRun(await n.runs.get(e));return r?await Nt(r,[`encrypt`]):void 0}function wi(e=globalThis,t,n,r){return{...Si(e),StepFunction:()=>{throw new d(`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 d(`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&&yi(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}let a=new li(n,i.name,i.startIndex);if(i.type===`bytes`){let n=L();t.push(n.promise);let{readable:r,writable:i}=new e.TransformStream;return R(a,i,n).catch(()=>{}),zt(r,n),r}else{let i=ci(wi(e,t,n,r),r),o=L();return t.push(o.promise),R(a,i.writable,o).catch(()=>{}),zt(i.readable,o),i.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:Ci(a,i.deploymentId),s=si(mi(e,t,a,o),o),c=new $(a,i.name),l=L();return t.push(l.promise),R(s.readable,c,l).catch(()=>{}),Rt(s.writable,l),Object.defineProperty(s.writable,O,{value:i.name,writable:!1}),Object.defineProperty(s.writable,D,{value:a,writable:!1}),typeof i.deploymentId==`string`&&Object.defineProperty(s.writable,C,{value:i.deploymentId,writable:!1}),s.writable},AbortController:e=>bi(e,t,n),AbortSignal:e=>xi(e,t,n)}}function Ti(e=globalThis){return{...Si(e),...nn(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[w]=n,delete t.responseWritable,t.respondWith=()=>{throw new d("`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 d(`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,{[S]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[O]:{value:t.name,writable:!1},[ce]:{value:t.type,writable:!1}}),WritableStream:t=>{let n={[O]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[D]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[C]={value:t.deploymentId,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new ti(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[E]:e.streamName,[k]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new ti(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function Ei(e=globalThis,t,n,r,a){return{...Si(e),StepFunction:e=>{let t=e.stepId,n=e.closureVars,r=`boundThis`in e,a=r?e.boundThis:void 0,o=Array.isArray(e.boundArgs)?e.boundArgs:[],s=de(t);if(!s)throw new d(`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&&o.length===0)return s;let c=function(...e){let t=r?a:this,c=o.length>0?[...o,...e]:e;if(n){let e=Jr.getStore();if(!e)throw new i(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return Jr.run(r,()=>s.apply(t,c))}return s.apply(t,c)};return Object.defineProperty(c,"name",{value:s.name}),Object.defineProperty(c,"stepId",{value:t,writable:!1,enumerable:!1,configurable:!1}),s.maxRetries!==void 0&&(c.maxRetries=s.maxRetries),c},WorkflowFunction:e=>Object.assign(()=>{throw new d(`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&&yi(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:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}let o=new li(n,i.name);if(i.type===`bytes`){let n=L();t.push(n.promise);let{readable:r,writable:i}=new e.TransformStream;return R(o,i,n).catch(()=>{}),zt(r,n),r}else{let i=ci(Ei(e,t,n,r,a),r),s=L();return t.push(s.promise),R(o,i.writable,s).catch(()=>{}),zt(i.readable,s),i.readable}},WritableStream:i=>{let o=typeof i.runId==`string`?i.runId:n,s=typeof i.deploymentId==`string`?i.deploymentId:o===n?a:void 0,c=o===n?r:Ci(o,s),l=si(gi(e,t,o,c),c),u=new $(o,i.name),d=L();return t.push(d.promise),R(l.readable,u,d).catch(()=>{}),Rt(l.writable,d),Object.defineProperty(l.writable,O,{value:i.name,writable:!1}),Object.defineProperty(l.writable,D,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,C,{value:s,writable:!1}),l.writable},AbortController:e=>bi(e,t,n),AbortSignal:e=>xi(e,t,n)}}async function Di(e,t){return await fn(e,t)}async function Oi(e,t){return pn(e,t)}async function ki(e,t,n,r=[],i=globalThis,a=!1){if(a)return Xt(I(e,mi(i,r,t,n)));try{return await Hr(e,n,{global:i,extraReducers:Hi(mi(i,r,t,n))})}catch(e){let t=oi(e),{message:n,hint:r}=Z(`workflow arguments`,t);throw new d(n,{hint:r,cause:t})}}async function Ai(e,t,n,r=globalThis,i={}){return Kr(await Oi(e,n),{global:r,extraRevivers:{...Ui(Ti(r)),...i}})}async function ji(e,t,n,r=globalThis,i=!1){if(i)return Xt(I(e,hi(r)));try{return await Wr(e,n,{global:r,extraReducers:Hi(hi(r))})}catch(e){let t=oi(e),{message:n,hint:r}=Z(`workflow return value`,t);throw new d(n,{hint:r,cause:t})}}async function Mi(e,t,n,r=[],i=globalThis,a={}){return Ur(e,n,{global:i,extraRevivers:{...Ui(wi(i,r,t,n)),...a}})}async function Ni(e,t,n,r=globalThis,i=!1){if(i)return Xt(I(e,hi(r)));try{return await Wr(e,n,{global:r,extraReducers:Hi(hi(r))})}catch(e){let t=oi(e),{message:n,hint:r}=Z(`step arguments`,t);throw new d(n,{hint:r,cause:t})}}async function Pi(e,t,n,r=[],i=globalThis,a={},o){return Gr(e,n,{global:i,extraRevivers:{...Ui(Ei(i,r,t,n,o)),...a}})}async function Fi(e,t,n,r=[],i=globalThis,a=!1){if(a)return Xt(I(e,gi(i,r,t,n)));try{return await Wr(e,n,{global:i,extraReducers:Hi(gi(i,r,t,n))})}catch(e){let t=oi(e),{message:n,hint:r}=Z(`step return value`,t);throw new d(n,{hint:r,cause:t})}}async function Ii(e,t,n,r=[],i=globalThis){try{let a=I(e,gi(i,r,t,n)),o=new TextEncoder().encode(a);return await Di(K(W.DEVALUE_V1,o),n)}catch(e){let t=oi(e),{message:n,hint:r}=Z(`step error`,t);throw new d(n,{hint:r,cause:t})}}async function Li(e,t,n,r=globalThis,i={}){let a=await Oi(e,n);if(!(a instanceof Uint8Array))return kt(a,{...Ti(r),...i});let{format:o,payload:s}=q(a);if(o===W.DEVALUE_V1)return Ot(new TextDecoder().decode(s),{...Ti(r),...i});throw Error(`Unsupported serialization format: ${o}`)}async function Ri(e,t,n,r=globalThis){try{let t=I(e,hi(r)),i=new TextEncoder().encode(t);return await Di(K(W.DEVALUE_V1,i),n)}catch(e){let t=oi(e),{message:n,hint:r}=Z(`run error`,t);throw new d(n,{hint:r,cause:t})}}async function zi(e,t,n,r=[],i=globalThis,a={}){let o=await Oi(e,n);if(!(o instanceof Uint8Array))return kt(o,{...wi(i,r,t,n),...a});let{format:s,payload:c}=q(o);if(s===W.DEVALUE_V1)return Ot(new TextDecoder().decode(c),{...wi(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${s}`)}async function Bi(e,t,n,r=globalThis,i={}){return Kr(await Oi(e,n),{global:r,extraRevivers:{...Ui(Ti(r)),...i}})}const Vi=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function Hi(e){let t={};for(let n of Vi)n in e&&(t[n]=e[n]);return t}function Ui(e){let t={};for(let n of Vi)n in e&&(t[n]=e[n]);return t}const Wi=[{format:W.ENCRYPTED,minVersion:`4.2.0-beta.64`}],Gi=new Set([W.DEVALUE_V1]);function Ki(e){if(!e||!Mt.default.valid(e))return{supportedFormats:Gi};let t=new Set(Gi);for(let{format:n,minVersion:r}of Wi)Mt.default.gte(e,r)&&t.add(n);return{supportedFormats:t}}const qi=`5.0.0-beta.11`,Ji=/^[a-zA-Z0-9_\-./@]+$/;function Yi(e){if(!Ji.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`__wkf_workflow_${e}`}const Xi=ue();function Zi(e){return`__health_check__${e}`}function Qi(e){let t=ne.safeParse(e);if(t.success)return t.data}function $i(e){return`wrun_hc_${e}`}async function ea(e,t,n){let r=await z(),i=Zi(e.correlationId),a=JSON.stringify({healthy:!0,endpoint:t,correlationId:e.correlationId,specVersion:n??3,workflowCoreVersion:qi,timestamp:Date.now()}),o=$i(e.correlationId);await r.streams.write(o,i,a),await r.streams.close(o,i)}async function ta(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 na(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),s}async function ra(e,t,n){let r=n?.timeout??3e4,i=Xi(),a=Zi(i),o=t===`workflow`?`__wkf_workflow_health_check`:`__wkf_step_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=(await e.streams.get($i(i),a)).getReader(),{chunks:n,timedOut:r}=await ta(t,500);if(r){try{t.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let o=na(n);if(o)return{...o,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 ia(e,t){return new b(`Event pagination ${t} for workflow run "${e}".`,{code:l.WORLD_CONTRACT_ERROR})}function aa(e,t,n){if(t){if(n.has(t))throw ia(e,`did not advance`);n.add(t)}}function oa(e,t,n){for(let r of n)t.has(r.eventId)||(t.add(r.eventId),e.push(r))}function sa(e,t,n,r){if(t){if(n===null)throw ia(e,`returned more pages without a cursor`);if(r.has(n))throw ia(e,`repeated a cursor`)}}function ca(e,t,n){return t!==null&&!n&&b.is(e)&&e.status===400}async function la(e,t){let n=t!==void 0;return Dr(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...Tn(e)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await z(),f=Date.now();for(;c;){let t=Date.now(),r=s;aa(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(ca(t,r,u)){Rr.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}oa(i,a,f.data),c=f.hasMore,sa(e,c,f.cursor,o),s=f.cursor??s,l++,Rr.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return Rr.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...On(i.length),...pr(l)}),{events:i,cursor:s}})}const ua={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function da(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:ua}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??3,workflowCoreVersion:qi}),{status:200,headers:{"Content-Type":`application/json`,...ua}}):await e(n)}}async function fa(e,...t){let n=t[0];await Dr(`queue.publish`,{attributes:{...$n(`vercel-queue`),...er(n),...nr(`publish`),..._r(`vercel-queue`),...vr(`vercel-queue`),...yr(`vqs`),...br(`publish`)},kind:await jr(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(tr(r))})}function pa(e){if(e.requestedAt)try{return rr(Date.now()-e.requestedAt.getTime())}catch{return}}function ma(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await Nt(n):void 0})(),n)}var ha=t({getHookByToken:()=>_a,resumeHook:()=>va,resumeWebhook:()=>ya});async function ga(e){let t=await z(),n=await t.hooks.getByToken(e),r=await t.runs.get(n.runId),i=await t.getEncryptionKeyForRun?.(r),a=i?await Nt(i):void 0;return n.metadata!==void 0&&(n.metadata=await Pi(n.metadata,n.runId,a)),{hook:n,run:r,encryptionKey:a}}async function _a(e){let{hook:t}=await ga(e);return t}async function va(e,t,n){return await $r(()=>Dr(`hook.resume`,async r=>{let i=await z();try{let a,o,s;if(typeof e==`string`){let t=await ga(e);a=t.hook,o=t.run,s=n??t.encryptionKey}else if(a=e,o=await i.runs.get(a.runId),n)s=n;else{let e=await i.getEncryptionKeyForRun?.(o);s=e?await Nt(e):void 0}r?.setAttributes({...ar(a.token),...or(a.hookId),...Tn(a.runId)});let c=o.executionContext?.workflowCoreVersion,{supportedFormats:l}=Ki(typeof c==`string`?c:void 0);l.has(W.ENCRYPTED)||(s=void 0);let u=[],d=x(a.specVersion),f=await Fi(t,a.runId,s,u,globalThis,d);(0,jt.waitUntil)(Promise.all(u).catch(e=>{if(e!==void 0)throw e})),await i.events.create(a.runId,{eventType:`hook_received`,specVersion:3,correlationId:a.hookId,eventData:{...d?{}:{token:a.token},payload:f}},{v1Compat:d}),r?.setAttributes({...Cn(o.workflowName)});let p=o.executionContext?.traceCarrier;if(p){let e=await kr(p);e&&r?.addLink?.({context:e})}return await i.queue(Yi(o.workflowName),{runId:a.runId,traceCarrier:o.executionContext?.traceCarrier??void 0},{deploymentId:o.deploymentId,specVersion:o.specVersion??1}),a}catch(t){throw r?.setAttributes({...ar(typeof e==`string`?e:e.token),...sr(!1)}),t}}))}async function ya(e,t){let{hook:n,encryptionKey:r}=await ga(e);if(n.isWebhook===!1)throw new g(e);let a,o;if(n.metadata&&typeof n.metadata==`object`&&`respondWith`in n.metadata)if(n.metadata.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;o=e,t[w]=n}else if(n.metadata.respondWith instanceof Response)a=n.metadata.respondWith;else throw new i(`Invalid \`respondWith\` value: ${n.metadata.respondWith}`,{slug:h.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else a=new Response(null,{status:202});if(await va(n,t,r),o){let e=o.getReader(),t=await e.read();t.value&&(a=t.value),e.cancel()}if(!a)throw new i(`Workflow run did not send a response`,{slug:h.WEBHOOK_RESPONSE_NOT_SENT});return a}export{nr as $,ri as A,Dn as At,Lr as B,R as Bt,si as C,On as Ct,Bi as D,An as Dt,Li as E,wn as Et,Qr as F,xn as Ft,Tr as G,Nr as H,Nt as Ht,Xr as I,Wt as It,Sr as J,Pr as K,$r as L,Ut as Lt,Q as M,jn as Mt,ei as N,Ln as Nt,Ai as O,Tn as Ot,Yr as P,Sn as Pt,tr as Q,Jr as R,z as Rt,wi as S,Mn as St,Pi as T,Cn as Tt,Cr as U,Te as Ut,zr as V,Rt as Vt,Dr as W,fr as X,xr as Y,er as Z,Ii as _,Un as _t,Yi as a,Bn as at,ji as b,Pn as bt,la as c,Yn as ct,fa as d,Rn as dt,$n as et,da as f,Kn as ft,Ni as g,Wn as gt,Ri as h,Qn as ht,pa as i,Gn as it,ni as j,Fn as jt,Mi as k,En as kt,ma as l,zn as lt,$ as m,Zn as mt,va as n,hr as nt,ea as o,Jn as ot,qi as p,Xn as pt,ir as q,ya as r,gr as rt,ra as s,qn as st,_a as t,mr as tt,Qi as u,Hn as ut,Fi as v,Vn as vt,zi as w,In as wt,mi as x,Nn as xt,ki as y,kn as yt,Rr as z,L as zt};
|