@makaio/framework 1.0.0-dev-1781081952714 → 1.0.0-dev-1781260968078

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 (194) hide show
  1. package/README.md +29 -0
  2. package/dist/.makaio-build.json +2 -2
  3. package/dist/adapters/acp-client/index.d.mts +4 -4
  4. package/dist/adapters/config/index.d.mts +1 -1
  5. package/dist/adapters/config/index.mjs +1 -1
  6. package/dist/adapters/index.d.mts +1 -1
  7. package/dist/adapters/index.mjs +1 -1
  8. package/dist/adapters/node.mjs +1 -1
  9. package/dist/ajv-BA2z5ztb.mjs +8 -0
  10. package/dist/bus/index.d.mts +19 -19
  11. package/dist/bus/index.mjs +1 -1
  12. package/dist/client-BJVDImPV.d.mts +175 -0
  13. package/dist/clients/index.d.mts +105 -2
  14. package/dist/clients/index.mjs +2 -2
  15. package/dist/contracts/adapter/index.d.mts +2 -2
  16. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  17. package/dist/contracts/artifact/index.d.mts +1 -1
  18. package/dist/contracts/client/index.d.mts +1 -1
  19. package/dist/contracts/extension/index.d.mts +3 -3
  20. package/dist/contracts/extension/index.mjs +1 -1
  21. package/dist/contracts/facet/index.d.mts +1 -1
  22. package/dist/contracts/index.d.mts +741 -228
  23. package/dist/contracts/index.mjs +1 -1
  24. package/dist/contracts/materialization/index.d.mts +3 -3
  25. package/dist/contracts/session/index.d.mts +2 -2
  26. package/dist/{cursor-storage-C_WTAESV.mjs → cursor-storage-CmKjSvKY.mjs} +1 -1
  27. package/dist/{definition-DqJOg6Lv.d.mts → definition-SiimP25_.d.mts} +1 -1
  28. package/dist/{detached-extension-handle-CxEBQnSa.mjs → detached-extension-handle-Diiwgm13.mjs} +1 -1
  29. package/dist/drizzle/0001_messages_content_tsv.na.md +18 -0
  30. package/dist/drizzle/0012_legal_kate_bishop.sql +3 -0
  31. package/dist/drizzle/0013_eager_rhodey.sql +56 -0
  32. package/dist/drizzle/0014_fancy_ultimo.sql +1 -0
  33. package/dist/drizzle/meta/0012_snapshot.json +2934 -0
  34. package/dist/drizzle/meta/0013_snapshot.json +2954 -0
  35. package/dist/drizzle/meta/0014_snapshot.json +2959 -0
  36. package/dist/drizzle/meta/_journal.json +21 -0
  37. package/dist/drizzle-wjquQK2m.mjs +1 -0
  38. package/dist/esm-CQVFKEW5.mjs +1 -0
  39. package/dist/expression/index.d.mts +11 -2
  40. package/dist/expression/index.mjs +4 -4
  41. package/dist/extension-DfNcE0zm.mjs +1 -0
  42. package/dist/extension-ZBN4BGre.mjs +1 -0
  43. package/dist/{filesystem-service-DH9zlxyd.mjs → filesystem-service-BjfrUmGS.mjs} +1 -1
  44. package/dist/git/index.mjs +14 -14
  45. package/dist/{globby-4SrlyIlj.mjs → globby-BIH65cbN.mjs} +1 -1
  46. package/dist/handler-DSfSAlxx.mjs +1 -0
  47. package/dist/handlers-C8EtpSqK.mjs +41 -0
  48. package/dist/{index-BCKRUuI2.d.mts → index-B2xbnMZe.d.mts} +1 -1
  49. package/dist/{index-YDfOv0GT.d.mts → index-BDRKAxIV.d.mts} +160 -7
  50. package/dist/{index-CwKzQuIX.d.mts → index-BQiHs8EF.d.mts} +12 -12
  51. package/dist/{index-BheaEhyI.d.mts → index-BtztOqaF.d.mts} +6 -6
  52. package/dist/{index-BmV60tMf.d.mts → index-BvSyOgTY.d.mts} +1298 -30
  53. package/dist/{index-D6bw4qJp.d.mts → index-CARxIllg.d.mts} +98 -98
  54. package/dist/{index-Bibt5jAX.d.mts → index-CZ_TcT6J.d.mts} +8 -8
  55. package/dist/{index-CNOTkyGw.d.mts → index-Cb64d5c5.d.mts} +307 -383
  56. package/dist/{index-DETxgKS2.d.mts → index-CgjslA5-.d.mts} +88 -15
  57. package/dist/{index-C3zfJg6s.d.mts → index-D5CI1V5d.d.mts} +16 -16
  58. package/dist/{index-jlQ4IhR5.d.mts → index-DDQkhhRo.d.mts} +281 -273
  59. package/dist/{index-Db0uJ_Cg2.d.mts → index-DTdqGAfH2.d.mts} +18 -8
  60. package/dist/{index-Clut1ljB.d.mts → index-Drz_a7kW.d.mts} +1 -1
  61. package/dist/kernel/extension/index.d.mts +1 -1
  62. package/dist/kernel/extension/index.mjs +1 -1
  63. package/dist/kernel/index.d.mts +2 -2
  64. package/dist/kernel/index.mjs +1 -1
  65. package/dist/kernel/observability/index.d.mts +1 -1
  66. package/dist/{lib-B9kVK_1_.mjs → lib-CNOQJtgs.mjs} +1 -1
  67. package/dist/{lib-DPruLs5D.mjs → lib-Cq5R6Tx9.mjs} +19 -22
  68. package/dist/lib-nlcl5kRW.mjs +2 -0
  69. package/dist/{load-extensions-C-TqCwzL.mjs → load-extensions-wELQ4BBN.mjs} +1 -1
  70. package/dist/mcp-http-server/index.mjs +1 -1
  71. package/dist/{namespace-ByyuIFpL.d.mts → namespace-7tsuJhQ9.d.mts} +28 -28
  72. package/dist/{namespace-BlS_i9KT.d.mts → namespace-B73Sxj5L.d.mts} +1 -1
  73. package/dist/{namespace-aBIAWxY3.d.mts → namespace-Ba4bxtHQ.d.mts} +12 -12
  74. package/dist/{namespace-DBKWNrk7.d.mts → namespace-DDCjoQUj.d.mts} +3 -3
  75. package/dist/{namespace-Ds6HkJEU.d.mts → namespace-DRFJN-_z.d.mts} +134 -134
  76. package/dist/namespace-DwE2g8Wm.mjs +1 -0
  77. package/dist/{orchestrator-shared-FnWrPS09.mjs → orchestrator-shared-Dt4WDse7.mjs} +1 -1
  78. package/dist/{out-CvZYgczi.mjs → out-C1JFb2Bp.mjs} +1 -1
  79. package/dist/package-Be2Ez4vv.mjs +1 -0
  80. package/dist/package.json +1 -1
  81. package/dist/primitive-runtime-Xrc9xh6p.mjs +1 -0
  82. package/dist/registry-RG-bkw3c.mjs +146 -0
  83. package/dist/rules/index.mjs +1 -1
  84. package/dist/runtime-bun/index.mjs +1 -1
  85. package/dist/runtime-node/extension-validation.mjs +1 -1
  86. package/dist/runtime-node/index.d.mts +57 -36
  87. package/dist/runtime-node/index.mjs +26 -53
  88. package/dist/runtime-node/makaio-config.mjs +1 -1
  89. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  90. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  91. package/dist/{schema-CDL_pyyM.d.mts → schema-BNrM9LWb.d.mts} +216 -10
  92. package/dist/schema-BerZmr2q.mjs +1 -0
  93. package/dist/schema-BrnYlDwZ.mjs +1 -0
  94. package/dist/{schemas-t1VR6_b_.d.mts → schemas-CkOSG2eJ.d.mts} +3 -3
  95. package/dist/{schemas-Exixg77V2.d.mts → schemas-DAFYpgHk2.d.mts} +12 -12
  96. package/dist/{schemas-on3_N5HP.d.mts → schemas-Dv5FxHDT.d.mts} +134 -134
  97. package/dist/services/agent-runtime/index.d.mts +2 -2
  98. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  99. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  100. package/dist/services/filesystem/index.mjs +1 -1
  101. package/dist/services/filesystem/namespace.d.mts +6 -6
  102. package/dist/services/filesystem/schemas.d.mts +3 -3
  103. package/dist/services/git/namespace.d.mts +2 -2
  104. package/dist/services/git/schemas.d.mts +2 -2
  105. package/dist/services/harness/index.d.mts +29 -17
  106. package/dist/services/harness/index.mjs +1 -1
  107. package/dist/services/harness/storage/schema.d.mts +60 -16
  108. package/dist/services/harness/storage/schema.mjs +1 -1
  109. package/dist/services/index.d.mts +103 -103
  110. package/dist/services/index.mjs +1 -1
  111. package/dist/services/log-import/browser.d.mts +2 -2
  112. package/dist/services/log-import/index.d.mts +7 -12
  113. package/dist/services/log-import/index.mjs +2 -2
  114. package/dist/services/log-import/log-import.d.mts +1 -1
  115. package/dist/services/log-import/namespace.d.mts +2 -2
  116. package/dist/services/log-import/schemas.d.mts +1 -1
  117. package/dist/services/session/handlers/index.mjs +1 -1
  118. package/dist/services/session/index.d.mts +7 -7
  119. package/dist/services/session/index.mjs +1 -1
  120. package/dist/services/session/messages/namespace.d.mts +1 -1
  121. package/dist/services/session/messages/namespace.mjs +1 -1
  122. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  123. package/dist/services/session/session-events/namespace.d.mts +1 -1
  124. package/dist/services/session/session-events/namespace.mjs +1 -1
  125. package/dist/services/session/storage/namespace.d.mts +1 -1
  126. package/dist/services/session/storage/schema.d.mts +2 -2
  127. package/dist/services/session/storage/schema.mjs +1 -1
  128. package/dist/services/session/testing/index.d.mts +18 -2
  129. package/dist/services/session/testing/index.mjs +52 -3
  130. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  131. package/dist/services/session/turns/namespace.d.mts +1 -1
  132. package/dist/services/session/turns/namespace.mjs +1 -1
  133. package/dist/services/settings/namespace.d.mts +12 -12
  134. package/dist/services/subagent-template/index.d.mts +1 -1
  135. package/dist/services/subagent-template/schemas.d.mts +1 -1
  136. package/dist/services/tool-approval/index.mjs +1 -1
  137. package/dist/services/tools/index.mjs +1 -1
  138. package/dist/session-KnewDVxt.mjs +39 -0
  139. package/dist/{session-lineage-CKg6mErA.d.mts → session-lineage-CXzV_hAP.d.mts} +1 -1
  140. package/dist/{src-Dvp41Cg2.mjs → src-CBG3IHUl.mjs} +1 -1
  141. package/dist/storage/drizzle/client.d.mts +2 -78
  142. package/dist/storage/drizzle/client.mjs +1 -1
  143. package/dist/storage/drizzle/columns/postgres.d.mts +88 -0
  144. package/dist/storage/drizzle/columns/postgres.mjs +1 -0
  145. package/dist/storage/drizzle/columns/sqlite.d.mts +81 -0
  146. package/dist/storage/drizzle/columns/sqlite.mjs +1 -0
  147. package/dist/storage/drizzle/index.d.mts +976 -23
  148. package/dist/storage/drizzle/index.mjs +1 -1
  149. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  150. package/dist/storage/handlers/drizzle/index.mjs +1 -1
  151. package/dist/storage/handlers/index.d.mts +1 -1
  152. package/dist/storage/handlers/index.mjs +1 -1
  153. package/dist/style.css +540 -540
  154. package/dist/testing/drizzle-harness.d.mts +52 -6
  155. package/dist/testing/drizzle-harness.mjs +1 -1
  156. package/dist/testing/index.d.mts +34 -2
  157. package/dist/testing/index.mjs +1 -1
  158. package/dist/{tool-approval-service-BgNcJvKx.mjs → tool-approval-service-Cb2F1yT6.mjs} +1 -1
  159. package/dist/tools-D5DVHC-R.mjs +1 -0
  160. package/dist/{types-CmMesAgR.d.mts → types-BMpIa4fx.d.mts} +1 -1
  161. package/dist/{types-D0fPFh-D.d.mts → types-D5IMwOkJ.d.mts} +1 -1
  162. package/dist/{types-DiGqpZOD.d.mts → types-DLVitCZP.d.mts} +195 -195
  163. package/dist/ui-components/index.d.mts +1 -1
  164. package/dist/ui-components/index.mjs +2 -2
  165. package/dist/ui-hooks/index.d.mts +6 -6
  166. package/dist/ui-views/index.mjs +2 -2
  167. package/dist/workflow-engine/index.d.mts +492 -96
  168. package/dist/workflow-engine/index.mjs +1 -1
  169. package/dist/workflow-engine/package.mjs +1 -1
  170. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  171. package/dist/workflow-worker-CK9Sqj7D.mjs +1 -0
  172. package/package.json +40 -1
  173. package/dist/ajv-BJsabpMb.mjs +0 -8
  174. package/dist/drizzle-DpjZFY_j.mjs +0 -1
  175. package/dist/esm-BdLRFEUy.mjs +0 -3
  176. package/dist/extension--5Q190u_.mjs +0 -1
  177. package/dist/extension-DFIZ3FCJ.mjs +0 -1
  178. package/dist/fast-uri-BF2Xuiop.mjs +0 -1
  179. package/dist/handlers-Bev7-xjL.mjs +0 -41
  180. package/dist/lib-aRogYLqg.mjs +0 -5
  181. package/dist/namespace-CDiM5Bcr.mjs +0 -1
  182. package/dist/namespace-h0HIuqx0.mjs +0 -1
  183. package/dist/package-1DS4bXg5.mjs +0 -1
  184. package/dist/primitive-runtime-DcYYWy_6.mjs +0 -8
  185. package/dist/schema-DCJyzRHe.mjs +0 -1
  186. package/dist/schema-DOnJmAPw.mjs +0 -1
  187. package/dist/session-BnfsJoZi.mjs +0 -134
  188. package/dist/tools-DC4KrqI1.mjs +0 -1
  189. package/dist/types-BhXRffJ_.d.mts +0 -31
  190. package/dist/workflow-worker-DvP753UN.mjs +0 -1
  191. /package/dist/{cleanEnvForAdapter-BlpmyXYk.mjs → cleanEnvForAdapter-vZfPGi0X.mjs} +0 -0
  192. /package/dist/{create-static-mount-CFGo91CI.mjs → create-static-mount-BB1MIQ9J.mjs} +0 -0
  193. /package/dist/{jsonl-transport-BxNXizIm.mjs → jsonl-transport-C21tpVfe.mjs} +0 -0
  194. /package/dist/{src-Z3vAZJfw.mjs → src-DedDL9iv.mjs} +0 -0
@@ -1 +1 @@
1
- import{f as e,p as t,s as n}from"../primitive-runtime-DcYYWy_6.mjs";import{a as r,i,n as a,o,r as s,t as c}from"../package-1DS4bXg5.mjs";import{JsonValueSchema as l,WorkflowFrameStateSchema as u}from"@makaio/framework/contracts";const d=new Set([...u.shape.status.options]);function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e){if(!f(e))return!1;for(let t of Object.values(e))if(!f(t)||typeof t.status!=`string`||!d.has(t.status)||`result`in t&&t.result!==void 0&&!l.safeParse(t.result).success)return!1;return!0}function m(e){let t={trigger:f(e.trigger)?e.trigger:{},steps:p(e.steps)?e.steps:{},inputs:l.safeParse(e.inputs).success?e.inputs:{}};return`item`in e&&(t.item=e.item),typeof e.index==`number`&&(t.index=e.index),t}export{i as WorkflowEngineService,c as WorkflowEngineToken,r as WorkflowExecutor,e as WorkflowStorageNamespace,t as WorkflowStorageSubjects,m as buildWorkflowExpressionContextFromResolvedInputs,a as createWorkflowEnginePackage,o as registerDrizzleWorkflowStorage,n as runShellStep,s as workflowEnginePackage};
1
+ import{D as e,F as t,f as n,h as r,j as i,p as a,s as o,x as s}from"../primitive-runtime-Xrc9xh6p.mjs";import{a as c,i as l,n as u,o as d,r as f,t as p}from"../package-Be2Ez4vv.mjs";import{JsonValueSchema as m,WorkflowFrameStateSchema as h}from"@makaio/framework/contracts";const g=new Set([...h.shape.status.options]);function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function v(e){if(!_(e))return!1;for(let t of Object.values(e))if(!_(t)||typeof t.status!=`string`||!g.has(t.status)||`result`in t&&t.result!==void 0&&!m.safeParse(t.result).success)return!1;return!0}function y(e){let t={trigger:_(e.trigger)?e.trigger:{},steps:v(e.steps)?e.steps:{},inputs:m.safeParse(e.inputs).success?e.inputs:{}};return`item`in e&&(t.item=e.item),typeof e.index==`number`&&(t.index=e.index),t}export{l as WorkflowEngineService,p as WorkflowEngineToken,c as WorkflowExecutor,n as WorkflowStorageNamespace,a as WorkflowStorageSubjects,y as buildWorkflowExpressionContextFromResolvedInputs,u as createWorkflowEnginePackage,d as registerDrizzleWorkflowStorage,o as runShellStep,r as workflowDefinitionsDual,f as workflowEnginePackage,s as workflowExecutionsDual,e as workflowStepSpansDual,i as worklogFrameEntriesDual,t as worklogSummariesDual};
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"../package-1DS4bXg5.mjs";export{n as WorkflowEngineToken,e as createWorkflowEnginePackage,t as workflowEnginePackage};
1
+ import{n as e,r as t,t as n}from"../package-Be2Ez4vv.mjs";export{n as WorkflowEngineToken,e as createWorkflowEnginePackage,t as workflowEnginePackage};
@@ -1 +1 @@
1
- import{T as e,a as t,c as n,d as r,i,p as a,r as o,t as s}from"../primitive-runtime-DcYYWy_6.mjs";import{WORKFLOW_CANCELLED_REASON as c}from"@makaio/framework/contracts";async function l(t,n,r,i){let o=await m(t,n,r);return await t.request(a.setExecution,{execution:o}),r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:0,completedAt:o.completedAt}):await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:i,completedAt:o.completedAt}),r===`cancelled`?{executionId:n.executionId,workflowId:n.workflowId,status:`cancelled`,...i===void 0?{}:{reason:i}}:{executionId:n.executionId,workflowId:n.workflowId,status:`completed`}}function u(e,t){return t.status===`completed`?{executionId:e.executionId,workflowId:e.workflowId,status:`completed`,...t.artifact===void 0?{}:{artifact:t.artifact}}:t.status===`cancelled`?{executionId:e.executionId,workflowId:e.workflowId,status:`cancelled`,...t.reason===void 0?{}:{reason:t.reason}}:t.status===`paused`?{executionId:e.executionId,workflowId:e.workflowId,status:`paused`,pausedAtGateId:t.pausedAtGateId,pausedAtFrameId:t.pausedAtFrameId}:{executionId:e.executionId,workflowId:e.workflowId,status:`failed`,error:t.error}}function d(e){let t,i=()=>{t=n({bus:e.bus,activeExecutions:e.activeExecutions,shellAbortControllers:e.shellAbortControllers,activeRunnerSteps:e.activeRunnerSteps,cancelTimeoutMs:r.cancelTimeoutMs},e.executionId,c).catch(t=>(console.error(`[WorkflowOrchestrator] Failed to persist cancellation for ${e.executionId}:`,t),!1))};return e.signal.addEventListener(`abort`,i,{once:!0}),e.signal.aborted&&i(),async()=>(e.signal.removeEventListener(`abort`,i),t??!1)}async function f(e,t){let n=await e.requestOptional(a.getExecution,{executionId:t});return n.handled?n.data.execution?.startedAt??void 0:void 0}async function p(e,t){return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:`running`,inputs:t.inputs,config:t.config??{},startedAt:await f(e,t.executionId)??Date.now(),triggerPayload:t.triggerPayload,scope:t.scope}}async function m(e,t,n){let r=Date.now();return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:n,inputs:t.inputs,config:t.config??{},startedAt:await f(e,t.executionId)??r,completedAt:r,triggerPayload:t.triggerPayload,scope:t.scope}}async function h(e,n,r,a,o,l,u,d){let f=e.suspensionStrategy===`wait-in-process`?void 0:await g(e.executionId,l,{required:!0}),p=await i({definition:n,execution:r,runContext:a,zodSchema:d?.artifact,bus:l}),m=new t(e.executionId,e.workflowId,n,r,o,l,u,void 0,p,{context:e.context,env:e.env},{suspensionStrategy:e.suspensionStrategy,resumeFrames:f}),h=m.buildExpressionContext(),_=await s(n.root,m,h);return _.status===`failed`?{status:`failed`,error:_.error}:_.status===`paused`?{status:`paused`,pausedAtGateId:_.pausedAtGateId,pausedAtFrameId:_.pausedAtFrameId}:_.status===`cancelled`||u.aborted?{status:`cancelled`,reason:c}:{status:`completed`,artifact:p?.current}}async function g(e,t,n={}){try{let r=await t.requestOptional(a.listFrames,{executionId:e});if(!r.handled){if(n.required===!0)throw Error(`Frame storage handler is required to resume execution '${e}'.`);return}return r.data.frames.length===0?void 0:o(r.data.frames)}catch(e){if(n.required===!0)throw e;return}}function _(e,t){return{executionId:e.executionId,workflowId:e.workflowId,source:e.source,...e.source.kind===`definition`?{definitionSnapshot:e.definition??t}:{},workerManifest:{packages:[]},inputs:e.inputs,config:e.config??{},scope:e.scope,triggerPayload:e.triggerPayload,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},...e.executionHints===void 0?{}:{executionHints:e.executionHints},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:e.cancelSubject,context:e.context,env:e.env,createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy}}async function v(t,n,r,i,o){r.status=`paused`,await t.request(a.setExecution,{execution:r}),await t.emit(e.execution.paused,{executionId:n.executionId,workflowId:n.workflowId,pausedAtGateId:i,pausedAtFrameId:o})}async function y(t,n,r,i,a,o){r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:a-i.startedAt,completedAt:a}):r===`cancelled`?await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:c,completedAt:a}):await t.emit(e.execution.failed,{executionId:n.executionId,workflowId:n.workflowId,error:o??`Workflow execution failed`,completedAt:a})}async function b(e){let{config:t,loaded:n,bus:r,signal:i}=e,{definition:o}=n;if(i.aborted)return l(r,t,`cancelled`,c);if(o.root.nodes.length===0)return l(r,t,`completed`);let s=await p(r,t);await r.request(a.setExecution,{execution:s});let f=new Map(n.runtimeHandlers),m=new Map,g=new Map,b=new Map,x=_(t,o);m.set(t.executionId,{execution:s,workflow:o,runContext:x,runtimeHandlers:f});let S=d({signal:i,executionId:t.executionId,bus:r,activeExecutions:m,shellAbortControllers:g,activeRunnerSteps:b}),C={status:`completed`},w=!1;try{C=await h(t,o,s,x,f,r,i,n.zodSchemas)}catch(e){C={status:`failed`,error:e instanceof Error?e.message:String(e)}}finally{w=await S(),m.clear()}if(w)return u(t,{status:`cancelled`,reason:c});if((i.aborted||s.status===`cancelled`)&&(C={status:`cancelled`,reason:c}),C.status===`paused`)return await v(r,t,s,C.pausedAtGateId,C.pausedAtFrameId),u(t,C);let T=Date.now(),E=C.status===`failed`?C.error:void 0;return s.status=C.status,s.completedAt=T,s.error=E,await r.request(a.setExecution,{execution:s}),await y(r,t,C.status,s,T,E),u(t,C)}export{b as runWorkflowOrchestrator};
1
+ import{I as e,a as t,c as n,d as r,i,p as a,r as o,t as s}from"../primitive-runtime-Xrc9xh6p.mjs";import{WORKFLOW_CANCELLED_REASON as c}from"@makaio/framework/contracts";async function l(t,n,r,i){let o=await m(t,n,r);return await t.request(a.setExecution,{execution:o}),r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:0,completedAt:o.completedAt}):await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:i,completedAt:o.completedAt}),r===`cancelled`?{executionId:n.executionId,workflowId:n.workflowId,status:`cancelled`,...i===void 0?{}:{reason:i}}:{executionId:n.executionId,workflowId:n.workflowId,status:`completed`}}function u(e,t){return t.status===`completed`?{executionId:e.executionId,workflowId:e.workflowId,status:`completed`,...t.artifact===void 0?{}:{artifact:t.artifact}}:t.status===`cancelled`?{executionId:e.executionId,workflowId:e.workflowId,status:`cancelled`,...t.reason===void 0?{}:{reason:t.reason}}:t.status===`paused`?{executionId:e.executionId,workflowId:e.workflowId,status:`paused`,pausedAtGateId:t.pausedAtGateId,pausedAtFrameId:t.pausedAtFrameId}:{executionId:e.executionId,workflowId:e.workflowId,status:`failed`,error:t.error}}function d(e){let t,i=()=>{t=n({bus:e.bus,activeExecutions:e.activeExecutions,shellAbortControllers:e.shellAbortControllers,activeRunnerSteps:e.activeRunnerSteps,cancelTimeoutMs:r.cancelTimeoutMs},e.executionId,c).catch(t=>(console.error(`[WorkflowOrchestrator] Failed to persist cancellation for ${e.executionId}:`,t),!1))};return e.signal.addEventListener(`abort`,i,{once:!0}),e.signal.aborted&&i(),async()=>(e.signal.removeEventListener(`abort`,i),t??!1)}async function f(e,t){let n=await e.requestOptional(a.getExecution,{executionId:t});return n.handled?n.data.execution?.startedAt??void 0:void 0}async function p(e,t){return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:`running`,inputs:t.inputs,config:t.config??{},startedAt:await f(e,t.executionId)??Date.now(),triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function m(e,t,n){let r=Date.now();return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:n,inputs:t.inputs,config:t.config??{},startedAt:await f(e,t.executionId)??r,completedAt:r,triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function h(e,n,r,a,o,l,u,d){let f=e.suspensionStrategy===`wait-in-process`?void 0:await g(e.executionId,l,{required:!0}),p=await i({definition:n,execution:r,runContext:a,zodSchema:d?.artifact,bus:l}),m=new t(e.executionId,e.workflowId,n,r,o,l,u,void 0,p,{context:e.context,env:e.env},{suspensionStrategy:e.suspensionStrategy,resumeFrames:f}),h=m.buildExpressionContext(),_=await s(n.root,m,h);return _.status===`failed`?{status:`failed`,error:_.error}:_.status===`paused`?{status:`paused`,pausedAtGateId:_.pausedAtGateId,pausedAtFrameId:_.pausedAtFrameId}:_.status===`cancelled`||u.aborted?{status:`cancelled`,reason:c}:{status:`completed`,artifact:p?.current}}async function g(e,t,n={}){try{let r=await t.requestOptional(a.listFrames,{executionId:e});if(!r.handled){if(n.required===!0)throw Error(`Frame storage handler is required to resume execution '${e}'.`);return}return r.data.frames.length===0?void 0:o(r.data.frames)}catch(e){if(n.required===!0)throw e;return}}function _(e,t){return{executionId:e.executionId,workflowId:e.workflowId,source:e.source,...e.source.kind===`definition`?{definitionSnapshot:e.definition??t}:{},workerManifest:{packages:[]},inputs:e.inputs,config:e.config??{},scope:e.scope,triggerPayload:e.triggerPayload,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},...e.executionHints===void 0?{}:{executionHints:e.executionHints},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:e.cancelSubject,context:e.context,env:e.env,createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy}}async function v(t,n,r,i,o){r.status=`paused`,await t.request(a.setExecution,{execution:r}),await t.emit(e.execution.paused,{executionId:n.executionId,workflowId:n.workflowId,pausedAtGateId:i,pausedAtFrameId:o})}async function y(t,n,r,i,a,o){r===`completed`?await t.emit(e.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:a-i.startedAt,completedAt:a}):r===`cancelled`?await t.emit(e.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:c,completedAt:a}):await t.emit(e.execution.failed,{executionId:n.executionId,workflowId:n.workflowId,error:o??`Workflow execution failed`,completedAt:a})}async function b(e){let{config:t,loaded:n,bus:r,signal:i}=e,{definition:o}=n;if(i.aborted)return l(r,t,`cancelled`,c);if(o.root.nodes.length===0)return l(r,t,`completed`);let s=await p(r,t);await r.request(a.setExecution,{execution:s});let f=new Map(n.runtimeHandlers),m=new Map,g=new Map,b=new Map,x=_(t,o);m.set(t.executionId,{execution:s,workflow:o,runContext:x,runtimeHandlers:f});let S=d({signal:i,executionId:t.executionId,bus:r,activeExecutions:m,shellAbortControllers:g,activeRunnerSteps:b}),C={status:`completed`},w=!1;try{C=await h(t,o,s,x,f,r,i,n.zodSchemas)}catch(e){C={status:`failed`,error:e instanceof Error?e.message:String(e)}}finally{w=await S(),m.clear()}if(w)return u(t,{status:`cancelled`,reason:c});if((i.aborted||s.status===`cancelled`)&&(C={status:`cancelled`,reason:c}),C.status===`paused`)return await v(r,t,s,C.pausedAtGateId,C.pausedAtFrameId),u(t,C);let T=Date.now(),E=C.status===`failed`?C.error:void 0;return s.status=C.status,s.completedAt=T,s.error=E,await r.request(a.setExecution,{execution:s}),await y(r,t,C.status,s,T,E),u(t,C)}export{b as runWorkflowOrchestrator};
@@ -0,0 +1 @@
1
+ import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{n as r,o as i,t as a}from"./await-trigger-DREnXCEJ.mjs";import{basename as o,join as s}from"node:path";import{WorkerNodeCapabilitiesSchema as c,WorkerNodeSubjects as l,WorkflowWorkerConfigSchema as u}from"@makaio/framework/contracts";import{runWorkflowOrchestrator as d}from"@makaio/framework/workflow-engine/workflow-orchestrator";var f=n(((e,t)=>{t.exports={name:`piscina`,version:`5.1.4`,description:`A fast, efficient Node.js Worker Thread Pool implementation`,main:`./dist/main.js`,types:`./dist/index.d.ts`,exports:{types:`./dist/index.d.ts`,import:`./dist/esm-wrapper.mjs`,require:`./dist/main.js`},engines:{node:`>=20.x`},scripts:{build:`tsc && gen-esm-wrapper . dist/esm-wrapper.mjs`,lint:`eslint`,test:`node scripts/run-tests.js --pattern='test/**/*test.ts'`,"test:ci":`npm run lint && npm run build && npm run test:coverage`,"test:coverage":`node scripts/run-tests.js --coverage --pattern='test/**/*test.ts'`,prepack:`npm run build`,benchmark:`node --allow-natives-syntax benchmark/index.js --scope all`,"benchmark:ci":`node --allow-natives-syntax benchmark/index.js --scope all --reporter json | jq '.[] | .name, .opsSec'`,"benchmark:simple":`node --allow-natives-syntax benchmark/index.js --scope simple:all`,"benchmark:simple:default":`node --allow-natives-syntax benchmark/index.js --scope simple`,"benchmark:simple:async":`node --allow-natives-syntax benchmark/index.js --scope simple:async`,"benchmark:startup":`node --allow-natives-syntax benchmark/index.js --scope startup`,"benchmark:queue":`node --allow-natives-syntax benchmark/index.js --scope queue`},repository:{type:`git`,url:`git+https://github.com/piscinajs/piscina.git`},keywords:[`fast`,`worker threads`,`thread pool`,`wade wilson`],author:`James M Snell <jasnell@gmail.com>`,contributors:[`Anna Henningsen <anna@addaleax.net>`,`Matteo Collina <matteo.collina@gmail.com>`,`Carlos Fuentes <me@metcoder.dev>`],license:`MIT`,devDependencies:{"@types/node":`^22.4.1`,"abort-controller":`^3.0.0`,"bench-node":`^0.7.0`,"concat-stream":`^2.0.0`,eslint:`^9.16.0`,"gen-esm-wrapper":`^1.1.1`,glob:`^11.0.2`,neostandard:`^0.12.0`,tsx:`^4.20.3`,typescript:`5.8.3`},optionalDependencies:{"@napi-rs/nice":`^1.0.4`},bugs:{url:`https://github.com/piscinajs/piscina/issues`},homepage:`https://github.com/piscinajs/piscina#readme`,directories:{example:`examples`,test:`test`}}})),p=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.kFieldCount=e.kResponseCountField=e.kRequestCountField=e.kQueueOptions=e.kValue=e.kTransferable=e.kWorkerData=e.kMovable=void 0,e.kMovable=Symbol(`Piscina.kMovable`),e.kWorkerData=Symbol(`Piscina.kWorkerData`),e.kTransferable=Symbol.for(`Piscina.transferable`),e.kValue=Symbol.for(`Piscina.valueOf`),e.kQueueOptions=Symbol.for(`Piscina.queueOptions`),e.kRequestCountField=0,e.kResponseCountField=1,e.kFieldCount=2})),m=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AbortError=void 0,e.onabort=t,e.AbortError=class extends Error{constructor(e){super(`The task has been aborted`,{cause:e})}get name(){return`AbortError`}};function t(e,t){return`addEventListener`in e?(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)):(e.once(`abort`,t),()=>e.removeListener(`abort`,t))}})),h=n((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.commonState=t.READY=void 0,t.isTransferable=a,t.isMovable=o,t.markMovable=s,t.maybeFileURLToPath=c,t.getAvailableParallelism=l,t.promiseResolvers=u;let n=e(`node:url`),r=e(`node:os`),i=p();t.READY=`_WORKER_READY`;function a(e){return typeof e==`object`&&!!e&&i.kTransferable in e&&i.kValue in e}function o(e){return a(e)&&e[i.kMovable]===!0}function s(e){Object.defineProperty(e,i.kMovable,{enumerable:!1,configurable:!0,writable:!0,value:!0})}t.commonState={isWorkerThread:!1,workerData:void 0};function c(e){return e.startsWith(`file:`)?(0,n.fileURLToPath)(new n.URL(e)):e}function l(){return(0,r.availableParallelism)()}function u(){if(Promise.withResolvers!=null)return Promise.withResolvers();let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}})),g=n((t=>{var n=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.ArrayTaskQueue=void 0;let r=n(e(`node:assert`));t.ArrayTaskQueue=class{constructor(){this.tasks=[]}get size(){return this.tasks.length}shift(){return this.tasks.shift()??null}push(e){this.tasks.push(e)}remove(e){let t=this.tasks.indexOf(e);r.default.notStrictEqual(t,-1),this.tasks.splice(t,1)}}})),_=n((t=>{var n=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},r=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},i=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a;Object.defineProperty(t,`__esModule`,{value:!0}),t.FixedQueue=void 0;let o=i(e(`node:assert`)),s=2048,c=s-1;var l=class{constructor(){this.bottom=0,this.top=0,this.list=Array(s),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&c)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&c}shift(){let e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&c,e)}remove(e){let t=this.list.indexOf(e);o.default.notStrictEqual(t,-1);let n=t;for(;;){let e=n+1&c;if(this.list[n]=this.list[e],this.list[n]===void 0)break;if(e===t){this.list[n]=void 0;break}n=e}this.top=this.top-1&c}};t.FixedQueue=class{constructor(){a.set(this,0),this.head=this.tail=new l}isEmpty(){return this.head.isEmpty()}push(e){var t;this.head.isFull()&&(this.head=this.head.next=new l),this.head.push(e),r(this,a,(t=n(this,a,`f`),t++,t),`f`)}shift(){var e;let t=this.tail,i=t.shift();return i!==null&&r(this,a,(e=n(this,a,`f`),e--,e),`f`),t.isEmpty()&&t.next!==null&&(this.tail=t.next,t.next=null),i}remove(e){var t;let i=null,o=this.tail;for(;;){if(o.list.includes(e)){o.remove(e),r(this,a,(t=n(this,a,`f`),t--,t),`f`);break}if(o.next===null)break;i=o,o=o.next}o.isEmpty()&&(i===null?o.next!==null&&(this.tail=o.next):o.next===null?this.head=i:i.next=o.next)}get size(){return n(this,a,`f`)}},a=new WeakMap})),v=n((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TaskInfo=t.FixedQueue=t.ArrayTaskQueue=void 0,t.isTaskQueue=l;let n=e(`node:perf_hooks`),r=e(`node:async_hooks`),i=m(),a=h(),o=p();var s=g();Object.defineProperty(t,`ArrayTaskQueue`,{enumerable:!0,get:function(){return s.ArrayTaskQueue}});var c=_();Object.defineProperty(t,`FixedQueue`,{enumerable:!0,get:function(){return c.FixedQueue}});function l(e){return typeof e==`object`&&!!e&&`size`in e&&typeof e.shift==`function`&&typeof e.remove==`function`&&typeof e.push==`function`}let u=0;t.TaskInfo=class extends r.AsyncResource{constructor({task:e,transferList:t,filename:r,name:i,abortSignal:s,triggerAsyncId:c},l){super(`Piscina.Task`,{requireManualDestroy:!0,triggerAsyncId:c}),this.workerInfo=null,this.aborted=!1,this._abortListener=()=>{this.aborted=!0},this._abortCleaner=null,this.callback=l,this.task=e,this.transferList=t,(0,a.isMovable)(e)&&(this.transferList??=[],this.transferList=this.transferList.concat(e[o.kTransferable]),this.task=e[o.kValue]),this.filename=r,this.name=i,this.taskId=u++,this.abortSignal=s,this.created=n.performance.now(),this.started=0}onAbort(e){this._abortListener=()=>{this.aborted=!0,e()}}setAbortListener(e){this._abortCleaner=(0,i.onabort)(e,this._abortListener)}releaseTask(){let e=this.task;return this.task=null,e}onResponse(e){}done(e,t){var n;this.runInAsyncScope(this.callback,null,e,t),this.emitDestroy(),(n=this._abortCleaner)==null||n.call(this)}get[o.kQueueOptions](){return this.task?.[o.kQueueOptions]??null}get interface(){return{taskId:this.taskId,filename:this.filename,name:this.name,created:this.created,isAbortable:this.abortSignal!==null,[o.kQueueOptions]:this[o.kQueueOptions]}}}})),y=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Errors=void 0,e.Errors={ThreadTermination:()=>Error(`Terminating worker thread`),FilenameNotProvided:()=>Error(`filename must be provided to run() or in options object`),TaskQueueAtLimit:()=>Error(`Task queue is at limit`),NoTaskQueueAvailable:()=>Error(`No task queue available and all Workers are busy`),CloseTimeout:()=>Error(`Close operation timed out`)}})),b=n((t=>{var n=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},r=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},i,a;Object.defineProperty(t,`__esModule`,{value:!0}),t.PiscinaHistogramHandler=void 0;let o=e(`node:perf_hooks`);t.PiscinaHistogramHandler=class e{constructor(){i.set(this,void 0),a.set(this,void 0),n(this,i,(0,o.createHistogram)(),`f`),n(this,a,(0,o.createHistogram)(),`f`)}get runTimeSummary(){return e.createHistogramSummary(r(this,i,`f`))}get waitTimeSummary(){return e.createHistogramSummary(r(this,a,`f`))}get runTimeCount(){return r(this,i,`f`).count}recordRunTime(t){r(this,i,`f`).record(e.toHistogramIntegerNano(t))}recordWaitTime(t){r(this,a,`f`).record(e.toHistogramIntegerNano(t))}resetWaitTime(){r(this,a,`f`).reset()}resetRunTime(){r(this,i,`f`).reset()}static createHistogramSummary(e){let{mean:t,stddev:n,min:r,max:i}=e;return{average:t/1e3,mean:t/1e3,stddev:n/1e3,min:r/1e3,max:i/1e3,p0_001:e.percentile(.001)/1e3,p0_01:e.percentile(.01)/1e3,p0_1:e.percentile(.1)/1e3,p1:e.percentile(1)/1e3,p2_5:e.percentile(2.5)/1e3,p10:e.percentile(10)/1e3,p25:e.percentile(25)/1e3,p50:e.percentile(50)/1e3,p75:e.percentile(75)/1e3,p90:e.percentile(90)/1e3,p97_5:e.percentile(97.5)/1e3,p99:e.percentile(99)/1e3,p99_9:e.percentile(99.9)/1e3,p99_99:e.percentile(99.99)/1e3,p99_999:e.percentile(99.999)/1e3}}static toHistogramIntegerNano(e){return Math.max(1,Math.trunc(e*1e3))}},i=new WeakMap,a=new WeakMap})),x=n((t=>{var n=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AsynchronouslyCreatedResourcePool=t.AsynchronouslyCreatedResource=void 0;let r=n(e(`node:assert`));t.AsynchronouslyCreatedResource=class{constructor(){this.onreadyListeners=[],this.ondestroyListeners=[]}markAsReady(){let e=this.onreadyListeners;(0,r.default)(e!=null),this.onreadyListeners=null;for(let t of e)t()}isReady(){return this.onreadyListeners==null}onReady(e){if(this.onreadyListeners==null){e();return}this.onreadyListeners.push(e)}onDestroy(e){this.ondestroyListeners!=null&&this.ondestroyListeners.push(e)}markAsDestroyed(){let e=this.ondestroyListeners;(0,r.default)(e!=null),this.ondestroyListeners=null;for(let t of e)t()}isDestroyed(){return this.ondestroyListeners==null}},t.AsynchronouslyCreatedResourcePool=class{constructor(e){this.pendingItems=new Set,this.readyItems=new Set,this.maximumUsage=e,this.onAvailableListeners=[],this.onTaskDoneListeners=[]}add(e){this.pendingItems.add(e),e.onReady(()=>{this.pendingItems.has(e)&&(this.pendingItems.delete(e),this.readyItems.add(e),this.maybeAvailable(e))})}delete(e){this.pendingItems.delete(e),this.readyItems.delete(e)}*[Symbol.iterator](){yield*this.pendingItems,yield*this.readyItems}get size(){return this.pendingItems.size+this.readyItems.size}maybeAvailable(e){if(e.currentUsage()<this.maximumUsage)for(let t of this.onAvailableListeners)t(e)}onAvailable(e){this.onAvailableListeners.push(e)}taskDone(e){for(let t=0;t<this.onTaskDoneListeners.length;t++)this.onTaskDoneListeners[t](e)}onTaskDone(e){this.onTaskDoneListeners.push(e)}getCurrentUsage(){let e=0;for(let t of this.readyItems){let n=t.currentUsage();Number.isFinite(n)&&(e+=n)}return e}}})),S=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.LeastBusyBalancer=t;function t(e){let{maximumUsage:t}=e;return(e,n)=>{let r=null,i=t;for(let t of n){if(t.currentUsage===0){r=t;break}t.isRunningAbortableTask||e.isAbortable===!1&&t.currentUsage<i&&(r=t,i=t.currentUsage)}return r}}})),C=n((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__exportStar||function(e,t){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(t,r)&&n(t,e,r)},i=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AsynchronouslyCreatedResourcePool=t.WorkerInfo=void 0;let a=e(`node:worker_threads`),o=e(`node:perf_hooks`),s=i(e(`node:assert`)),c=y(),l=p(),u=b(),d=x();Object.defineProperty(t,`AsynchronouslyCreatedResourcePool`,{enumerable:!0,get:function(){return d.AsynchronouslyCreatedResourcePool}}),r(S(),t),t.WorkerInfo=class extends d.AsynchronouslyCreatedResource{constructor({worker:e,port:t,enableHistogram:n},r){super(),this.idleTimeout=null,this.lastSeenResponseCount=0,this.terminating=!1,this.destroyed=!1;let{filename:i,...s}=e;this.worker=new a.Worker(i,s),this.port=t,this.onMessage=r,this.port.on(`message`,this._handleResponse.bind(this)),this.taskInfos=new Map,this.sharedBuffer=new Int32Array(new SharedArrayBuffer(l.kFieldCount*Int32Array.BYTES_PER_ELEMENT)),this.histogram=n?(0,o.createHistogram)():null}get id(){return this.worker.threadId}onWorkerMessage(e){this.worker.on(`message`,e)}onWorkerError(e){this.worker.on(`error`,e)}onWorkerExit(e){this.worker.on(`exit`,e)}onPortClose(e){this.port.on(`close`,e)}init(e,t){return this.worker.postMessage(e,t),this}workerRef(){return this.worker.ref(),this}workerUnref(){return this.worker.unref(),this}destroy(){if(!(this.terminating||this.destroyed)){this.terminating=!0,this.clearIdleTimeout(),this.worker.terminate(),this.port.close();for(let e of this.taskInfos.values())e.done(c.Errors.ThreadTermination());this.taskInfos.clear(),this.terminating=!1,this.destroyed=!0,this.markAsDestroyed()}}setIdleTimeout(e,t,...n){this.idleTimeout=setTimeout(e,t,...n).unref()}clearIdleTimeout(){this.idleTimeout!=null&&(clearTimeout(this.idleTimeout),this.idleTimeout=null)}ref(){return this.port.ref(),this}unref(){return this.port.unref(),this}_handleResponse(e){var t;(t=this.histogram)==null||t.record(u.PiscinaHistogramHandler.toHistogramIntegerNano(e?.time)),this.onMessage(e),this.taskInfos.size===0&&this.unref()}postTask(e){(0,s.default)(!this.taskInfos.has(e.taskId)),(0,s.default)(!this.terminating&&!this.destroyed);let t={task:e.releaseTask(),taskId:e.taskId,filename:e.filename,name:e.name,histogramEnabled:this.histogram==null?0:1};try{this.port.postMessage(t,e.transferList),queueMicrotask(()=>this.clearIdleTimeout()),e.workerInfo=this,this.taskInfos.set(e.taskId,e),this.ref(),Atomics.add(this.sharedBuffer,l.kRequestCountField,1),Atomics.notify(this.sharedBuffer,l.kRequestCountField,1)}catch(t){e.done(t)}}processPendingMessages(){if(this.destroyed)return;let e=Atomics.load(this.sharedBuffer,l.kResponseCountField);if(e!==this.lastSeenResponseCount){this.lastSeenResponseCount=e;let t;for(;(t=(0,a.receiveMessageOnPort)(this.port))!=null;)this._handleResponse(t.message)}}isRunningAbortableTask(){if(this.taskInfos.size!==1)return!1;let[[,e]]=this.taskInfos;return e.abortSignal!=null}currentUsage(){return this.isRunningAbortableTask()?1/0:this.taskInfos.size}popTask(e){let t=this.taskInfos.get(e)??null;return t!=null&&this.taskInfos.delete(e),t}get interface(){let e=this;return{get id(){return e.worker.threadId},get currentUsage(){return e.currentUsage()},get isRunningAbortableTask(){return e.isRunningAbortableTask()},get histogram(){return e.histogram==null?null:u.PiscinaHistogramHandler.createHistogramSummary(e.histogram)},get terminating(){return e.terminating},get destroyed(){return e.destroyed},[l.kWorkerData]:e}}}})),w=n((t=>{var n=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},r=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},i,a,o,s;Object.defineProperty(t,`__esModule`,{value:!0}),t.ArrayTaskQueue=t.FixedQueue=t.version=t.queueOptionsSymbol=t.valueSymbol=t.transferableSymbol=t.Piscina=t.workerData=t.isWorkerThread=t.move=void 0;let c=e(`node:worker_threads`),l=e(`node:events`),u=e(`node:path`),d=e(`node:util`),g=e(`node:perf_hooks`),_=e(`node:timers/promises`),x=f();Object.defineProperty(t,`version`,{enumerable:!0,get:function(){return x.version}});let S=p();Object.defineProperty(t,`queueOptionsSymbol`,{enumerable:!0,get:function(){return S.kQueueOptions}}),Object.defineProperty(t,`transferableSymbol`,{enumerable:!0,get:function(){return S.kTransferable}}),Object.defineProperty(t,`valueSymbol`,{enumerable:!0,get:function(){return S.kValue}});let w=v();Object.defineProperty(t,`ArrayTaskQueue`,{enumerable:!0,get:function(){return w.ArrayTaskQueue}}),Object.defineProperty(t,`FixedQueue`,{enumerable:!0,get:function(){return w.FixedQueue}});let T=C(),E=m(),D=b(),O=y(),k=h(),A=(0,k.getAvailableParallelism)(),j={filename:null,name:`default`,minThreads:Math.max(Math.floor(A/2),1),maxThreads:A*1.5,idleTimeout:0,maxQueue:1/0,concurrentTasksPerWorker:1,atomics:`sync`,taskQueue:new w.ArrayTaskQueue,niceIncrement:0,trackUnmanagedFds:!0,closeTimeout:3e4,recordTiming:!0,workerHistogram:!1},M={transferList:void 0,filename:null,signal:null,name:null},N={force:!1};var P=class{constructor(e){i.set(this,void 0),n(this,i,e,`f`)}get[(i=new WeakMap,S.kTransferable)](){return r(this,i,`f`)}get[S.kValue](){return r(this,i,`f`)}},F=class{constructor(e){a.set(this,void 0),n(this,a,e,`f`)}get[(a=new WeakMap,S.kTransferable)](){return r(this,a,`f`).buffer}get[S.kValue](){return r(this,a,`f`)}},I=class{constructor(e,t){this.skipQueue=[],this.completed=0,this.histogram=null,this.start=g.performance.now(),this.inProcessPendingMessages=!1,this.startingUp=!1,this.closingUp=!1,this.workerFailsDuringBootstrap=!1,this.destroying=!1,this.publicInterface=e,this.taskQueue=t.taskQueue??new w.FixedQueue;let n=t.filename?(0,k.maybeFileURLToPath)(t.filename):null;this.options={...j,...t,filename:n,maxQueue:0},this.options.recordTiming&&(this.histogram=new D.PiscinaHistogramHandler),t.maxThreads!==void 0&&this.options.minThreads>=t.maxThreads&&(this.options.minThreads=t.maxThreads),t.minThreads!==void 0&&this.options.maxThreads<=t.minThreads&&(this.options.maxThreads=t.minThreads),t.maxQueue===`auto`?this.options.maxQueue=this.options.maxThreads**2:this.options.maxQueue=t.maxQueue??j.maxQueue,this.balancer=this.options.loadBalancer??(0,T.LeastBusyBalancer)({maximumUsage:this.options.concurrentTasksPerWorker}),this.workers=new T.AsynchronouslyCreatedResourcePool(this.options.concurrentTasksPerWorker),this.workers.onTaskDone(this._onWorkerTaskDone.bind(this)),this.maxCapacity=this.options.maxThreads*this.options.concurrentTasksPerWorker,this.startingUp=!0,this._ensureMinimumWorkers(),this.startingUp=!1,this._needsDrain=!1}_ensureMinimumWorkers(){if(!(this.closingUp||this.destroying))for(;this.workers.size<this.options.minThreads;)this._addNewWorker()}_addNewWorker(){if(this.closingUp===!0)return;let{port1:e,port2:t}=new c.MessageChannel,n=new T.WorkerInfo({worker:{filename:(0,u.resolve)(__dirname,`worker.js`),env:this.options.env,argv:this.options.argv,execArgv:this.options.execArgv,resourceLimits:this.options.resourceLimits,workerData:this.options.workerData,trackUnmanagedFds:this.options.trackUnmanagedFds},port:e,enableHistogram:this.options.workerHistogram},i.bind(this)),r={filename:this.options.filename,name:this.options.name,port:t,sharedBuffer:n.sharedBuffer,atomics:this.options.atomics,niceIncrement:this.options.niceIncrement};n.onDestroy(()=>{this.publicInterface.emit(`workerDestroy`,n.interface)}),n.onWorkerMessage(s.bind(this)),n.onWorkerError(l.bind(this)),n.onWorkerExit(f.bind(this)),n.onPortClose(()=>{n.workerRef()}),this.startingUp===!0?(n.markAsReady(),queueMicrotask(()=>{this.publicInterface.emit(`workerCreate`,n.interface),this._onWorkerReady(n)})):n.onReady(()=>{this.publicInterface.emit(`workerCreate`,n.interface),this._onWorkerReady(n)}),n.init(r,[t]).workerUnref(),this.workers.add(n);function i(e){let{taskId:t,result:r}=e,i=n.popTask(t);if(this.workers.taskDone(n),i==null){let t=Error(`Unexpected message from Worker: ${(0,d.inspect)(e)}`);this.publicInterface.emit(`error`,t)}else i.done(e.error,r);this._processPendingMessages()}function a(){n.currentUsage()===0&&n.unref(),n.isReady()===!1&&n.markAsReady()}function o(e){this.publicInterface.emit(`message`,e)}function s(e){e instanceof Object&&k.READY in e?a():o.call(this,e)}function l(e){this._onError(n,e,!1)}function f(e){if(this.destroying===!1){let t=Error(`worker exited with code: ${e}`);this._onError(n,t,!0)}}}_onError(e,t,n){let r=[...e.taskInfos.values()];if(e.taskInfos.clear(),this._removeWorker(e),e.isReady()&&!this.workerFailsDuringBootstrap?this._ensureMinimumWorkers():this.workerFailsDuringBootstrap=!0,r.length>0)for(let e of r)e.done(t,null);else n||this.publicInterface.emit(`error`,t)}_processPendingMessages(){if(!(this.inProcessPendingMessages||this.options.atomics===`disabled`)){this.inProcessPendingMessages=!0;try{for(let e of this.workers)e.processPendingMessages()}finally{this.inProcessPendingMessages=!1}}}_removeWorker(e){e.destroy(),this.workers.delete(e)}_onWorkerReady(e){this._onWorkerAvailable(e)}_onWorkerTaskDone(e){this._onWorkerAvailable(e)}_onWorkerAvailable(e){let t=null;for(;this.taskQueue.size>0||this.skipQueue.length>0;){let e=this.skipQueue.shift()||this.taskQueue.shift();if(t??=[...this.workers].map(e=>e.interface),!this._distributeTask(e,t))if(this.workers.size<this.options.maxThreads){this._addNewWorker();continue}else break}this.options.idleTimeout!==1/0&&e.currentUsage()===0&&this.workers.size>this.options.minThreads&&e.setIdleTimeout(()=>{e.currentUsage()===0&&this.workers.size>this.options.minThreads&&this._removeWorker(e)},this.options.idleTimeout)}_distributeTask(e,t){var n;if(e.aborted)return!0;let r=this.balancer(e.interface,t);if(r!=null&&r[S.kWorkerData]!=null){let t=g.performance.now();return(n=this.histogram)==null||n.recordWaitTime(t-e.created),e.started=t,r[S.kWorkerData].postTask(e),queueMicrotask(()=>this._maybeDrain()),!0}return e.abortSignal==null?this.taskQueue.push(e):this.skipQueue.push(e),!1}runTask(e,t){let{filename:n,name:r}=t,{transferList:i=[]}=t;if(n??=this.options.filename,r??=this.options.name,typeof n!=`string`)return Promise.reject(O.Errors.FilenameNotProvided());n=(0,k.maybeFileURLToPath)(n);let a;if(this.closingUp||this.destroying){let e=new AbortController;e.abort(`queue is being terminated`),a=e.signal}else a=t.signal??null;let{promise:o,resolve:s,reject:c}=(0,k.promiseResolvers)(),l=new w.TaskInfo({task:e,transferList:i,filename:n,name:r,abortSignal:a,triggerAsyncId:this.publicInterface.asyncResource.asyncId()},(e,t)=>{var n;this.completed++,l.started&&((n=this.histogram)==null||n.recordRunTime(g.performance.now()-l.started)),e===null?s(t):c(e),queueMicrotask(this._maybeDrain.bind(this))});if(a!=null){if(a.aborted)return c(new E.AbortError(a.reason)),o;l.onAbort(()=>{c(new E.AbortError(a.reason)),l.workerInfo==null?this.taskQueue.remove(l):(this._removeWorker(l.workerInfo),this._ensureMinimumWorkers())}),l.setAbortListener(a)}if(this.taskQueue.size>0){let e=this.options.maxQueue+this.pendingCapacity();return this.taskQueue.size>=e?this.options.maxQueue===0?c(O.Errors.NoTaskQueueAvailable()):c(O.Errors.TaskQueueAtLimit()):this.taskQueue.push(l),queueMicrotask(this._maybeDrain.bind(this)),o}let u=[...this.workers.readyItems].map(e=>e.interface);return this._distributeTask(l,u)||(this.workers.size<this.options.maxThreads&&this._addNewWorker(),this.options.maxQueue<=0&&this.pendingCapacity()===0&&c(O.Errors.NoTaskQueueAvailable())),queueMicrotask(this._maybeDrain.bind(this)),o}pendingCapacity(){return this.workers.pendingItems.size*this.options.concurrentTasksPerWorker}_maybeDrain(){let{maxCapacity:e}=this,t=this.workers.getCurrentUsage();e===t?(this._needsDrain=!0,queueMicrotask(()=>this.publicInterface.emit(`needsDrain`))):e>t&&this._needsDrain&&(this._needsDrain=!1,queueMicrotask(()=>this.publicInterface.emit(`drain`)))}async destroy(){for(this.destroying=!0;this.skipQueue.length>0;)this.skipQueue.shift().done(Error(`Terminating worker thread`));for(;this.taskQueue.size>0;)this.taskQueue.shift().done(Error(`Terminating worker thread`));let e=[];for(;this.workers.size>0;){let[t]=this.workers;e.push((0,l.once)(t.worker,`exit`)),this._removeWorker(t)}await Promise.allSettled(e),this.destroying=!1}async close(e){if(this.closingUp=!0,e.force){let e=this.skipQueue.length;for(let t=0;t<e;t++){let e=this.skipQueue.shift();e.workerInfo===null?e.done(new E.AbortError(`pool is closed`)):this.skipQueue.push(e)}let t=this.taskQueue.size;for(let e=0;e<t;e++){let e=this.taskQueue.shift();e.workerInfo===null?e.done(new E.AbortError(`pool is closed`)):this.taskQueue.push(e)}}let t=()=>new Promise(e=>{let t=this.workers.size;if(t===0){e();return}let n=0,r=r=>{r.taskInfos.size===0&&n++,t===n&&e()};this.workers.onTaskDone(r);for(let e of this.workers)r(e),this.workers.onTaskDone(r)}),n=async e=>{throw await(0,_.setTimeout)(e,null,{ref:!1}),O.Errors.CloseTimeout()};try{await Promise.race([t(),n(this.options.closeTimeout)])}catch(e){this.publicInterface.emit(`error`,e)}finally{await this.destroy(),this.publicInterface.emit(`close`),this.closingUp=!1}}},L=class e extends l.EventEmitterAsyncResource{constructor(e={}){if(super({...e,name:`Piscina`}),o.set(this,void 0),s.set(this,null),typeof e.filename!=`string`&&e.filename!=null)throw TypeError(`options.filename must be a string or null`);if(typeof e.name!=`string`&&e.name!=null)throw TypeError(`options.name must be a string or null`);if(e.minThreads!==void 0&&(typeof e.minThreads!=`number`||e.minThreads<0))throw TypeError(`options.minThreads must be a non-negative integer`);if(e.maxThreads!==void 0&&(typeof e.maxThreads!=`number`||e.maxThreads<1))throw TypeError(`options.maxThreads must be a positive integer`);if(e.minThreads!==void 0&&e.maxThreads!==void 0&&e.minThreads>e.maxThreads)throw RangeError(`options.minThreads and options.maxThreads must not conflict`);if(e.idleTimeout!==void 0&&(typeof e.idleTimeout!=`number`||e.idleTimeout<0))throw TypeError(`options.idleTimeout must be a non-negative integer`);if(e.maxQueue!==void 0&&e.maxQueue!==`auto`&&(typeof e.maxQueue!=`number`||e.maxQueue<0))throw TypeError(`options.maxQueue must be a non-negative integer`);if(e.concurrentTasksPerWorker!==void 0&&(typeof e.concurrentTasksPerWorker!=`number`||e.concurrentTasksPerWorker<1))throw TypeError(`options.concurrentTasksPerWorker must be a positive integer`);if(e.atomics!=null&&(typeof e.atomics!=`string`||![`sync`,`async`,`disabled`].includes(e.atomics)))throw TypeError(`options.atomics should be a value of sync, sync or disabled.`);if(e.resourceLimits!==void 0&&(typeof e.resourceLimits!=`object`||e.resourceLimits===null))throw TypeError(`options.resourceLimits must be an object`);if(e.taskQueue!==void 0&&!(0,w.isTaskQueue)(e.taskQueue))throw TypeError(`options.taskQueue must be a TaskQueue object`);if(e.niceIncrement!==void 0&&(typeof e.niceIncrement!=`number`||e.niceIncrement<0&&process.platform!==`win32`))throw TypeError(`options.niceIncrement must be a non-negative integer on Unix systems`);if(e.trackUnmanagedFds!==void 0&&typeof e.trackUnmanagedFds!=`boolean`)throw TypeError(`options.trackUnmanagedFds must be a boolean value`);if(e.closeTimeout!==void 0&&(typeof e.closeTimeout!=`number`||e.closeTimeout<0))throw TypeError(`options.closeTimeout must be a non-negative integer`);if(e.loadBalancer!==void 0&&(typeof e.loadBalancer!=`function`||e.loadBalancer.length<1))throw TypeError(`options.loadBalancer must be a function with at least two args`);if(e.workerHistogram!==void 0&&typeof e.workerHistogram!=`boolean`)throw TypeError(`options.workerHistogram must be a boolean`);n(this,o,new I(this,e),`f`)}run(e,t=M){if(typeof t!=`object`||!t)return Promise.reject(TypeError(`options must be an object`));let{transferList:n,filename:i,name:a,signal:s}=t;return n!==void 0&&!Array.isArray(n)?Promise.reject(TypeError(`transferList argument must be an Array`)):i!=null&&typeof i!=`string`?Promise.reject(TypeError(`filename argument must be a string`)):a!=null&&typeof a!=`string`?Promise.reject(TypeError(`name argument must be a string`)):s!=null&&typeof s!=`object`?Promise.reject(TypeError(`signal argument must be an object`)):r(this,o,`f`).runTask(e,{transferList:n,filename:i,name:a,signal:s})}async close(e=N){if(typeof e!=`object`||!e)throw TypeError(`options must be an object`);let{force:t}=e;return t!==void 0&&typeof t!=`boolean`?Promise.reject(TypeError(`force argument must be a boolean`)):(t??=N.force,r(this,o,`f`).close({force:t}))}destroy(){return r(this,o,`f`).destroy()}[(o=new WeakMap,s=new WeakMap,Symbol.dispose)](){this.close()}[Symbol.asyncDispose](){return this.close()}get maxThreads(){return r(this,o,`f`).options.maxThreads}get minThreads(){return r(this,o,`f`).options.minThreads}get options(){return r(this,o,`f`).options}get threads(){let e=[];for(let t of r(this,o,`f`).workers)e.push(t.worker);return e}get queueSize(){let e=r(this,o,`f`);return Math.max(e.taskQueue.size-e.pendingCapacity(),0)}get completed(){return r(this,o,`f`).completed}get histogram(){if(r(this,s,`f`)==null){let e={get runTime(){return this.histogram?.runTimeSummary},get waitTime(){return this.histogram?.waitTimeSummary},resetRunTime(){var e;(e=this.histogram)==null||e.resetRunTime()},resetWaitTime(){var e;(e=this.histogram)==null||e.resetWaitTime()}};Object.defineProperty(e,`histogram`,{value:r(this,o,`f`).histogram,writable:!1,enumerable:!1,configurable:!1}),n(this,s,e,`f`)}return r(this,s,`f`)}get utilization(){if(r(this,o,`f`).histogram==null)return 0;let e=r(this,o,`f`).histogram.runTimeCount;if(e===0)return 0;let t=this.duration*r(this,o,`f`).options.maxThreads;return r(this,o,`f`).histogram.runTimeSummary.mean/1e3*e/t}get duration(){return g.performance.now()-r(this,o,`f`).start}get needsDrain(){return r(this,o,`f`)._needsDrain}static get isWorkerThread(){return k.commonState.isWorkerThread}static get workerData(){return k.commonState.workerData}static get version(){return x.version}static get Piscina(){return e}static get FixedQueue(){return w.FixedQueue}static get ArrayTaskQueue(){return w.ArrayTaskQueue}static move(e){return typeof e==`object`&&e&&typeof e!=`function`&&((0,k.isTransferable)(e)||(e=d.types.isArrayBufferView(e)?new F(e):new P(e)),(0,k.markMovable)(e)),e}static get transferableSymbol(){return S.kTransferable}static get valueSymbol(){return S.kValue}static get queueOptionsSymbol(){return S.kQueueOptions}};t.default=L,t.Piscina=L,t.move=L.move,t.isWorkerThread=L.isWorkerThread,t.workerData=L.workerData})),T=t(n(((e,t)=>{t.exports=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(w()).default}))(),1),E=T.default;T.default.ArrayTaskQueue,T.default.FixedQueue,T.default.Piscina,T.default.isWorkerThread,T.default.move,T.default.queueOptionsSymbol,T.default.transferableSymbol,T.default.valueSymbol,T.default.version,T.default.workerData;var D=class{pool;constructor(e){this.pool=new E({filename:e.workerEntry,maxThreads:e.maxConcurrency??4,idleTimeout:e.idleTimeoutMs??3e4})}async run(e,t){return this.pool.run(e,{signal:t})}onMessage(e){return this.pool.on(`message`,e),()=>this.pool.off(`message`,e)}async dispose(){await this.pool.destroy()}},O=class{options;manifest;pool;constructor(e){this.options=e,this.manifest=e.manifest}async run(e,t,n){return this.pool??=new D(this.options),this.pool.run({config:e,manifest:n??this.manifest},t)}runWithReadiness(e,t,n){this.pool??=new D(this.options);let r=this.pool,a,o=!1,s,c=new Promise((t,n)=>{s=n,a=r.onMessage(n=>{i(n)&&(n.executionId!==e.executionId||n.cancelSubject!==e.cancelSubject||(o=!0,a?.(),t(n)))})}),l=r.run({config:e,manifest:n??this.manifest},t);return l.then(()=>{o||(o=!0,a?.(),s(Error(`Workflow worker completed before ready signal: ${e.executionId}`)))},e=>{o||(o=!0,a?.(),s(e instanceof Error?e:Error(String(e))))}),{result:l,ready:c}}async dispose(){await this.pool?.dispose()}};function k(e){return e.mode===`source`?s(e.moduleDir,`workflow-worker`,`worker-entry.ts`):s(e.moduleDir,`workflow-worker`,`worker-entry.mjs`)}function A(e,t){let n=t.executionHints?.requirements?.capabilities??[];if(n.length===0)return e;let r=e?.customCapabilities??[];return{...e,customCapabilities:[...new Set([...r,...n])]}}var j=class{options;constructor(e){this.options=e}run(e,t,n,r){let i=n??this.options.manifest,a=A(this.options.requirements,e),o=r?.dispatchMetadata;return this.options.dispatch({config:e,...i!==void 0&&{manifest:i},...a!==void 0&&{requirements:a},...o!==void 0&&{metadata:o}},t)}},M=class{#e;constructor(e){this.#e=e.bus}async run(e,t,n){let i=u.parse(e),o=await r(i);return d({config:await a(i,o,this.#e,t),loaded:o,bus:this.#e,signal:t})}};function N(){return{packages:[]}}function P(e){let t=o(e.runtimeModuleDir)===`src`?`source`:`dist`,n=F({moduleDir:e.runtimeModuleDir,defaultWorkerEntryMode:t,runner:e.workflowRunner,bus:e.bus});return{...n!==void 0&&{workflowRunner:n},executorConfig:{busUrl:e.busUrl,busAuth:{kind:`none`},platformDefaults:e.platformDefaults,makaioHome:e.makaioHome}}}function F(e){let{runner:t}=e;if(t)switch(t.mode){case void 0:case`in-process`:if(e.bus===void 0)throw Error(`InProcessWorkflowRunner requires a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'in-process'.`);return new M({bus:e.bus});case`worker-node`:{let n=e.bus,r=t.dispatch??(n===void 0?void 0:(e,t)=>n.request(l.dispatch,{config:e.config,manifest:e.manifest,requirements:e.requirements,metadata:e.metadata},{signal:t}));if(r===void 0)throw Error(`WorkerNodeRunner requires either a dispatch function or a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'worker-node'.`);return new j({dispatch:r,...t.manifest!==void 0&&{manifest:t.manifest},...t.requirements!==void 0&&{requirements:t.requirements}})}case`piscina`:return new O({workerEntry:t.workerEntry??k({moduleDir:e.moduleDir,mode:t.workerEntryMode??e.defaultWorkerEntryMode}),manifest:t.manifest??N(),maxConcurrency:t.maxConcurrency,idleTimeoutMs:t.idleTimeoutMs})}}function I(e){return e instanceof Error?e:Error(String(e??`WorkerNode wait aborted`))}function L(e){return typeof e.runWithReadiness==`function`}const R={persistentStorage:!0,customCapabilities:[`workflow.local-runtime`,`workflow.thin-runner`],suspensionStrategy:`wait-in-process`};var z=class{options;environment=`piscina`;baseCapabilities;constructor(e){this.options=e,this.baseCapabilities=c.parse({...R,...e.baseCapabilities,suspensionStrategy:e.baseCapabilities?.suspensionStrategy??R.suspensionStrategy})}get id(){return this.options.id}get displayName(){return this.options.displayName}async provision(e){let t=new AbortController,n=L(this.options.runner)?this.options.runner.runWithReadiness(e.workerConfig,t.signal,e.workerManifest):{result:this.options.runner.run(e.workerConfig,t.signal,e.workerManifest),ready:void 0},r=n.result,i=n.ready?.then(e=>({adapters:e.adapters}));return i?.catch(()=>void 0),r.catch(()=>void 0),{nodeId:e.nodeId,...i!==void 0&&{ready:i},waitForResult:async e=>{if(e.aborted)return t.abort(e.reason),Promise.reject(I(e.reason));let n,i=new Promise((e,t)=>{n=t}),a=()=>{t.abort(e.reason),n(I(e.reason))};e.addEventListener(`abort`,a,{once:!0});try{return await Promise.race([r,i])}finally{e.removeEventListener(`abort`,a)}},cancel:e=>(t.abort(e??`WorkerNode cancelled`),Promise.resolve()),terminate:()=>(t.abort(`WorkerNode terminated`),Promise.resolve())}}};export{j as a,M as i,F as n,k as o,P as r,O as s,z as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makaio/framework",
3
- "version": "1.0.0-dev-1781081952714",
3
+ "version": "1.0.0-dev-1781260968078",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/makaio-ai/makaio-framework.git",
@@ -17,6 +17,37 @@
17
17
  "scripts": {
18
18
  "build": "bun build.ts"
19
19
  },
20
+ "dependencies": {
21
+ "@hono/node-server": "^1.14.1",
22
+ "@libsql/client": "^0.17.3",
23
+ "ajv": "^8.18.0",
24
+ "ajv-formats": "^3.0.1",
25
+ "drizzle-orm": "^0.45.2",
26
+ "glob": "13.0.6",
27
+ "hono": "^4.12.23",
28
+ "ws": "^8.21.0",
29
+ "zod": "^4.1.13"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^18.0.0 || ^19.0.0",
33
+ "react-dom": "^18.0.0 || ^19.0.0",
34
+ "react-resizable": "3.1.3",
35
+ "vitest": "^4.1.0"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "react": {
39
+ "optional": true
40
+ },
41
+ "react-dom": {
42
+ "optional": true
43
+ },
44
+ "react-resizable": {
45
+ "optional": true
46
+ },
47
+ "vitest": {
48
+ "optional": true
49
+ }
50
+ },
20
51
  "exports": {
21
52
  "./package.json": "./package.json",
22
53
  "./bus": {
@@ -307,6 +338,14 @@
307
338
  "types": "./dist/storage/drizzle/client.d.mts",
308
339
  "default": "./dist/storage/drizzle/client.mjs"
309
340
  },
341
+ "./storage/drizzle/columns/sqlite": {
342
+ "types": "./dist/storage/drizzle/columns/sqlite.d.mts",
343
+ "default": "./dist/storage/drizzle/columns/sqlite.mjs"
344
+ },
345
+ "./storage/drizzle/columns/postgres": {
346
+ "types": "./dist/storage/drizzle/columns/postgres.d.mts",
347
+ "default": "./dist/storage/drizzle/columns/postgres.mjs"
348
+ },
310
349
  "./storage/handlers": {
311
350
  "types": "./dist/storage/handlers/index.d.mts",
312
351
  "default": "./dist/storage/handlers/index.mjs"
@@ -1,8 +0,0 @@
1
- import{t as e}from"./chunk-DTipWd-i.mjs";import{n as t,r as n,t as r}from"./fast-uri-BF2Xuiop.mjs";var i=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),a=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=i();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var a=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=a;var o=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=o;let s=(0,t._)`\n`;e.ValueScope=class extends a{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?s:t.nil}}get(){return this._scope}name(e){return new o(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),o=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=i(),n=a();var r=i();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var o=a();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var s=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},c=class extends s{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=j(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},l=class extends s{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=j(this.rhs,e,n),this}get names(){return A(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},u=class extends l{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},d=class extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},f=class extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},p=class extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},m=class extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=j(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},h=class extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(M(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>k(e,t.names),{})}},g=class extends h{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},_=class extends h{},v=class extends g{};v.kind=`else`;var y=class e extends g{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new v(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(N(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=j(this.condition,e,t),this}get names(){let e=super.names;return A(e,this.condition),this.else&&k(e,this.else.names),e}};y.kind=`if`;var b=class extends g{};b.kind=`for`;var x=class extends b{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=j(this.iteration,e,t),this}get names(){return k(super.names,this.iteration.names)}},S=class extends b{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return A(A(super.names,this.from),this.to)}},C=class extends b{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=j(this.iterable,e,t),this}get names(){return k(super.names,this.iterable.names)}},w=class extends g{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};w.kind=`func`;var T=class extends h{render(e){return`return `+super.render(e)}};T.kind=`return`;var E=class extends g{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&k(e,this.catch.names),this.finally&&k(e,this.finally.names),e}},D=class extends g{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};D.kind=`catch`;var O=class extends g{render(e){return`finally`+super.render(e)}};O.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
2
- `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new _]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new c(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new l(e,t,n))}add(t,n){return this._leafNode(new u(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new m(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new y(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new y(e))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(y,v)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new x(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new S(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new C(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new C(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(b)}label(e){return this._leafNode(new d(e))}break(e){return this._leafNode(new f(e))}return(e){let t=new T;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(T)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new E;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new D(e),t(e)}return n&&(this._currNode=r.finally=new O,this.code(n)),this._endBlockNode(D,O)}throw(e){return this._leafNode(new p(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new w(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(w)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof y))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function k(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function A(e,n){return n instanceof t._CodeOrName?k(e,n.names):e}function j(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function M(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function N(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${z(e)}`}e.not=N;let P=R(e.operators.AND);function F(...e){return e.reduce(P)}e.and=F;let I=R(e.operators.OR);function L(...e){return e.reduce(I)}e.or=L;function R(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${z(n)} ${e} ${z(r)}`}function z(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),s=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=o(),n=i();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function a(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(s(e,t),!c(t,e.self.RULES.all))}e.alwaysValidSchema=a;function s(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||C(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=s;function c(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=c;function l(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=l;function u({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=u;function d(e){return m(decodeURIComponent(e))}e.unescapeFragment=d;function f(e){return encodeURIComponent(p(e))}e.escapeFragment=f;function p(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=p;function m(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=m;function h(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=h;function g({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:g({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),v(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:_}),items:g({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function _(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&v(e,r,n),r}e.evaluatedPropsToName=_;function v(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=v;let y={};function b(e,t){return e.scopeValue(`func`,{ref:t,code:y[t.code]||(y[t.code]=new n._Code(t.code))})}e.useFunc=b;var x;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(x||(e.Type=x={}));function S(e,n,r){if(e instanceof t.Name){let i=n===x.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+p(e)}e.getErrorPath=S;function C(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=C})),c=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),l=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=o(),n=s(),r=c();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:c,allErrors:l}=o,u=m(n,r,i);a??(c||l)?d(s,u):f(o,(0,t._)`[${u}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:c}=a;d(o,m(t,n,i)),s||c||f(a,r.default.vErrors)}e.reportExtraError=a;function l(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=l;function u({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=u;function d(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function f(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let p={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function m(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:h(e,n,r)}function h(e,t,n={}){let{gen:r,it:i}=e,a=[g(i,n),_(e,n)];return v(e,t,a),r.object(...a)}function g({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function _({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[p.schemaPath,o]}function v(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:u,propertyName:d,topSchemaRef:f,schemaPath:m}=l;a.push([p.keyword,o],[p.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),u.messages&&a.push([p.message,typeof i==`function`?i(e):i]),u.verbose&&a.push([p.schema,c],[p.parentSchema,(0,t._)`${f}${m}`],[r.default.data,s]),d&&a.push([p.propertyName,d])}})),u=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=l(),n=o(),r=c(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?u(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function s(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),u(e)):n.var(t,!0)}e.boolOrEmptySchema=s;function u(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),d=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),f=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),p=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=d(),n=f(),r=l(),i=o(),a=s();var c;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(c||(e.DataType=c={}));function u(e){let t=p(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=u;function p(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=p;function m(e,t){let{gen:r,data:i,opts:a}=e,o=g(t,a.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(s){let n=b(t,i,a.strictNumbers,c.Wrong);r.if(n,()=>{o.length?_(e,t,o):S(e)})}return s}e.coerceAndCheckDataType=m;let h=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function g(e,t){return t?e.filter(e=>h.has(e)||t===`array`&&e===`array`):[]}function _(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(b(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(h.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),S(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),v(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
3
- || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
4
- || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
5
- || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function v({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function y(e,t,n,r=c.Correct){let a=r===c.Correct?i.operators.EQ:i.operators.NEQ,o;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:o=(0,i._)`Array.isArray(${t})`;break;case`object`:o=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:o=s((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:o=s();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===c.Correct?o:(0,i.not)(o);function s(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=y;function b(e,t,n,r){if(e.length===1)return y(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,y(e,t,n,r));return o}e.checkDataTypes=b;let x={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function S(e){let t=C(e);(0,r.reportError)(t,x)}e.reportTypeError=S;function C(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),m=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=o(),n=s();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),h=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=o(),n=s(),r=c(),i=s();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(m(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function l({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(m(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=l;function u(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=u;function d(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=d;function f(e,n,r){return(0,t._)`${d(e)}.call(${n}, ${r})`}e.isOwnProperty=f;function p(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${f(e,n,r)}`:a}e.propertyInData=p;function m(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(f(e,n,r))):a}e.noPropertyInData=m;function h(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=h;function g(e,t){return h(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=g;function _({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=_;let v=(0,t._)`new RegExp`;function y({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?v:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=y;function b(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=b;function x(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=x})),g=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=o(),n=c(),r=h(),i=l();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=p(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let u=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}e.macroKeywordCode=a;function s(e,i){let{gen:a,keyword:o,schema:s,parentSchema:c,$data:l,it:m}=e;f(m,i);let h=p(a,o,!l&&i.compile?i.compile.call(m.self,s,c,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&u(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&u(e),x(()=>d(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!l||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=s;function u(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function d(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function f({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function p(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function m(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=m;function g({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=g})),_=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=o(),n=s();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),v=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let r=s(),i=n(),a=t(),o=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function c(e,t=!0){return typeof e==`boolean`?!0:t===!0?!u(e):t?d(e)<=t:!1}e.inlineRef=c;let l=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function u(e){for(let t in e){if(l.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(u)||typeof n==`object`&&u(n))return!0}return!1}function d(e){let t=0;for(let n in e)if(n===`$ref`||(t++,!o.has(n)&&(typeof e[n]==`object`&&(0,r.eachItem)(e[n],e=>t+=d(e)),t===1/0)))return 1/0;return t}function f(e,t=``,n){return n!==!1&&(t=h(t)),p(e,e.parse(t))}e.getFullPath=f;function p(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=p;let m=/#\/?$/;function h(e){return e?e.replace(m,``):``}e.normalizeId=h;function g(e,t,n){return n=h(n),e.resolve(t,n)}e.resolveUrl=g;let _=/^[a-z_][-a-z0-9._]*$/i;function v(e,t){if(typeof e==`boolean`)return{};let{schemaId:n,uriResolver:r}=this.opts,o=h(e[n]||t),s={"":o},c=f(r,o,!1),l={},u=new Set;return a(e,{allKeys:!0},(e,t,r,i)=>{if(i===void 0)return;let a=c+t,o=s[i];typeof e[n]==`string`&&(o=f.call(this,e[n])),m.call(this,e.$anchor),m.call(this,e.$dynamicAnchor),s[t]=o;function f(t){let n=this.opts.uriResolver.resolve;if(t=h(o?n(o,t):t),u.has(t))throw p(t);u.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?d(e,r.schema,t):t!==h(a)&&(t[0]===`#`?(d(e,l[t],t),l[t]=e):this.refs[t]=a),t}function m(e){if(typeof e==`string`){if(!_.test(e))throw Error(`invalid anchor "${e}"`);f.call(this,`#${e}`)}}}),l;function d(e,t,n){if(t!==void 0&&!i(e,t))throw p(n)}function p(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=v})),y=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=u(),n=p(),r=f(),i=p(),a=m(),d=g(),h=_(),y=o(),b=c(),x=v(),S=s(),C=l();function w(e){if(N(e)&&(F(e),M(e))){O(e);return}T(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=w;function T({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,y._)`${b.default.data}, ${b.default.valCxt}`,r.$async,()=>{e.code((0,y._)`"use strict"; ${A(n,i)}`),D(e,i),e.code(a)}):e.func(t,(0,y._)`${b.default.data}, ${E(i)}`,r.$async,()=>e.code(A(n,i)).code(a))}function E(e){return(0,y._)`{${b.default.instancePath}="", ${b.default.parentData}, ${b.default.parentDataProperty}, ${b.default.rootData}=${b.default.data}${e.dynamicRef?(0,y._)`, ${b.default.dynamicAnchors}={}`:y.nil}}={}`}function D(e,t){e.if(b.default.valCxt,()=>{e.var(b.default.instancePath,(0,y._)`${b.default.valCxt}.${b.default.instancePath}`),e.var(b.default.parentData,(0,y._)`${b.default.valCxt}.${b.default.parentData}`),e.var(b.default.parentDataProperty,(0,y._)`${b.default.valCxt}.${b.default.parentDataProperty}`),e.var(b.default.rootData,(0,y._)`${b.default.valCxt}.${b.default.rootData}`),t.dynamicRef&&e.var(b.default.dynamicAnchors,(0,y._)`${b.default.valCxt}.${b.default.dynamicAnchors}`)},()=>{e.var(b.default.instancePath,(0,y._)`""`),e.var(b.default.parentData,(0,y._)`undefined`),e.var(b.default.parentDataProperty,(0,y._)`undefined`),e.var(b.default.rootData,b.default.data),t.dynamicRef&&e.var(b.default.dynamicAnchors,(0,y._)`{}`)})}function O(e){let{schema:t,opts:n,gen:r}=e;T(e,()=>{n.$comment&&t.$comment&&V(e),R(e),r.let(b.default.vErrors,null),r.let(b.default.errors,0),n.unevaluated&&k(e),I(e),H(e)})}function k(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,y._)`${n}.evaluated`),t.if((0,y._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,y._)`${e.evaluated}.props`,(0,y._)`undefined`)),t.if((0,y._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,y._)`${e.evaluated}.items`,(0,y._)`undefined`))}function A(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,y._)`/*# sourceURL=${n} */`:y.nil}function j(e,n){if(N(e)&&(F(e),M(e))){P(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function M({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function N(e){return typeof e.schema!=`boolean`}function P(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&V(e),z(e),B(e);let a=r.const(`_errs`,b.default.errors);I(e,a),r.var(t,(0,y._)`${a} === ${b.default.errors}`)}function F(e){(0,S.checkUnknownRules)(e),L(e)}function I(e,t){if(e.opts.jtd)return W(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);W(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function L(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,S.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function R(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,S.checkStrictMode)(e,`default is ignored in the schema root`)}function z(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,x.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function B(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function V({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,y._)`${b.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,y.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,y._)`${b.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function H(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,y._)`${b.default.errors} === 0`,()=>t.return(b.default.data),()=>t.throw((0,y._)`new ${i}(${b.default.vErrors})`)):(t.assign((0,y._)`${r}.errors`,b.default.vErrors),a.unevaluated&&U(e),t.return((0,y._)`${b.default.errors} === 0`))}function U({gen:e,evaluated:t,props:n,items:r}){n instanceof y.Name&&e.assign((0,y._)`${t}.props`,n),r instanceof y.Name&&e.assign((0,y._)`${t}.items`,r)}function W(e,t,n,a){let{gen:o,schema:s,data:c,allErrors:l,opts:u,self:d}=e,{RULES:f}=d;if(s.$ref&&(u.ignoreKeywordsWithRef||!(0,S.schemaHasRulesButRef)(s,f))){o.block(()=>Z(e,`$ref`,f.all.$ref.definition));return}u.jtd||ee(e,t),o.block(()=>{for(let e of f.rules)p(e);p(f.post)});function p(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,c,u.strictNumbers)),G(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):G(e,d),l||o.if((0,y._)`${b.default.errors} === ${a||0}`))}}function G(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&Z(e,n.keyword,n.definition,t.type)})}function ee(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(K(e,t),e.opts.allowUnionTypes||te(e,t),q(e,e.dataTypes))}function K(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{J(e.dataTypes,t)||Y(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),re(e,t)}}function te(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&Y(e,`use allowUnionTypes to allow union type keyword`)}function q(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>ne(t,e))&&Y(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ne(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function J(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function re(e,t){let n=[];for(let r of e.dataTypes)J(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function Y(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,S.checkStrictMode)(e,t,e.opts.strictTypes)}var X=class{constructor(e,t,n){if((0,d.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,S.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,Q(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,d.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,b.default.errors))}result(e,t,n){this.failResult((0,y.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,y.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,y._)`${t} !== undefined && (${(0,y.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?C.reportExtraError:C.reportError)(this,this.def.error,t)}$dataError(){(0,C.reportError)(this,this.def.$dataError||C.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,C.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=y.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=y.nil,t=y.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,y.or)((0,y._)`${r} === undefined`,t)),e!==y.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==y.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,y.or)(o(),s());function o(){if(n.length){if(!(t instanceof y.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,y._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return y.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,y._)`!${n}(${t})`}return y.nil}}subschema(e,t){let n=(0,h.getSubschema)(this.it,e);(0,h.extendSubschemaData)(n,this.it,e),(0,h.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return j(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=S.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=S.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,y.Name)),!0}};e.KeywordCxt=X;function Z(e,t,n,r){let i=new X(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,d.funcKeywordCode)(i,n):`macro`in n?(0,d.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,d.funcKeywordCode)(i,n)}let ie=/^\/(?:[^~]|~0|~1)*$/,ae=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Q(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return b.default.rootData;if(e[0]===`/`){if(!ie.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=b.default.rootData}else{let o=ae.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(c(`property/index`,s));return r[t-s]}if(s>t)throw Error(c(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,y._)`${a}${(0,y.getProperty)((0,S.unescapeJsonPointer)(e))}`,o=(0,y._)`${o} && ${a}`);return o;function c(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=Q})),b=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),x=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=v();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),S=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=o(),n=b(),r=c(),i=v(),a=s(),l=y();var u=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=u;function d(e){let a=m.call(this,e);if(a)return a;let o=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:s,lines:c}=this.opts.code,{ownProperties:u}=this.opts,d=new t.CodeGen(this.scope,{es5:s,lines:c,ownProperties:u}),f;e.$async&&(f=d.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let p=d.scopeName(`validate`);e.validateName=p;let h={gen:d,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:d.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:p,ValidationError:f,schema:e.schema,schemaEnv:e,rootId:o,baseId:e.baseId||o,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,l.validateFunctionCode)(h),d.optimize(this.opts.code.optimize);let n=d.toString();g=`${d.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(p,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:p,validateCode:n,scopeValues:d._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=d;function f(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=g.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new u({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=p.call(this,a)}e.resolveRef=f;function p(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:d.call(this,e)}function m(e){for(let t of this._compilations)if(h(t,e))return t}e.getCompilingSchema=m;function h(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function g(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||_.call(this,e,t)}function _(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return S.call(this,n,e);let o=(0,i.normalizeId)(r),s=this.refs[o]||this.schemas[o];if(typeof s==`string`){let t=_.call(this,e,s);return typeof t?.schema==`object`?S.call(this,n,t):void 0}if(typeof s?.schema==`object`){if(s.validate||d.call(this,s),o===(0,i.normalizeId)(t)){let{schema:t}=s,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new u({schema:t,schemaId:n,root:e,baseId:a})}return S.call(this,n,s)}}e.resolveSchema=_;let x=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function S(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!x.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=_.call(this,r,e)}let{schemaId:s}=this.opts;if(o||=new u({schema:n,schemaId:s,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),C=e(((e,t)=>{t.exports={$id:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,description:`Meta-schema for $data reference (JSON AnySchema extension proposal)`,type:`object`,required:[`$data`],properties:{$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},additionalProperties:!1}})),w=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),T=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=y();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=o();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=b(),i=x(),a=d(),c=S(),l=o(),u=v(),f=p(),m=s(),h=C(),g=w(),_=(e,t)=>new RegExp(e,t);_.code=`new RegExp`;let T=[`removeAdditional`,`useDefaults`,`coerceTypes`],E=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),D={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},O={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function k(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??_,a=e.uriResolver??g.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var A=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...k(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new l.ValueScope({scope:{},prefixes:E,es5:t,lines:n}),this.logger=R(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),j.call(this,D,e,`NOT SUPPORTED`),j.call(this,O,e,`DEPRECATED`,`warn`),this._metaOpts=I.call(this),e.formats&&P.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&F.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),N.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=h;n===`id`&&(r={...h},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,u.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=M.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new c.SchemaEnv({schema:{},schemaId:n});if(t=c.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=M.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,u.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(B.call(this,n,t),!t)return(0,m.eachItem)(n,e=>V.call(this,e)),this;U.call(this,t);let r={...t,type:(0,f.getJSONTypes)(t.type),schemaType:(0,f.getJSONTypes)(t.schemaType)};return(0,m.eachItem)(n,r.type.length===0?e=>V.call(this,e,r):e=>r.type.forEach(t=>V.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=G(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:o}=this.opts;if(typeof e==`object`)a=e[o];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let s=this._cache.get(e);if(s!==void 0)return s;n=(0,u.normalizeId)(a||n);let l=u.getSchemaRefs.call(this,e,n);return s=new c.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:n,localRefs:l}),this._cache.set(s.schema,s),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=s),r&&this.validateSchema(e,!0),s}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):c.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{c.compileSchema.call(this,e)}finally{this.opts=t}}};A.ValidationError=r.default,A.MissingRefError=i.default,e.default=A;function j(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function M(e){return e=(0,u.normalizeId)(e),this.schemas[e]||this.refs[e]}function N(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function P(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function F(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function I(){let e={...this.opts};for(let t of T)delete e[t];return e}let L={log(){},warn(){},error(){}};function R(e){if(e===!1)return L;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let z=/^[a-z_$][a-z0-9_$:-]*$/i;function B(e,t){let{RULES:n}=this;if((0,m.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!z.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function V(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,f.getJSONTypes)(t.type),schemaType:(0,f.getJSONTypes)(t.schemaType)}};t.before?H.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function H(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function U(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=G(t)),e.validateSchema=this.compile(t,!0))}let W={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function G(e){return{anyOf:[e,W]}}})),E=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),D=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=x(),n=h(),r=o(),i=c(),a=S(),l=s(),u={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:c,validateName:l,opts:u,self:p}=o,{root:m}=c;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(c===m)return f(e,l,c,c.$async);let t=n.scopeValue(`root`,{ref:m});return f(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){f(e,d(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,u.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function d(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=d;function f(e,t,a,o){let{gen:s,it:c}=e,{allErrors:u,schemaEnv:d,opts:f}=c,p=f.passContext?i.default.this:r.nil;o?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=s.let(`valid`);s.try(()=>{s.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||s.assign(i,!0)},e=>{s.if((0,r._)`!(${e} instanceof ${c.ValidationError})`,()=>s.throw(e)),g(e),u||s.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;s.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),s.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!c.opts.unevaluated)return;let t=a?.validate?.evaluated;if(c.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(c.props=l.mergeEvaluated.props(s,t.props,c.props));else{let t=s.var(`props`,(0,r._)`${e}.evaluated.props`);c.props=l.mergeEvaluated.props(s,t,c.props,r.Name)}if(c.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(c.items=l.mergeEvaluated.items(s,t.items,c.items));else{let t=s.var(`items`,(0,r._)`${e}.evaluated.items`);c.items=l.mergeEvaluated.items(s,t,c.items,r.Name)}}}e.callRef=f,e.default=u})),O=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=E(),n=D();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),k=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),A=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),j=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),M=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s(),r=j();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),N=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(),n=o();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,n.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,n._)`{pattern: ${e}}`},code(e){let{data:r,$data:i,schema:a,schemaCode:o,it:s}=e,c=s.opts.unicodeRegExp?`u`:``,l=i?(0,n._)`(new RegExp(${o}, ${c}))`:(0,t.usePattern)(e,a);e.fail$data((0,n._)`!${l}.test(${r})`)}}})),P=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),F=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(),n=o(),r=s();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),I=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),L=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=n();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),R=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=p(),n=o(),r=s(),i=L();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),z=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s(),r=L();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),B=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s(),r=L();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),V=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=k(),n=A(),r=M(),i=N(),a=P(),o=F(),s=I(),c=R(),l=z(),u=B();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),H=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=o(),n=s(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),U=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=o(),n=s(),r=h(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),W=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=U();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),G=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s(),r=h(),i=H();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),ee=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),K=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=o(),n=s(),r=h();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
6
- missingProperty: ${i},
7
- depsCount: ${n},
8
- deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);c(e,t),l(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function c(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=c;function l(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=l,e.default=i})),te=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),q=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(),n=o(),r=c(),i=s();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),ne=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=y(),n=h(),r=s(),i=q();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),J=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(),n=o(),r=s(),i=s();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),re=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=s();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Y=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:h().validateUnion,error:{message:`must match a schema in anyOf`}}})),X=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),Z=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=s();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),ie=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=s(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),ae=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=s();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),Q=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=H(),n=W(),r=U(),i=G(),a=ee(),o=K(),s=te(),c=q(),l=ne(),u=J(),d=re(),f=Y(),p=X(),m=Z(),h=ie(),g=ae();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),oe=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),$=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[oe().default]})),se=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),ce=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=O(),n=V(),r=Q(),i=$(),a=se();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),le=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),ue=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=o(),n=le(),r=S(),i=x(),a=s();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),de=e(((e,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),fe=e(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=T(),r=ce(),i=ue(),a=de(),s=[`/properties`],c=`http://json-schema.org/draft-07/schema`;var l=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,s):a;this.addMetaSchema(e,c,!1),this.refs[`http://json-schema.org/schema`]=c}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(c)?c:void 0)}};e.Ajv=l,t.exports=e=l,t.exports.Ajv=l,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=l;var u=y();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return u.KeywordCxt}});var d=o();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return d._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return d.CodeGen}});var f=b();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return f.default}});var p=x();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return p.default}})}));export{s as _,$ as a,V as c,T as d,S as f,c as g,y as h,se as i,O as l,b as m,ue as n,Q as o,x as p,ce as r,K as s,fe as t,D as u,o as v};
@@ -1 +0,0 @@
1
- import{and as e,eq as t,getTableColumns as n,inArray as r,sql as i}from"drizzle-orm";import{didAffectRows as a}from"@makaio/framework/storage/drizzle";function o(e,t){return{[e]:t}}function s(e,t,r){let i=n(e);if(!r)return i[t];let a=r(e);if(a.length===0)throw Error(`createDrizzleCrudHandlers: conflictTarget returned an empty array. Provide at least one column for the conflict target.`);return a}function c(e,r,i){let{table:a,idField:s,singularKey:c,mapper:l,getSubject:u}=i;return e.on(u,async e=>{let{id:i}=e.payload,u=n(a)[s],[d]=await r.select().from(a).where(t(u,i)).limit(1);e.setResult(o(c,d?l(d):null))})}function l(e,r,a){let{table:o,idField:s,singularKey:c,mapper:l,toDbValues:u,setSubject:d,resolvedConflictTarget:f,lifecycle:p}=a;return e.on(d,async a=>{let d=a.payload[c],m=d[s],h=Date.now(),g=n(o),_=u(d),v={..._,[s]:m,createdAt:h,updatedAt:h};if(!p){await r.insert(o).values(v).onConflictDoUpdate({target:f,set:{..._,[s]:m,updatedAt:h,createdAt:i`COALESCE(${g.createdAt}, excluded.created_at)`}}),a.setResult({id:m});return}let y=await r.insert(o).values(v).onConflictDoNothing({target:f}).returning();if(y.length>0){await e.emit(p.created,l(y[0])),a.setResult({id:m});return}let[b]=await r.update(o).set({..._,updatedAt:h}).where(t(g[s],m)).returning();b&&await e.emit(p.updated,l(b)),a.setResult({id:m})})}function u(e,r,i){let{table:o,idField:s,deleteSubject:c}=i;return e.on(c,async e=>{let{id:i}=e.payload,c=n(o)[s],l=await r.delete(o).where(t(c,i));e.setResult({deleted:a(l)})})}function d(e,r,i){let{table:a,idField:o,singularKey:s,getSubject:c,deleteSubject:l,lifecycle:u}=i;return e.on(l,async i=>{let{id:l}=i.payload,d=n(a)[o],[f]=await r.select({id:d}).from(a).where(t(d,l)).limit(1);await i.next(),f&&((await e.request(c,{id:l}))[s]||await e.emit(u.deleted,{id:l}))})}function f(e){if(e.conflictTarget&&e.lifecycle)throw Error(`createDrizzleCrudHandlers: conflictTarget is not yet compatible with lifecycle events. The lifecycle path uses a PK-based UPDATE fallback that cannot resolve rows by natural key.`);let{table:t,subjects:n,idField:r,singularKey:i,mapper:a,toDbValues:o,conflictTarget:f,lifecycle:p}=e,m=s(t,r,f);return(e,s)=>{let f=[];return f.push(c(e,s,{table:t,idField:r,singularKey:i,mapper:a,getSubject:n.get})),f.push(l(e,s,{table:t,idField:r,singularKey:i,mapper:a,toDbValues:o,setSubject:n.set,resolvedConflictTarget:m,lifecycle:p})),p&&f.push(d(e,s,{table:t,idField:r,singularKey:i,getSubject:n.get,deleteSubject:n.delete,lifecycle:p})),f.push(u(e,s,{table:t,idField:r,deleteSubject:n.delete})),()=>f.forEach(e=>e())}}function p(t){let{table:n,subject:r,pluralKey:i,mapper:a,buildPredicates:o}=t;return(t,s)=>{let c=(e,t)=>({[e]:t});return t.on(r,async t=>{let r=o(t.payload,n),l=r.length>0?e(...r):void 0,u=l?await s.select().from(n).where(l):await s.select().from(n);t.setResult(c(i,u.map(a)))})}}function m(e,n){return n?[r(e.scope,[`default`,n])]:[t(e.scope,`default`)]}export{p as n,f as r,m as t};
@@ -1,3 +0,0 @@
1
- const e=(e,r,i)=>{let a=e instanceof RegExp?t(e,i):e,o=r instanceof RegExp?t(r,i):r,s=a!==null&&o!=null&&n(a,o,i);return s&&{start:s[0],end:s[1],pre:i.slice(0,s[0]),body:i.slice(s[0]+a.length,s[1]),post:i.slice(s[1]+o.length)}},t=(e,t)=>{let n=t.match(e);return n?n[0]:null},n=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},r=`\0SLASH`+Math.random()+`\0`,i=`\0OPEN`+Math.random()+`\0`,a=`\0CLOSE`+Math.random()+`\0`,o=`\0COMMA`+Math.random()+`\0`,s=`\0PERIOD`+Math.random()+`\0`,c=new RegExp(r,`g`),l=new RegExp(i,`g`),u=new RegExp(a,`g`),d=new RegExp(o,`g`),f=new RegExp(s,`g`),p=/\\\\/g,ee=/\\{/g,m=/\\}/g,h=/\\,/g,g=/\\./g;function _(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function te(e){return e.replace(p,r).replace(ee,i).replace(m,a).replace(h,o).replace(g,s)}function v(e){return e.replace(c,`\\`).replace(l,`{`).replace(u,`}`).replace(d,`,`).replace(f,`.`)}function y(t){if(!t)return[``];let n=[],r=e(`{`,`}`,t);if(!r)return t.split(`,`);let{pre:i,body:a,post:o}=r,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;let c=y(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),n.push.apply(n,s),n}function ne(e){return e?(e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),x(te(e),!0).map(v)):[]}function re(e){return`{`+e+`}`}function ie(e){return/^-?0\d/.test(e)}function ae(e,t){return e<=t}function b(e,t){return e>=t}function x(t,n){let r=[],i=e(`{`,`}`,t);if(!i)return[t];let o=i.pre,s=i.post.length?x(i.post,!1):[``];if(/\$$/.test(i.pre))for(let e=0;e<s.length;e++){let t=o+`{`+i.body+`}`+s[e];r.push(t)}else{let e=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=e||c,u=i.body.indexOf(`,`)>=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(t=i.pre+`{`+i.body+a+i.post,x(t)):[t];let d;if(l)d=i.body.split(/\.\./);else if(d=y(i.body),d.length===1&&d[0]!==void 0&&(d=x(d[0],!1).map(re),d.length===1))return s.map(e=>i.pre+d[0]+e);let f;if(l&&d[0]!==void 0&&d[1]!==void 0){let e=_(d[0]),t=_(d[1]),n=Math.max(d[0].length,d[1].length),r=d.length===3&&d[2]!==void 0?Math.abs(_(d[2])):1,i=ae;t<e&&(r*=-1,i=b);let a=d.some(ie);f=[];for(let o=e;i(o,t);o+=r){let e;if(c)e=String.fromCharCode(o),e===`\\`&&(e=``);else if(e=String(o),a){let t=n-e.length;if(t>0){let n=Array(t+1).join(`0`);e=o<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e<d.length;e++)f.push.apply(f,x(d[e],!1))}for(let e=0;e<f.length;e++)for(let t=0;t<s.length;t++){let i=o+f[e]+s[t];(!n||l||i)&&r.push(i)}}return r}const S=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},oe={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},C=e=>e.replace(/[[\]\\-]/g,`\\$&`),w=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),T=e=>e.join(``),E=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(oe))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(C(d)+`-`+C(t)):t===d&&r.push(C(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(C(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(C(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[w(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+T(r)+`]`,p=`[`+(l?``:`^`)+T(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},D=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`):t?e.replace(/\[([^\/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,`$1$2`).replace(/\\([^\/{}])/g,`$1`),se=new Set([`!`,`?`,`+`,`*`,`@`]),O=e=>se.has(e),k=`(?!\\.)`,ce=new Set([`[`,`.`]),A=new Set([`..`,`.`]),j=new Set(`().*{}+?[]^$\\!`),M=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),N=`[^/]`,P=N+`*?`,F=N+`+?`;var I=class e{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...t){for(let n of t)if(n!==``){if(typeof n!=`string`&&!(n instanceof e&&n.#i===this))throw Error(`invalid part: `+n);this.#r.push(n)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let t=this.#i;for(let n=0;n<this.#a;n++){let r=t.#r[n];if(!(r instanceof e&&r.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(t){let n=new e(this.type,t);for(let e of this.#r)n.copyIn(e);return n}static#f(t,n,r,i){let a=!1,o=!1,s=-1,c=!1;if(n.type===null){let l=r,u=``;for(;l<t.length;){let r=t.charAt(l++);if(a||r===`\\`){a=!a,u+=r;continue}if(o){l===s+1?(r===`^`||r===`!`)&&(c=!0):r===`]`&&!(l===s+2&&c)&&(o=!1),u+=r;continue}else if(r===`[`){o=!0,s=l,c=!1,u+=r;continue}if(!i.noext&&O(r)&&t.charAt(l)===`(`){n.push(u),u=``;let a=new e(r,n);l=e.#f(t,a,l,i),n.push(a);continue}u+=r}return n.push(u),l}let l=r+1,u=new e(null,n),d=[],f=``;for(;l<t.length;){let r=t.charAt(l++);if(a||r===`\\`){a=!a,f+=r;continue}if(o){l===s+1?(r===`^`||r===`!`)&&(c=!0):r===`]`&&!(l===s+2&&c)&&(o=!1),f+=r;continue}else if(r===`[`){o=!0,s=l,c=!1,f+=r;continue}if(O(r)&&t.charAt(l)===`(`){u.push(f),f=``;let n=new e(r,u);u.push(n),l=e.#f(t,n,l,i);continue}if(r===`|`){u.push(f),f=``,d.push(u),u=new e(null,n);continue}if(r===`)`)return f===``&&n.#r.length===0&&(n.#u=!0),u.push(f),f=``,n.push(...d,u),l;f+=r}return n.type=null,n.#t=void 0,n.#r=[t.substring(r-1)],l}static fromGlob(t,n={}){let r=new e(null,void 0,n);return e.#f(t,r,0,n),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(t){let n=t??!!this.#c.dot;if(this.#e===this&&this.#d(),!this.type){let r=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),i=this.#r.map(n=>{let[i,a,o,s]=typeof n==`string`?e.#m(n,this.#t,r):n.toRegExpSource(t);return this.#t=this.#t||o,this.#n=this.#n||s,i}).join(``),a=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&A.has(this.#r[0]))){let e=ce,r=n&&e.has(i.charAt(0))||i.startsWith(`\\.`)&&e.has(i.charAt(2))||i.startsWith(`\\.\\.`)&&e.has(i.charAt(4)),o=!n&&!t&&e.has(i.charAt(0));a=r?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?k:``}let o=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(o=`(?:$|\\/)`),[a+i+o,D(i),this.#t=!!this.#t,this.#n]}let r=this.type===`*`||this.type===`+`,i=this.type===`!`?`(?:(?!(?:`:`(?:`,a=this.#p(n);if(this.isStart()&&this.isEnd()&&!a&&this.type!==`!`){let e=this.toString();return this.#r=[e],this.type=null,this.#t=void 0,[e,D(this.toString()),!1,!1]}let o=!r||t||n?``:this.#p(!0);o===a&&(o=``),o&&(a=`(?:${a})(?:${o})*?`);let s=``;if(this.type===`!`&&this.#u)s=(this.isStart()&&!n?k:``)+F;else{let e=this.type===`!`?`))`+(this.isStart()&&!n&&!t?k:``)+P+`)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&o?`)`:this.type===`*`&&o?`)?`:`)${this.type}`;s=i+a+e}return[s,D(a),this.#t=!!this.#t,this.#n]}#p(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#m(e,t,n=!1){let r=!1,i=``,a=!1;for(let o=0;o<e.length;o++){let s=e.charAt(o);if(r){r=!1,i+=(j.has(s)?`\\`:``)+s;continue}if(s===`\\`){o===e.length-1?i+=`\\\\`:r=!0;continue}if(s===`[`){let[n,r,s,c]=E(e,o);if(s){i+=n,a||=r,o+=s-1,t||=c;continue}}if(s===`*`){i+=n&&e===`*`?F:P,t=!0;continue}if(s===`?`){i+=N,t=!0;continue}i+=M(s)}return[i,D(e),!!t,a]}};const L=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),R=(e,t,n={})=>(S(t),!n.nocomment&&t.charAt(0)===`#`?!1:new $(t,n).match(e)),z=/^\*+([^+@!?\*\[\(]*)$/,B=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),V=e=>t=>t.endsWith(e),H=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),U=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),W=/^\*+\.\*+$/,le=e=>!e.startsWith(`.`)&&e.includes(`.`),ue=e=>e!==`.`&&e!==`..`&&e.includes(`.`),de=/^\.\*+$/,fe=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),pe=/^\*+$/,me=e=>e.length!==0&&!e.startsWith(`.`),he=e=>e.length!==0&&e!==`.`&&e!==`..`,ge=/^\?+([^+@!?\*\[\(]*)?$/,_e=([e,t=``])=>{let n=G([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},ve=([e,t=``])=>{let n=K([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},ye=([e,t=``])=>{let n=K([e]);return t?e=>n(e)&&e.endsWith(t):n},be=([e,t=``])=>{let n=G([e]);return t?e=>n(e)&&e.endsWith(t):n},G=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},K=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},q=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,J={win32:{sep:`\\`},posix:{sep:`/`}};R.sep=q===`win32`?J.win32.sep:J.posix.sep;const Y=Symbol(`globstar **`);R.GLOBSTAR=Y,R.filter=(e,t={})=>n=>R(n,e,t);const X=(e,t={})=>Object.assign({},e,t);R.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return R;let t=R;return Object.assign((n,r,i={})=>t(n,r,X(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,X(e,n))}static defaults(n){return t.defaults(X(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,X(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,X(e,r))}},unescape:(n,r={})=>t.unescape(n,X(e,r)),escape:(n,r={})=>t.escape(n,X(e,r)),filter:(n,r={})=>t.filter(n,X(e,r)),defaults:n=>t.defaults(X(e,n)),makeRe:(n,r={})=>t.makeRe(n,X(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,X(e,r)),match:(n,r,i={})=>t.match(n,r,X(e,i)),sep:t.sep,GLOBSTAR:Y})};const Z=(e,t={})=>(S(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:ne(e));R.braceExpand=Z,R.makeRe=(e,t={})=>new $(e,t).makeRe(),R.match=(e,t,n={})=>{let r=new $(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const Q=/[?*]|[+@!]\(.*?\)|\[|\]/,xe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var $=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){S(e),t||={},this.options=t,this.pattern=e,this.platform=t.platform||q,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!Q.test(e[2]))&&!Q.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)e[t][n]===`**`&&(e[t][n]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=this.options;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),r=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),i=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),a=!i&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),o=r?3:n?0:void 0,s=a?3:i?0:void 0;if(typeof o==`number`&&typeof s==`number`){let[n,r]=[e[o],t[s]];n.toLowerCase()===r.toLowerCase()&&(t[s]=n,s>o?t=t.slice(s):o>s&&(e=e.slice(o)))}}let{optimizationLevel:i=1}=this.options;i>=2&&(e=this.levelTwoFileOptimize(e)),this.debug(`matchOne`,this,{file:e,pattern:t}),this.debug(`matchOne`,e.length,t.length);for(var a=0,o=0,s=e.length,c=t.length;a<s&&o<c;a++,o++){this.debug(`matchOne loop`);var l=t[o],u=e[a];if(this.debug(t,l,u),l===!1)return!1;if(l===Y){this.debug(`GLOBSTAR`,[t,l,u]);var d=a,f=o+1;if(f===c){for(this.debug(`** at the end`);a<s;a++)if(e[a]===`.`||e[a]===`..`||!r.dot&&e[a].charAt(0)===`.`)return!1;return!0}for(;d<s;){var p=e[d];if(this.debug(`
2
- globstar while`,e,d,t,f,p),this.matchOne(e.slice(d),t.slice(f),n))return this.debug(`globstar found match!`,d,s,p),!0;if(p===`.`||p===`..`||!r.dot&&p.charAt(0)===`.`){this.debug(`dot detected!`,e,d,t,f);break}this.debug(`globstar swallow a segment, and continue`),d++}return!!(n&&(this.debug(`
3
- >>> no match, partial?`,e,d,t,f),d===s))}let i;if(typeof l==`string`?(i=u===l,this.debug(`string match`,l,u,i)):(i=l.test(u),this.debug(`pattern match`,l,u,i)),!i)return!1}if(a===s&&o===c)return!0;if(a===s)return n;if(o===c)return a===s-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Z(this.pattern,this.options)}parse(e){S(e);let t=this.options;if(e===`**`)return Y;if(e===``)return``;let n,r=null;(n=e.match(pe))?r=t.dot?he:me:(n=e.match(z))?r=(t.nocase?t.dot?U:H:t.dot?V:B)(n[1]):(n=e.match(ge))?r=(t.nocase?t.dot?ve:_e:t.dot?ye:be)(n):(n=e.match(W))?r=t.dot?ue:le:(n=e.match(de))&&(r=fe);let i=I.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,`test`,{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?xe(e):e===Y?Y:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==Y||a===Y||(a===void 0?i!==void 0&&i!==Y?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==Y&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=Y))});let i=t.filter(e=>e!==Y);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^\/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e=0;e<i.length;e++){let o=i[e],s=r;if(n.matchBase&&o.length===1&&(s=[a]),this.matchOne(s,o,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return R.defaults(e).Minimatch}};R.AST=I,R.Minimatch=$,R.escape=L,R.unescape=D;export{R as n,$ as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./window-registry-XjOExitT.mjs";import{n as t}from"./namespace-BXqetkc3.mjs";import{n}from"./extension-namespace-BBgYOttA.mjs";import{t as r}from"./schema-introspection-CuRZPYEc.mjs";import{z as i}from"zod";import a from"node:path";import{createBusNamespace as o}from"@makaio/framework/core";import{ProviderDefinitionSchema as s,versionSatisfies as c}from"@makaio/framework/contracts";import{ToastSubjects as l}from"@makaio/framework/contracts/toast";import{ExtensionWarningSchema as u,getExtensionWarningActionLabel as d}from"@makaio/framework/contracts/extension";import{TrayMenuSubjects as f}from"@makaio/framework/services/tray-menu";const p=i.object({name:i.string(),displayName:i.string()}),m=o(`kernel:boot`,{getState:{request:i.object({}),response:i.object({complete:i.boolean(),completedCount:i.number(),totalCount:i.number(),currentService:i.string().optional(),failedServices:i.array(i.string()),skippedServices:i.array(i.string()).default([]),totalDurationMs:i.number().optional()})},"service.starting":p,"service.ready":p.extend({durationMs:i.number().int().nonnegative()}),"service.failed":p.extend({errorMessage:i.string()}),"service.skipped":p.extend({reason:i.string()}),progress:i.object({completedCount:i.number(),totalCount:i.number(),currentService:i.string().optional()}),complete:i.object({totalDurationMs:i.number(),failedServices:i.array(i.string())})}),h=m.subjects;var g=class extends Error{reason;constructor(e){super(e),this.name=`ServiceSkipError`,this.reason=e}};function _(e){return{name:e.name,displayName:e.displayName}}var v=class{bus;state;cleanup;constructor(e,t){this.bus=e,this.state={complete:!1,completedCount:0,totalCount:t,failedServices:[],skippedServices:[],startedAt:Date.now()},this.cleanup=this.bus.on(h.getState,e=>{e.setResult({complete:this.state.complete,completedCount:this.state.completedCount,totalCount:this.state.totalCount,...this.state.currentService===void 0?{}:{currentService:this.state.currentService},failedServices:[...this.state.failedServices],skippedServices:[...this.state.skippedServices],...this.state.totalDurationMs===void 0?{}:{totalDurationMs:this.state.totalDurationMs}})})}dispose(){this.cleanup()}starting(e){let t=_(e);this.state.currentService=t.displayName,this.state.currentServiceStartedAt=Date.now(),this.bus.emit(h.service.starting,t).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.starting emit failed for "${t.name}":`,e)})}ready(e){let t=_(e);this.state.completedCount+=1;let n=this.state.currentServiceStartedAt===void 0?0:Math.max(0,Date.now()-this.state.currentServiceStartedAt);this.bus.emit(h.service.ready,{...t,durationMs:n}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.ready emit failed for "${t.name}":`,e)}),this.emitProgress()}failed(e,t){let n=_(e);this.state.completedCount+=1,this.state.failedServices.push(n.name),this.bus.emit(h.service.failed,{...n,errorMessage:t}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.failed emit failed for "${n.name}":`,e)}),this.emitProgress()}skipped(e,t){let n=_(e);this.state.completedCount+=1,this.state.skippedServices.push(n.name),this.bus.emit(h.service.skipped,{...n,reason:t}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.skipped emit failed for "${n.name}":`,e)}),this.emitProgress()}complete(){this.state.complete=!0,delete this.state.currentService,delete this.state.currentServiceStartedAt,this.state.totalDurationMs=Date.now()-this.state.startedAt,this.bus.emit(h.complete,{totalDurationMs:this.state.totalDurationMs,failedServices:[...this.state.failedServices]}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.complete emit failed:`,e)})}emitProgress(){this.bus.emit(h.progress,{completedCount:this.state.completedCount,totalCount:this.state.totalCount,...this.state.currentService===void 0?{}:{currentService:this.state.currentService}}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.progress emit failed:`,e)})}};function ee(e){return{subject:`wiring.apply`,$meta:{namespace:`client:${e}`,isRequest:!0,local:!1,channel:!1,payload:{request:{},response:{}}}}}const y=`action`;function b(e,t){return`${e}:${t}`}function te(e,t,n){return e.on(l.interacted,r=>{let{toastId:i,actionId:a}=r.payload,o=b(i,a),s=t.get(o);s&&x(e,s,i,n).catch(e=>{console.error(`[ExtensionCoordinator] Warning action dispatch failed for toast "${i}":`,e)})})}async function x(e,t,n,r){switch(t.kind){case`configure-integration`:await C(e,t.clientId,n,r);break;case`open-url`:console.info(`[ExtensionCoordinator] Toast "${n}" open-url action not routable from runtime layer: ${t.url}`);break;case`run-command`:console.info(`[ExtensionCoordinator] Toast "${n}" run-command action not routable from runtime layer: ${t.command}`);break;case`install-extension`:console.info(`[ExtensionCoordinator] Toast "${n}" install-extension action not routable from runtime layer: ${t.extensionName}`);break;default:S(t)}}function S(e){throw Error(`[ExtensionCoordinator] Unsupported warning action: ${JSON.stringify(e)}`)}async function C(e,t,n,r){let i=ee(t),a=await e.requestOptional(i,{scope:`user`,makaioCommand:r});if(!a.handled){console.warn(`[ExtensionCoordinator] Toast "${n}" configure-integration: no wiring handler for client "${t}". Is the client package loaded?`);return}let{applied:o,skipped:s}=a.data;console.info(`[ExtensionCoordinator] Toast "${n}" configure-integration: wired client "${t}" — ${o} applied, ${s} skipped.`)}function w(e){return e.map(e=>({name:e.name,description:e.description,hasInteractive:!!e.interactive,subcommands:e.subcommands.map(e=>({name:e.name,description:e.description,args:r(e.schema)}))}))}async function T(e,t,n){let{command:r,subcommand:i,args:a}=e,o=t.find(e=>e.name===r);if(!o)return{exitCode:1,stdout:[],stderr:[`Unknown command: ${r}`]};let s=o.subcommands.find(e=>e.name===i);if(!s)return{exitCode:1,stdout:[],stderr:[`Unknown subcommand: ${i}`]};let c=s.schema.safeParse(a??{});if(!c.success)return{exitCode:1,stdout:[],stderr:[`Validation failed:`,...c.error.issues.map(e=>` ${e.path.join(`.`)||`(root)`}: ${e.message}`)]};if(o.beforeRun)try{let e=await o.beforeRun({subcommandName:i,args:c.data??{},bus:n});if(!e.proceed)return{exitCode:e.exitCode??1,stdout:[],stderr:[e.message]}}catch(e){return{exitCode:1,stdout:[],stderr:[`beforeRun hook failed: ${e instanceof Error?e.message:String(e)}`]}}let l=[],u=[],d={write:e=>l.push(e),error:e=>u.push(e)},f=0,p=new AbortController().signal;try{await s.handler({args:c.data,bus:n,output:d,signal:p,setExitCode:e=>{f=e}})}catch(e){f===0&&(f=1),u.push(e instanceof Error?e.message:String(e))}return{exitCode:f,stdout:l,stderr:u}}function E(e){let{pkg:t,state:n,error:r,enabled:i}=e;return{name:t.name,displayName:t.displayName,state:n,...t.surface===void 0?{}:{surface:t.surface},enabled:i,...t.browser===void 0?{}:{browser:t.browser},...r===void 0?{}:{error:r}}}function D(e){let r=[];return r.push(e.bus.on(n.list,t=>{t.setResult({extensions:e.list()})})),r.push(e.bus.on(n.get,t=>{let n=e.entries.get(t.payload.name);t.setResult({extension:n?E(n):null})})),r.push(e.bus.on(n.setEnabled,async t=>{let n=await e.handleSetEnabled(t.payload.name,t.payload.enabled);t.setResult({success:n})})),r.push(e.bus.on(n.contributions.catalog,t=>{let n=[],r=[];for(let[t,i]of e.entries)if(i.state===`active`){for(let e of i.pkg.providers??[])n.push({packageName:t,definition:s.parse(e)});for(let e of i.pkg.clients??[])r.push({packageName:t,definition:e})}t.setResult({providers:n,clients:r})})),r.push(e.bus.on(t.listContributions,t=>{t.setResult({contributions:w(e.cliContributions)})})),r.push(e.bus.on(t.execute,async t=>{t.setResult(await T(t.payload,e.cliContributions,e.bus))})),r.push(e.bus.on(n.warnings.list,t=>{let{extensionName:n}=t.payload;if(n!==void 0){let r=e.entries.get(n),i=r&&r.warnings.length>0?[{extensionName:n,warnings:[...r.warnings]}]:[];t.setResult({entries:i});return}let r=[];for(let[t,n]of e.entries)n.warnings.length>0&&r.push({extensionName:t,warnings:[...n.warnings]});t.setResult({entries:r})})),r}async function ne(e){for(let[t,n]of e.entries)n.state===`active`&&await k(e,t,n)}function re(e){if(e&&O(e))return[{id:y,label:d(e)}]}function O(e){return e.kind===`configure-integration`}function ie(e,t){let n=`${t}:`;for(let t of e.keys())t.startsWith(n)&&e.delete(t)}async function k(e,t,n){ie(e.warningActionMap,t);let r=n.warnings.filter(e=>e.severity===`degraded`);if(r.length!==0)for(let i=0;i<r.length;i++){let a=r[i];console.warn(`[${t}] ⚠ ${a.title}: ${a.message}`);let o=`${t}:${a.title}:${i}`,s=re(a.action);try{await e.bus.emit(l.show,{level:`warning`,title:a.title,message:`${n.pkg.displayName}: ${a.message}`,toastId:o,durationMs:null,...s&&{actions:s}}),a.action&&O(a.action)&&e.warningActionMap.set(b(o,y),a.action)}catch(e){console.warn(`[${t}] toast emission failed for warning "${a.title}":`,e)}}}function ae(e){return Object.freeze({extensionName:e})}function oe(e,t,n,r){if(!t)return;let i={...n??{},...r??{}};try{return t.parse(i)}catch(n){console.warn(`[ExtensionCoordinator] Config parse failed for "${e}", starting with schema defaults:`,n instanceof Error?n.message:n);try{return t.parse({})}catch{console.warn(`[ExtensionCoordinator] Fallback config parse also failed for "${e}" — config will be absent`);return}}}function A(e,t,n){let r;if(n.pkg.configSchema)try{r=e.loadConfig?.(t)}catch(e){console.error(`[ExtensionCoordinator] loadConfig threw for "${t}":`,e)}return oe(t,n.pkg.configSchema,n.configDefaults,r)}function j(e,t,n){if(!e.extensionContextBase)throw Error(`ExtensionCoordinator: extensionContextBase is required to start extensions with a create factory. Provide it via the constructor.`);return{...e.extensionContextBase,bus:e.bus,identity:t.identity,dataDir:a.join(e.extensionContextBase.makaioHome,t.identity.extensionName),getService:t=>e.getExtensionService(t.name),signal:e.signal,hasExtension:e.hasActiveExtension,...n===void 0?{}:{config:n}}}function M(e){return{adapters:!!e.adapters?.length,tools:!!e.tools,triggers:!!e.triggers,providers:!!e.providers?.length,clients:!!e.clients?.length,ui:!!e.ui,storage:!!e.storage,sessionEventActions:!!e.sessionEventActions}}function N(e,t,r){let i=t.state;t.state=r,e.emit(n.stateChanged,{name:t.pkg.name,displayName:t.pkg.displayName,from:i,to:r,...t.error===void 0?{}:{error:t.error},contributes:M(t.pkg)}).catch(e=>{console.error(`[ExtensionCoordinator] stateChanged emit failed for "${t.pkg.name}":`,e)})}async function P(e,t,n,r,i){i===`activated`?await F(e,t,n,r):await I(e,n)}async function F(e,t,n,r){let i=[];try{for(let a of e){if(a.filter&&!a.filter(r.pkg))continue;let e=j(t,r,A(t,n,r));await a.processActivated(n,r.pkg,e),i.push(a)}}catch(e){for(let e of i.reverse())if(e.processStopped)try{await e.processStopped(n)}catch(e){console.error(`[ExtensionCoordinator] Contribution processor rollback error for "${n}":`,e)}throw e}}async function I(e,t){for(let n of[...e].reverse())if(n.processStopped)try{await n.processStopped(t)}catch(e){console.error(`[ExtensionCoordinator] Contribution processor error (stopped) for "${t}":`,e)}}async function L(e,t,r){let i=e.entries.get(t);if(!i)return!1;let a=r?await R(e,t,i):await z(e,t,i),o=i.enabled===r;return!a&&!o||(await e.persistEnabled?.(t,r),!a)?!1:(e.bus.emit(n.enabledChanged,{name:t,enabled:r}).catch(e=>{console.error(`[ExtensionCoordinator] enabledChanged emit failed for "${t}":`,e)}),!0)}async function R(e,t,n){if(n.state!==`stopped`&&n.state!==`failed`&&n.state!==`skipped`)return!1;let{pkg:r}=n,i,a=(r.dependencies??[]).filter(t=>{if(t.optional)return!1;let n=e.entries.get(t.name);return!n||n.state!==`active`});if(a.length>0)return n.error=`Required dependencies not active: ${a.map(e=>e.name).join(`, `)}`,console.error(`[ExtensionCoordinator] Cannot re-enable "${t}":`,n.error),N(e.bus,n,`failed`),!1;n.enabled=!0,n.error=void 0,N(e.bus,n,`initializing`);let o=A(e,t,n);if(r.storage?.registerHandlers&&e.db!==void 0)try{let t=j(e,n,o),a=r.storage.registerHandlers(e.bus,e.db,t);typeof a==`function`&&(i=a,n.storageCleanup=a)}catch(r){return n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" storage re-registration failed:`,r),N(e.bus,n,`failed`),!1}if(r.create){let a;try{let t=j(e,n,o);a=await r.create(t),await a.init?.(),n.service=a}catch(r){return await B(t,a,i,n),r instanceof g?n.pkg.critical?(n.error=`Critical extension cannot skip startup: ${r.reason}`,console.error(`[ExtensionCoordinator] Extension "${t}" failed to re-initialize:`,n.error),N(e.bus,n,`failed`),!1):(n.error=r.reason,N(e.bus,n,`skipped`),!1):(n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" failed to re-initialize:`,r),N(e.bus,n,`failed`),!1)}}try{await P(e.contributionProcessors,e,t,n,`activated`)}catch(r){return await B(t,n.service,i,n),n.service=void 0,n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" contribution processing failed:`,r),N(e.bus,n,`failed`),!1}return N(e.bus,n,`active`),await e.runHealthCheck(t),await e.emitWarningsForEntry(t,n),!0}async function z(e,t,r){if(r.state!==`active`)return!1;let i=Array.from(e.entries.entries()).filter(([e,n])=>e===t||n.state!==`active`?!1:n.pkg.dependencies?.some(e=>!e.optional&&e.name===t)??!1).map(([e])=>e);if(i.length>0)return r.error=`Cannot disable "${t}" while active dependents remain: ${i.join(`, `)}`,console.error(`[ExtensionCoordinator] ${r.error}`),!1;if(r.enabled=!1,r.error=void 0,await P(e.contributionProcessors,e,t,r,`stopped`),r.service)try{await r.service.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Error during disable destroy of "${t}":`,e)}finally{r.service=void 0}if(r.storageCleanup)try{r.storageCleanup()}catch(e){console.error(`[ExtensionCoordinator] Storage cleanup error during disable of "${t}":`,e)}finally{r.storageCleanup=void 0}N(e.bus,r,`stopped`),r.warnings=[];try{await e.bus.emit(n.warnings.changed,{extensionName:t,warnings:[]})}catch(e){console.error(`[ExtensionCoordinator] warnings.changed emit failed for "${t}":`,e)}return!0}async function B(e,t,n,r){try{await t?.destroy?.()}catch(t){console.error(`[ExtensionCoordinator] Service cleanup error after failed enable of "${e}":`,t)}try{n?.()}catch(t){console.error(`[ExtensionCoordinator] Storage cleanup error after failed enable of "${e}":`,t)}finally{r.storageCleanup=void 0}}function V(e){let t=new Map;for(let n of e)t.has(n.name)&&(console.info(`[ExtensionCoordinator] Extension "${n.name}" overrides an earlier registration`),t.delete(n.name)),t.set(n.name,n);return[...t.values()]}function H(e,t,n){let r=new Set(e.map(e=>e.name)),i=e.filter(e=>U(e,t,n)),a=new Map(i.map(e=>[e.name,e])),o=new Set(a.keys()),s=!0;for(;s;){s=!1;for(let e of o)(a.get(e).dependencies??[]).some(e=>!e.optional&&r.has(e.name)&&!o.has(e.name))&&(o.delete(e),s=!0)}return i.filter(e=>o.has(e.name))}function U(e,t,n){if(!G(e,t))return!1;let r=e.requires;return!r||r.length===0||!n?!0:r.every(e=>{switch(e.type){case`host`:return n.hosts.has(e.id);case`capability`:return n.capabilities.has(e.id)?e.version===void 0?!0:W(n,e.id,e.version):!1}})}function W(e,t,n){let r=e.capabilityVersions?.get(t);return r!==void 0&&c(r,n)}function G(e,t){return e.surface===void 0||e.surface===`any`||e.surface===t}function K(e){let t=q(e);return se(e,t,new Map(e.map(e=>[e.name,e]))),ue(t,le(e,t))}function q(e){let t=new Set;for(let n of e){if(t.has(n.name))throw Error(`ExtensionCoordinator: duplicate package name detected: "${n.name}"`);t.add(n.name)}return t}function se(e,t,n){for(let r of e)ce(r,t,n)}function ce(e,t,n){let r=e.dependencies??[],i=r.filter(e=>!e.optional&&!t.has(e.name));if(i.length>0)throw Error(`ExtensionCoordinator: package "${e.name}" declares missing dependencies: ${i.map(e=>e.name).join(`, `)}`);for(let t of r){let r=n.get(t.name);if(r===void 0)continue;let i=r.version;if(!c(i,t.version))throw Error(`ExtensionCoordinator: package "${e.name}" dependency "${t.name}" version ${i} does not satisfy ${t.version}`)}}function le(e,t){let n=new Map;for(let r of e){let e=(r.dependencies??[]).filter(e=>t.has(e.name)).map(e=>e.name);n.set(r.name,new Set(e))}return n}function ue(e,t){let n=[];for(let[e,r]of t)r.size===0&&n.push(e);let r=[],i=new Set;for(;n.length>0;){let e=n.shift();if(!i.has(e)){i.add(e),r.push(e);for(let[r,a]of t)a.has(e)&&(a.delete(e),a.size===0&&!i.has(r)&&n.push(r))}}if(r.length!==e.size){let t=[...e].filter(e=>!i.has(e));throw Error(`ExtensionCoordinator: circular dependency detected among: ${t.join(`, `)}`)}return r}async function de(e){if(!e.runMigrations)return;let t=[];for(let n of e.loadOrder){let r=e.entries.get(n);if(!r)throw Error(`Extension "${n}" is in loadOrder but missing from entries`);let i=r.pkg.storage?.migrations;if(!i)continue;let a=fe(n,r.pkg,i);t.push({name:n,migrationsPath:a,migrationSourceId:r.pkg.storage?.migrationSourceId??a})}t.length!==0&&await e.runMigrations(t)}function fe(e,t,n){if(a.isAbsolute(n))return n;let r=t.storage?.packageRoot;if(!r)throw Error(`Extension "${e}" declares relative storage.migrations "${n}" without storage.packageRoot`);let i=a.resolve(r),o=a.resolve(i,n),s=a.relative(i,o);if(s.startsWith(`..`)||a.isAbsolute(s))throw Error(`Extension "${e}" declares storage.migrations "${n}" outside storage.packageRoot`);return o}async function J(e,t){let r=e.entries.get(t);if(!r?.service||r.state!==`active`)return;let{checkHealth:i}=r.service;if(!i)return;let a;try{let e=await i.call(r.service),n=u.array().safeParse(e);n.success?a=n.data:(console.error(`[ExtensionCoordinator] checkHealth for "${t}" returned invalid data:`,n.error),a=[])}catch(e){console.error(`[ExtensionCoordinator] checkHealth threw for "${t}":`,e),a=[]}r.warnings=a;try{await e.bus.emit(n.warnings.changed,{extensionName:t,warnings:[...a]})}catch(e){console.error(`[ExtensionCoordinator] warnings.changed emit failed for "${t}":`,e)}}function pe(e,t){if(t.windows)for(let n of t.windows)e.windowRegistry.register(t.name,t.displayName,n);if(t.tray&&e.trayEntries.push({...t.tray,packageName:t.name}),t.cli){let n=t.cli;`subcommands`in n&&e.cliContributions.push(n)}}function me(e){return Array.from(e.values()).filter(e=>e.enabled).map(e=>e.pkg).filter(e=>!!e.http)}async function he(e){let t=[...e.loadOrder].reverse();for(let n of t){let t=e.entries.get(n);if(t){if(t.state===`active`&&await P(e.contributionProcessors,e.contextHost,n,t,`stopped`),t.service)try{await t.service.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Error during shutdown of "${n}":`,e)}finally{t.service=void 0}if(t.storageCleanup)try{t.storageCleanup()}catch(e){console.error(`[ExtensionCoordinator] Storage cleanup error for "${n}":`,e)}finally{t.storageCleanup=void 0}t.state===`active`&&N(e.contextHost.bus,t,`stopped`)}}}async function ge(e,t){if(!t.tray)return;let n=_e(t);await e.request(f.register,{entry:n})}function _e(e){let t=e.tray;if(!t)throw Error(`[tray-menu-entry-bridge] extension "${e.name}" does not declare a tray entry`);return{packageName:e.name,entryId:t.opensWindow??t.action??`default`,label:t.label,section:t.section??`views`,priority:50,enabled:!0,metadata:t.opensWindow?{registrationId:`${e.name}:${t.opensWindow}`}:t.action?{action:t.action}:void 0}}async function Y(e,t,n){if(!n.enabled){N(e.bus,n,`skipped`),e.bootProgress.skipped(n.pkg,`disabled`);return}let r=(n.pkg.dependencies??[]).filter(t=>t.optional?!1:e.entries.get(t.name)?.state!==`active`);if(r.length>0){let i=`Required dependencies not active: ${r.map(e=>e.name).join(`, `)}`;if(Q(e,t,n,i),n.pkg.critical)throw Error(`Critical package "${t}" failed: ${i}`);return}e.bootProgress.starting(n.pkg),N(e.bus,n,`initializing`);let i=A(e.contextHost,t,n);if(be(e,t,n,i)){if(!n.pkg.create){await ve(e,t,n);return}await ye(e,t,n,i)}}async function ve(e,t,n){try{await P(e.contributionProcessors,e.contextHost,t,n,`activated`)}catch(r){if(Z(t,n),X(e,t,n,r))return;if(Q(e,t,n,r instanceof Error?r.message:String(r)),n.pkg.critical)throw r;return}N(e.bus,n,`active`),e.bootProgress.ready(n.pkg),await $(e.bus,t,n)}async function ye(e,t,n,r){let i;try{let a=j(e.contextHost,n,r);i=await n.pkg.create(a),await i.init?.(),n.service=i,await P(e.contributionProcessors,e.contextHost,t,n,`activated`),N(e.bus,n,`active`),e.bootProgress.ready(n.pkg),await $(e.bus,t,n)}catch(r){try{await i?.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Service cleanup error after failed start of "${t}":`,e)}if(n.service=void 0,Z(t,n),X(e,t,n,r))return;if(Q(e,t,n,r instanceof Error?r.message:String(r)),n.pkg.critical)throw r}}function X(e,t,n,r){if(!(r instanceof g))return!1;if(n.pkg.critical){let i=`Critical package cannot skip startup: ${r.reason}`;throw Q(e,t,n,i),Error(`Critical package "${t}" failed: ${i}`,{cause:r})}return n.error=r.reason,console.info(`[ExtensionCoordinator] Package "${t}" skipped: ${r.reason}`),N(e.bus,n,`skipped`),e.bootProgress.skipped(n.pkg,r.reason),!0}function be(e,t,n,r){if(!n.pkg.storage?.registerHandlers||e.db===void 0)return!0;try{let t=j(e.contextHost,n,r),i=n.pkg.storage.registerHandlers(e.bus,e.db,t);return i&&(n.storageCleanup=i),!0}catch(r){let i=r instanceof Error?r.message:String(r);if(console.error(`[ExtensionCoordinator] Package "${t}" storage registration failed:`,r),Q(e,t,n,i),n.pkg.critical)throw r;return!1}}function Z(e,t){if(t.storageCleanup)try{t.storageCleanup()}catch(t){console.error(`[ExtensionCoordinator] Storage cleanup error after failed start of "${e}":`,t)}finally{t.storageCleanup=void 0}}function Q(e,t,n,r){n.error=r,console.error(`[ExtensionCoordinator] Package "${t}" failed:`,r),N(e.bus,n,`failed`),e.bootProgress.failed(n.pkg,r)}async function $(e,t,n){try{await ge(e,n.pkg)}catch(e){console.warn(`[ExtensionCoordinator] Failed to register tray entry for ${t}:`,e)}}var xe=class{bus;surface;db;extensionContextBase;runtimeEnvironment;shutdownController=new AbortController;entries=new Map;loadOrder=[];loaded=!1;started=!1;rpcCleanups=[];contributionProcessors=[];warningActionMap=new Map;windowRegistry=new e;_trayEntries=[];_cliContributions=[];persistEnabled;loadEnabled;loadConfig;runMigrations;constructor(e,t={}){this.bus=e,this.surface=t.surface??`headless`,this.db=t.db,this.extensionContextBase=t.extensionContextBase,this.runtimeEnvironment=t.runtimeEnvironment,this.persistEnabled=t.persistEnabled,this.loadEnabled=t.loadEnabled,this.loadConfig=t.loadConfig,this.runMigrations=t.runMigrations,this.rpcCleanups.push(te(this.bus,this.warningActionMap,t.launcherCommand??`makaio`))}get trayEntries(){return this._trayEntries.map(e=>({...e}))}get cliContributions(){return this._cliContributions}extensionsWithHttp(){return me(this.entries)}load(e,t){if(this.loaded)throw Error(`ExtensionCoordinator.load() called twice. The coordinator is single-use; create a new instance if needed.`);let n=V(H(e,this.surface,this.runtimeEnvironment));this.loadOrder=K(n);for(let e of this.loadOrder){let r=n.find(t=>t.name===e),i={pkg:r,identity:ae(r.name),state:`discovered`,enabled:this.loadEnabled?.(e)!==!1,warnings:[]};if(t){let n=t.get(e);n&&(i.configDefaults=n)}this.entries.set(e,i),r.namespaces&&this.bus.registerNamespaces(r.namespaces),pe({windowRegistry:this.windowRegistry,trayEntries:this._trayEntries,cliContributions:this._cliContributions},r)}this.rpcCleanups.push(...D({bus:this.bus,entries:this.entries,cliContributions:this._cliContributions,list:()=>this.list(),handleSetEnabled:(e,t)=>this.handleSetEnabled(e,t)})),this.loaded=!0}async startAll(){if(!this.loaded)throw Error(`ExtensionCoordinator.startAll() called before load(). Call load() first.`);if(this.started)throw Error(`ExtensionCoordinator.startAll() called twice. The coordinator is single-use; create a new instance if needed.`);this.started=!0;let e=new v(this.bus,this.loadOrder.length);this.rpcCleanups.push(()=>e.dispose());try{await de({loadOrder:this.loadOrder,entries:this.entries,runMigrations:this.runMigrations});for(let t of this.loadOrder){let n=this.entries.get(t);n&&await Y({bus:this.bus,db:this.db,entries:this.entries,contributionProcessors:this.contributionProcessors,contextHost:this.createExtensionContextHost(),bootProgress:e},t,n)}let t=this.createExtensionHealthHost();await Promise.all(this.loadOrder.map(e=>this.entries.get(e)?.state===`active`?J(t,e):void 0)),await ne({bus:this.bus,entries:this.entries,warningActionMap:this.warningActionMap})}finally{e.complete()}}async shutdown(){this.shutdownController.abort();for(let e of this.rpcCleanups)e();this.rpcCleanups=[],this.warningActionMap.clear(),await he({entries:this.entries,loadOrder:this.loadOrder,contributionProcessors:this.contributionProcessors,contextHost:this.createExtensionContextHost()})}list(){return[...this.entries.values()].map(e=>E(e))}getExtensionService(e){let t=typeof e==`string`?e:e.name;return this.entries.get(t)?.service}getExtension(e){return this.entries.get(e)?.pkg}forEachActiveExtension(e){let t=this.createExtensionContextHost();for(let n of this.loadOrder){let r=this.entries.get(n);if(!r||r.state!==`active`)continue;let i=j(t,r,A(t,n,r));e(n,r.pkg,i)}}forExtension(e,t){let n=this.entries.get(e);if(!n||n.state!==`active`)return;let r=this.createExtensionContextHost(),i=j(r,n,A(r,e,n));t(e,n.pkg,i)}registerContributionProcessor(e){return this.contributionProcessors.push(e),()=>{let t=this.contributionProcessors.indexOf(e);t>=0&&this.contributionProcessors.splice(t,1)}}async handleSetEnabled(e,t){return L({bus:this.bus,db:this.db,entries:this.entries,extensionContextBase:this.extensionContextBase,loadConfig:this.loadConfig,signal:this.shutdownController.signal,hasActiveExtension:e=>this.hasActiveExtension(e),persistEnabled:this.persistEnabled,contributionProcessors:this.contributionProcessors,getExtensionService:e=>this.getExtensionService(e),runHealthCheck:e=>J(this.createExtensionHealthHost(),e),emitWarningsForEntry:(e,t)=>k({bus:this.bus,entries:this.entries,warningActionMap:this.warningActionMap},e,t)},e,t)}createExtensionContextHost(){return{bus:this.bus,extensionContextBase:this.extensionContextBase,loadConfig:this.loadConfig,signal:this.shutdownController.signal,hasActiveExtension:e=>this.hasActiveExtension(e),getExtensionService:e=>this.getExtensionService(e)}}createExtensionHealthHost(){return{bus:this.bus,entries:this.entries}}hasActiveExtension(e){return this.entries.get(e)?.state===`active`}};export{m as a,g as i,V as n,h as o,H as r,xe as t};