eve 0.52.4 → 0.53.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.
Files changed (149) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/src/cli/commands/init-agent-workspace.d.ts +2 -0
  3. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  4. package/dist/src/cli/commands/init-install.d.ts +8 -0
  5. package/dist/src/cli/commands/init-install.js +1 -0
  6. package/dist/src/cli/commands/init.d.ts +3 -4
  7. package/dist/src/cli/commands/init.js +1 -1
  8. package/dist/src/cli/dev/tui/message-queue.js +1 -1
  9. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  10. package/dist/src/cli/run.js +2 -2
  11. package/dist/src/cli/telemetry/index.d.ts +3 -0
  12. package/dist/src/cli/telemetry/index.js +1 -1
  13. package/dist/src/compiled/.vendor-stamp.json +17 -16
  14. package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +23 -2
  15. package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -4
  16. package/dist/src/compiled/@ai-sdk/google/index.d.ts +145 -33
  17. package/dist/src/compiled/@ai-sdk/google/index.js +10 -7
  18. package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +176 -7
  19. package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
  20. package/dist/src/compiled/@ai-sdk/openai/index.d.ts +71 -40
  21. package/dist/src/compiled/@ai-sdk/openai/index.js +8 -8
  22. package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
  23. package/dist/src/compiled/@ai-sdk/provider/index.d.ts +225 -3
  24. package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +220 -151
  25. package/dist/src/compiled/@workflow/core/create-hook.d.ts +3 -0
  26. package/dist/src/compiled/@workflow/core/index.js +2 -2
  27. package/dist/src/compiled/@workflow/core/private.js +1 -1
  28. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +59 -7
  29. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +42 -0
  30. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +31 -1
  31. package/dist/src/compiled/@workflow/core/runtime.d.ts +2 -2
  32. package/dist/src/compiled/@workflow/core/runtime.js +2 -2
  33. package/dist/src/compiled/@workflow/core/serialization.d.ts +22 -0
  34. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  35. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  36. package/dist/src/compiled/@workflow/errors/index.d.ts +37 -3
  37. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  38. package/dist/src/compiled/@workflow/world/attributes-validation.d.ts +68 -0
  39. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  40. package/dist/src/compiled/@workflow/world/interfaces.d.ts +21 -0
  41. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  42. package/dist/src/compiled/@workflow/world-vercel/index.js +3 -3
  43. package/dist/src/compiled/_chunks/workflow/attribute-changes-C6H-fRVP.js +20 -0
  44. package/dist/src/compiled/_chunks/workflow/dist-DDeH-1ER.js +40 -0
  45. package/dist/src/compiled/_chunks/workflow/dist-DhncQSl7.js +74 -0
  46. package/dist/src/compiled/_chunks/workflow/{dist-BIO9Inoc.js → dist-xTushGCp.js} +1 -1
  47. package/dist/src/compiled/_chunks/workflow/frames-DsEqSDes.js +3 -0
  48. package/dist/src/compiled/_chunks/workflow/{private-aXEeo0fU.js → private-CFJkQA7R.js} +1 -1
  49. package/dist/src/compiled/_chunks/workflow/resume-hook-BRDLAb67.js +1 -0
  50. package/dist/src/compiled/_chunks/workflow/run-BM2OFphk.js +1 -0
  51. package/dist/src/compiled/_chunks/workflow/sleep-6cG0F99-.js +1 -0
  52. package/dist/src/compiled/_chunks/workflow/{ws-transport-M7uk8HV8.js → ws-transport-DuK82LLz.js} +1 -1
  53. package/dist/src/compiler/extension-compatibility.d.ts +7 -6
  54. package/dist/src/compiler/extension-compatibility.js +1 -1
  55. package/dist/src/compiler/manifest.js +1 -1
  56. package/dist/src/compiler/normalize-agent-config.js +1 -1
  57. package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
  58. package/dist/src/context/dynamic-model-lifecycle.js +1 -1
  59. package/dist/src/context/keys.d.ts +11 -2
  60. package/dist/src/context/keys.js +1 -1
  61. package/dist/src/evals/mock-model.js +1 -1
  62. package/dist/src/evals/runner/run-evals.d.ts +1 -1
  63. package/dist/src/evals/runner/run-evals.js +1 -1
  64. package/dist/src/execution/activity-cohort.d.ts +20 -0
  65. package/dist/src/execution/activity-cohort.js +1 -0
  66. package/dist/src/execution/authorization-callback-match.d.ts +1 -0
  67. package/dist/src/execution/authorization-callback-match.js +1 -1
  68. package/dist/src/execution/cancelled-model-call-batch.d.ts +15 -0
  69. package/dist/src/execution/cancelled-model-call-batch.js +1 -0
  70. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  71. package/dist/src/execution/model-call-batching.d.ts +11 -0
  72. package/dist/src/execution/model-call-batching.js +1 -0
  73. package/dist/src/execution/parked-delivery-wait.js +1 -1
  74. package/dist/src/execution/session-activity-projection.d.ts +2 -0
  75. package/dist/src/execution/session-activity-projection.js +1 -1
  76. package/dist/src/execution/skills/instructions.js +1 -1
  77. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  78. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +5 -5
  79. package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
  80. package/dist/src/execution/tools/subagent/start.js +1 -1
  81. package/dist/src/execution/tools/workflow/body.js +1 -1
  82. package/dist/src/execution/turn-workflow.js +1 -1
  83. package/dist/src/execution/wire/session-inbox-resume.js +1 -1
  84. package/dist/src/execution/workflow-steps.d.ts +1 -1
  85. package/dist/src/execution/workflow-steps.js +1 -1
  86. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  87. package/dist/src/harness/authorization.d.ts +1 -0
  88. package/dist/src/harness/authorization.js +1 -1
  89. package/dist/src/harness/compaction.js +1 -1
  90. package/dist/src/harness/current-messages.d.ts +8 -2
  91. package/dist/src/harness/current-messages.js +1 -1
  92. package/dist/src/harness/hitl/approval-input-requests.js +1 -1
  93. package/dist/src/harness/input-requests.js +1 -1
  94. package/dist/src/harness/pending-input-batches.d.ts +4 -0
  95. package/dist/src/harness/pending-input-batches.js +1 -1
  96. package/dist/src/harness/tool-loop.js +2 -2
  97. package/dist/src/harness/turn-client-context.d.ts +1 -1
  98. package/dist/src/internal/application/package.js +1 -1
  99. package/dist/src/internal/authored-definition/core.js +1 -1
  100. package/dist/src/internal/authored-package-boundary.js +1 -1
  101. package/dist/src/internal/mock-model-identity.d.ts +2 -0
  102. package/dist/src/internal/mock-model-identity.js +1 -0
  103. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  104. package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
  105. package/dist/src/public/tools/index.d.ts +1 -0
  106. package/dist/src/public/tools/index.js +1 -1
  107. package/dist/src/runtime/resolve-agent.js +1 -1
  108. package/dist/src/self-modification/agent.d.ts +2 -2
  109. package/dist/src/self-modification/agent.js +1 -1
  110. package/dist/src/self-modification/config.d.ts +15 -0
  111. package/dist/src/self-modification/config.js +1 -1
  112. package/dist/src/self-modification/extension/extension.d.ts +3 -0
  113. package/dist/src/self-modification/extension/extension.js +1 -1
  114. package/dist/src/self-modification/setup.d.ts +3 -0
  115. package/dist/src/self-modification/setup.js +25 -4
  116. package/dist/src/setup/integrations/self-modification/setup.js +1 -1
  117. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  118. package/dist/src/setup/scaffold/create/project.js +2 -2
  119. package/dist/src/setup/scaffold/update/web-options.js +1 -1
  120. package/dist/src/shared/agent-definition.d.ts +11 -2
  121. package/dist/src/tasks/delivery-context.d.ts +2 -2
  122. package/dist/src/tasks/delivery-context.js +2 -18
  123. package/dist/src/tasks/delivery-policy.js +1 -1
  124. package/dist/src/tools/durable-callbacks.d.ts +18 -1
  125. package/dist/src/tools/durable-callbacks.js +1 -1
  126. package/dist/src/tools/workflow-definition.d.ts +38 -4
  127. package/docs/agent-config.md +44 -8
  128. package/docs/channels/overview.mdx +2 -0
  129. package/docs/channels/slack.mdx +2 -0
  130. package/docs/concepts/execution-model-and-durability.mdx +20 -2
  131. package/docs/evals/running.mdx +3 -1
  132. package/docs/guides/dev-tui.md +11 -11
  133. package/docs/guides/dynamic-capabilities.md +36 -1
  134. package/docs/guides/instrumentation.md +3 -2
  135. package/docs/instructions.mdx +1 -1
  136. package/docs/reference/cli.md +1 -1
  137. package/docs/reference/telemetry.md +1 -1
  138. package/docs/reference/typescript-api.md +36 -35
  139. package/docs/subagents/index.mdx +1 -1
  140. package/docs/tools/overview.mdx +4 -2
  141. package/docs/tools/workflows.mdx +15 -10
  142. package/package.json +17 -17
  143. package/dist/src/compiled/_chunks/workflow/attribute-changes-DpruylJZ.js +0 -20
  144. package/dist/src/compiled/_chunks/workflow/dist-ChzQSWQA.js +0 -65
  145. package/dist/src/compiled/_chunks/workflow/dist-veFIAdWV.js +0 -40
  146. package/dist/src/compiled/_chunks/workflow/frames-DKxlMf3X.js +0 -3
  147. package/dist/src/compiled/_chunks/workflow/resume-hook-DWDi_wCN.js +0 -1
  148. package/dist/src/compiled/_chunks/workflow/run-vsAdI41O.js +0 -1
  149. package/dist/src/compiled/_chunks/workflow/sleep-BKxoNDRv.js +0 -1
@@ -0,0 +1,20 @@
1
+ import{a as e,t}from"./rolldown-runtime-DPpTSio4.js";import{D as n,O as r,T as i,b as a,et as o,ft as s,o as c,ot as l,p as u,rt as d,zl as f}from"./dist-DDeH-1ER.js";import{A as p,P as m,_ as h,a as g,c as _,g as v,i as y,j as ee,k as b,l as te,m as x,p as S,u as ne}from"./dist-xTushGCp.js";import{a as re,d as C,f as ie,n as ae,t as oe,u as se}from"./private-CFJkQA7R.js";import{types as w}from"node:util";import{AsyncLocalStorage as ce}from"node:async_hooks";function le(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 ue(e){return le(`workflow`,e)}function de(e){return le(`step`,e)}function fe(e){return _e(de(e),e)}function pe(e){return _e(ue(e),e)}function me(e){return ue(e)?.shortName??ge(`workflow`,e)??e}function he(e){return de(e)?.shortName??ge(`step`,e)??e}function ge(e,t){if(!t.startsWith(`${e}--`))return null;let n=t.split(`--`).filter(Boolean),r=n.at(-1)?.split(`-`).filter(Boolean).at(-1)??``;if([`default`,`__default`].includes(r)){let t=n.at(-2)?.split(`-`).filter(Boolean).at(-1);t&&t!==e&&(r=t)}return r||null}function _e(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}function ve(e,t){let n=Error.captureStackTrace;n?.(e,t)}const ye=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:!e.env.NO_COLOR&&!!e.stdout?.isTTY:!1})(),be=(e,t)=>n=>ye?`\x1b[${e}m${n}\x1b[${t}m`:n,T={bold:be(1,22),dim:be(2,22),italic:be(3,23),red:be(31,39),blue:be(34,39),cyan:be(36,39),yellow:be(33,39),magenta:be(35,39)},xe={info:T.blue,help:T.cyan,warn:T.yellow,error:T.red};function Se(e){let t=Array.isArray(e)?e.join(`
2
+ `):e;return xe.info(`${T.bold(`hint:`)} ${t}`)}function Ce(e){return xe.info(`${T.bold(`docs:`)} ${e}`)}function we(e){return T.italic(`${T.dim("`")}${e}${T.dim("`")}`)}function E(e){return T.dim(e)}function Te(e){return T.bold(e)}function Ee(e){return T.red(e)}function De(e){return T.magenta(e)}function Oe(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
3
+ `),a=r===t.length-1,o=a?`╰▶ `:`├▶ `,s=a?` `:`│ `,c=i.map((e,t)=>`${t===0?o:s}${e}`);n.push(...c)}),n.join(`
4
+ `)}const ke=Symbol.for(`nodejs.util.inspect.custom`);function Ae(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function je(e){return`code`in e?we(e.code):`dim`in e?E(e.dim):e.text}function Me(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(Ae).join(``)}function Ne(e){return e.type===`docs`?Ce(e.url):e.segments.map(je).join(``)}function Pe(e){let t=[e.title.map(Ae).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;Me(n).split(`
5
+ `).forEach((e,n)=>{t.push(`${n===0?a:o}${e}`)})}),t.join(`
6
+ `)}function Fe(e){return Oe(e.title.map(je).join(``),e.details.map(Ne))}var Ie=class extends Error{fatal=!0;#e;constructor(e){super(Pe(e)),this.#e=e}[ke](){let e=Fe(this.#e),t=this.message.split(`
7
+ `).length,n=(this.stack??``).split(`
8
+ `).slice(t).join(`
9
+ `);return n?`${this.name}: ${e}\n${n}`:`${this.name}: ${e}`}toString(){return`${this.name}: ${Fe(this.#e)}`}},Le=class extends Ie{name=`NotInWorkflowContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow function`}],details:[{type:`docs`,url:t}]})}},Re=class extends Ie{name=`NotInStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a step function`}],details:[{type:`docs`,url:t}]})}},ze=class extends Ie{name=`NotInWorkflowOrStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow or step function`}],details:[{type:`docs`,url:t}]})}};const Be=Symbol.for(`WORKFLOW_CONTEXT`);function Ve(){let e=globalThis[Be];if(!e){let e=new ze(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`);throw ve(e,Ve),e}return e}var He=class extends Ie{name=`UnavailableInWorkflowContextError`;constructor(e,t){let n=globalThis[Be]?.workflowName,r=(()=>{if(!n)return null;let e=n.match(/^(workflow\/|step\/)(.*)$/);return e?[{dim:e[1]},{text:e[2]}]:[{text:n}]})(),i=r?{type:`plain`,segments:[{text:`this call was made from the `},...r,{text:` workflow context.`}]}:{type:`plain`,segments:[{text:`this call was made from a workflow context.`}]};super({title:[{code:e},{text:` cannot be called from a workflow context.`}],details:[{type:`plain`,segments:[{text:`calling this in a workflow context can cause determinism issues.`}]},i,{type:`docs`,url:t}]})}};function Ue(e,t,n){let r=new Le(e,t);throw ve(r,n),r}function We(e,t,n){let r=new Re(e,t);throw ve(r,n),r}function Ge(e,t,n){let r=new ze(e,t);throw ve(r,n),r}function Ke(e,t,n){let r=new He(e,t);throw ve(r,n),r}var qe=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),Je=t(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),Ye=t(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=qe(),a=Je();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*$`)})),Xe=t(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),Ze=t(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),D=t(((e,t)=>{let n=Je(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=qe(),{safeRe:a,t:o}=Ye(),s=Xe(),{compareIdentifiers:c}=Ze();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`);this.prerelease=l[4]?l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):[],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)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)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}}})),Qe=t(((e,t)=>{let n=D();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}}})),$e=t(((e,t)=>{let n=Qe();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),et=t(((e,t)=>{let n=Qe();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),tt=t(((e,t)=>{let n=D();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}}})),nt=t(((e,t)=>{let n=Qe();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`}})),rt=t(((e,t)=>{let n=D();t.exports=(e,t)=>new n(e,t).major})),it=t(((e,t)=>{let n=D();t.exports=(e,t)=>new n(e,t).minor})),at=t(((e,t)=>{let n=D();t.exports=(e,t)=>new n(e,t).patch})),ot=t(((e,t)=>{let n=Qe();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),O=t(((e,t)=>{let n=D();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),st=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>n(t,e,r)})),ct=t(((e,t)=>{let n=O();t.exports=(e,t)=>n(e,t,!0)})),lt=t(((e,t)=>{let n=D();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),ut=t(((e,t)=>{let n=lt();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),dt=t(((e,t)=>{let n=lt();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),ft=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>n(e,t,r)>0})),pt=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>n(e,t,r)<0})),mt=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>n(e,t,r)===0})),ht=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>n(e,t,r)!==0})),gt=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>n(e,t,r)>=0})),_t=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>n(e,t,r)<=0})),vt=t(((e,t)=>{let n=mt(),r=ht(),i=ft(),a=gt(),o=pt(),s=_t();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}`)}}})),yt=t(((e,t)=>{let n=D(),r=Qe(),{safeRe:i,t:a}=Ye();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],c=o[3]||`0`,l=o[4]||`0`,u=t.includePrerelease&&o[5]?`-${o[5]}`:``,d=t.includePrerelease&&o[6]?`+${o[6]}`:``;return r(`${s}.${c}.${l}${u}${d}`,t)}})),bt=t(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),k=t(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,ie(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=>C(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let ee=[..._.values()];return r.set(t,ee),ee}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(ae(this.set[t],e,this.options))return!0;return!1}};let r=new(bt()),i=Xe(),a=xt(),o=Je(),s=D(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=Ye(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=qe(),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=te(e,t),o(`caret`,e),e=ee(e,t),o(`tildes`,e),e=S(e,t),o(`xrange`,e),e=re(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,ee=(e,t)=>e.trim().split(/\s+/).map(e=>b(e,t)).join(` `),b=(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})},te=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(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})},S=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>ne(e,t)).join(` `)),ne=(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})},re=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),C=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),ie=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()),ae=(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}})),xt=t(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.value=this.semver===n?``: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=``),this.semver=r[2]?new c(r[2],this.options.loose):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===``||new l(t.value,n).test(this.value):t.operator===``?t.value===``||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=Xe(),{safeRe:i,t:a}=Ye(),o=vt(),s=Je(),c=D(),l=k()})),St=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Ct=t(((e,t)=>{let n=k();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),wt=t(((e,t)=>{let n=D(),r=k();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}})),Tt=t(((e,t)=>{let n=D(),r=k();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}})),Et=t(((e,t)=>{let n=D(),r=k(),i=ft();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}})),Dt=t(((e,t)=>{let n=k();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),Ot=t(((e,t)=>{let n=D(),r=xt(),{ANY:i}=r,a=k(),o=St(),s=ft(),c=pt(),l=_t(),u=gt();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}})),kt=t(((e,t)=>{let n=Ot();t.exports=(e,t,r)=>n(e,t,`>`,r)})),At=t(((e,t)=>{let n=Ot();t.exports=(e,t,r)=>n(e,t,`<`,r)})),jt=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),Mt=t(((e,t)=>{let n=St(),r=O();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}})),Nt=t(((e,t)=>{let n=k(),r=xt(),{ANY:i}=r,a=St(),o=O(),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})),Pt=t(((e,t)=>{let n=Ye(),r=qe(),i=D(),a=Ze();t.exports={parse:Qe(),valid:$e(),clean:et(),inc:tt(),diff:nt(),major:rt(),minor:it(),patch:at(),prerelease:ot(),compare:O(),rcompare:st(),compareLoose:ct(),compareBuild:lt(),sort:ut(),rsort:dt(),gt:ft(),lt:pt(),eq:mt(),neq:ht(),gte:gt(),lte:_t(),cmp:vt(),coerce:yt(),Comparator:xt(),Range:k(),satisfies:St(),toComparators:Ct(),maxSatisfying:wt(),minSatisfying:Tt(),minVersion:Et(),validRange:Dt(),outside:Ot(),gtr:kt(),ltr:At(),intersects:jt(),simplifyRange:Mt(),subset:Nt(),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}}));const Ft=2**32-1,It=Ft-1;var A=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};const Lt=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function Rt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===Lt}function zt(e){return Object.prototype.toString.call(e).slice(8,-1)}function Bt(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
10
+ `:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;case`\b`:return`\\b`;case`\f`:return`\\f`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:return e<` `?`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}function j(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=Bt(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 Ht=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Ut(e){return Ht.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Wt(e){return!(!Number.isInteger(e)||e<0||e>It)}function Gt(e){return!(!Number.isInteger(e)||e<0||e>Ft)}function Kt(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return Wt(+e)}function qt(e){for(var t=e.length-1;t>=0&&!Kt(e[t]);t--);return t+1}function Jt(e){let t=Object.keys(e);return t.length=qt(t),t}function Yt(e){return new Uint8Array(e).toBase64()}function Xt(e){return Uint8Array.fromBase64(e).buffer}function Zt(e){return Buffer.from(e).toString(`base64`)}function Qt(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function $t(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function en(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}const tn=typeof Uint8Array.fromBase64==`function`,nn=typeof process==`object`&&process.versions?.node!==void 0,rn=tn?Yt:nn?Zt:$t,an=tn?Xt:nn?Qt:en;function on(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}const sn=Object.freeze({kind:`not-plain`}),cn=Object.freeze({kind:`symbol-keys`}),ln=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>zt(e),isThenable:e=>typeof e.then==`function`,toPromise:e=>Promise.resolve(e),unbox:e=>e.valueOf(),toISOString:e=>isNaN(e.getDate())?``:e.toISOString(),toStringValue:e=>e.toString(),regExpInfo:e=>({source:e.source,flags:e.flags}),valuesOf:e=>e,entriesOf:e=>e,viewInfo:e=>({buffer:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength,length:e.length,bufferByteLength:e.buffer.byteLength}),toArrayBuffer:e=>e,lengthOf:e=>e.length,hasOwn:(e,t)=>Object.hasOwn(e,t),indicesOf:e=>Jt(e),shapeOf:e=>Rt(e)?Vt(e).length>0?cn:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:sn,get:(e,t)=>e[t]}),un=Object.freeze({fromPrimitive:e=>e,fromISOString:e=>new Date(e),fromStringValue:(e,t)=>e===`URL`?new URL(t):e===`URLSearchParams`?new URLSearchParams(t):Temporal[e.slice(9)].from(t),fromArrayBuffer:e=>e,fromRegExpInfo:(e,t)=>new RegExp(e,t),fromViewInfo:(e,t,n,r)=>{let i=globalThis[e];return n===void 0?new i(t):new i(t,n,r)},box:e=>Object(e),createArray:e=>Array(e),createSparseArray:e=>{let t=[];return t[It]=void 0,delete t[It],t.length=e,t},createObject:()=>({}),createNullPrototypeObject:()=>Object.create(null),createSet:()=>new Set,createMap:()=>new Map,set:(e,t,n)=>{e[t]=n},addValue:(e,t)=>{e.add(t)},addEntry:(e,t,n)=>{e.set(t,n)}});function dn(e,t,n){return fn(JSON.parse(e),t,n)}function fn(e,t,n){let r=on(un,n?.operations);if(typeof e==`number`)return s(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let i=e,a=Array(i.length),o=null;function s(e,n=!1){if(e===-1)return r.fromPrimitive(void 0);if(e===-3)return r.fromPrimitive(NaN);if(e===-4)return r.fromPrimitive(1/0);if(e===-5)return r.fromPrimitive(-1/0);if(e===-6)return r.fromPrimitive(-0);if(n||typeof e!=`number`)throw Error(`Invalid input`);if(e in a)return a[e];let c=i[e];if(!c||typeof c!=`object`)a[e]=r.fromPrimitive(c);else if(Array.isArray(c)){if(typeof c[0]==`string`){let n=c[0],l=t&&Object.hasOwn(t,n)?t[n]:void 0;if(l){let t=c[1];if(typeof t!=`number`&&(t=i.push(c[1])-1),Object.hasOwn(a,t))return a[e]=l(a[t]);if(o??=new Set,o.has(t))throw Error(`Invalid circular reference`);return o.add(t),a[e]=l(s(t)),o.delete(t),a[e]}switch(n){case`Date`:a[e]=r.fromISOString(c[1]);break;case`Set`:let t=r.createSet();a[e]=t;for(let e=1;e<c.length;e+=1)r.addValue(t,s(c[e]));break;case`Map`:let o=r.createMap();a[e]=o;for(let e=1;e<c.length;e+=2)r.addEntry(o,s(c[e]),s(c[e+1]));break;case`RegExp`:a[e]=r.fromRegExpInfo(c[1],c[2]);break;case`Object`:{let t=c[1];if(typeof i[t]==`object`&&i[t][0]!==`BigInt`)throw Error(`Invalid input`);a[e]=r.box(s(t));break}case`BigInt`:a[e]=r.fromPrimitive(BigInt(c[1]));break;case`null`:let l=r.createNullPrototypeObject();a[e]=l;for(let e=1;e<c.length;e+=2){if(c[e]===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");r.set(l,c[e],s(c[e+1]))}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{if(i[c[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=s(c[1]);a[e]=r.fromViewInfo(n,t,c[2],c[3]);break}case`ArrayBuffer`:{let t=c[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(an(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,c[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(c[0]===-7){let t=c[1];if(!Gt(t))throw Error(`Invalid input`);let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<c.length;e+=2){let i=c[e];if(!Wt(i)||i>=t)throw Error(`Invalid input`);r.set(n,i,s(c[e+1]))}}else{let t=r.createArray(c.length);a[e]=t;for(let e=0;e<c.length;e+=1){let n=c[e];n!==-2&&r.set(t,e,s(n))}}}else{let t=r.createObject();a[e]=t;for(let e of Object.keys(c)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");r.set(t,e,s(c[e]))}}return a[e]}return s(0)}function pn(e,t,n){let r=mn(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function mn(e,t,n,r){let i=on(ln,r?.operations),a=[],o=new Map,s=[];if(n)for(let e of Object.getOwnPropertyNames(n))s.push({key:e,fn:n[e]});let c=[],l=0;function u(n,r){let d=i.typeOf(n);if(d===`undefined`)return-1;let f;if(d===`number`){if(f=i.toPrimitive(n),Number.isNaN(f))return-3;if(f===1/0)return-4;if(f===-1/0)return-5;if(f===0&&1/f<0)return-6}let p=i.identify(n);if(o.has(p))return o.get(p);r??=l++,o.set(p,r);for(let{key:e,fn:t}of s){let i=t(n);if(i)return a[r]=`["${e}",${u(i)}]`,r}if(d===`function`)throw new A(`Cannot stringify a function`,c,n,t);if(d===`symbol`)throw new A(`Cannot stringify a Symbol primitive`,c,n,t);let m=``;if(d!==`object`)m=hn(d===`number`?f:i.toPrimitive(n));else if(i.isThenable(n)){if(!e)throw new A(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,c,n,t);m=i.toPromise(n).then(e=>{let t=u(e,r);t<0&&(a[r]=t)})}else{let e=i.tagOf(n);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:m=`["Object",${u(i.unbox(n))}]`;break;case`Date`:m=`["Date","${i.toISOString(n)}"]`;break;case`URL`:m=`["URL",${j(i.toStringValue(n))}]`;break;case`URLSearchParams`:m=`["URLSearchParams",${j(i.toStringValue(n))}]`;break;case`RegExp`:let{source:r,flags:a}=i.regExpInfo(n);m=a?`["RegExp",${j(r)},"${a}"]`:`["RegExp",${j(r)}]`;break;case`Array`:{let e=!1,t=i.lengthOf(n);m=`[`;for(let r=0;r<t;r+=1)if(r>0&&(m+=`,`),i.hasOwn(n,r))c.push(`[${r}]`),m+=u(i.get(n,r)),c.pop();else if(e)m+=-2;else{let r=i.indicesOf(n),a=r.length,o=String(t).length;if((t-a)*3>4+o+a*(o+1)){m=`[-7,`+t;for(let e=0;e<r.length;e++){let t=r[e];c.push(`[${t}]`),m+=`,`+t+`,`+u(i.get(n,t)),c.pop()}break}e=!0,m+=-2}m+=`]`;break}case`Set`:m=`["Set"`;for(let e of i.valuesOf(n))m+=`,${u(e)}`;m+=`]`;break;case`Map`:m=`["Map"`;for(let[e,t]of i.entriesOf(n)){let n=i.typeOf(e),r=n!==`object`&&n!==`function`&&n!==`symbol`;c.push(`.get(${r?hn(i.toPrimitive(e)):`...`})`),m+=`,${u(e)},${u(t)}`,c.pop()}m+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let t=i.viewInfo(n);m=`["`+e+`",`+u(t.buffer),t.byteLength!==t.bufferByteLength&&(m+=`,${t.byteOffset},${t.length}`),m+=`]`;break}case`DataView`:{let t=i.viewInfo(n);m=`["`+e+`",`+u(t.buffer),t.byteLength!==t.bufferByteLength&&(m+=`,${t.byteOffset},${t.byteLength}`),m+=`]`;break}case`ArrayBuffer`:m=`["ArrayBuffer","${rn(i.toArrayBuffer(n))}"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:m=`["${e}",${j(i.toStringValue(n))}]`;break;default:{let e=i.shapeOf(n);if(e.kind===`not-plain`)throw new A(`Cannot stringify arbitrary non-POJOs`,c,n,t);if(e.kind===`symbol-keys`)throw new A(`Cannot stringify POJOs with symbolic keys`,c,n,t);if(e.kind===`null-proto`){m=`["null"`;for(let r of e.keys){if(r===`__proto__`)throw new A(`Cannot stringify objects with __proto__ keys`,c,n,t);c.push(Ut(r)),m+=`,${j(r)},${u(i.get(n,r))}`,c.pop()}m+=`]`}else{m=`{`;let r=!1;for(let a of e.keys){if(a===`__proto__`)throw new A(`Cannot stringify objects with __proto__ keys`,c,n,t);r&&(m+=`,`),r=!0,c.push(Ut(a)),m+=`${j(a)}:${u(i.get(n,a))}`,c.pop()}m+=`}`}}}}return a[r]=m,r}let d=u(t);return d<0?`${d}`:a}function hn(e){let t=typeof e;return t===`string`?j(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var gn=e(Pt(),1);async function _n(e,t=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new b(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,t)}async function vn(e,t,n){let r=globalThis.crypto.getRandomValues(new Uint8Array(12)),i;try{i=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,t)}catch(e){throw new S(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let a=new Uint8Array(12+i.byteLength);return a.set(r,0),a.set(new Uint8Array(i),12),a}async function yn(e,t,n){if(t.byteLength<28)throw new S(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,12),i=t.subarray(12),a;try{a=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,i)}catch(e){let n=e instanceof Error?e.message:String(e);throw new S(`AES-256-GCM decryption failed: ${n}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(a)}const bn=Symbol.for(`WORKFLOW_USE_STEP`),xn=Symbol.for(`WORKFLOW_SET_ATTRIBUTES`),Sn=Symbol.for(`WORKFLOW_CREATE_HOOK`),Cn=Symbol.for(`WORKFLOW_SLEEP`),wn=Symbol.for(`WORKFLOW_GET_STREAM_ID`),Tn=Symbol.for(`WORKFLOW_STABLE_ULID`),M=Symbol.for(`WORKFLOW_STREAM_NAME`),En=Symbol.for(`WORKFLOW_STREAM_TYPE`),Dn=Symbol.for(`WORKFLOW_STREAM_FRAMING`),On=Symbol.for(`WORKFLOW_STREAM_SERVER_RUN_ID`),kn=Symbol.for(`WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID`),An=Symbol.for(`WORKFLOW_STREAM_SERVER_PUBLIC_KEY`),jn=Symbol.for(`WORKFLOW_STREAM_DRAIN`),Mn=Symbol.for(`BODY_INIT`),Nn=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),Pn=Symbol.for(`workflow-class-registry`),N=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),P=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),Fn=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),In=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`),Ln=()=>r(`WORKFLOW_STREAM_MAX_INFLIGHT_CHUNKS`,1e3,{integer:!0,min:1}),Rn=()=>r(`WORKFLOW_STREAM_MAX_CHUNKS_PER_BATCH`,1e3,{integer:!0,min:1}),zn=()=>r(`WORKFLOW_STREAM_MAX_BYTES_PER_BATCH`,1048576,{integer:!0,min:1}),Bn=()=>r(`WORKFLOW_STREAM_MAX_BUFFERED_BYTES`,8388608,{integer:!0,min:1}),Vn=()=>r(`WORKFLOW_LOCK_POLL_INTERVAL_MS`,10,{integer:!0,min:1});function Hn(){let e={...ie(),pendingOps:0,doneResolved:!1,streamEnded:!1};return e.promise.catch(()=>{}),e}function Un(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Wn(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Gn(e){let t=e.drainBarrier;if(!t){e.resolve();return}t().then(()=>e.resolve(),t=>e.reject(t))}function Kn(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}Un(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.writablePollingInterval=void 0,Gn(t))},Vn());t.writablePollingInterval=n}function qn(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}Wn(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.readablePollingInterval=void 0,Gn(t))},Vn());t.readablePollingInterval=n}function Jn(e,t,n){let r=t[jn];return typeof r==`function`&&(n.drainBarrier=r),Yn(e,t,n)}async function Yn(e,t,n){let r=e.getReader(),i=t.getWriter(),a;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),i.closed.then(()=>{throw new b(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await i.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await i.write(e.value)}finally{n.pendingOps--}}}catch(e){throw n.streamEnded=!0,a=e,n.drainBarrier&&await n.drainBarrier().catch(()=>{}),n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(a).catch(()=>{}),r.releaseLock(),i.releaseLock()}}function Xn(e){let t=e.specVersion;if(!(t!=null&&t>=6&&t<=7))throw new b(`This Workflow runtime supports Worlds with spec version 6 through 7, but the configured World declares spec version ${t??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const Zn=Symbol.for(`@workflow/world//cache`),Qn=Symbol.for(`@workflow/world//cachePromise`),$n=Symbol.for(`@workflow/world//getWorldFn`);async function er(){let e=globalThis;if(e[Zn])return Xn(e[Zn]),e[Zn];if(e[Qn])return e[Zn]=await e[Qn],Xn(e[Zn]),e[Zn];let t=e[$n];if(t){let e=await t();return Xn(e),e}throw Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.")}const tr=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]),nr=new TextEncoder;function rr(e){if(e.byteLength!==32)throw new b(`Run key material must be exactly 32 bytes, got ${e.byteLength}`)}function ir(e,t){if(e.byteLength!==32)throw new b(`${t} must be exactly 32 bytes, got ${e.byteLength}`)}async function ar(e){rr(e);let t=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),n=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:nr.encode(`workflow/encp/x25519/v1`)},t,256),r=new Uint8Array(n);return{scalar:r,publicKey:await or(r)}}async function or(e){let t=await sr(e,!0),n=await globalThis.crypto.subtle.exportKey(`jwk`,t);if(!n.x)throw new b(`X25519 JWK export did not include a public key component ("x")`);let r=fr(n.x);if(r.byteLength!==32)throw new b(`X25519 JWK export produced a ${r.byteLength}-byte public key, expected 32`);return r}async function sr(e,t){let n=new Uint8Array(tr.length+e.byteLength);return n.set(tr,0),n.set(e,tr.length),globalThis.crypto.subtle.importKey(`pkcs8`,n,{name:`X25519`},t,[`deriveBits`])}function cr(e){return globalThis.crypto.subtle.importKey(`raw`,e,{name:`X25519`},!0,[])}const lr=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function ur(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,a=n+2<e.length?e[n+2]:0;t+=lr[r>>2&63],t+=lr[(r&3)<<4|i>>4&15],t+=n+1<e.length?lr[(i&15)<<2|a>>6&3]:`=`,t+=n+2<e.length?lr[a&63]:`=`}return t}function dr(e){let t=e.length;for(;t>0&&e[t-1]===`=`;)t--;let n=e.slice(0,t);if(n.includes(`=`)||n.length%4==1||t!==e.length&&e.length%4!=0)return;let r=0,i=0,a=[];for(let e=0;e<n.length;e++){let t=lr.indexOf(n[e]);if(t===-1)return;r=r<<6|t,i+=6,i>=8&&(i-=8,a.push(r>>i&255))}if(!(i>0&&r&(1<<i)-1))return new Uint8Array(a)}function fr(e){let t=0,n=0,r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a===`=`)break;let o=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(a);if(o===-1)throw new b(`Invalid base64url character "${a}" in X25519 JWK key component`);t=t<<6|o,n+=6,n>=8&&(n-=8,r.push(t>>n&255))}return new Uint8Array(r)}async function pr(e,t,n,r){let i=nr.encode(`workflow/encp/aes256gcm/v1`),a=new Uint8Array(i.length+t.length+n.length);a.set(i,0),a.set(t,i.length),a.set(n,i.length+t.length);let o=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),s=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:a},o,256);return globalThis.crypto.subtle.importKey(`raw`,new Uint8Array(s),`AES-GCM`,!1,r)}async function mr(e){ir(e,`Recipient public key`);let t;try{t=await cr(e)}catch(e){throw new b(`Invalid X25519 recipient public key: ${e instanceof Error?e.message:String(e)}`,{cause:e})}let n=await globalThis.crypto.subtle.generateKey({name:`X25519`},!0,[`deriveBits`]),r=new Uint8Array(await globalThis.crypto.subtle.exportKey(`raw`,n.publicKey)),i;try{i=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:t},n.privateKey,256)}catch(e){throw new b(`X25519 key agreement failed: the recipient public key is not a valid curve point (low-order point or corrupted key material)`,{cause:e})}return{ephemeralPublicKey:r,contentKey:await pr(new Uint8Array(i),r,e,[`encrypt`])}}async function hr(e,t){if(t.byteLength!==32)throw new S(`Sealed payload has a malformed ephemeral public key: expected 32 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let n;try{let[r,i]=await Promise.all([sr(e.scalar,!1),cr(t)]);n=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:i},r,256)}catch(e){throw new S(`X25519 key agreement failed while opening a sealed payload: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return pr(new Uint8Array(n),t,e.publicKey,[`decrypt`])}async function gr(e,t,n){let{ephemeralPublicKey:r,contentKey:i}=await mr(e),a=await vn(i,t,n),o=new Uint8Array(r.byteLength+a.byteLength);return o.set(r,0),o.set(a,r.byteLength),o}async function _r(e,t,n){if(t.byteLength<60)throw new S(`Sealed payload too short: expected at least 60 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,32),i=t.subarray(32);return yn(await hr(e,r),i,n)}function vr(e,t){let n;return{async seal(r){n??=mr(e);let{ephemeralPublicKey:i,contentKey:a}=await n,o=await vn(a,r,t),s=new Uint8Array(i.byteLength+o.byteLength);return s.set(i,0),s.set(o,i.byteLength),s}}}function yr(e,t){let n,r;return{async open(i){if(i.byteLength<60)throw new S(`Sealed payload too short: expected at least 60 bytes, got ${i.byteLength}`,{context:{operation:`decrypt`,byteLength:i.byteLength}});let a=i.subarray(0,32),o=i.subarray(32),s=br(a);(s!==n||!r)&&(n=s,r=hr(e,a));let c;try{c=await r}catch(e){throw n=void 0,r=void 0,e}return yn(c,o,t)}}}function br(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}function xr(e){if(!e)return;let t=dr(e);if(t&&t.byteLength===32)return t}let F=null,Sr=null;function Cr(e,t){let n=F,r=Sr;F=e??null,Sr=e?new WeakSet:null;try{return t()}finally{F=n,Sr=r}}const wr=f(`@workflow/core//useStepClosures.fns`,1,()=>({fns:new WeakSet}));function Tr(e){return wr.fns.add(e),e}function Er(e){return typeof e==`function`&&wr.fns.has(e)}function Dr(e,t){if(!F||(F.totalExecutions=(F.totalExecutions??F.executions.length)+1,F.executions.length>=5))return;let n={kind:e};t!==void 0&&(n.detail=t),F.executions.push(n)}function I(e){F&&Sr&&(Sr.has(e)||(Sr.add(e),Dr(`proxy`)))}const L=Function.prototype.bind.bind(Function.prototype.call);function R(e,t){let n=Object.getOwnPropertyDescriptor(e,t)?.get;if(!n)throw Error(`Missing intrinsic getter: ${String(t)}`);return L(n)}const Or=L(Date.prototype.getDate),kr=L(Date.prototype.getTime),Ar=L(Date.prototype.toISOString),jr=R(RegExp.prototype,`source`),Mr=R(RegExp.prototype,`flags`),Nr=R(ArrayBuffer.prototype,`byteLength`),Pr=L(Map.prototype.entries),Fr=L(Set.prototype.values),Ir=L(Number.prototype.valueOf),Lr=L(String.prototype.valueOf),Rr=L(Boolean.prototype.valueOf),zr=L(BigInt.prototype.valueOf),Br=Object.getPrototypeOf(Uint8Array.prototype),Vr=R(Br,Symbol.toStringTag),Hr=R(Br,`buffer`),Ur=R(Br,`byteOffset`),Wr=R(Br,`byteLength`),Gr=R(Br,`length`),Kr=R(DataView.prototype,`buffer`),qr=R(DataView.prototype,`byteOffset`),Jr=R(DataView.prototype,`byteLength`),Yr=R(SharedArrayBuffer.prototype,`byteLength`),Xr=L(Headers.prototype[Symbol.iterator]),Zr=R(URL.prototype,`href`),Qr=L(URLSearchParams.prototype.toString),{isProxy:z}=w,$r=L(Function.prototype.toString);function ei(e){if(z(e))return!1;let t=Object.getOwnPropertyDescriptor(e,`name`)?.value;return typeof t==`string`&&t.startsWith(`bound `)?!1:$r(e).endsWith(`{ [native code] }`)||Reflect.getPrototypeOf(e)===Function.prototype}function B(e,t){if(e===null||typeof e!=`object`&&typeof e!=`function`)return;if(z(e))return I(e),e[t];let n=e;for(;n!==null;){if(z(n))return I(n),e[t];let r=Object.getOwnPropertyDescriptor(n,t);if(r)return`value`in r?r.value:r.get?(ei(r.get)||Dr(`getter`,String(t)),r.get.call(e)):void 0;n=Reflect.getPrototypeOf(n)}}function ti(e,t){if(e===null||typeof e!=`object`&&typeof e!=`function`)return!1;if(z(e))return I(e),t in e;let n=e;for(;n!==null;){if(z(n))return I(n),t in e;if(Object.getOwnPropertyDescriptor(n,t))return!0;n=Reflect.getPrototypeOf(n)}return!1}function V(e,t){if(!t||typeof e!=`object`||!e)return!1;z(e)&&I(e);let n=Reflect.getPrototypeOf(e);for(;n!==null;){if(n===t)return!0;z(n)&&I(n),n=Reflect.getPrototypeOf(n)}return!1}function ni(e){return z(e)?(I(e),e.href):Zr(e)}function ri(e){return z(e)?(I(e),String(e)):Qr(e)}function ii(e){return z(e)?(I(e),Array.from(e)):[...Xr(e)]}function ai(e){return[...Pr(e)]}function oi(e){return[...Fr(e)]}function si(e){return w.isDataView(e)?{buffer:Kr(e),byteOffset:qr(e),byteLength:Jr(e)}:{buffer:Hr(e),byteOffset:Ur(e),byteLength:Wr(e)}}const ci=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Float16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),li=new Set([`Date`,`RegExp`,`Map`,`Set`,`Array`,`DataView`,`ArrayBuffer`,`SharedArrayBuffer`,`Number`,`String`,`Boolean`,`BigInt`,`URL`,`URLSearchParams`,...ci]);function ui(e){if(w.isDate(e))return`Date`;if(w.isRegExp(e))return`RegExp`;if(w.isMap(e))return`Map`;if(w.isSet(e))return`Set`;if(Array.isArray(e))return`Array`;if(w.isTypedArray(e)){let t=Vr(e);return t!==void 0&&ci.has(t)?t:void 0}if(w.isDataView(e))return`DataView`;if(w.isArrayBuffer(e))return`ArrayBuffer`;if(w.isSharedArrayBuffer(e))return`SharedArrayBuffer`;if(w.isNumberObject(e))return`Number`;if(w.isStringObject(e))return`String`;if(w.isBooleanObject(e))return`Boolean`;if(w.isBigIntObject(e))return`BigInt`;if(V(e,URL.prototype))return`URL`;if(V(e,URLSearchParams.prototype))return`URLSearchParams`}function di(e){let t=B(e,Symbol.toStringTag);return typeof t==`string`?t:void 0}const fi={tagOf:e=>{if(z(e))return I(e),ln.tagOf(e);let t=ui(e);if(t!==void 0)return t;let n=di(e);return n===void 0||li.has(n)?`Object`:n},isThenable:e=>w.isPromise(e)?!0:typeof B(e,`then`)==`function`,unbox:e=>w.isNumberObject(e)?Ir(e):w.isStringObject(e)?Lr(e):w.isBooleanObject(e)?Rr(e):zr(e),toISOString:e=>Number.isNaN(Or(e))?``:Ar(e),toStringValue:e=>V(e,URL.prototype)?ni(e):V(e,URLSearchParams.prototype)?ri(e):(Dr(`method`,`toString (${di(e)??`unknown`})`),e.toString()),regExpInfo:e=>({source:jr(e),flags:Mr(e)}),valuesOf:e=>oi(e),entriesOf:e=>ai(e),viewInfo:e=>{let t=si(e);return{...t,length:w.isDataView(e)?0:Gr(e),bufferByteLength:w.isSharedArrayBuffer(t.buffer)?Yr(t.buffer):Nr(t.buffer)}},shapeOf:e=>(z(e)&&I(e),ln.shapeOf(e)),get:(e,t)=>B(e,t)},pi=Symbol.for(`workflow-serialize`),mi=Symbol.for(`workflow-deserialize`);function hi(e=globalThis){let t=e,n=t[Pn];return n||(n=new Map,t[Pn]=n),n}const gi=`class//workflow//Run`;function _i(e,t,n=globalThis){hi(n).set(e,t)}function vi(e,t){return hi(t).get(e)}function yi(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=B(e,`classId`);return typeof t==`string`&&{classId:t}},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=B(e,`constructor`);if(!t||typeof t!=`function`)return!1;let n=B(t,pi);if(typeof n!=`function`)return!1;let r=B(t,`classId`);if(typeof r!=`string`)throw Error(`Class "${String(B(t,`name`))}" with ${String(pi)} must have a static "classId" property.`);return Dr(`method`,`[WORKFLOW_SERIALIZE] (${r})`),{classId:r,data:n.call(t,e)}}}}function bi(e=globalThis){return{Class:t=>{let n=t.classId,r=vi(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=vi(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[mi];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(mi)} method.`);return a.call(i,r)}}}function xi(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function H(e){let t=si(e);return xi(t.buffer,t.byteOffset,t.byteLength)}function U(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 Si(e){return JSON.parse(e)}function Ci(e){let t=Object.getOwnPropertyDescriptor(e,`stack`);return t&&`value`in t?t.value:(Dr(`getter`,`stack`),t?.get?t.get.call(e):B(e,`stack`))}function wi(e){if(!w.isNativeError(e))return!1;let t={message:B(e,`message`),stack:Ci(e)};return ti(e,`cause`)&&(t.cause=B(e,`cause`)),t}function Ti(e,t){return!w.isNativeError(t)||B(t,`name`)!==e?!1:wi(t)}function Ei(e){return t=>Ti(e,t)||!1}function Di(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 Oi(e=globalThis){return{ArrayBuffer:e=>w.isArrayBuffer(e)&&xi(e,0,Nr(e)),BigInt:e=>typeof e==`bigint`&&String(e),BigInt64Array:e=>w.isBigInt64Array(e)&&H(e),BigUint64Array:e=>w.isBigUint64Array(e)&&H(e),Date:e=>w.isDate(e)?Number.isNaN(Or(e))?`.`:Ar(e):!1,DOMException:e=>{if(typeof e!=`object`||!e)return!1;let t=B(e,`constructor`);if(!t||B(t,`name`)!==`DOMException`)return!1;let n={message:B(e,`message`),name:B(e,`name`),stack:Ci(e)};return ti(e,`cause`)&&(n.cause=B(e,`cause`)),n},EvalError:Ei(`EvalError`),FatalError:Ei(`FatalError`),HookConflictError:e=>{let t=Ti(`HookConflictError`,e);if(!t)return!1;let n={...t,token:B(e,`token`)},r=B(e,`conflictingRunId`);return r!==void 0&&(n.conflictingRunId=r),n},RangeError:Ei(`RangeError`),ReferenceError:Ei(`ReferenceError`),RetryableError:e=>{let t=Ti(`RetryableError`,e);if(!t)return!1;let n=B(e,`retryAfter`),r;if(w.isDate(n)){let e=kr(n);r=Number.isNaN(e)?Date.now()+1e3:e}else if(n&&typeof n==`object`){let e=B(n,`getTime`);if(typeof e==`function`){Dr(`method`,`getTime`);let t=e.call(n);r=Number.isNaN(t)?Date.now()+1e3:t}else r=Date.now()+1e3}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=Ti(`RuntimeDecryptionError`,e);if(!t)return!1;let n={...t},r=B(e,`context`);return r!==void 0&&(n.context=r),n},StreamError:e=>{let t=Ti(`StreamError`,e);if(!t)return!1;let n={...t},r=B(e,`status`),i=B(e,`url`);return typeof r==`number`&&(n.status=r),typeof i==`string`&&(n.url=i),n},SyntaxError:Ei(`SyntaxError`),TypeError:Ei(`TypeError`),URIError:Ei(`URIError`),AggregateError:e=>{let t=Ti(`AggregateError`,e);return t?{...t,errors:B(e,`errors`)}:!1},Error:e=>{if(!w.isNativeError(e))return!1;let t={name:B(e,`name`),message:B(e,`message`),stack:Ci(e)};return ti(e,`cause`)&&(t.cause=B(e,`cause`)),t},Float32Array:e=>w.isFloat32Array(e)&&H(e),Float64Array:e=>w.isFloat64Array(e)&&H(e),Headers:e=>V(e,Headers.prototype)&&ii(e),Int8Array:e=>w.isInt8Array(e)&&H(e),Int16Array:e=>w.isInt16Array(e)&&H(e),Int32Array:e=>w.isInt32Array(e)&&H(e),Map:e=>w.isMap(e)&&ai(e),RegExp:e=>w.isRegExp(e)&&{source:jr(e),flags:Mr(e)},Set:e=>w.isSet(e)&&oi(e),URL:e=>V(e,URL.prototype)&&ni(e),WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=B(e,`workflowId`);return typeof t==`string`&&{workflowId:t}},URLSearchParams:e=>{if(!V(e,URLSearchParams.prototype))return!1;let t=ri(e);return t===``?`.`:t},Uint8Array:e=>w.isUint8Array(e)&&H(e),Uint8ClampedArray:e=>w.isUint8ClampedArray(e)&&H(e),Uint16Array:e=>w.isUint16Array(e)&&H(e),Uint32Array:e=>w.isUint32Array(e)&&H(e)}}function ki(e=globalThis){return{ArrayBuffer:t=>U(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(U(t,e)),BigUint64Array:t=>new e.BigUint64Array(U(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:Di(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??y)(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`)]??g)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:Di(e,`RangeError`),ReferenceError:Di(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??ne)(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`)]??S,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},StreamError:t=>{let n=new(e[Symbol.for(`@workflow/errors//StreamError`)]??v)(t.message,{...`cause`in t?{cause:t.cause}:{},status:t.status,url:t.url});return t.stack!==void 0&&(n.stack=t.stack),n},SyntaxError:Di(e,`SyntaxError`),TypeError:Di(e,`TypeError`),URIError:Di(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(U(t,e)),Float64Array:t=>new e.Float64Array(U(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(U(t,e)),Int16Array:t=>new e.Int16Array(U(t,e)),Int32Array:t=>new e.Int32Array(U(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(U(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(U(t,e)),Uint16Array:t=>new e.Uint16Array(U(t,e)),Uint32Array:t=>new e.Uint32Array(U(t,e))}}function Ai(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=B(e,`stepId`);if(typeof t!=`string`)return!1;let n=B(e,`__closureVarsFn`),r;typeof n==`function`&&(Er(n)||Dr(`method`,`__closureVarsFn`),r=n());let i=ti(e,`__boundThis`),a=i?B(e,`__boundThis`):void 0,o=B(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 ji(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 Mi(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const W={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,SEALED:`encp`,GZIP:`gzip`,ZSTD:`zstd`},Ni=new TextEncoder,Pi=new TextDecoder,Fi=1e5,Ii={operations:{createSparseArray(e){if(e>Fi)throw RangeError(`Sparse array length ${e} exceeds the maximum of ${Fi}`);return un.createSparseArray(e)}}};function Li(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...yi(),...Ai(),...Oi(t)};break;case`step`:r={...yi(),...Oi(t)};break;case`client`:r={...yi(),...Oi(t)}}return n?{...r,...n}:r}function Ri(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...bi(t),...ji(t),...ki(t)};break;case`step`:r={...bi(t),...ki(t)};break;case`client`:r={...bi(t),...ki(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}}}return n?{...r,...n}:r}const G={formatPrefix:W.DEVALUE_V1,serialize(e,t,n){let r=Li(t,n?.global,n?.extraReducers),i=Cr(n?.guestCodeStats,()=>pn(e,r,{operations:fi}));return Ni.encode(i)},deserialize(e,t,n){let r=Ri(t,n?.global,n?.extraRevivers);return dn(Pi.decode(e),r,Ii)},deserializeLegacy(e,t,n){return fn(e,Ri(t,n?.global,n?.extraRevivers),Ii)}},zi=new TextEncoder,Bi=new TextDecoder;function K(e,t){if(!(t instanceof Uint8Array))return t;let n=zi.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function Vi(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=Bi.decode(t);return Mi(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=Bi.decode(t);if(!Mi(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}function Hi(){try{return typeof process<`u`&&process.env?.WORKFLOW_DISABLE_COMPRESSION===`1`}catch{return!1}}function Ui(){try{let e=process.env?.WORKFLOW_COMPRESSION_CODEC;return e===`gzip`||e===`zstd`?e:void 0}catch{return}}function Wi(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function Gi(){let e=Wi();return typeof e?.zstdCompressSync==`function`&&typeof e?.zstdDecompressSync==`function`}function Ki(){return typeof CompressionStream==`function`&&typeof DecompressionStream==`function`}async function qi(e,t){let n=t.writable.getWriter(),r=n.write(e).then(()=>n.close());r.catch(()=>{});let i=[],a=0,o=t.readable.getReader();for(;;){let{done:e,value:t}=await o.read();if(e)break;i.push(t),a+=t.length}await r;let s=new Uint8Array(a),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function Ji(e){return qi(e,new CompressionStream(`gzip`))}async function Yi(e){return qi(e,new DecompressionStream(`gzip`))}function Xi(e){let t=Wi(),n=t?.constants?.ZSTD_c_compressionLevel,r=n===void 0?void 0:{params:{[n]:3}};return new Uint8Array(t.zstdCompressSync(e,r))}function Zi(e){let t=Wi();if(!t?.zstdDecompressSync)throw Error(`Compressed (zstd) workflow data encountered but node:zlib zstd support is not available in this runtime (requires Node.js 22.15+). In the browser, register a zstd decoder via registerZstdDecoder (serialization-format.ts).`);return new Uint8Array(t.zstdDecompressSync(e))}function Qi(e,t,n,r){e&&(e.recorded=!0,e.compressed=t!==`none`,e.codec=t,e.uncompressedBytes=n,e.storedBytes=r)}function $i(){return Ui()===`gzip`?Ki()?`gzip`:`none`:Gi()?`zstd`:Ki()?`gzip`:`none`}async function ea(e,t,n){if(!(e instanceof Uint8Array))return e;if(!t||e.length<1024||Hi())return Qi(n,`none`,e.length,e.length),e;let r=$i();if(r===`none`)return Qi(n,`none`,e.length,e.length),e;let i=r===`zstd`?Xi(e):await Ji(e),a=r===`zstd`?W.ZSTD:W.GZIP,o=4+i.length;return o>=e.length*.95?(Qi(n,`none`,e.length,e.length),e):(Qi(n,r,e.length,o),K(a,i))}async function ta(e,t){if(!(e instanceof Uint8Array))return e;let n=Vi(e);if(n===W.ZSTD){let{payload:n}=q(e),r=Zi(n);return Qi(t,`zstd`,r.length,e.length),r}if(n===W.GZIP){if(!Ki())throw Error(`Compressed (gzip) workflow data encountered but DecompressionStream is not available in this runtime. Node.js 18+, browsers, and edge runtimes all support it.`);let{payload:n}=q(e),r=await Yi(n);return Qi(t,`gzip`,r.length,e.length),r}return Qi(t,`none`,e.length,e.length),e}const na=Symbol.for(`workflow.serialization.sealTarget`),ra=Symbol.for(`workflow.serialization.runKeys`);function ia(e,t){return{[na]:!0,recipientPublicKey:e,aad:t}}function aa(e,t,n){return{[ra]:!0,aes:e,keyPair:t,aad:n}}async function oa(e){let[t,n]=await Promise.all([_n(e),ar(e)]);return aa(t,n)}function sa(e){return typeof e==`object`&&!!e&&e[na]===!0}function ca(e){return typeof e==`object`&&!!e&&e[ra]===!0}function la(e){if(e){if(ca(e))return e.aes;if(!sa(e))return e}}async function ua(e){return typeof e==`function`?e():e}async function da(e,t){if(!t||!(e instanceof Uint8Array))return e;if(sa(t)){let n=await gr(t.recipientPublicKey,e,t.aad);return K(W.SEALED,n)}let n=await vn(ca(t)?t.aes:t,e);return K(W.ENCRYPTED,n)}async function fa(e,t){if(!ca(t))throw new S(`Sealed data encountered but no run keypair is available. Opening a sealed payload requires the run's own encryption key material; a symmetric key or a seal-only target cannot decrypt it.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encp`}});let{payload:n}=q(e);try{return await _r(t.keyPair,n,t.aad)}catch(e){throw S.is(e)&&e.context&&(e.context.formatPrefix=W.SEALED),e}}async function pa(e,t){if(!(e instanceof Uint8Array))return e;let n=Vi(e);if(n===W.SEALED)return fa(e,t);if(n!==W.ENCRYPTED)return e;let r=la(t);if(!r)throw new S(`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`}});let{payload:i}=q(e);try{return await yn(r,i)}catch(e){throw S.is(e)&&e.context&&(e.context.formatPrefix=n),e}}function ma(e,t,n){let[r,...i]=t.split(`
11
+ `),a=i.join(`
12
+ `),o=ha(r??``,n),s=ga(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
13
+ `)}function ha(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=va(t,`errorName`),o=va(t,`errorAttribution`);if(a||o){let e=o?o===`sdk`?De(`sdk error`):Ee(`user error`):``,t=a?Te(a):``,n=e&&t?E(` · `):``;i.push(` ${e}${n}${t}`)}let s=va(t,`workflowRunId`),c=va(t,`workflowName`);s?i.push(ba(`run`,s,c,pe)):c&&i.push(ba(`run`,null,c,pe));let l=va(t,`stepId`),u=va(t,`stepName`);if((l||u)&&i.push(ba(`step`,l,u,fe)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?i.push(` ${ya(`retry`)} ${e} ${E(`attempts ·`)} ${n} ${E(`max retries`)}`):e!==void 0&&i.push(` ${ya(`retry`)} ${e} ${E(`attempts`)}`)}let d=va(t,`errorCode`);d&&d!==a&&i.push(` ${ya(`code`)} ${E(d)}`);let f=va(t,`hint`);f&&i.push(` ${Se(f)}`);let p=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 p)i.push(` ${ya(e)} ${xa(t)}`);return i.length?i.join(`
14
+ `):null}function ga(e){if(!e)return null;let t=e.split(`
15
+ `),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(E(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&_a(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(E(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
16
+ `)}function _a(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 va(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function ya(e){return E(e.padEnd(6))}function ba(e,t,n,r){let i=t||E(`—`),a=n&&(e===`run`?ue(n):de(n))?`${E(`·`)} ${r(n)}`:``;return` ${ya(e)} ${i}${a?` `+a:``}`}function xa(e){if(typeof e==`string`)return e.includes(`
17
+ `)?e.split(`
18
+ `).map((e,t)=>t===0?e:` ${e}`).join(`
19
+ `):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function J(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Sa=J(`workflow.name`),Ca=J(`workflow.operation`),wa=J(`workflow.run.id`),Ta=J(`workflow.run.status`),Ea=J(`workflow.started_at`),Da=J(`workflow.events.count`),Oa=J(`workflow.execution.mode`),ka=J(`workflow.bundle.compile.cache_hit`),Aa=J(`workflow.replay.load.source`),ja=J(`workflow.events.parked.count`),Ma=J(`workflow.events.parked.event_id`),Na=J(`workflow.events.parked.event_type`),Pa=J(`workflow.arguments.count`),Fa=J(`workflow.result.type`),Ia=J(`workflow.trace.propagated`),La=J(`workflow.trace.mode`),Ra=J(`workflow.turbo`),za=J(`workflow.error.name`),Ba=J(`workflow.error.message`),Va=J(`workflow.error.code`),Ha=J(`workflow.steps.created`),Ua=J(`workflow.hooks.created`),Wa=J(`workflow.waits.created`),Ga=J(`workflow.steps.failed_serialization`),Ka=J(`workflow.inline_ownership.owned_recovery_steps`),qa=J(`workflow.inline_ownership.backstop_wakes_armed`),Ja=J(`workflow.route.type`),Ya=J(`workflow.route.handler_cached`),Xa=J(`workflow.route.invocation_count`),Za=J(`workflow.route.entrypoint_age_ms`),Qa=J(`workflow.route.module_body_init_ms`),$a=J(`faas.instance`),eo=J(`step.name`),to=J(`step.id`),no=J(`step.attempt`),ro=J(`step.status`),io=J(`step.max_retries`),ao=J(`step.ttfs_ms`),oo=J(`step.stso_ms`),so=J(`step.rsfs_ms`),co=J(`step.final_scheduling_replay_ms`),lo=J(`step.latency_optimizations`),uo=J(`step.skipped`),fo=J(`step.skip_reason`),po=J(`step.arguments.count`),mo=J(`step.result.type`),ho=J(`step.error.name`),go=J(`step.error.message`),_o=J(`step.fatal_error`),vo=J(`step.retry.exhausted`),yo=J(`step.retry.timeout_seconds`),bo=J(`step.retry.will_retry`),xo=J(`messaging.system`),So=J(`messaging.destination.name`),Co=J(`messaging.message.id`),wo=J(`messaging.operation.type`),To=J(`workflow.queue.overhead_ms`),Eo=J(`deployment.id`),Do=J(`workflow.deployment.pinned_id`),Oo=J(`workflow.deployment_mismatch.retry_count`),ko=J(`workflow.deployment_mismatch.recovered`),Ao=J(`workflow.hook.token`),jo=J(`workflow.hook.id`),Mo=J(`workflow.hook.found`),No=J(`workflow.hook.resume_committed`),Po=J(`workflow.hook.wake_published`),Fo=J(`workflow.hook.resilient_resume_materialized`),Io=J(`workflow.resume_setup_source`),Lo=J(`workflow.step.resilient_dispatch_recovered`),Ro=J(`workflow.step.resilient_dispatch_materialized`),zo=J(`workflow.resume.total_ms`),Bo=J(`workflow.resume.phase.producer_prep_ms`),Vo=J(`workflow.resume.phase.queue_delivery_ms`),Ho=J(`workflow.resume.phase.resume_setup_ms`),Uo=J(`workflow.resume.phase.replay_ms`),Wo=J(`workflow.resume.phase.step_dispatch_ms`),Go=J(`workflow.resume.phase.step_claim_ms`),Ko=J(`workflow.resume.phase.step_prepare_ms`),qo=J(`workflow.resume.trigger`),Jo=J(`workflow.resume.strategy`),Yo=J(`workflow.resume.setup_source`),Xo=J(`workflow.resume.step_execution`),Zo=J(`workflow.suspension.state`),Qo=J(`workflow.suspension.hook_count`),$o=J(`workflow.suspension.step_count`),es=J(`workflow.suspension.wait_count`),ts=J(`http.request.method`),ns=J(`http.route`),rs=J(`http.response.status_code`),is=J(`error.type`),as=J(`workflow.events.pages_loaded`),os=J(`workflow.queue.deserialize_time_ms`),ss=J(`workflow.queue.execution_time_ms`),cs=J(`workflow.queue.serialize_time_ms`),ls=J(`workflow.serialization.operation`),us=J(`workflow.serialization.compressed`),ds=J(`workflow.serialization.codec`),fs=J(`workflow.serialization.uncompressed_bytes`),ps=J(`workflow.serialization.stored_bytes`),ms=J(`workflow.serialization.compression_ratio`),hs=J(`workflow.serialization.guest_code_executions`),gs=J(`workflow.serialization.guest_code_details`),_s=J(`peer.service`),vs=J(`rpc.system`),ys=J(`rpc.service`),bs=J(`rpc.method`),xs=J(`error.retryable`),Ss=J(`error.category`),Cs=f(`@workflow/core//traceModeWarnings`,1,()=>({unrecognized:new Set}));function ws(){let e=process.env.WORKFLOW_TRACE_MODE;return e===`continuous`?`continuous`:(e&&e!==`linked`&&!Cs.unrecognized.has(e)&&(Cs.unrecognized.add(e),$s.warn(`Unrecognized WORKFLOW_TRACE_MODE value "${e}"; expected "linked" or "continuous". Falling back to "linked".`)),`linked`)}function Ts(e){return e!==void 0&&Object.keys(e).length>0}function Es(e,t){return e===`linked`&&Ts(t)?Promise.resolve(t):Os()}async function Ds(e,t){if(e!==`linked`)return qs();let n=await Js(Ts(t)?t:void 0);return n?[n]:void 0}async function Os(){let e=await Y.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function ks(e){let t=await Y.value;if(t)return t.propagation.extract(t.context.active(),e)}async function As(e,t){if(!e)return t();let n=await Y.value;if(!n)return t();let r=await ks(e);return r?n.context.with(r,async()=>await t()):t()}const Y=C(async()=>{try{return await import(`../../@opentelemetry/api/index.js`)}catch{return $s.info(`OpenTelemetry not available, tracing will be disabled`),null}}),js=C(async()=>{let e=await Y.value;if(!e)return null;let t=e.trace.getTracer(`workflow`);return Fs(e,t),t}),Ms=C(async()=>{let e=await Y.value;return e?e.metrics.getMeter(`workflow`).createHistogram(`workflow.step.execute.duration`,{description:`Duration of user step execution`,unit:`ms`}):null});let Ns=!1;function Ps(e){try{return typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:String(e)}catch{return`Unknown error`}}function Fs(e,t){let n=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);if(!Ns&&n){Ns=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.core`);console.warn(`[workflow:otel-diag] core`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] core failed:`,e instanceof Error?e.message:e)}}}async function Is(e,...t){let[n,r]=await Promise.all([js.value,Y.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 se.is(t)?(e.setStatus({code:r.SpanStatusCode.OK}),Hs(t,e)):e.setStatus({code:r.SpanStatusCode.ERROR,message:Ps(t)}),t}finally{e.end()}})}async function Ls(e){let[t,n]=await Promise.all([js.value,Y.value]);if(!t||!n)return{end(){},fail(){}};let r=t.startSpan(e),i=!1,a=e=>{i||(i=!0,r.setStatus(e),r.end())};return{end:()=>a({code:n.SpanStatusCode.OK}),fail:e=>a({code:n.SpanStatusCode.ERROR,message:Ps(e)})}}async function Rs(e){let t=await Y.value;return t?t.context.bind(t.context.active(),e):e}async function zs(){let e=await Y.value;if(!e)return{refresh(){},run:e=>e()};let t=e.context.active(),n={getValue:e=>t.getValue(e),setValue:(e,n)=>t.setValue(e,n),deleteValue:e=>t.deleteValue(e)};return{refresh:()=>{t=e.context.active()},run:t=>e.context.with(n,t)}}async function Bs(e,t,n){let r=await js.value;r&&r.startSpan(e,{...n,startTime:t}).end()}async function Vs(e,t){(await Ms.value)?.record(e,{"workflow.step.status":t})}function Hs(e,t){t.setAttributes({...Zo(`suspended`),...$o(e.stepCount),...Qo(e.hookCount),...es(e.waitCount)})}async function Us(e){let[t,n]=await Promise.all([ks(e),Y.value]);if(t&&n)return n.trace.getSpanContext(t)}async function Ws(){return await Ks(e=>e.trace.getActiveSpan())}async function Gs(e){return Ks(t=>t.SpanKind[e])}async function Ks(e){let t=await Y.value;if(t)return await e(t)}function qs(){return Ks(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function Js(e){if(!e)return;let[t,n]=await Promise.all([Us(e),Y.value]);if(t&&n&&n.trace.isSpanContextValid(t))return{context:t}}async function Ys(e,t){let n=await Y.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 Xs(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 Zs(e,t={}){let n=r=>{let i=n=>t.debugNamespace??`workflow:${e}:${n}`,a=t=>{let n=i(t);return(i,a)=>{let o=Object.keys(r).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...r,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(ma(`[workflow-sdk]`,i,c)),Xs(n,process.env.DEBUG)&&(console.debug(`[${n}] ${i}`,c??``),Ws().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:a(`debug`),info:a(`info`),warn:a(`warn`),error:a(`error`),child:e=>n({...r,...e}),forRun:(e,t,i)=>n({...r,workflowRunId:e,...t===void 0?{}:{workflowName:t},...i??{}})}};return n({})}const Qs=Zs(`step`),$s=Zs(`runtime`),ec=Zs(`webhook`),X=Zs(`events`);Zs(`adapter`),Zs(`build`,{debugNamespace:`workflow:build`});function tc(e){if(S.is(e))throw e}function Z(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof A&&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 A&&t.value!==void 0&&$s.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function nc(e,t,n){try{let r=G.serialize(e,`client`,n);return da(await ea(K(W.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){tc(e);let{message:t,hint:n}=Z(`client value`,e);throw new x(t,{hint:n,cause:e})}}async function rc(e,t,n){let r=await ta(await pa(e,t),n?.compressionStats);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 ic(e,t,n){try{let r=G.serialize(e,`step`,n);return da(await ea(K(W.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){tc(e);let{message:t,hint:n}=Z(`step value`,e);throw new x(t,{hint:n,cause:e})}}async function ac(e,t,n){let r=await ta(await pa(e,t),n?.compressionStats);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 oc(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 sc=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),cc=(()=>{let e=globalThis;return e[sc]??=new ce,e[sc]})();function lc(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${m(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${m(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${m(`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 a=i.join(` and `);return`${r.join(` and `)} to be enqueued\n Workflow will suspend and resume when ${a}`}function uc(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function dc(e){return`strm_${e}_system_abort`}function fc(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return dc(e.slice(5))}const pc=()=>r(`WORKFLOW_DEFERRED_CHECK_DELAY_MS`,100,{integer:!0,min:10}),mc=new Set([`hook_received`,`hook_conflict`,`wait_completed`,`attr_set`,`run_cancelled`]),hc=new Set([`wait_completed`]);function gc(e,t){return`${e}:${t}`}const _c=new Set([`run_completed`,`run_failed`,`run_cancelled`]);var Q;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Q||={});var vc=class{eventIndex;events;callbacks=[];parked=[];resolved=new Set;seenEventClasses=new Map;onConsumedEvent;onUnconsumedEvent;onDuplicateEvent;getPromiseQueue;isDeliveryIdle;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=[...e],this.eventIndex=0,this.onConsumedEvent=t.onConsumedEvent,this.onUnconsumedEvent=t.onUnconsumedEvent,this.onDuplicateEvent=t.onDuplicateEvent,this.getPromiseQueue=t.getPromiseQueue,this.isDeliveryIdle=t.isDeliveryIdle}get strandedEvent(){return this.parked[0]?.event}get parkedSummary(){let e=this.parked[0]?.event;if(e)return{count:this.parked.length,eventId:e.eventId,eventType:e.eventType}}append(e){for(let t of e)this.events.push(t);process.nextTick(this.consume)}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}notifyConsumedEvent(e){if(this.onConsumedEvent)try{this.onConsumedEvent(e)}catch(e){X.error(`onConsumedEvent callback threw an error`,{error:e})}}consume=()=>{for(;;){this.drainParked();let e=this.events[this.eventIndex]??null;if(e!==null&&d(e)){this.skipSealedNoop(e);continue}let t=this.offer(e);if(t&&this.eventIndex++,e===null){t||this.handleEndOfLog();return}if(!t){let t=this.firstEventTypeOfClass(e);if(t!==void 0){this.skipDuplicateEvent(e,t);continue}this.scheduleUnconsumedCheck(e,!0);return}}};offer(e){for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Q.NotConsumed;try{r=n(e)}catch(e){X.error(`EventConsumer callback threw an error`,{error:e})}if(r===Q.Consumed||r===Q.Finished)return e!==null&&(e.correlationId&&hc.has(e.eventType)&&this.resolved.add(gc(e.eventType,e.correlationId)),this.recordEventClass(e),this.notifyConsumedEvent(e)),r===Q.Finished&&this.callbacks.splice(t,1),!0}return!1}drainParked(){let e=this.parked.length>0;for(;e;){e=!1,this.dropParkedDuplicates();for(let t=0;t<this.parked.length;t++){let n=this.parked[t],r=this.eventIndex;this.eventIndex=n.index;let i;try{i=this.offer(n.event)}finally{this.eventIndex=r}if(i){this.parked.splice(t,1),e=this.parked.length>0;break}}}}dropParkedDuplicates(){for(let e=this.parked.length-1;e>=0;e--){let t=this.parked[e].event,n=this.firstEventTypeOfClass(t);if(n!==void 0){this.parked.splice(e,1),X.debug(`Releasing a parked event that repeats a class already in the log`,{eventId:t.eventId,eventType:t.eventType,firstEventType:n,correlationId:t.correlationId});try{this.onDuplicateEvent?.(t,n)}catch(e){X.error(`onDuplicateEvent callback threw an error`,{error:e})}}}}park(e){return!mc.has(e.eventType)||e.correlationId&&this.resolved.has(gc(e.eventType,e.correlationId))?!1:(this.parked.push({event:e,index:this.eventIndex}),this.eventIndex++,X.debug(`Parked an unclaimed event for later delivery`,{eventId:e.eventId,eventType:e.eventType,correlationId:e.correlationId,parked:this.parked.length}),!0)}eventClassKey(e){let t=o(e);return t===void 0?void 0:`${t.eventClass}:${t.entity}`}recordEventClass(e){let t=this.eventClassKey(e);t!==void 0&&!this.seenEventClasses.has(t)&&this.seenEventClasses.set(t,e.eventType)}firstEventTypeOfClass(e){let t=this.eventClassKey(e);return t===void 0?void 0:this.seenEventClasses.get(t)}skipSealedNoop(e){this.eventIndex++,X.debug(`Skipping sealed-log noop event`,{eventId:e.eventId})}skipDuplicateEvent(e,t){this.eventIndex++,X.debug(`Skipping event that repeats a class already in the log`,{eventId:e.eventId,eventType:e.eventType,firstEventType:t,correlationId:e.correlationId});try{this.onDuplicateEvent?.(e,t)}catch(e){X.error(`onDuplicateEvent callback threw an error`,{error:e})}}handleEndOfLog(){if(this.parked.length===0)return;let e=this.events.at(-1);if(!e||!_c.has(e.eventType)){X.debug(`Reached the end of the log still holding events`,{eventId:this.parked[0].event.eventId,eventType:this.parked[0].event.eventType,correlationId:this.parked[0].event.correlationId,parked:this.parked.length});return}this.scheduleUnconsumedCheck(this.parked[0].event,!1)}scheduleUnconsumedCheck(e,t){let n=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.whenDeliveryIdle(n,()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===n&&(this.pendingUnconsumedCheck=null,this.resolveUnconsumedEvent(e,t))},pc())})})}resolveUnconsumedEvent(e,t){if(t){if(this.events[this.eventIndex]!==e)return;if(this.park(e)){this.consume();return}}this.onUnconsumedEvent(e)}whenDeliveryIdle(e,t){let n=()=>{if(this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===e){if(this.isDeliveryIdle()){t();return}this.getPromiseQueue().then(()=>{this.unconsumedCheckVersion===e&&(this.pendingUnconsumedTimeout=setTimeout(n,0))})}};n()}},yc=class{aborted=!1;reason=void 0;[N];[P];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[N]=e,this[P]=t}_setAborted(e){if(!this.aborted){this.aborted=!0,this.reason=e,this.#t&&this.#t.call(this);for(let e of this.#e)e();this.#e=[]}}addEventListener(e,t){if(e===`abort`){if(this.aborted){t();return}this.#e.push(t)}}removeEventListener(e,t){e===`abort`&&(this.#e=this.#e.filter(e=>e!==t))}throwIfAborted(){if(this.aborted)throw this.reason??new DOMException(`The operation was aborted.`,`AbortError`)}};function bc(e){return class{signal;[N];[P];constructor(){let t=e.generateUlid(),n=dc(t),r=`abrt_${t}`;this[N]=n,this[P]=r,this.signal=new yc(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[P])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new te(`Replay divergence: abort hook event ${t.eventType} for ${i} belongs to token "${n}", but the current abort hook expects "${this[P]}"`,{eventId:t.eventId}))}),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,r=e.eventsConsumer.eventIndex,a=re(e,r,`hook`),o=oe(e,r,`hook`);return e.pendingDeliveries++,e.promiseQueue=e.promiseQueue.then(async()=>{let r;try{if(n!==void 0)try{let i=await e.replayPayloadCache.prepareEventPayload(t.eventId,`payload`,n),a=await Tl(n,e.runId,e.encryptionKey,e.globalThis,{},i);a&&typeof a==`object`&&`reason`in a&&(r=a.reason)}catch{}}finally{e.pendingDeliveries--}o.then(()=>{a.markDelivered(),this.signal._setAborted(r)})}),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[P]){n.abortRequested=!0,n.abortReason=t;break}}}}}function xc(){return{abort(e){let t=new yc(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new yc(``,``),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 Sc=c();function Cc(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function wc(e){return tc(e),e instanceof x&&e.cause!==void 0||e instanceof b&&e.cause!==void 0?e.cause:e}async function $(e,t){if(e.recorded)try{let n=await Ws();if(!n)return;let r=e.uncompressedBytes??0,i=e.storedBytes??0;n.setAttributes({...ls(t),...us(e.compressed??!1),...ds(e.codec??`none`),...fs(r),...ps(i),...e.compressed&&r>0?ms(1-i/r):{}})}catch{}}async function Tc(e){let t=e.totalExecutions??e.executions.length;if(t!==0)try{let n=await Ws();if(!n)return;let r=[...new Set(e.executions.map(e=>e.detail?`${e.kind} (${e.detail})`:e.kind))];n.setAttributes({...hs(t),...gs(r)})}catch{}}function Ec(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0},i;return new TransformStream({async transform(a,o){try{r.resolved||(r.key=await ua(t),r.resolved=!0,sa(r.key)&&(i=vr(r.key.recipientPublicKey,r.key.aad)));let s=pn(a,e),c=n.encode(s),l=K(W.DEVALUE_V1,c);i?l=K(W.SEALED,await i.seal(l)):r.key&&(l=await da(l,r.key));let u=new Uint8Array(4+l.length);new DataView(u.buffer).setUint32(0,l.length,!1),u.set(l,4),o.enqueue(u)}catch(e){if(S.is(e)){o.error(e);return}let{message:t,hint:n}=Z(`stream chunk`,e);o.error(new x(t,{hint:n,cause:e}))}}})}function Dc(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0},a;function o(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function s(o){for(i.resolved||(i.key=await ua(t),i.resolved=!0,ca(i.key)&&(a=yr(i.key.keyPair,i.key.aad)));r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let s=r.slice(4,4+t);r=r.slice(4+t);let{format:c,payload:l}=q(s);if(c===W.ENCRYPTED||c===W.SEALED){let e=c===W.SEALED;if(!(e?ca(i.key):la(i.key)!==void 0)){o.error(new S(e?`Sealed stream data encountered but no run keypair is available. Opening a sealed frame requires the run's own encryption key material.`:`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:l.byteLength,formatPrefix:e?`encp`:`encr`}}));return}let t;try{t=e?await a.open(q(s).payload):await pa(s,i.key)}catch(e){throw S.is(e)&&e.context&&(e.context.formatPrefix=c),e}({format:c,payload:l}=q(t))}if(c===W.DEVALUE_V1){let t=n.decode(l);o.enqueue(dn(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){o(t),await s(i);return}}else if(r.length>0){o(t),await s(i);return}let a=n.decode(t).split(`
20
+ `);for(let t of a)t.length>0&&i.enqueue(dn(t,e))},async flush(e){r.length>0&&await s(e)}})}const Oc=1e8;function kc(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>Oc){t.error(new b(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${Oc}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function Ac(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>Oc){r.error(new b(`Byte-stream frame length ${t} exceeds maximum (${Oc}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new b(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function jc(e,t,n,r,i){(async()=>{await Bs(`workflow.stream.read`,e,{kind:await Gs(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof i==`number`?{"workflow.stream.read.connect_ms":i}:{},...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}function Mc(e,t,n,r){(async()=>{await Bs(`workflow.stream.read.resolve_key`,e,{kind:await Gs(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.read.key_succeeded":r}})})()}function Nc(e,t,n,r,i,a){(async()=>{await Bs(`workflow.stream.read.complete`,e,{kind:await Gs(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read_complete`,"workflow.stream.read.total_ms":Date.now()-e,"workflow.stream.read.chunks":r,"workflow.stream.read.bytes":i,...typeof a==`number`?{"workflow.stream.read.reconnects":a}:{}}})})()}var Pc=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new b(`"name" is required, got "${t}"`);let r,i=!1,a,o=0,s=0;super({type:`bytes`,pull:async c=>{let l=this.#e;if(!l){r===void 0&&(r=Date.now());let i=await er(),o=Date.now(),s=await i.streams.get(e,t,n);a=Date.now()-o,l=this.#e=s.getReader()}if(!l){c.error(Error(`Failed to get reader`));return}let u=await l.read();u.done?(this.#e=void 0,r!==void 0&&Nc(r,e,t,o,s),c.close()):(!i&&u.value.byteLength>0&&r!==void 0&&(i=!0,jc(r,e,t,n,a)),o+=1,s+=u.value.byteLength,c.enqueue(u.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const Fc=()=>r(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),Ic=()=>r(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,1e3,{integer:!0,min:1});function Lc(e,t,n,r=async()=>void 0){let i=n===void 0||n>=0,a=n??0,o=0,s=0,c=0,l,u=!1,d,f=new Uint8Array,p,m,g=!1,_=0,y=0,ee=!1;function b(){if(ee)return;ee=!0;let n=Date.now();r().then(r=>{r&&Mc(n,e,t,!0)},()=>Mc(n,e,t,!1))}async function te(){if(u)return!1;let r=await er();if(u)return!1;let s=i?a+o:n,c=Date.now(),f=await r.streams.get(e,t,s);return u?(await f.cancel(d).catch(()=>{}),!1):(m===void 0&&(m=Date.now()-c),l=f.getReader(),!0)}async function x(){try{let n=await(await er()).streams.getInfo(e,t);return n.done&&a+o>n.tailIndex}catch{return!0}}async function S(){if(u||(l&&=(await l.cancel().catch(()=>{}),void 0),u))return!1;a+=o,o=0,f=new Uint8Array;let e=Fc(),n=Ic();for(;;){if(s++,c++,s>e)throw new v(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(c>n)throw new v(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{return!!await te()}catch(e){if(u)return!1;if(h.is(e))throw e}}}return new ReadableStream({pull:async r=>{if(!u)for(p===void 0&&(p=Date.now()),b();;){if(!l)try{if(!await te())return}catch(e){if(u)return;r.error(e);return}let a;try{a=await l.read()}catch(e){if(u)return;if(!i){r.error(e);return}try{if(!await S())return}catch(e){r.error(e);return}continue}if(u)return;if(a.done||!a.value){l=void 0;let n=!i||await x();if(u)return;if(!n){try{if(!await S())return}catch(e){r.error(e);return}continue}p!==void 0&&Nc(p,e,t,_,y,c),r.close();return}let d=a.value;if(d.length>0){let e=new Uint8Array(f.length+d.length);e.set(f,0),e.set(d,f.length),f=e}let h=!1;for(;f.length>=4;){let i=4+new DataView(f.buffer,f.byteOffset,f.byteLength).getUint32(0,!1);if(f.length<i)break;r.enqueue(f.slice(0,i)),f=f.slice(i),o++,_++,y+=i,!g&&p!==void 0&&(g=!0,jc(p,e,t,n,m)),h=!0}if(h){s=0;return}}},cancel:async e=>{u=!0,d=e;let t=l;l=void 0,t&&await t.cancel(e).catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)})}})}const Rc=()=>{let e=r(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,NaN,{integer:!0});return Number.isNaN(e)?void 0:e};function zc(e,t,n,r,i,a,o){(async()=>{await Bs(`workflow.stream.flush`,e,{kind:await Gs(`CLIENT`),attributes:{"workflow.run.id":n,"workflow.stream.name":r,"workflow.stream.operation":`flush`,"workflow.stream.flush.buffer_dwell_ms":t-e,"workflow.stream.flush.chunks":i,"workflow.stream.flush.bytes":a,"workflow.stream.write.chunk_rtt":o}})})()}function Bc(e,t,n){(async()=>{await Bs(`workflow.stream.close`,e,{kind:await Gs(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`close`,"workflow.stream.close.rpc_ms":Date.now()-e}})})()}var Vc=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new b(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new b(`"name" is required, got "${t}"`);let r=er(),i=n,a=async()=>{if(i){try{await i}catch{}i=void 0}},o=`wrtr_${Sc()}`,s=a().then(async()=>(await r).streams.createWriteSession?.(e,t,{writerId:o})),c=0,l=[],u=0,d=0,f=0,p=null,m=null,h,g=Rc(),_=null,v=Rn(),y=zn(),ee=Ln(),te=Bn(),x,S=[],ne=[],re=e=>{let t=[...S,...ne];S=[],ne=[];for(let n of t)n.reject(e)},C=()=>{let e=0,t=0;for(let n of l){if(e>=v||e>0&&t+n.byteLength>y)break;e++,t+=n.byteLength}let n=l.slice(0,e);return l=l.slice(e),u-=t,{group:n,bytes:t}},ie=async(n,i,o)=>{await a();let l=await r,u=await s,d=Date.now();if(u)await u.write(c,n);else if(typeof l.streams.writeMulti==`function`&&n.length>1)await l.streams.writeMulti(e,t,n);else for(let r of n)await l.streams.write(e,t,r);c+=n.length,o!==void 0&&zc(o,d,e,t,n.length,i,Date.now()-d)},ae=async()=>{for(;l.length>0;){p&&=(clearTimeout(p),null);let e=x,t=Date.now(),{group:n,bytes:r}=C();d=n.length,f=r,x=l.length>0?t:void 0;try{await ie(n,r,e),d=0,f=0}catch(t){throw l=n.concat(l),u+=r,d=0,f=0,x=e!==void 0&&x!==void 0?Math.min(e,x):e??x,t}let i=S;S=[];for(let e of i)e.resolve()}},oe=()=>{m||h!==void 0||l.length===0||(m=ae().then(()=>{if(m=null,l.length>0){oe();return}let e=ne;ne=[];for(let t of e)t.resolve()},e=>{m=null,h??=e,re(h)}))},se=()=>{if(!(p||m)){if(g===void 0){_??=Promise.resolve(r).then(e=>{g=e.streamFlushIntervalMs??0},()=>{g=0}).then(()=>{l.length>0&&se()});return}if(g<=0){oe();return}p=setTimeout(()=>{p=null,oe()},g)}},w=async()=>{for(;;){if(h!==void 0)throw h;if(l.length===0&&!m)return;oe(),await new Promise((e,t)=>{ne.push({resolve:e,reject:t})})}};super({async write(e){if(h!==void 0)throw h;for(x===void 0&&(x=Date.now()),l.push(e),u+=e.byteLength,l.length>=v||u>=y?oe():se();h===void 0&&(l.length+d>=ee||u+f>=te);)oe(),await new Promise((e,t)=>{S.push({resolve:e,reject:t})});if(h!==void 0)throw h},async close(){await w(),await a();let n=await r,i=await s,o=Date.now();i?await i.close():await n.streams.close(e,t),Bc(o,e,t)},async abort(e){try{await w()}catch{}p&&=(clearTimeout(p),null),l=[],u=0,h??=e??Error(`Stream aborted`),re(h),await(await s.catch(()=>void 0))?.dispose?.()}}),Object.defineProperty(this,jn,{value:w,enumerable:!1,writable:!1})}};function Hc(e=globalThis){let t=C(()=>qc(e,`Request`)),n=C(()=>qc(e,`Response`));return{...yi(),...Ai(),...Oi(e),Request:e=>{if(!V(e,t.value))return!1;let n={method:B(e,`method`),url:B(e,`url`),headers:B(e,`headers`),body:B(e,`body`),duplex:B(e,`duplex`)},r=B(e,Nn);r&&(n.responseWritable=r);let i=B(e,`signal`);return i&&(B(i,`aborted`)||B(i,N))&&(n.signal=i),n},Response:e=>V(e,n.value)?{type:B(e,`type`),url:B(e,`url`),status:B(e,`status`),statusText:B(e,`statusText`),headers:B(e,`headers`),body:B(e,`body`),redirected:B(e,`redirected`)}:!1}}function Uc(e,t,n,r,i,a){let o=t[N],s=t[P];if(!o){let e=(n[Tn]||Sc)();o=dc(e),s=`abrt_${e}`,t[N]=o,t[P]=s,t.signal&&(t.signal[N]=o,t.signal[P]=s)}return Gc(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function Wc(e,t){let n=t[N]??t.signal?.[N],r=t[P]??t.signal?.[P];if(!n)throw Error(`AbortController/AbortSignal stream name is not set`);return{streamName:n,hookToken:r,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function Gc(e,t,n,r,i){e.aborted||e[Fn]||(e[Fn]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await ua(r),a=await vl({aborted:!0,reason:e.reason},n,i),o=new Vc(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function Kc(e=globalThis,t,n,r,i=!1,a,o=t){return{...Hc(e),ReadableStream:s=>{if(!(s instanceof e.ReadableStream))return!1;if(s.locked)throw new x(`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 c=`strm_${(e[Tn]||Sc)()}`,l=Cc(s),u=new Vc(n,c,a);l===`bytes`?i?t.push(s.pipeThrough(kc()).pipeTo(u)):t.push(s.pipeTo(u)):t.push(s.pipeThrough(Ec(Kc(e,t,n,r,i,a,o),r)).pipeTo(u));let d={name:c};return l&&(d.type=l),l===`bytes`&&i&&(d.framing=`framed-v1`),d},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let r=t[M],i=t[On];if(typeof r==`string`&&typeof i==`string`){let e={name:r,runId:i},n=t[An];typeof n==`string`&&(e.encryptionPublicKey=n);let a=t[kn];return typeof a==`string`&&(e.deploymentId=a),e}let a=`strm_${(e[Tn]||Sc)()}`,s=new Pc(n,a);return o.push(s.pipeTo(t)),{name:a}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Uc(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Uc(i,i,e,t,n,r)}}function qc(e,t){let n=B(e,t)??B(globalThis,t);if(typeof n==`function`)return B(n,`prototype`)}function Jc(e=globalThis){let t=C(()=>qc(e,`ReadableStream`)),n=C(()=>qc(e,`WritableStream`)),r=C(()=>qc(e,`AbortController`)),i=C(()=>qc(e,`AbortSignal`));return{...Hc(e),ReadableStream:e=>{if(!V(e,t.value))return!1;let n=B(e,Mn);if(n!==void 0)return{bodyInit:n};let r=B(e,M);if(!r)throw new b("ReadableStream `name` is not set");let i={name:r},a=B(e,En);a&&(i.type=a);let o=B(e,Dn);return o&&(i.framing=o),i},WritableStream:e=>{if(!V(e,n.value))return!1;let t=B(e,M);if(!t)throw new b("WritableStream `name` is not set");let r={name:t},i=B(e,On);typeof i==`string`&&(r.runId=i);let a=B(e,kn);typeof a==`string`&&(r.deploymentId=a);let o=B(e,An);return typeof o==`string`&&(r.encryptionPublicKey=o),r},AbortController:e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=B(e,N),i=V(e,r.value);if(n===void 0&&!i){let t=B(e,`signal`);if(typeof t!=`object`||!t||B(t,N)===void 0)return!1}let a=B(e,`signal`);return a?Wc(a,t):!1},AbortSignal:e=>{if(typeof e!=`object`||!e)return!1;let t=B(e,N)!==void 0,n=V(e,i.value);return!t&&!n?!1:Wc(e,e)}}}function Yc(e=globalThis,t,n,r,i=!1,a,o=t){return{...Hc(e),ReadableStream:s=>{if(!(s instanceof e.ReadableStream))return!1;if(s.locked)throw new x(`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 c=s[M],l=s[En],u=s[Dn];if(!c){c=`strm_${(e[Tn]||Sc)()}`,l=Cc(s),u=l===`bytes`&&i?`framed-v1`:u;let d=new Vc(n,c,a);l===`bytes`?u===`framed-v1`?t.push(s.pipeThrough(kc()).pipeTo(d)):t.push(s.pipeTo(d)):t.push(s.pipeThrough(Ec(Yc(e,t,n,r,i,a,o),r)).pipeTo(d))}let d={name:c};return l&&(d.type=l),u&&(d.framing=u),d},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let i=t[M],a=t[On];i||(i=`strm_${(e[Tn]||Sc)()}`,o.push(new Pc(n,i).pipeThrough(Dc(ll(e,o,n,r),r)).pipeTo(t)));let s={name:i};typeof a==`string`&&(s.runId=a);let c=t[An];typeof c==`string`&&(s.encryptionPublicKey=c);let l=t[kn];return typeof l==`string`&&(s.deploymentId=l),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Uc(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Uc(i,i,e,t,n,r)}}function Xc(...e){let t=new WeakSet;function n(e){let t=e[In];t&&!t.signal.aborted&&t.abort()}function r(e){if(typeof e==`object`&&e&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function Zc(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new Pc(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=cc.getStore(),r=await yl(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function Qc(e,t,n){let r=e,i=e.signal;r[N]=t.streamName,r[P]=t.hookToken,i[N]=t.streamName,i[P]=t.hookToken,n&&(r[In]=n,i[In]=n)}function $c(e,t){let n=e,r=t;n[N]!==void 0&&(r[N]=n[N]),n[P]!==void 0&&(r[P]=n[P]),n[In]!==void 0&&(r[In]=n[In])}function el(e,t,n){let r=new AbortController;e.aborted?(Qc(r,e),r.abort(e.reason)):e.streamName?Qc(r,e,Zc(r,n,e.streamName,t)):Qc(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=cc.getStore();if(n&&(n.ops.push((async()=>{try{let r=await vl({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new Vc(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-BRDLAb67.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function tl(e,t,n){let r=new AbortController;return e.aborted?(Qc(r,e),r.abort(e.reason)):e.streamName?Qc(r,e,Zc(r,n,e.streamName,t)):Qc(r,e),r.signal}function nl(e=globalThis){return{...bi(e),...ki(e)}}async function rl(e,t,n){let r=xr(n);if(r)return ia(r);let i=await er();if(!i.getEncryptionKeyForRun)return;let a=t?await i.getEncryptionKeyForRun(e,{deploymentId:t}):await i.getEncryptionKeyForRun(await i.runs.get(e));return a?await _n(a,[`encrypt`]):void 0}function il(e,{deploymentId:t,encryptionPublicKey:n}){typeof t==`string`&&Object.defineProperty(e,kn,{value:t,writable:!1}),typeof n==`string`&&Object.defineProperty(e,An,{value:n,writable:!1})}function al({global:e,ops:t,runId:n,name:r,key:i,deploymentId:a,encryptionPublicKey:o,runReadyBarrier:s}){let c=Ec(Kc(e,t,n,i),i),l=new Vc(n,r,s),u=Hn();return t.push(u.promise),Jn(c.readable,l,u).catch(()=>{}),Kn(c.writable,u),Object.defineProperty(c.writable,M,{value:r,writable:!1}),Object.defineProperty(c.writable,On,{value:n,writable:!1}),il(c.writable,{deploymentId:a,encryptionPublicKey:o}),c.writable}function ol(e,t,n,r,i,a){let o,s,c=!1,l;return l=new ReadableStream({async pull(u){try{o||(o=sl(e,t,n,a,{onReadableState:e=>{s=e}}).ReadableStream({name:r,startIndex:i}).getReader(),s&&!c&&(c=!0,qn(l,s)));let d=await o.read();d.done?u.close():u.enqueue(d.value)}catch(e){u.error(e)}},async cancel(e){await o?.cancel(e).catch(()=>{})}},{highWaterMark:0}),l}function sl(e=globalThis,t,n,r,i){return{...nl(e),StepFunction:()=>{throw new x(`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 x(`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&&$c(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:a=>{if(`bodyInit`in a){let t=a.bodyInit;return new e.Response(t).body}if(a.type===`bytes`){let r=new Pc(n,a.name,a.startIndex),o=Hn();t.push(o.promise);let{readable:s,writable:c}=a.framing===`framed-v1`?Ac():new e.TransformStream;return Jn(r,c,o).catch(()=>{}),i?.onReadableState?i.onReadableState(o):qn(s,o),s}{let o,s=()=>(o??=ua(r),o),c=Lc(n,a.name,a.startIndex,s),l=Dc(sl(e,t,n,s),s),u=Hn();return t.push(u.promise),Jn(c,l.writable,u).catch(()=>{}),i?.onReadableState?i.onReadableState(u):qn(l.readable,u),l.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:rl(a,i.deploymentId,i.encryptionPublicKey);return al({global:e,ops:t,runId:a,name:i.name,key:o,deploymentId:i.deploymentId,encryptionPublicKey:i.encryptionPublicKey})},AbortController:e=>el(e,t,n),AbortSignal:e=>tl(e,t,n)}}function cl(e=globalThis){return{...nl(e),...ji(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[Nn]=n,delete t.responseWritable,t.respondWith=()=>{throw new x("`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 x(`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,{[Mn]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[M]:{value:t.name,writable:!1},[En]:{value:t.type,writable:!1},[Dn]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[M]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[On]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[kn]={value:t.deploymentId,writable:!1}),typeof t.encryptionPublicKey==`string`&&(n[An]={value:t.encryptionPublicKey,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new yc(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[N]:e.streamName,[P]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new yc(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function ll(e=globalThis,t,n,r,i){return{...nl(e),StepFunction:e=>{let t=e.stepId,n=e.closureVars,r=`boundThis`in e,i=r?e.boundThis:void 0,a=Array.isArray(e.boundArgs)?e.boundArgs:[],o=ae(t);if(!o)throw new x(`Step function "${t}" not found. Make sure the step function is registered.`,{hint:`Make sure the step file is included in your build (i.e. it is listed in the workflow manifest), and that the SWC plugin is configured for the file.`});if(!n&&!r&&a.length===0)return o;let s=function(...e){let t=r?i:this,s=a.length>0?[...a,...e]:e;if(n){let e=cc.getStore();if(!e)throw new b(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return cc.run(r,()=>o.apply(t,s))}return o.apply(t,s)};return Object.defineProperty(s,"name",{value:o.name}),Object.defineProperty(s,"stepId",{value:t,writable:!1,enumerable:!1,configurable:!1}),o.maxRetries!==void 0&&(s.maxRetries=o.maxRetries),s},WorkflowFunction:e=>Object.assign(()=>{throw new x(`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&&$c(t.signal,i.signal),n&&(i.respondWith=async e=>{let t=n.getWriter();await t.write(e),await t.close()}),i},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:a=>{if(`bodyInit`in a){let t=a.bodyInit;return new e.Response(t).body}let o=new Pc(n,a.name);if(a.type===`bytes`){let n=Hn();t.push(n.promise);let{readable:r,writable:i}=a.framing===`framed-v1`?Ac():new e.TransformStream;return Jn(o,i,n).catch(()=>{}),qn(r,n),r}{let a=Dc(ll(e,t,n,r,i),r),s=Hn();return t.push(s.promise),Jn(o,a.writable,s).catch(()=>{}),qn(a.readable,s),a.readable}},WritableStream:a=>{let o=typeof a.runId==`string`?a.runId:n,s=typeof a.deploymentId==`string`?a.deploymentId:o===n?i:void 0,c=o===n?r:rl(o,s,a.encryptionPublicKey),l=Ec(Yc(e,t,o,c),c),u=new Vc(o,a.name),d=Hn();return t.push(d.promise),Jn(l.readable,u,d).catch(()=>{}),Kn(l.writable,d),Object.defineProperty(l.writable,M,{value:a.name,writable:!1}),Object.defineProperty(l.writable,On,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,kn,{value:s,writable:!1}),typeof a.encryptionPublicKey!=`string`&&o===n&&ca(r)&&Object.defineProperty(l.writable,An,{value:ur(r.keyPair.publicKey),writable:!1}),typeof a.encryptionPublicKey==`string`&&Object.defineProperty(l.writable,An,{value:a.encryptionPublicKey,writable:!1}),l.writable},AbortController:e=>el(e,t,n),AbortSignal:e=>tl(e,t,n)}}async function ul(e,t){return await da(e,t)}const dl=async(e,t)=>{let n={},r=await ta(await pa(e,t),n);return await $(n,`deserialize`),{data:r}};function fl(e,t=globalThis,n={}){return oc(e.data,{global:t,extraRevivers:{...Ol(cl(t)),...n}})}function pl(e,t=globalThis,n={}){let{data:r}=e;if(!(r instanceof Uint8Array))return fn(r,{...cl(t),...n});let{format:i,payload:a}=q(r);if(i===W.DEVALUE_V1)return dn(new TextDecoder().decode(a),{...cl(t),...n});throw Error(`Unsupported serialization format: ${i}`)}async function ml(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c=r){if(a)return Si(pn(e,Kc(i,r,t,n,o,void 0,c)));try{let a={},l=await nc(e,n,{global:i,extraReducers:Dl(Kc(i,r,t,n,o,void 0,c)),compression:s,compressionStats:a});return await $(a,`serialize`),l}catch(e){let t=wc(e),{message:n,hint:r}=Z(`workflow arguments`,t);throw new x(n,{hint:r,cause:t})}}async function hl(e,t,n,r=globalThis,i={},a){return fl(a??await dl(e,n),r,i)}async function gl(e,t,n,r=globalThis,i=!1,a=!1,o){if(i)return Si(pn(e,Jc(r)));try{let t={},i=o??{executions:[]},s=await ic(e,n,{global:r,extraReducers:Dl(Jc(r)),compression:a,compressionStats:t,guestCodeStats:i});return await $(t,`serialize`),await Tc(i),s}catch(e){let t=wc(e),{message:n,hint:r}=Z(`workflow return value`,t);throw new x(n,{hint:r,cause:t})}}async function _l(e,t,n,r=[],i=globalThis,a={}){let o={},s=await rc(e,n,{global:i,extraRevivers:{...Ol(sl(i,r,t,n)),...a},compressionStats:o});return await $(o,`deserialize`),s}async function vl(e,t,n,r=globalThis,i=!1,a=!1,o){if(i)return Si(pn(e,Jc(r)));try{let t={},i=o??{executions:[]},s=await ic(e,n,{global:r,extraReducers:Dl(Jc(r)),compression:a,compressionStats:t,guestCodeStats:i});return await $(t,`serialize`),await Tc(i),s}catch(e){let t=wc(e),{message:n,hint:r}=Z(`step arguments`,t);throw new x(n,{hint:r,cause:t})}}async function yl(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await ac(e,n,{global:i,extraRevivers:{...Ol(ll(i,r,t,n,o)),...a},compressionStats:s});return await $(s,`deserialize`),c}async function bl(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c,l=r){if(a)return Si(pn(e,Yc(i,r,t,n,o,c,l)));try{let a={},u=await ic(e,n,{global:i,extraReducers:Dl(Yc(i,r,t,n,o,c,l)),compression:s,compressionStats:a});return await $(a,`serialize`),u}catch(e){let t=wc(e),{message:n,hint:r}=Z(`step return value`,t);throw new x(n,{hint:r,cause:t})}}async function xl(e,t,n,r=[],i=globalThis,a=!1){try{let o=pn(e,Yc(i,r,t,n)),s=new TextEncoder().encode(o),c=K(W.DEVALUE_V1,s),l={},u=await ul(await ea(c,a,l),n);return await $(l,`serialize`),u}catch(e){let t=wc(e),{message:n,hint:r}=Z(`step error`,t);throw new x(n,{hint:r,cause:t})}}async function Sl(e,t,n,r=globalThis,i={},a){return pl(a??await dl(e,n),r,i)}async function Cl(e,t,n,r=globalThis,i=!1){try{let t=pn(e,Jc(r)),a=new TextEncoder().encode(t),o=K(W.DEVALUE_V1,a),s={},c=await ul(await ea(o,i,s),n);return await $(s,`serialize`),c}catch(e){let t=wc(e),{message:n,hint:r}=Z(`run error`,t);throw new x(n,{hint:r,cause:t})}}async function wl(e,t,n,r=[],i=globalThis,a={}){let o={},s=await ta(await pa(e,n),o);if(await $(o,`deserialize`),!(s instanceof Uint8Array))return fn(s,{...sl(i,r,t,n),...a});let{format:c,payload:l}=q(s);if(c===W.DEVALUE_V1)return dn(new TextDecoder().decode(l),{...sl(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${c}`)}async function Tl(e,t,n,r=globalThis,i={},a){return fl(a??await dl(e,n),r,i)}const El=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function Dl(e){let t={};for(let n of El)n in e&&(t[n]=e[n]);return t}function Ol(e){let t={};for(let n of El)n in e&&(t[n]=e[n]);return t}const kl=[{format:W.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:W.GZIP,minVersion:`5.0.0-beta.18`},{format:W.ZSTD,minVersion:`5.0.0-beta.18`},{format:W.SEALED,minVersion:`5.0.0-beta.37`}],Al=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],jl=new Set([W.DEVALUE_V1]);function Ml(e){if(!e||!gn.default.valid(e))return{supportedFormats:jl,framedByteStreams:!1};let t=new Set(jl);for(let{format:n,minVersion:r}of kl)gn.default.gte(e,r)&&t.add(n);let n={supportedFormats:t,framedByteStreams:!1};for(let{capability:t,minVersion:r}of Al)gn.default.gte(e,r)&&(n[t]=!0);return n}const Nl=`5.0.0-beta.50`,Pl=/^[a-zA-Z0-9_\-./@]+$/;function Fl(e,t){if(!Pl.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${i(`workflow`,n(t))}${e}`}const Il=c();function Ll(e){return`__health_check__${e}`}function Rl(e){let t=a.safeParse(e);if(t.success)return t.data}function zl(e){return`wrun_hc_${e}`}async function Bl(e,t){let n=await er(),r=Ll(e.correlationId),i;if(e.runId)try{let t=await n.getEncryptionKeyForRun?.(e.runId);t&&(i=ur((await ar(t)).publicKey))}catch(t){$s.warn(`Health check could not derive a run public key; the caller will fall back to a key lookup`,{correlationId:e.correlationId,error:t instanceof Error?t.message:String(t)})}let a=JSON.stringify({healthy:!0,correlationId:e.correlationId,specVersion:t??7,workflowCoreVersion:Nl,hookResumeInputVersion:1,...i?{encryptionPublicKey:i}:{},timestamp:Date.now()}),o=zl(e.correlationId);await n.streams.write(o,r,a),await n.streams.close(o,r)}function Vl(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function Hl(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 Ul(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),typeof o.encryptionPublicKey==`string`&&(s.encryptionPublicKey=o.encryptionPublicKey),typeof o.hookResumeInputVersion==`number`&&(s.hookResumeInputVersion=o.hookResumeInputVersion),s}async function Wl(e,t){let r=t?.timeout??3e4,a=e.createRunId?.()??Il(),o=Ll(a),s=`${i(`workflow`,n(t?.namespace))}health_check`,c=Date.now();try{for(await e.queue(s,{__healthCheck:!0,correlationId:a,...t?.runId?{runId:t.runId}:{}},{specVersion:1,deploymentId:t?.deploymentId});Date.now()-c<r;)try{let t=r-(Date.now()-c),n=(await Vl(e.streams.get(zl(a),o),t)).getReader(),{chunks:i,timedOut:s}=await Hl(n,500);if(s){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=Ul(i);if(l)return{...l,latencyMs:Date.now()-c};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 Gl(e,t){return new p(`Event pagination ${t} for workflow run "${e}".`,{code:ee.WORLD_CONTRACT_ERROR})}function Kl(e,t,n){if(t){if(n.has(t))throw Gl(e,`did not advance`);n.add(t)}}function ql(e,t,n){if(t.length===0)return;let r=n??new Set(e.map(e=>e.eventId));for(let n of t)r.has(n.eventId)||(r.add(n.eventId),e.push(n))}function Jl(e,t){let n=e.length;for(;n>0;){let r=e[n-1];if(r.eventId===t.eventId)return;if(r.eventId<t.eventId)break;n--}e.splice(n,0,t)}function Yl(e,t,n,r){if(t){if(n===null)throw Gl(e,`returned more pages without a cursor`);if(r.has(n))throw Gl(e,`repeated a cursor`)}}function Xl(e,t,n){return t!==null&&!n&&p.is(e)&&e.status===400}async function Zl(e,t){let n=t!==void 0;return Is(`workflow.replay.load`,async r=>{r?.setAttributes({...wa(e),...Aa(n?`events_list_incremental`:`events_list`)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await er(),f=Date.now();for(;c;){let t=Date.now(),r=s;Kl(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(Xl(t,r,u)){$s.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}ql(i,f.data,a),c=f.hasMore,Yl(e,c,f.cursor,o),s=f.cursor??s,l++,$s.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return $s.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...Da(i.length),...as(l)}),{events:i,cursor:s}})}function Ql(e,t){ql(e.events,t.events),e.cursor=t.cursor??e.cursor}function $l(){return process.env.WORKFLOW_SLOT_GAP_CHECK!==`0`}function eu(e,t){let n=e.length;ql(e,t);let r=e.length-n;return r>0&&e.sort((e,t)=>e.eventId<t.eventId?-1:+(e.eventId>t.eventId)),r}function tu(e,t){let n=t.events?.length??0;return n===0?{added:0,offered:0,truncated:!1}:t.hasMore===!0?{added:0,offered:n,truncated:!0}:{added:eu(e,t.events??[]),offered:n,truncated:!1}}function nu(e){let t;for(let n of e){let e=u(n.eventId);(t===void 0||e>t)&&(t=e)}return t}function ru(e){let t=new Set,n=0;for(let r of e){let e=u(r.eventId);t.add(e),e>n&&(n=e)}if(n===0)return;let r=t.has(1)?1:2;if(t.size===n-r+1)return;let i,a=0;for(let e=r;e<=n;e++)t.has(e)||(i??=e,a++);if(i!==void 0)return{firstMissingSlot:i,missingCount:a,maxSlot:n}}async function iu(e,t){let n=t,r=ru(n.events);for(let t=0;r!==void 0&&t<3;t++)await new Promise(e=>setTimeout(e,25*2**t)),n=await Zl(e),r=ru(n.events);return{log:n,gap:r}}function au(e){let t=nu(e);return t===void 0?{}:{eventCount:t}}function ou(e,t){if(!_.is(e))return null;let n=e.details;if(typeof n!=`object`||!n)return null;let{events:r,cursor:i}=n;if(!Array.isArray(r)||r.length===0)return null;for(let e of r)if(typeof e!=`object`||!e||typeof e.eventId!=`string`||e.runId!==t)return null;return{events:r,cursor:typeof i==`string`?i:null}}const su={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function cu(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:su}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??7,workflowCoreVersion:Nl}),{status:200,headers:{"Content-Type":`application/json`,...su}}):await e(n)}}function lu(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function uu(e,t){return`${e}:${lu(t)}`}async function du(e,...t){let n=t[0];await Is(`queue.publish`,{attributes:{...xo(`vercel-queue`),...So(n),...wo(`publish`),..._s(`vercel-queue`),...vs(`vercel-queue`),...ys(`vqs`),...bs(`publish`)},kind:await Gs(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(Co(r))})}function fu(e){if(e.requestedAt)try{return To(Date.now()-e.requestedAt.getTime())}catch{return}}async function pu(e,t,n){let r=typeof t==`string`?await e.getEncryptionKeyForRun?.(t,n):await e.getEncryptionKeyForRun?.(t);return r?await oa(r):void 0}function mu(e,t){let n;return()=>(n||=pu(e,t),n)}function hu(t){import(`./functions-C02-JHBK.js`).then(t=>e(t.default,1)).then(({waitUntil:e})=>{e(t)})}function gu(e,t){hu(e.catch(e=>{if(e?.name!==`AbortError`&&e?.name!==`ResponseAborted`)try{t(e)}catch{}}))}async function _u(e){let t=e();return hu(t.catch(()=>{})),t}function vu(e,t={}){if(typeof e!=`object`||!e||Array.isArray(e))throw new y(`setAttributes requires a plain object, got ${e===null?`null`:Array.isArray(e)?`array`:typeof e}`);let n=Object.entries(e).map(([e,t])=>({key:e,value:t===void 0?null:t}));if(n.length===0)return n;let r=t.allowReservedAttributes===!0;try{s(n,{allowReservedAttributes:r})}catch(e){throw e instanceof l?new y(e.message):e}return n}export{cc as $,Ra as $n,po as $t,xl as A,Oa as An,bn as Ar,Po as At,Sl as B,Za as Bn,Le as Br,cs as Bt,Nl as C,ka as Cn,An as Cr,$a as Ct,al as D,Ba as Dn,wn as Dr,No as Dt,Xc as E,Va as En,Sn as Er,Fo as Et,rl as F,Ma as Fn,Ge as Fr,Co as Ft,il as G,wa as Gn,Yo as Gt,hl as H,Xa as Hn,ue as Hr,Vo as Ht,ol as I,Na as In,Ke as Ir,wo as It,Q as J,Ea as Jn,Xo as Jt,xc as K,Do as Kn,Go as Kt,Ec as L,ja as Ln,Be as Lr,xo as Lt,ml as M,Sa as Mn,He as Mr,rs as Mt,gl as N,Ca as Nn,We as Nr,ns as Nt,Cl as O,za as On,xn as Or,Io as Ot,Kc as P,Ka as Pn,Ue as Pr,So as Pt,uc as Q,Ia as Qn,qo as Qt,wl as R,Aa as Rn,Ve as Rr,os as Rt,cu as S,qa as Sn,kn as Sr,is as St,Vc as T,Oo as Tn,Nn as Tr,jo as Tt,_l as U,Qa as Un,he as Ur,Uo as Ut,Tl as V,Ya as Vn,ze as Vr,Bo as Vt,dl as W,Ja as Wn,me as Wr,Ho as Wt,lc as X,Ga as Xn,Jo as Xt,vc as Y,Ha as Yn,Ko as Yt,fc as Z,La as Zn,zo as Zt,du as _,uo as _n,Jn as _r,As as _t,Ql as a,to as an,gi as ar,Rs as at,au as b,ao as bn,Tn as br,Ss as bt,Bl as c,eo as cn,mi as cr,Es as ct,$l as d,mo as dn,ur as dr,Ts as dt,no as en,Wa as er,Z as et,Zl as f,vo as fn,xr as fr,Js as ft,ou as g,fo as gn,Hn as gr,Is as gt,Rl as h,so as hn,Xn as hr,Ls as ht,tu as i,co as in,W as ir,Hs as it,bl as j,Ua as jn,_n as jr,ts as jt,vl as k,Da as kn,Cn as kr,Ao as kt,Wl as l,Ro as ln,pi as lr,Gs as lt,mu as m,bo as mn,er as mr,Os as mt,gu as n,ho as nn,ca as nr,Qs as nt,fu as o,lo as on,_i as or,Ds as ot,nu as p,yo as pn,ar as pr,Vs as pt,bc as q,Ta as qn,Wo as qt,_u as r,_o as rn,ia as rr,ec as rt,Fl as s,io as sn,vi as sr,zs as st,vu as t,go as tn,oa as tr,$s as tt,Jl as u,Lo as un,Tr as ur,ws as ut,pu as v,ro as vn,Kn as vr,Ys as vt,Ml as w,ko as wn,On as wr,Mo as wt,uu as x,Pa as xn,M as xr,xs as xt,iu as y,oo as yn,Mn as yr,Eo as yt,yl as z,Fa as zn,Re as zr,ss as zt};