@protobase/ui 0.113.1 → 0.114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/messages.d.ts +2 -2
- package/dist/app/app.d.ts +4 -1
- package/dist/app/app.js +9 -7
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/comments/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/displays/virtual-cards.js +1 -0
- package/dist/app/embedded-list/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/first-frame.d.ts +13 -0
- package/dist/app/first-frame.js +23 -0
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/gallery-layout.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/index.html +0 -17
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/main.js +19 -7
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-mode/shown-layout.d.ts +1 -1
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/record-row/record-row.js +1 -0
- package/dist/app/refresh-mark.d.ts +2 -1
- package/dist/app/refresh-mark.js +3 -1
- package/dist/app/reveal-when-loaded.d.ts +8 -2
- package/dist/app/reveal-when-loaded.js +12 -5
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app/splash-hold.d.ts +0 -1
- package/dist/app/splash-hold.js +1 -1
- package/dist/app/start-screen.d.ts +0 -9
- package/dist/app/start-screen.js +1 -10
- package/dist/app/ui-ready.d.ts +11 -0
- package/dist/app/ui-ready.js +12 -0
- package/dist/app-shell/app-shell.js +3 -1
- package/dist/app-shell/close-sidebar.d.ts +10 -0
- package/dist/app-shell/close-sidebar.js +17 -0
- package/dist/app-shell/drawer.d.ts +7 -1
- package/dist/app-shell/drawer.js +26 -7
- package/dist/app-shell/index.d.ts +2 -1
- package/dist/app-shell/index.js +2 -1
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/app-shell/top-bar.js +4 -4
- package/dist/assistant-dock/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/calls/messages.d.ts +2 -2
- package/dist/chat/messages.d.ts +2 -2
- package/dist/data/query-keys.d.ts +6 -0
- package/dist/data/query-keys.js +10 -0
- package/dist/data/start-cache/cached-plugins.d.ts +6 -0
- package/dist/data/start-cache/cached-plugins.js +10 -0
- package/dist/data-grid/data-grid.js +1 -0
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/data-grid/row-source.d.ts +5 -0
- package/dist/data-grid/use-paged-rows.d.ts +5 -3
- package/dist/data-grid/use-paged-rows.js +21 -6
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/inline-child-table/messages.d.ts +2 -2
- package/dist/live/grid-loader.d.ts +1 -0
- package/dist/live/grid-loader.js +3 -1
- package/dist/live/use-live-rows.js +1 -0
- package/dist/mocks/orders.d.ts +1 -1
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/members-page.js +13 -7
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/organizations/use-organizations.d.ts +4 -1
- package/dist/organizations/use-organizations.js +25 -19
- package/dist/package.js +1 -1
- package/dist/plugins/plugin-source.d.ts +24 -4
- package/dist/plugins/plugin-source.js +48 -14
- package/dist/plugins/use-plugin-loads.d.ts +3 -1
- package/dist/plugins/use-plugin-loads.js +24 -7
- package/dist/primitives/skeleton.js +1 -0
- package/dist/roles/use-active-role.d.ts +4 -1
- package/dist/roles/use-active-role.js +18 -13
- package/dist/shell/assets/api-provider-BJJrOoO4.js +2 -0
- package/dist/shell/assets/app-VoTi41IN.js +16 -0
- package/dist/shell/assets/badge-OU9hb6yQ.js +2 -0
- package/dist/shell/assets/checkbox-DFfK432Y.js +2 -0
- package/dist/shell/assets/createLucideIcon-DGm8SdFI.js +2 -0
- package/dist/shell/assets/display-value-CIH2qfgQ.js +2 -0
- package/dist/shell/assets/{field-badge-3QmjR1r3.js → field-badge-DX2Mc_fH.js} +2 -2
- package/dist/shell/assets/{graph-view-CIk96BRv.js → graph-view-CY9LPr0B.js} +2 -2
- package/dist/shell/assets/{html-viewer-ATz2AVBi.js → html-viewer-BPGMH_GA.js} +2 -2
- package/dist/shell/assets/{in-place-form-frfvnKaj.js → in-place-form-RWSQGEg4.js} +2 -2
- package/dist/shell/assets/index-Bzb-O7ER.js +2 -0
- package/dist/shell/assets/index-HnFovy2Q.css +2 -0
- package/dist/shell/assets/{intl-cache-bXVNV0Yq.js → intl-cache-D4doUjK1.js} +2 -2
- package/dist/shell/assets/{lib-d3-interpolate-Cl0dHO4f.js → lib-d3-interpolate-D3u38iyJ.js} +2 -2
- package/dist/shell/assets/{lib-d3-transition-DUHAGQ8z.js → lib-d3-transition-BUpPvFvt.js} +2 -2
- package/dist/shell/assets/{lib-d3-zoom-gQh2osrj.js → lib-d3-zoom-BF7SPKNh.js} +2 -2
- package/dist/shell/assets/{lib-vis.gl-react-maplibre-CU7gWYjg.js → lib-vis.gl-react-maplibre-C7-0xNFC.js} +2 -2
- package/dist/shell/assets/{lib-xyflow-react-DGg_5r7u.js → lib-xyflow-react-CKyW7szC.js} +2 -2
- package/dist/shell/assets/maplibre-9ViQO48S.js +2 -0
- package/dist/shell/assets/{markdown-content-mNJHzGOa.js → markdown-content-DTB9RQDs.js} +2 -2
- package/dist/shell/assets/{record-map-BsXXSshB.js → record-map-CVqCWtfe.js} +2 -2
- package/dist/shell/assets/{records-map-D8EBzOu8.js → records-map-ClYSxrVR.js} +2 -2
- package/dist/shell/assets/{run-trace-view-Tf6Jwd46.js → run-trace-view-CN16MiXg.js} +2 -2
- package/dist/shell/assets/search-picker-BGpvJQRD.js +2 -0
- package/dist/shell/assets/shared-protobase-ui-BC8LqGQB.js +2 -0
- package/dist/shell/assets/step-catalog-CZY0ZpCC.js +2 -0
- package/dist/shell/assets/step-panel-DhD80lsJ.js +2 -0
- package/dist/shell/assets/use-app-address-B4Uk3nWy.js +2 -0
- package/dist/shell/assets/{use-meta-BqEqOLNe.js → use-meta-D5kYywHm.js} +2 -2
- package/dist/shell/assets/{use-sibling-page-Dm7aUfaa.js → use-sibling-page-BJ81HcOP.js} +3 -3
- package/dist/shell/assets/value-badge-Dpd8dRqq.js +2 -0
- package/dist/shell/assets/{vendor-WWp_xlp2.js → vendor-3etemhgS.js} +4 -4
- package/dist/shell/assets/{workflow-canvas-B8ciy9xI.js → workflow-canvas-C1nGpi5w.js} +2 -2
- package/dist/shell/assets/{workflow-graph-editor-QT-3e-M9.js → workflow-graph-editor-DAJa4lq6.js} +2 -2
- package/dist/shell/assets/workflow-workbench-HramVZEJ.js +4 -0
- package/dist/shell/assets/{workflows-Bku4o2su.js → workflows-DlvOln9v.js} +2 -2
- package/dist/shell/assets/{workflows-start-kl7rSSay.js → workflows-start-QUKfwFqf.js} +2 -2
- package/dist/shell/index.html +16 -19
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/api-provider-BJJrOoO4.js.map +1 -0
- package/dist/shell-source-maps/assets/app-VoTi41IN.js.map +1 -0
- package/dist/shell-source-maps/assets/{badge-ChHXC28D.js.map → badge-OU9hb6yQ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{checkbox-COOOlJPG.js.map → checkbox-DFfK432Y.js.map} +1 -1
- package/dist/shell-source-maps/assets/createLucideIcon-DGm8SdFI.js.map +1 -0
- package/dist/shell-source-maps/assets/display-value-CIH2qfgQ.js.map +1 -0
- package/dist/shell-source-maps/assets/{field-badge-3QmjR1r3.js.map → field-badge-DX2Mc_fH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-CIk96BRv.js.map → graph-view-CY9LPr0B.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-ATz2AVBi.js.map → html-viewer-BPGMH_GA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{in-place-form-frfvnKaj.js.map → in-place-form-RWSQGEg4.js.map} +1 -1
- package/dist/shell-source-maps/assets/index-Bzb-O7ER.js.map +1 -0
- package/dist/shell-source-maps/assets/{intl-cache-bXVNV0Yq.js.map → intl-cache-D4doUjK1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-d3-interpolate-Cl0dHO4f.js.map → lib-d3-interpolate-D3u38iyJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-d3-transition-DUHAGQ8z.js.map → lib-d3-transition-BUpPvFvt.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-d3-zoom-gQh2osrj.js.map → lib-d3-zoom-BF7SPKNh.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-vis.gl-react-maplibre-CU7gWYjg.js.map → lib-vis.gl-react-maplibre-C7-0xNFC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{lib-xyflow-react-DGg_5r7u.js.map → lib-xyflow-react-CKyW7szC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-BufRSV4y.js.map → maplibre-9ViQO48S.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-mNJHzGOa.js.map → markdown-content-DTB9RQDs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-BsXXSshB.js.map → record-map-CVqCWtfe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-D8EBzOu8.js.map → records-map-ClYSxrVR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-Tf6Jwd46.js.map → run-trace-view-CN16MiXg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{search-picker-BHmYOFF8.js.map → search-picker-BGpvJQRD.js.map} +1 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-BC8LqGQB.js.map +1 -0
- package/dist/shell-source-maps/assets/{step-catalog-DZNovnPL.js.map → step-catalog-CZY0ZpCC.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-3aRZ2Dlj.js.map → step-panel-DhD80lsJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-app-address-B6k3dkV0.js.map → use-app-address-B4Uk3nWy.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-meta-BqEqOLNe.js.map → use-meta-D5kYywHm.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-sibling-page-Dm7aUfaa.js.map → use-sibling-page-BJ81HcOP.js.map} +1 -1
- package/dist/shell-source-maps/assets/{value-badge-BKLV4otJ.js.map → value-badge-Dpd8dRqq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{vendor-WWp_xlp2.js.map → vendor-3etemhgS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-B8ciy9xI.js.map → workflow-canvas-C1nGpi5w.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-QT-3e-M9.js.map → workflow-graph-editor-DAJa4lq6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-C5eHhxQh.js.map → workflow-workbench-HramVZEJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflows-Bku4o2su.js.map → workflows-DlvOln9v.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflows-start-kl7rSSay.js.map → workflows-start-QUKfwFqf.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/styles.css +14 -0
- package/package.json +5 -5
- package/dist/app/hold-start-for-first-loads.d.ts +0 -12
- package/dist/app/hold-start-for-first-loads.js +0 -43
- package/dist/shell/assets/api-provider-CcDtTh0D.js +0 -2
- package/dist/shell/assets/app-C1xWr51x.js +0 -16
- package/dist/shell/assets/badge-ChHXC28D.js +0 -2
- package/dist/shell/assets/checkbox-COOOlJPG.js +0 -2
- package/dist/shell/assets/display-value-fDiKbfJO.js +0 -2
- package/dist/shell/assets/index-BkCaPeOq.css +0 -2
- package/dist/shell/assets/index-C4cMQVG2.js +0 -2
- package/dist/shell/assets/maplibre-BufRSV4y.js +0 -2
- package/dist/shell/assets/messages-ClKBpZlk.js +0 -2
- package/dist/shell/assets/search-picker-BHmYOFF8.js +0 -2
- package/dist/shell/assets/shared-protobase-ui-C1jBhoci.js +0 -2
- package/dist/shell/assets/step-catalog-DZNovnPL.js +0 -2
- package/dist/shell/assets/step-panel-3aRZ2Dlj.js +0 -2
- package/dist/shell/assets/use-app-address-B6k3dkV0.js +0 -2
- package/dist/shell/assets/value-badge-BKLV4otJ.js +0 -2
- package/dist/shell/assets/workflow-workbench-C5eHhxQh.js +0 -4
- package/dist/shell-source-maps/assets/api-provider-CcDtTh0D.js.map +0 -1
- package/dist/shell-source-maps/assets/app-C1xWr51x.js.map +0 -1
- package/dist/shell-source-maps/assets/display-value-fDiKbfJO.js.map +0 -1
- package/dist/shell-source-maps/assets/index-C4cMQVG2.js.map +0 -1
- package/dist/shell-source-maps/assets/messages-ClKBpZlk.js.map +0 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-C1jBhoci.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{t as r}from"./guarded-D7vqlAj1.js";import{
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{t as r}from"./guarded-D7vqlAj1.js";import{v as i}from"./api-provider-BJJrOoO4.js";import{in as a}from"./app-VoTi41IN.js";import{t as o}from"./createLucideIcon-DGm8SdFI.js";import{t as s}from"./cn-B1sdg8aY.js";import{C as c,D as l,M as u,N as d,O as f,S as p,a as m,b as h,c as g,d as _,f as v,g as y,h as ee,i as te,j as b,l as ne,m as x,n as S,o as re,p as C,r as ie,s as w,t as T,u as ae}from"./checkbox-DFfK432Y.js";import{t as E}from"./badge-OU9hb6yQ.js";import{c as D,d as O,f as k,i as A,l as j,o as M,s as oe}from"./workflows-DlvOln9v.js";import{O as se,S as N,T as P,a as ce,b as F,c as le,f as ue,i as de,l as fe,o as pe,s as me,v as he,w as ge}from"./workflows-start-QUKfwFqf.js";import{a as _e,c as ve,f as I,i as ye,l as be,n as xe,o as Se,p as Ce,r as L,s as we,t as Te,u as Ee}from"./lib-xyflow-react-CKyW7szC.js";import{t as De}from"./use-elk-u1Ql5AOs.js";var Oe={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};Oe.node;var ke=o(Oe),R=e(t(),1),Ae={"app:http":()=>S(`stepHttp`),"app:records.create":()=>S(`stepRecordsCreate`),"app:records.update":()=>S(`stepRecordsUpdate`),"app:records.get":()=>S(`stepRecordsGet`),"app:records.list":()=>S(`stepRecordsList`),"app:mail.send":()=>S(`stepMailSend`),"app:mail.template":()=>S(`stepMailTemplate`),"app:piece":()=>S(`stepPiece`)},je=(e,t)=>Ae[e]?.()??t??e,Me=(e,t)=>{let n=je(e,t),r=de(e);return r?S(`stepTypeVersion`,{type:n,version:r.version}):n},Ne={Pass:()=>S(`typePass`),Choice:()=>S(`typeChoice`),Wait:()=>S(`typeWait`),Map:()=>S(`typeMap`),Block:()=>S(`typeBlock`),Succeed:()=>S(`typeSucceed`),Fail:()=>S(`typeFail`)},Pe=e=>Ne[e]?.()??e,Fe=(e,t)=>{if(e.Type!==`Task`)return Pe(e.Type);let{type:n,waits:r}=N(String(e.Resource)),i=je(n,t?.step_types.find(e=>e.id===n)?.label);return r?S(`stepTypeWaits`,{type:i}):i},Ie={url:()=>S(`inputUrl`),method:()=>S(`inputMethod`),headers:()=>S(`inputHeaders`),query:()=>S(`inputQuery`),body:()=>S(`inputBody`),response:()=>S(`inputResponse`),resource:()=>S(`inputResource`),data:()=>S(`inputData`),key:()=>S(`inputKey`),filter:()=>S(`inputFilter`),order_by:()=>S(`inputOrderBy`),limit:()=>S(`inputLimit`),to:()=>S(`inputTo`),subject:()=>S(`inputSubject`),text:()=>S(`inputText`),html:()=>S(`inputHtml`),attachments:()=>S(`inputAttachments`),piece:()=>S(`inputPiece`),action:()=>S(`inputAction`),connection:()=>S(`inputConnection`),props:()=>S(`inputProps`),when:()=>S(`inputWhen`),body_schema:()=>S(`inputBodySchema`)},Le=(e,t)=>Ie[e]?.()??t??e,Re={manual:()=>S(`triggerManual`),"app:record":()=>S(`triggerRecord`)},ze=(e,t)=>Re[e]?.()??t??e,Be=e=>Object.keys(e??{})[0],Ve=(e,t)=>{let n=Be(e);return n===void 0?S(`triggerUnknown`):ze(n,t?.triggers.find(e=>e.id===n)?.label)},He={succeeded:()=>S(`traceSucceeded`),caught:()=>S(`traceCaught`),retrying:()=>S(`traceRetrying`),failed:()=>S(`traceFailed`),current:()=>S(`traceCurrent`)},Ue=e=>He[e](),We=(e,t)=>t?.step_types.find(t=>t.id===N(e.Resource).type)?.cache,Ge=(e,t)=>e.Type===`Task`&&e.Cache===!0&&We(e,t)?.choice===`discouraged`,Ke=(e,t)=>{let n=We(e,t);if(n?.choice!==`hidden`)return n?.choice===`switch`?{on:e.Cache??n.default===!0,forces:!1,offValue:!1,disclaimer:void 0}:{on:e.Cache===!0,forces:!0,offValue:void 0,disclaimer:n?.choice===`discouraged`?n.disclaimer:void 0}},z=e=>encodeURIComponent(e),qe=e=>e.map(e=>`/${z(e)}`).join(``),Je=e=>e===``?[]:e.split(`/`).slice(1).map(decodeURIComponent),Ye=(e,t)=>`break:${z(e)}|${qe(t)}`,Xe=(e,t)=>`make:${z(e)}|${z(t)}`,Ze=(e,t)=>`when:${z(e)}|${t.join(`/`)}`,Qe=(e,t)=>`select:${z(e)}|${z(t)}`,B=e=>`in:${z(e)}`,V=e=>`out:${qe(e)}`,$e=`break-in`,et=`make-out`,tt=`condition-out`,nt=`select-out`,rt=`value`,it=e=>e?.startsWith(`in:`)?decodeURIComponent(e.slice(3)):void 0,at=e=>e?.startsWith(`out:`)?Je(e.slice(4)):void 0,H=e(n(),1),ot=(e,t)=>{let n=e.pure.find(e=>e.id===t.target),r=it(t.targetHandle);return n?.kind===`condition`&&r!==void 0?{step:n.target,at:[...n.at,Number(r)]}:void 0},st=e=>e.kind===`condition`?{step:e.target,at:e.at}:void 0,ct=(e,t)=>{for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length},lt=(e,t,n)=>{let r=new Map,i=[];for(let e of t){let t=n(e);if(!t){i.push(e);continue}let a=`step:${t.step}`;r.has(a)||(r.set(a,[]),i.push(a)),r.get(a).push({removal:e,at:t.at})}return i.flatMap(e=>typeof e==`string`&&r.has(e)?r.get(e).toSorted((e,t)=>ct(t.at,e.at)).map(({removal:e})=>e):[e])},ut=e=>e.Type===`Choice`&&Array.isArray(e.Choices)?e.Choices:[],dt=e=>`Catch`in e&&Array.isArray(e.Catch)?e.Catch:[],ft=(e,t,n,r)=>{let i=p(t,n),a=(n,r,a,o)=>Object.hasOwn(e.States,a)?[{id:`${i}\n${r}`,kind:n,source:i,target:p(t,a),field:r,...o!==void 0&&{label:o}}]:[];return[...`Next`in r&&typeof r.Next==`string`?a(`next`,`Next`,r.Next):[],...ut(r).flatMap((e,t)=>a(`rule`,`Choices[${t}].Next`,e.Next,e.Condition)),...r.Type===`Choice`&&typeof r.Default==`string`?a(`default`,`Default`,r.Default):[],...dt(r).flatMap((e,t)=>e.Next===void 0?[]:a(`catch`,`Catch[${t}].Next`,e.Next,Array.isArray(e.ErrorEquals)?e.ErrorEquals.join(`, `):void 0))]},pt=(e,t)=>{let n=t.length>0?t.join(`/`):void 0,r=Object.entries(e.States).map(([r,i])=>{let a={kind:`state`,id:p(t,r),name:r,state:i,scope:t,...n!==void 0&&{parent:n},first:e.StartAt===r},o=P(i),s=o?.States?pt(o,[...t,r]):{nodes:[],edges:[]};return{nodes:[a,...s.nodes],edges:[...ft(e,t,r,i),...s.edges]}});return{nodes:r.flatMap(e=>e.nodes),edges:r.flatMap(e=>e.edges)}},mt=(e,t,n)=>[...k(e)].flatMap(([r,i])=>{let a=p(t,r),o=[...O(i)].map(e=>{let n=i.data.has(e)?`reads`:`status`;return{id:`${p(t,e)}\n${n}\n${a}`,kind:n,source:p(t,e),target:a,field:n}}),s=P(e.States[r]),c=s?.States?mt(s,[...t,r],!1):[];return[...n&&o.length===0?[{id:`\nStart\n${a}`,kind:`start`,source:``,target:a,field:`StartAt`}]:[],...o,...c]}),ht=e=>{let t=e.stateMachine,n=pt(t,[]);if(ce(e)===`data`)return{nodes:[{kind:`trigger`,id:``,trigger:e.trigger},...n.nodes.map(e=>e.kind===`state`?{...e,first:!1}:e)],edges:mt(t,[],!0)};let r=t.StartAt!==void 0&&Object.hasOwn(t.States,t.StartAt)?[{id:`
|
|
2
2
|
StartAt`,kind:`start`,source:``,target:t.StartAt,field:`StartAt`}]:[];return{nodes:[{kind:`trigger`,id:``,trigger:e.trigger},...n.nodes],edges:[...r,...n.edges]}},U={width:224,height:64},gt=(e,t)=>`${e}\u0000${t}`,_t={"elk.algorithm":`layered`,"elk.direction":`RIGHT`,"elk.hierarchyHandling":`INCLUDE_CHILDREN`,"elk.layered.spacing.nodeNodeBetweenLayers":`72`,"elk.spacing.nodeNode":`32`,"elk.edgeLabels.inline":`false`},vt={"elk.layered.layering.strategy":`LONGEST_PATH`},yt={"elk.padding":`[top=48,left=24,bottom=24,right=24]`},bt=e=>e.kind===`state`&&h(e.state),xt=(e,t={})=>{let n=e=>{let n=t.sizes?.get(e)??U,r=t.ports?.get(e);return r?.length?{id:e,...n,layoutOptions:{"elk.portConstraints":`FIXED_POS`},ports:r.map(t=>({id:gt(e,t.handle),x:t.side===`in`?0:n.width,y:t.y,width:0,height:0,layoutOptions:{"elk.port.side":t.side===`in`?`WEST`:`EAST`}}))}:{id:e,...n}},r=(e,n)=>n!==void 0&&t.ports?.get(e)?.some(e=>e.handle===n)?gt(e,n):e,i=e=>(t.pure??[]).filter(t=>t.parent===e).map(e=>n(e.id)),a=t=>{if(!bt(t))return n(t.id);let r=e.nodes.filter(e=>e.kind===`state`&&e.parent===t.id);return{id:t.id,layoutOptions:yt,children:[...r.map(a),...i(t.id)],edges:s(t.id)}},o=n=>{let r=t.pure?.find(e=>e.id===n);if(r)return r.parent;let i=e.nodes.find(e=>e.id===n);return i?.kind===`state`?i.parent:void 0},s=n=>[...e.edges.filter(e=>o(e.target)===n).map(e=>({id:e.id,sources:[e.source],targets:[e.target]})),...(t.wires??[]).filter(e=>o(e.target)===n&&o(e.source)===n).map(e=>({id:e.id,sources:[r(e.source,e.sourceHandle)],targets:[r(e.target,e.targetHandle)]}))],c=e.nodes.filter(e=>e.kind===`trigger`||e.parent===void 0);return{id:`root`,layoutOptions:t.dataOrder?{..._t,...vt}:_t,children:[...c.map(a),...i(void 0)],edges:s(void 0)}},St=e=>{let t=new Map,n=e=>{for(let r of e.children??[])t.set(r.id,{x:r.x??0,y:r.y??0,width:r.width??U.width,height:r.height??U.height}),n(r)};return n(e),t},Ct=async(e,t)=>St(await e.layout(t)),wt=24,Tt=8,Et=(e,t)=>{let n=t?[...e]:e.filter(e=>e.required||e.state!==`empty`);return{shown:n,folded:e.length-n.length}},Dt=(e,t,n,r=52)=>r+Math.max(e,typeof t==`number`?t:t.length)*26+(n?wt:0)+Tt,Ot={string:()=>S(`typeString`),integer:()=>S(`typeInteger`),number:()=>S(`typeNumber`),boolean:()=>S(`typeBoolean`),object:()=>S(`typeObject`),array:()=>S(`typeArray`),null:()=>S(`typeNull`),any:()=>S(`typeAny`)},W=e=>e.title===void 0?e.kinds===`any`?Ot.any():e.kinds.map(e=>Ot[e]()).reduce((e,t)=>S(`typeOr`,{first:e,second:t})):e.title,G=e=>e.kinds===`any`?`any`:e.kinds[0],kt={status:()=>S(`outputStatus`),headers:()=>S(`outputHeaders`),body:()=>S(`outputBody`),record:()=>S(`outputRecord`),resource:()=>S(`outputResource`),key:()=>S(`outputKey`),records:()=>S(`outputRecords`),message_id:()=>S(`outputMessageId`)},At=(e,t=!1,n=!1)=>{if(e.length===0)return S(t?`pinRunInput`:`pinResult`);if(e.length===1&&e[0]===`#status`)return S(`stepStatusType`);let r=e.at(-1);return n||!Object.hasOwn(kt,r)?r:kt[r]()},jt=e=>e===`#condition`?S(`onlyWhen`):Le(e),Mt={"=":()=>S(`conditionEquals`),"!=":()=>S(`conditionNotEquals`),">":()=>S(`conditionGreater`),"<":()=>S(`conditionLess`),matches:()=>S(`conditionMatches`),and:()=>S(`conditionAnd`),or:()=>S(`conditionOr`),not:()=>S(`conditionNot`),expression:()=>S(`conditionExpression`)},Nt=e=>Mt[e](),Pt=({part:e})=>Nt(e.kind===`compare`||e.kind===`logic`?e.op:e.kind),Ft={SUCCEEDED:()=>S(`statusSucceeded`),FAILED:()=>S(`statusFailed`),TIMED_OUT:()=>S(`statusTimedOut`),ABORTED:()=>S(`statusAborted`),SKIPPED:()=>S(`statusSkipped`)},It=e=>Object.hasOwn(Ft,e)?Ft[e]():e,Lt=34,Rt=280,zt=8,Bt=(e,t)=>e.kind===`condition`?{shown:e.inputs,folded:0}:e.kind===`make`?Et(e.inputs,t||e.inputs.length<=zt):{shown:[],folded:0},Vt=(e,t,n)=>{let r=new Set(t.filter(t=>t.source===e.id).map(e=>e.sourceHandle)),i=e.outputs.filter(e=>r.has(V(e.path))),a=i.length>0&&i.length<e.outputs.length;return n||!a?{shown:e.outputs,folded:0,foldable:a}:{shown:i,folded:e.outputs.length-i.length,foldable:a}},Ht=e=>106+e*26+8,Ut=(e,t,n)=>{let r=new Map;for(let i of e.nodes){if(i.kind===`state`&&h(i.state))continue;let{shown:e,folded:a}=Et(t.inputs.get(i.id)??[],n.has(i.id));r.set(i.id,{width:296,height:Dt(e.length,t.outputs.get(i.id)??[],a>0||n.has(i.id))})}for(let e of t.pure){if(e.kind===`condition`&&e.part.kind===`expression`){r.set(e.id,{width:216,height:Ht(e.inputs.length)});continue}if(e.kind===`select`){r.set(e.id,{width:Rt,height:Dt(e.part.cases.length+3,1,!1,Lt)});continue}if(e.kind===`break`){let i=Vt(e,t.edges,n.has(e.id));r.set(e.id,{width:216,height:Dt(0,i.shown.length,i.foldable,Lt)});continue}let{shown:i,folded:a}=Bt(e,n.has(e.id));r.set(e.id,{width:216,height:Dt(i.length,1,e.kind===`make`&&(a>0||n.has(e.id)),Lt)})}return r},Wt=(e,t)=>e+t*26+13,Gt=13,Kt=38,qt=(e,t,n)=>{let r=new Map;for(let i of e.nodes){if(i.kind===`state`&&h(i.state))continue;let{shown:e}=Et(t.inputs.get(i.id)??[],n.has(i.id));r.set(i.id,[...e.map((e,t)=>({handle:B(e.key),side:`in`,y:Wt(52,t)})),...(t.outputs.get(i.id)??[]).map((e,t)=>({handle:V(e.path),side:`out`,y:Wt(52,t)}))])}for(let e of t.pure){let i=(e,t=Kt)=>e.map((e,n)=>({handle:B(e.key),side:`in`,y:Wt(t,n)}));if(e.kind===`break`){let{shown:i}=Vt(e,t.edges,n.has(e.id));r.set(e.id,[{handle:$e,side:`in`,y:Gt},...i.map((e,t)=>({handle:V(e.path),side:`out`,y:Wt(Kt,t)}))])}else if(e.kind===`make`)r.set(e.id,[{handle:et,side:`out`,y:Gt},...i(Bt(e,n.has(e.id)).shown)]);else if(e.kind===`select`)r.set(e.id,[{handle:nt,side:`out`,y:Gt},...i(e.inputs)]);else{let t=e.part.kind===`expression`?Kt+64+4:Kt;r.set(e.id,[{handle:tt,side:`out`,y:Gt},...i(e.inputs,t)])}}return r},Jt=(e,t)=>{let n=e.nodes.find(e=>e.id===(t.kind===`break`?t.source:t.target));return n?.kind===`state`?n.parent:void 0},Yt=`trigger`,K=e=>e===``?Yt:`state:${e}`,q=e=>e!==Yt&&!e.startsWith(`state:`),J=e=>e===Yt?``:e.startsWith(`state:`)?e.slice(6):e,Xt=(e,t,n)=>{let{shown:r,folded:i}=Et(e.inputs.get(t)??[],n);return{inputs:r,outputs:e.outputs.get(t)??[],folded:i,open:n}},Zt=(e,t,n,r,i,a,o,s,c=!1)=>e.nodes.map(e=>{let l=t?.get(e.id)??{x:0,y:0,...U},u=e.kind===`state`?e.parent:void 0,d=e.kind===`trigger`?Ve(e.trigger,a):Fe(e.state,a),f=e.kind===`state`&&Ge(e.state,a),p=e.kind===`state`?S(`stateNode`,{name:e.name,type:d}):S(`triggerNode`,{trigger:d}),m=o?.get(e.id)??[],h=[...f?[S(`cacheForcedAgainst`)]:[],...m.map(e=>e.message)];return{id:K(e.id),type:e.kind,ariaLabel:[p,...h].join(`, `),position:{x:l.x,y:l.y},width:l.width,height:l.height,measured:{width:l.width,height:l.height},data:{node:e,kind:d,problems:n.get(e.id)??[],...i?.has(e.id)&&{trace:i.get(e.id)},...f&&{cacheWarning:f},...m.length>0&&{warnings:m},...s&&{pins:Xt(s.data,e.id,s.open.has(e.id))},...c&&{dataOrder:c}},draggable:!1,deletable:e.kind===`state`,selected:e.id===r,...u!==void 0&&{parentId:K(u),extent:`parent`}}}),Qt=40,$t=e=>e.length>Qt?`${e.slice(0,39)}…`:e,en=e=>{if(e.kind==="default")return S(`otherwise`);if(e.kind===`catch`)return S(`onError`,{errors:e.label??``});if(e.kind===`rule`)return e.label?$t(e.label):S(`conditionToWrite`)},tn=e=>({id:e.id,source:K(e.source),sourceHandle:`out`,target:K(e.target),targetHandle:`in`,deletable:!1,data:{kind:e.kind,field:e.field,source:e.source},...e.kind===`status`&&{className:`pb-workflow-status`}}),nn=(e,t=!1)=>e.edges.map(e=>{if(t)return tn(e);let n=en(e);return{id:e.id,source:K(e.source),sourceHandle:e.kind,target:K(e.target),targetHandle:`in`,deletable:e.kind!==`start`,data:{kind:e.kind,field:e.field,source:e.source},...n!==void 0&&{label:n},...e.kind===`catch`&&{className:`pb-workflow-catch`}}}),rn=(e,t,n,r)=>t.pure.map(i=>{let a=n?.get(i.id)??{x:0,y:0,...U},o=Jt(e,i),{shown:s,folded:c}=Bt(i,r.has(i.id)),l=i.kind===`break`?Vt(i,t.edges,r.has(i.id)):void 0,u=e.nodes.find(e=>e.id===(i.kind===`break`?i.source:i.target));return{id:i.id,type:`pure`,position:{x:a.x,y:a.y},width:a.width,height:a.height,measured:{width:a.width,height:a.height},data:{node:u,kind:i.kind,problems:[],pureData:{pure:i,shownInputs:s,shownOutputs:l?.shown??[],folded:l?.folded??c,open:r.has(i.id),foldable:l?l.foldable:c>0||r.has(i.id)}},draggable:!1,deletable:!0,...o!==void 0&&{parentId:K(o),extent:`parent`}}}),an=(e,t)=>{let n=e=>{let n=t.pure.find(t=>t.id===e);return n?n.kind===`break`?n.source:n.target:e},r=new Set(t.edges.map(e=>`${n(e.source)}\n${n(e.target)}`));return nn({...e,edges:e.edges.filter(e=>e.source!==``&&!r.has(`${e.source}\n${e.target}`))},!0)},on=e=>{let t=new Set(e.pure.map(e=>e.id)),n=e=>t.has(e)?e:K(e);return e.edges.map(e=>({id:e.id,source:n(e.source),sourceHandle:e.sourceHandle,target:n(e.target),targetHandle:e.targetHandle,deletable:!e.expression,data:{kind:`data`,wire:e},className:`pb-wire pb-wire-${G(e.type)}${e.expression?` pb-wire-expression`:``}`}))},sn=(0,R.createContext)(void 0),cn={succeeded:`green`,caught:`amber`,retrying:`amber`,failed:`red`,current:`blue`},ln=(0,R.createContext)(void 0),Y=()=>(0,R.useContext)(ln),un=e=>{if(e.options)return`choice`;if(e.type.kinds===`any`)return;let[t,...n]=e.type.kinds.filter(e=>e!==`null`);if(t===`string`&&n.every(e=>e===`integer`||e===`number`))return`string`;if(!(n.length>0))return t===`integer`||t===`number`?`number`:t===`boolean`?`boolean`:void 0},dn=e=>e.trim()===``?void 0:Number.isNaN(Number(e))?e:Number(e),fn=({name:e,className:t,value:n,onChange:r})=>{let[i,a]=(0,R.useState)();return(0,H.jsx)(f,{"aria-label":e,wrapperClassName:`${t} h-6 w-[55%] px-1.5`,className:`text-xs`,inputMode:`decimal`,value:i??(n===void 0?``:String(n)),onChange:e=>{a(e.target.value),r(dn(e.target.value))},onBlur:()=>a(void 0)})},pn=({pin:e,label:t,onChange:n})=>{if(e.state===`wired`||e.state===`made`||e.key===`#condition`&&e.state!==`expression`)return null;if(e.state===`expression`)return(0,H.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-muted px-1 font-mono text-xs text-muted-foreground`,title:S(`pinExpression`,{expression:String(e.value)}),children:`ƒ`});let r=un(e);if(e.state===`literal`&&typeof e.value==`object`)return(0,H.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,title:S(`pinObjectValue`),children:`{…}`});if(!r)return e.state===`literal`?(0,H.jsx)(`span`,{className:`ml-auto min-w-0 truncate text-xs text-muted-foreground`,children:String(e.value)}):null;let i=S(`inputValue`,{label:t});if(!n)return(0,H.jsx)(`span`,{className:`ml-auto min-w-0 truncate text-xs text-muted-foreground`,children:e.value===void 0?``:String(e.value)});let a=`nodrag nopan nowheel ml-auto min-w-0`;return r===`boolean`?(0,H.jsx)(T,{className:a,checked:e.value===!0,label:i,onChange:e=>n(e)}):r===`choice`?(0,H.jsxs)(l,{"aria-label":i,className:`${a} h-6 max-w-[55%] px-1 py-0 text-xs`,value:typeof e.value==`string`?e.value:``,onChange:e=>n(e.target.value===``?void 0:e.target.value),children:[(0,H.jsx)(`option`,{value:``}),e.options.map(t=>(0,H.jsx)(`option`,{value:t,children:e.statuses?It(t):t},t))]}):r===`number`?(0,H.jsx)(fn,{name:i,className:a,value:e.value,onChange:n}):(0,H.jsx)(f,{"aria-label":i,wrapperClassName:`${a} h-6 w-[55%] px-1.5`,className:`text-xs`,value:e.value===void 0?``:String(e.value),onChange:e=>n(e.target.value===``?void 0:e.target.value)})},mn=e=>`pb-pin pb-pin-${G(e.type)}`,hn=({pin:e,step:t,keys:n,connectable:r,name:i,onValue:a,bare:o=!1})=>{let s=Y(),c=i??jt(e.key);return(0,H.jsxs)(`div`,{className:`relative flex h-[26px] items-center gap-1.5 pr-2 pl-3`,children:[(0,H.jsx)(L,{id:B(e.key),type:`target`,position:I.Left,isConnectable:r,className:mn(e)}),(0,H.jsxs)(`span`,{className:`min-w-0 shrink truncate text-xs text-body`,title:S(`pinTypeTitle`,{label:c,type:W(e.type)}),children:[c,e.required&&(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-danger-text`,children:`*`})]}),!o&&(0,H.jsx)(pn,{pin:e,label:c,...s&&r&&{onChange:a??(e=>s.setArgument(t,n,e))}})]})},gn=({pin:e,connectable:t,trigger:n=!1,field:r=!1})=>{let i=At(e.path,n,r);return(0,H.jsxs)(`div`,{className:`relative flex h-[26px] items-center justify-end pr-3 pl-2`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate text-xs text-body`,title:S(`pinTypeTitle`,{label:i,type:W(e.type)}),children:i}),(0,H.jsx)(L,{id:V(e.path),type:`source`,position:I.Right,isConnectable:t,className:mn(e)})]})},_n=({inputs:e,outputs:t,connectable:n})=>{let r=(e,t)=>({top:`${(e+1)*100/(t+1)}%`});return(0,H.jsxs)(H.Fragment,{children:[e.map((t,i)=>(0,H.jsx)(L,{id:B(t.key),type:`target`,position:I.Left,isConnectable:n,className:mn(t),style:r(i,e.length),title:S(`pinTypeTitle`,{label:jt(t.key),type:W(t.type)})},t.key)),t.map((e,i)=>(0,H.jsx)(L,{id:V(e.path),type:`source`,position:I.Right,isConnectable:n,className:mn(e),style:r(i,t.length),title:S(`pinTypeTitle`,{label:At(e.path),type:W(e.type)})},e.path.join(`/`)))]})},vn=({node:e,folded:t,open:n,fields:r=!1})=>{let i=Y();return t===0&&!n?null:(0,H.jsx)(`button`,{type:`button`,className:`nodrag h-6 w-full px-3 text-left text-xs text-muted-foreground hover:text-foreground`,onClick:()=>i?.toggleOpen(e),disabled:!i,children:r?n?S(`foldLessFields`):S(`foldMoreFields`,{count:t}):n?S(`foldLess`):S(`foldMore`,{count:t})})},yn=({node:e,inputs:t,outputs:n,folded:r,open:i,editable:a,trigger:o=!1})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-[3fr_2fr]`,children:[(0,H.jsx)(`div`,{className:`min-w-0`,children:t.map(t=>(0,H.jsx)(hn,{pin:t,step:e,keys:[t.key],connectable:a},t.key))}),(0,H.jsx)(`div`,{className:`min-w-0`,children:n.map(e=>(0,H.jsx)(gn,{pin:e,connectable:a,trigger:o},JSON.stringify(e.path)))})]}),(0,H.jsx)(vn,{node:e,folded:r,open:i})]}),bn=(0,R.createContext)(void 0),xn=`nodrag absolute -top-4 -right-4 z-10`,Sn=({node:e,name:t})=>{let n=(0,R.useContext)(bn);return n?(0,H.jsx)(i,{size:`icon`,className:xn,"aria-label":S(`unpin`,{name:t}),title:S(`unpinHelp`),onClick:t=>{t.stopPropagation(),n(e)},children:(0,H.jsx)(ke,{className:`size-3.5`,"aria-hidden":!0})}):(0,H.jsxs)(`span`,{className:s(xn,`inline-flex size-7 items-center justify-center rounded-md border border-border-strong bg-background text-muted-foreground shadow-sm`),title:S(`movedByHand`),children:[(0,H.jsx)(ke,{className:`size-3.5`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`sr-only`,children:S(`movedByHand`)})]})},X=[18,38],Cn=e=>{if(e.Type===`Choice`)return[{kind:`rule`,top:X[0],label:S(`when`)},{kind:`default`,top:X[1],label:S(`otherwise`)}];let t=[`Task`,`Pass`,`Wait`,`Map`,`Block`].includes(e.Type)?[{kind:`next`,top:X[0]}]:[],n=e.Type===`Task`||e.Type===`Map`||e.Type===`Block`?[{kind:`catch`,top:X[t.length],label:S(`onErrorHandle`)}]:[];return[...t,...n]},wn=(e,t,n)=>{let r=(0,R.useContext)(sn);if(!r||!t)return{};let i=t=>{t.stopPropagation(),r(e)},a=n?S(`addStepAtNamedHandle`,{handle:n}):S(`addStepAtHandle`);return{role:`button`,tabIndex:0,"aria-label":a,title:a,onClick:i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(e))}}},Tn=({source:e,path:t,editable:n})=>(0,H.jsx)(L,{id:e.kind,type:`source`,position:I.Right,isConnectable:n,style:{top:e.top},className:s(`pb-workflow-exec`,`pb-workflow-handle-${e.kind}`),...wn({kind:e.kind,source:t},n,e.label),children:e.label&&(0,H.jsx)(`span`,{className:`pb-workflow-handle-label`,children:e.label})}),En=({state:e,path:t,editable:n})=>Cn(e).map(e=>(0,H.jsx)(Tn,{source:e,path:t,editable:n},e.kind)),Dn=({count:e})=>e>0&&(0,H.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-danger-text`,title:S(`problemCount`,{count:e}),children:[(0,H.jsx)(d,{className:`size-3.5`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:S(`problemCount`,{count:e})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,children:e})]}),On=({label:e})=>(0,H.jsxs)(`span`,{className:`inline-flex shrink-0 items-center text-warning-text`,title:e,children:[(0,H.jsx)(d,{className:`size-3.5`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:e})]}),kn=({trace:e})=>(0,H.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end gap-0.5`,children:[e.changed?(0,H.jsx)(`span`,{title:S(`changedSinceRun`),className:`rounded-full border border-dashed px-1.5 text-xs text-muted-foreground`,children:S(`changedShort`)}):(0,H.jsx)(E,{tone:cn[e.status],children:Ue(e.status)}),e.steps>1&&(0,H.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:S(`traceSteps`,{count:e.steps})})]}),An=(e,t,n)=>s(`rounded-lg border bg-background text-body shadow-sm`,t>0||n?.status===`failed`?`border-danger`:`border-border-strong`,e&&`ring-2 ring-primary/40`),jn=({name:e,kind:t,problems:n,first:r,trace:i,warnings:a=[]})=>(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:[t,r&&(0,H.jsxs)(`span`,{className:`text-primary-text`,children:[` · `,S(`startsHere`)]})]}),a.length>0&&(0,H.jsx)(On,{label:a.join(`
|
|
3
3
|
`)}),(0,H.jsx)(Dn,{count:n}),i&&(0,H.jsx)(kn,{trace:i})]}),(0,H.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:e})]}),Mn=()=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(L,{id:`in`,type:`target`,position:I.Left,isConnectable:!1,className:`pb-workflow-side`,style:{top:X[0]}}),(0,H.jsx)(L,{id:`out`,type:`source`,position:I.Right,isConnectable:!1,className:`pb-workflow-side`,style:{top:X[0]}})]}),Nn=({condition:e})=>e!==void 0&&(0,H.jsx)(`span`,{className:`absolute top-1 right-6 max-w-[45%] truncate rounded bg-muted px-1 text-[0.625rem] text-muted-foreground`,title:e,children:S(`onlyWhenBadge`)}),Pn=({id:e,data:t,selected:n,isConnectable:r})=>{let{node:i,kind:a,problems:o,trace:c,cacheWarning:l,warnings:u=[],pins:d,dataOrder:f,moved:p}=t;return i.kind===`state`?(0,H.jsxs)(`div`,{className:s(An(n,o.length,c),`h-full`,h(i.state)&&`bg-muted/40`),children:[p&&(0,H.jsx)(Sn,{node:e,name:i.name}),(0,H.jsxs)(`div`,{className:`relative h-[52px] py-2 pr-6 pl-4`,children:[f?(0,H.jsx)(Mn,{}):(0,H.jsx)(L,{id:`in`,type:`target`,position:I.Left,isConnectable:r,className:`pb-workflow-exec`,style:{top:X[0]}}),f&&(0,H.jsx)(Nn,{condition:i.state.Condition}),(0,H.jsx)(jn,{name:i.name,kind:a,problems:o.length,first:i.first&&i.parent!==void 0,trace:c,warnings:[...l?[S(`cacheForcedAgainst`)]:[],...u.map(e=>e.message)]}),!f&&(0,H.jsx)(En,{state:i.state,path:i.id,editable:r}),d&&h(i.state)&&(0,H.jsx)(_n,{inputs:d.inputs,outputs:d.outputs,connectable:r})]}),d&&!h(i.state)&&(0,H.jsx)(yn,{node:i.id,inputs:d.inputs,outputs:d.outputs,folded:d.folded,open:d.open,editable:r})]}):null},Fn=({id:e,data:t,selected:n,isConnectable:r})=>{let{node:i,kind:a,problems:o,pins:c,dataOrder:l,moved:u}=t,d=wn({kind:`start`,source:i.id},r&&!l);return i.kind===`trigger`?(0,H.jsxs)(`div`,{className:s(An(n,o.length),`h-full border-dashed`),children:[u&&(0,H.jsx)(Sn,{node:e,name:S(`trigger`)}),(0,H.jsxs)(`div`,{className:`relative h-[52px] py-2 pr-6 pl-4`,children:[(0,H.jsx)(jn,{name:a,kind:S(`trigger`),problems:o.length}),l?(0,H.jsx)(L,{id:`out`,type:`source`,position:I.Right,isConnectable:!1,className:`pb-workflow-side`,style:{top:X[0]}}):(0,H.jsx)(L,{id:`start`,type:`source`,position:I.Right,isConnectable:r,className:`pb-workflow-exec`,style:{top:X[0]},...d})]}),c&&(0,H.jsx)(yn,{node:i.id,inputs:[],outputs:c.outputs,folded:0,open:!1,editable:r,trigger:!0})]}):null},In=`protobase:workflow-graph-view`,Ln=e=>r(()=>e().getItem(`protobase:workflow-graph-view`),null)===`simple`?`simple`:`pins`,Rn=(e,t)=>r(()=>t===`pins`?e().removeItem(In):e().setItem(In,t),void 0),zn=()=>localStorage,Bn=()=>{let[e,t]=(0,R.useState)(()=>Ln(zn));return[e,e=>{t(e),Rn(zn,e)}]},Vn=(e,t)=>e.part.kind===`not`?S(`conditionNotSide`):e.part.kind===`matches`?S(t===`0`?`conditionMatchesText`:`conditionMatchesPattern`):e.part.kind===`logic`?String.fromCharCode(65+Number(t)%26):S(t===`0`?`conditionSideA`:`conditionSideB`),Hn=({node:e,source:t})=>{let n=Y(),[r,i]=(0,R.useState)(),a=t.trim();return(0,H.jsx)(`textarea`,{"aria-label":S(`conditionExpressionText`),className:`nodrag nopan nowheel block w-full resize-none rounded border border-border bg-background px-1.5 py-1 font-mono text-xs text-foreground`,style:{height:64},spellCheck:!1,readOnly:!n,value:r??a,onChange:e=>i(e.target.value),onBlur:()=>{i(void 0);let t=r?.trim();t!==void 0&&t!==a&&n?.setCondition(e.target,t===``?void 0:`{% ${t} %}`)}})},Un=e=>e.replace(/^\$states\.context\.Steps\./,``).replace(/^\$states\.context\.Execution\.Input/,`input`),Wn=({node:e,editable:t})=>{let n=Y(),[r,i]=(0,R.useState)(),a=S(`conditionMatchesPattern`),o=String(e.inputs[1]?.value??``);return(0,H.jsxs)(`div`,{className:`relative flex h-[26px] items-center gap-1.5 pr-2 pl-3`,children:[(0,H.jsx)(`span`,{className:`min-w-0 shrink truncate text-xs text-body`,children:a}),(0,H.jsx)(f,{"aria-label":S(`inputValue`,{label:a}),wrapperClassName:`nodrag nopan nowheel ml-auto h-6 w-[60%] min-w-0 px-1.5`,className:`font-mono text-xs`,value:r??o,disabled:!n||!t,onChange:t=>{i(t.target.value),t.target.value!==``&&n?.setConditionSide(e.target,[...e.at,1],t.target.value)},onBlur:()=>i(void 0)})]})},Gn=({node:e,editable:t})=>{let n=Y(),r=(0,H.jsx)(L,{id:tt,type:`source`,position:I.Right,isConnectable:!1,className:`pb-pin pb-pin-boolean`,style:{top:13}});return e.part.kind===`expression`?(0,H.jsxs)(`div`,{className:`relative grid gap-1 px-2 pt-1`,children:[r,(0,H.jsx)(Hn,{node:e,source:e.part.source}),(0,H.jsx)(`div`,{className:`-mx-2`,children:e.inputs.map(e=>(0,H.jsxs)(`div`,{className:`relative flex h-[26px] items-center pr-2 pl-3`,children:[(0,H.jsx)(L,{id:B(e.key),type:`target`,position:I.Left,isConnectable:!1,className:`pb-pin pb-pin-${G(e.type)}`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-body`,title:S(`pinTypeTitle`,{label:e.key,type:W(e.type)}),children:Un(e.key)})]},e.key))})]}):(0,H.jsxs)(`div`,{className:`relative pt-1`,children:[r,e.inputs.map(r=>e.part.kind===`matches`&&r.key===`1`?(0,H.jsx)(Wn,{node:e,editable:t},r.key):(0,H.jsx)(hn,{pin:r,step:e.target,keys:[],name:Vn(e,r.key),bare:e.part.kind===`logic`&&Number(r.key)===e.part.sides.length,connectable:t,onValue:t=>n?.setConditionSide(e.target,[...e.at,Number(r.key)],t??``)},r.key))]})},Kn=(e,t)=>typeof t==`number`&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):typeof t==`boolean`&&(e===`true`||e===`false`)?e===`true`:e,qn=`nodrag nopan nowheel h-6 min-w-0 px-1.5`,Jn=({label:e,value:t,onChange:n,disabled:r})=>(0,H.jsx)(f,{"aria-label":e,wrapperClassName:`${qn} flex-1`,className:`text-xs`,value:String(t),disabled:r,onChange:e=>n(Kn(e.target.value,t))}),Yn=({node:e,editable:t})=>{let n=Y(),r=!n||!t,i=t=>n?.setArgument(e.target,[e.key],D(t)),{part:a}=e,o=(e,t)=>i({...a,cases:a.cases.map((n,r)=>r===e?{...n,...t}:n)});return(0,H.jsxs)(`div`,{className:`relative pt-1`,children:[(0,H.jsx)(L,{id:nt,type:`source`,position:I.Right,isConnectable:!1,className:`pb-pin pb-pin-${G(e.type)}`,style:{top:13}}),e.inputs.map(n=>(0,H.jsx)(hn,{pin:n,step:e.target,keys:[],name:S(`selectInput`),connectable:t,onValue:e=>i({...a,operand:{value:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:``}})},n.key)),a.cases.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex h-[26px] items-center gap-1 pr-2 pl-3`,children:[(0,H.jsx)(Jn,{label:S(`selectWhen`,{case:t+1}),value:e.when,disabled:r,onChange:e=>o(t,{when:e})}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-muted-foreground`,children:`→`}),(0,H.jsx)(Jn,{label:S(`selectThen`,{case:t+1}),value:e.then,disabled:r,onChange:e=>o(t,{then:e})}),(0,H.jsx)(`button`,{type:`button`,className:`nodrag shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-40`,"aria-label":S(`selectRemoveCase`,{case:t+1}),disabled:r||a.cases.length===1,onClick:()=>i({...a,cases:a.cases.filter((e,n)=>n!==t)}),children:(0,H.jsx)(b,{className:`size-3`,"aria-hidden":!0})})]},t)),(0,H.jsxs)(`div`,{className:`flex h-[26px] items-center gap-1 pr-2 pl-3`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-body`,children:S(`selectOtherwise`)}),(0,H.jsx)(Jn,{label:S(`selectOtherwise`),value:a.otherwise,disabled:r,onChange:e=>i({...a,otherwise:e})})]}),(0,H.jsx)(`button`,{type:`button`,className:`nodrag h-6 w-full px-3 text-left text-xs text-muted-foreground hover:text-foreground`,disabled:r,onClick:()=>i({...a,cases:[...a.cases,{when:``,then:``}]}),children:S(`selectAddCase`)})]})},Xn=e=>e.kind===`condition`?Pt(e):e.kind===`select`?S(`selectTitle`):e.kind===`break`?S(`breakTitle`,{type:W(e.type)}):S(`makeTitle`,{type:W(e.type)}),Zn=({pure:e})=>(0,H.jsx)(`div`,{className:`truncate border-b px-3 py-1.5 text-xs font-medium text-foreground`,children:Xn(e)}),Qn=({id:e,data:t,selected:n,isConnectable:r})=>{let{pureData:i,moved:a}=t;if(!i)return null;let{pure:o,shownInputs:c,shownOutputs:l,folded:u,open:d,foldable:f}=i;return(0,H.jsxs)(`div`,{className:s(`h-full rounded-lg border border-dashed border-border-strong bg-background text-body shadow-sm`,n&&`ring-2 ring-primary/40`),children:[a&&(0,H.jsx)(Sn,{node:e,name:Xn(o)}),(0,H.jsx)(Zn,{pure:o}),o.kind===`condition`?(0,H.jsx)(Gn,{node:o,editable:r}):o.kind===`select`?(0,H.jsx)(Yn,{node:o,editable:r}):o.kind===`break`?(0,H.jsxs)(`div`,{className:`relative pt-1`,children:[(0,H.jsx)(L,{id:$e,type:`target`,position:I.Left,isConnectable:!1,className:`pb-pin pb-pin-${G(o.type)}`,style:{top:13}}),l.map(e=>(0,H.jsx)(gn,{pin:e,connectable:r,field:!0},JSON.stringify(e.path))),f&&(0,H.jsx)(vn,{node:o.id,folded:u,open:d,fields:!0})]}):(0,H.jsxs)(`div`,{className:`relative pt-1`,children:[(0,H.jsx)(L,{id:et,type:`source`,position:I.Right,isConnectable:!1,className:`pb-pin pb-pin-${G(o.type)}`,style:{top:13}}),c.map(e=>(0,H.jsx)(hn,{pin:e,step:o.target,keys:[o.key,e.key],connectable:r},e.key)),(0,H.jsx)(vn,{node:o.id,folded:u,open:d})]})]})},$n=({offer:e,onClose:t})=>(0,H.jsxs)(`div`,{role:`dialog`,"aria-label":S(`pureOfferTitle`),className:`absolute z-10 grid gap-1 rounded-md border bg-background p-1 shadow-md`,style:{left:e.x,top:e.y},children:[e.choices.map((e,n)=>(0,H.jsx)(i,{size:`sm`,variant:`ghost`,className:`justify-start`,autoFocus:n===0,onClick:()=>{e.add(),t()},children:e.label},e.label)),(0,H.jsx)(i,{size:`sm`,variant:`ghost`,onClick:t,children:S(`pureOfferClose`)})]}),er=e=>typeof e==`object`&&!!e&&!Array.isArray(e),tr=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),Z={kinds:[`boolean`]},nr=e=>e.sides.flatMap(e=>M(e)?nr(e):`read`in e?[e.read]:[]),rr=e=>!M(e)&&`read`in e&&`step`in e.read.base&&tr(e.read.path,[`Status`]),ir=(e,t)=>{if(t&&t.kinds!==`any`){let e=t.kinds.filter(e=>e!==`null`);if(e.length===1&&[`string`,`integer`,`number`,`boolean`].includes(e[0]))return{kinds:e}}return{kinds:[typeof e==`number`?`number`:typeof e==`boolean`?`boolean`:`string`]}},ar=e=>{let t=new Map;for(let[n,r]of ge(e.stateMachine)){let i=`Assign`in r&&er(r.Assign)?r.Assign:{};for(let[r,a]of Object.entries(i)){let i=a===`{% $states.result %}`?c(e.stateMachine,n)?.join(`/`):void 0;t.set(r,t.has(r)||i===void 0?null:i)}}return t},or=(e,t,n=[])=>{let r=new Map(ge(e.stateMachine).map(([t,n])=>[c(e.stateMachine,t).join(`/`),n])),i=ce(e)===`data`,a=new Map([[``,y(e,t)],...[...r].map(([e,n])=>[e,[...ee(n,t),...i?[x]:[]]])]),o=new Map([...r].filter(([,e])=>i||e.Type===`Task`).map(([e,n])=>[e,[...i?[g(n)]:[],...v(n,t)]])),s=e=>[...r.keys()].find(t=>t.split(`/`).at(-1)===e),l=new Map,u=new Map,d=[],f=[],p=new Map,m=ar(e),h=(e,t,n,r=!1)=>{let i=`data:${e.node}|${e.handle}->${t}|${n}`;r&&p.has(i)||p.set(i,{id:i,source:e.node,sourceHandle:e.handle,target:t,targetHandle:n,type:e.type,...r&&{expression:!0}})},te=(e,t)=>{let n=e.find(e=>tr(e.path,t));return n||(n={path:t,type:F(void 0)},e.push(n)),n},b=(e,t)=>{let n=a.get(e),r=n.find(e=>tr(e.path,t)),i=n.some(e=>e.path.length>0&&e.path[0]!==`#status`);if(r||t.length===0||i&&t.length===1){let i=r??te(n,t);return{node:e,handle:V(i.path),type:i.type}}let o=S(e,t.slice(0,-1)),s=te(o.outputs,t.slice(-1));return{node:o.id,handle:V(s.path),type:s.type}},S=(n,i)=>{let a=Ye(n,i),o=l.get(a);if(o)return o;let s=ae(e,r.get(n),t,i),c={kind:`break`,id:a,source:n,path:i,type:F(s),outputs:ne(s).map(([e,t])=>({path:[e],type:F(t)}))};return l.set(a,c),h(b(n,i),a,$e),c},re=(e,t,n)=>{let r=ie(e);if(r)return h(r,t,n);for(let r of pe(e)){let e=T(r);e&&h(e,t,n,!0)}},ie=e=>{let t=me(e);return t&&T(t)},T=e=>{if(`step`in e.base){let t=s(e.base.step);return t===void 0||!a.has(t)?void 0:b(t,[C,...e.path])}let t=`input`in e.base?``:m.get(e.base.variable);return t==null||!a.has(t)?void 0:b(t,e.path)},E=e=>{if(M(e)||!(`read`in e))return;if(!rr(e))return T(e.read);let t=s(e.read.base.step);return t===void 0||!a.has(t)?void 0:b(t,[C])},D=(e,t,n,r)=>{let i=Ze(e,n),a=t.sides,o=a.map(E),s=a.map((e,n)=>{let r=String(n);if(M(e))return{key:r,type:Z,required:!1,value:void 0,state:`made`};if(`read`in e)return{key:r,type:o[n]?.type??F(void 0),required:!1,value:fe(e.read),state:`wired`};if(`pattern`in e)return{key:r,type:{kinds:[`string`]},required:!1,value:e.pattern,state:`literal`};if(t.kind===`matches`)return{key:r,type:{kinds:[`string`]},required:!1,value:e.value,state:`literal`};if(t.kind!==`compare`)return{key:r,type:Z,required:!1,value:e.value,state:`literal`};let i=a[1-n];return rr(i)?{key:r,type:{kinds:[`string`]},required:!1,value:e.value,state:`literal`,options:j,statuses:!0}:{key:r,type:ir(e.value,o[1-n]?.type),required:!1,value:e.value,state:`literal`}});t.kind===`logic`&&s.push({key:String(a.length),type:Z,required:!1,value:void 0,state:`empty`}),d.push({kind:`condition`,id:i,target:e,at:n,part:t,inputs:s}),h({node:i,handle:tt,type:Z},r.node,r.handle),a.forEach((t,r)=>{M(t)?D(e,t,[...n,r],{node:i,handle:B(String(r))}):o[r]&&h(o[r],i,B(String(r)))})},O=(e,t)=>{let n=A(t),r={node:e,handle:B(w)};if(n&&nr(n).every(e=>E({read:e})))return D(e,n,[],r);let i=Ze(e,[]),a=pe(t).flatMap(e=>{let t=E({read:e});return t?[{read:e,source:t}]:[]});d.push({kind:`condition`,id:i,target:e,at:[],part:{kind:`expression`,source:se(t)},inputs:a.map(({read:e,source:t})=>({key:le(e),type:t.type,required:!1,value:fe(e),state:`wired`}))}),h({node:i,handle:tt,type:Z},r.node,r.handle);for(let{read:e,source:t}of a)h(t,i,B(le(e)),!0)},k=(e,t)=>{let n=oe(t.value),r=n&&E(n.operand);if(!n||`read`in n.operand&&!r)return!1;let i=Qe(e,t.key),a=`read`in n.operand?{key:rt,type:r.type,required:!1,value:fe(n.operand.read),state:`wired`}:{key:rt,type:{kinds:[`string`]},required:!1,value:n.operand.value,state:`literal`};return f.push({kind:`select`,id:i,target:e,key:t.key,part:n,type:t.type,inputs:[a]}),h({node:i,handle:nt,type:t.type},e,B(t.key)),r&&h(r,i,B(rt)),!0},N=(e,n)=>{let i=Xe(e,n),a=u.get(i);if(a)return a;let s=o.get(e)?.find(e=>e.key===n),c=r.get(e),l=he(ue(c,t),[n]),d=er(s?.value)?s.value:{},f=new Set(Array.isArray(l?.required)?l.required:[]),p=ne(l).map(([e,t])=>_(e,t,d[e],f.has(e))),m=Object.keys(d).filter(e=>!p.some(t=>t.key===e)).map(e=>_(e,he(l,[e])??{},d[e],!1)),g={kind:`make`,id:i,target:e,key:n,type:s?.type??F(l),inputs:[...p,...m]};u.set(i,g),h({node:i,handle:et,type:g.type},e,B(n));for(let e of g.inputs)re(e.value,i,B(e.key));return g};for(let[e,t]of o)for(let[n,r]of t.entries()){if(r.key===`#condition`&&r.state===`expression`){t[n]={...r,state:`made`},O(e,r.value);continue}if(r.state===`expression`&&k(e,r)){t[n]={...r,state:`made`};continue}r.state===`made`&&N(e,r.key),(r.state===`wired`||r.state===`expression`)&&re(r.value,e,B(r.key))}for(let e of n)e.kind===`break`&&a.has(e.source)&&S(e.source,e.path),e.kind===`make`&&o.get(e.target)?.some(t=>t.key===e.key&&t.state!==`wired`&&t.state!==`expression`)&&N(e.target,e.key);return{inputs:o,outputs:a,pure:[...l.values(),...u.values(),...d,...f],edges:[...p.values()]}},sr=e=>e.reason===`notBefore`?S(`refuseNotBefore`,{step:e.step}):e.reason===`otherScope`?S(`refuseOtherScope`,{step:e.step}):e.reason===`shapesOutput`?S(`refuseShaped`,{step:e.step}):e.reason===`type`?S(`refuseType`,{source:W(e.source),target:W(e.target)}):S(`refuseNotPins`),Q=e=>it(e)!==void 0||at(e)!==void 0,$=(e,t)=>({node:J(e),handle:t??``}),cr=e=>e!==`any`&&e.includes(`object`),lr=(e,t)=>e.map(e=>({label:Nt(e),add:()=>t(e)})),ur=(e,t)=>{let n=e=>e.kind===`break`?Ye(e.source,e.path):Xe(e.target,e.key),r=e=>e.kind===`break`&&t.some(t=>t.kind===`break`&&t.source===e.source&&t.path.every((t,n)=>e.path[n]===t));return e.filter(e=>!r(e)&&!t.some(t=>t.id===n(e)))},dr=(e,t,n,r,i)=>{let a=r?.edits,[o,s]=(0,R.useState)([]),[c,l]=(0,R.useState)(new Set),[u,d]=(0,R.useState)(),f=(0,R.useRef)({definition:e,editing:r});(0,R.useEffect)(()=>{f.current={definition:e,editing:r}});let p=(0,R.useMemo)(()=>n&&or(e,n,o),[e,n,o]),m=ce(e)===`data`,h=(0,R.useMemo)(()=>{if(p)return{sizes:Ut(t,p,c),pure:p.pure.map(e=>({id:e.id,parent:Jt(t,e)})),wires:p.edges.map(e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),ports:qt(t,p,c),dataOrder:m}},[t,p,c,m]),g=r&&{setArgument:(t,n,i)=>r.onChange(r.edits.setArgument(e,t,n,i)),setConditionSide:(t,n,i)=>r.onChange(r.edits.setConditionSide(e,t,n,{value:i})),setCondition:(t,n)=>r.onChange(r.edits.setArgument(e,t,[`#condition`],n)),toggleOpen:e=>l(t=>t.has(e)?new Set([...t].filter(t=>t!==e)):new Set([...t,e]))},_=(t,n)=>{if(!p||!a||!Q(t.handle)||!Q(n.handle))return;let[r,i]=at(t.handle)?[t,n]:[n,t],o=a.wireRefusal(e,p,$(r.node,r.handle),$(i.node,i.handle));return o&&sr(o)},v=t=>!!(p&&a)&&a.wireRefusal(e,p,$(t.source,t.sourceHandle),$(t.target,t.targetHandle))===void 0,y=t=>{r&&p&&r.onChange(r.edits.connectData(e,p,$(t.source,t.sourceHandle),$(t.target,t.targetHandle)))},ee=(e,t,n)=>{if(!p||!a)return e;let r=e,i=n.flatMap(e=>{let t=e.data?.wire,n=t&&p.pure.find(e=>e.kind===`break`&&e.id===t.target||e.kind===`make`&&e.id===t.source);return n?[{id:n.id}]:[]}),o=[...t.filter(e=>q(e.id)),...i.filter(e=>!t.some(t=>t.id===e.id))],c=n.flatMap(e=>{let t=e.data?.wire;return t&&!o.some(e=>e.id===t.source||e.id===t.target)?[{wire:t}]:[]}),l=o.flatMap(e=>p.pure.filter(t=>t.id===e.id).map(e=>({pure:e}))),u=[...c,...l];for(let e of lt(p,u,e=>`wire`in e?ot(p,e.wire):st(e.pure)))r=`wire`in e?a.disconnectData(r,p,e.wire):a.removePure(r,p,e.pure);return o.length>0&&s(e=>ur(e,o.flatMap(e=>p.pure.filter(t=>t.id===e.id)))),r},te=(e,t)=>{let{definition:n,editing:r}=f.current;r?.onChange(r.edits.addSelect(n,e,t))},b=(e,t,n)=>{let{definition:r,editing:i}=f.current;i?.onChange(i.edits.addCondition(r,e,t,n))};return{data:p,open:c,layout:h,actions:g,check:_,isValid:v,connect:y,remove:ee,connectEnd:(e,t)=>{if(!p||!r||t.isValid||t.toHandle||!t.fromHandle?.id||!t.fromNode)return;let n=J(t.fromNode.id),a=t.fromHandle.id,o=`changedTouches`in e?e.changedTouches[0]:e,c=i.current?.getBoundingClientRect(),l={x:o.clientX-(c?.left??0),y:o.clientY-(c?.top??0)},u=at(a);if(u){let e=p.pure.find(e=>e.id===n),t=(e?.kind===`break`?e.outputs:p.outputs.get(n)??[]).find(e=>JSON.stringify(e.path)===JSON.stringify(u))?.type;if(!t||!cr(t.kinds))return;let r=e?.kind===`break`?{source:e.source,path:[...e.path,...u]}:{source:n,path:u};d({...l,choices:[{label:S(`breakTitle`,{type:W(t)}),add:()=>s(e=>[...e,{kind:`break`,...r}])}]});return}let f=it(a),m=p.pure.find(e=>e.id===n);if(m?.kind===`condition`){let e=m.inputs.find(e=>e.key===f);if(!e||e.state!==`literal`&&e.state!==`empty`||m.part.kind!==`logic`&&m.part.kind!==`not`)return;d({...l,choices:lr(r.edits.conditionChoices(!1),e=>b(m.target,[...m.at,Number(f)],e))});return}let h=f===void 0?void 0:p.inputs.get(n)?.find(e=>e.key===f);if(h?.key===`#condition`&&h.state===`empty`){d({...l,choices:lr(r.edits.conditionChoices(!0),e=>b(n,[],e))});return}if(h&&h.key!==`#condition`&&!cr(h.type.kinds)&&(h.state===`empty`||h.state===`literal`)){d({...l,choices:[{label:S(`selectOffer`),add:()=>te(n,h.key)}]});return}h&&cr(h.type.kinds)&&h.state!==`wired`&&h.state!==`expression`&&d({...l,choices:[{label:S(`makeTitle`,{type:W(h.type)}),add:()=>s(e=>[...e,{kind:`make`,target:n,key:h.key}])}]})},offer:u,closeOffer:()=>d(void 0)}},fr=(0,R.createContext)(void 0),pr=({fromX:e,fromY:t,toX:n,toY:r,fromPosition:i,toPosition:a,connectionStatus:o,fromNode:s,fromHandle:c,toNode:l,toHandle:u})=>{let d=(0,R.useContext)(fr),[f]=Ce({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:a}),p=o===`invalid`&&l&&u?.id&&c.id?d?.({node:s.id,handle:c.id},{node:l.id,handle:u.id}):void 0;return(0,H.jsxs)(`g`,{className:p?`pb-wire-refused`:void 0,children:[(0,H.jsx)(`path`,{d:f,fill:`none`,className:`react-flow__connection-path`}),p&&(0,H.jsx)(`foreignObject`,{x:n+12,y:r-30,width:260,height:28,className:`overflow-visible`,children:(0,H.jsx)(`div`,{className:`inline-block rounded border border-danger bg-danger-soft px-1.5 py-0.5 text-xs whitespace-nowrap text-danger-text shadow`,children:p})})]})},mr=(e,t)=>{let n=De(),[r,i]=(0,R.useState)(),a=(0,R.useMemo)(()=>JSON.stringify(xt(e,t)),[e,t]);return(0,R.useEffect)(()=>{if(!n)return;let e=!0;return Ct(n,JSON.parse(a)).then(t=>{e&&i(t)}),()=>{e=!1}},[n,a]),r},hr={state:Pn,trigger:Fn,pure:Qn},gr=e=>e?.kind===`state`?e.scope.join(`/`):``,_r=({laidOut:e,tidied:t})=>{let n=ve();return(0,R.useEffect)(()=>{e&&n.fitView({maxZoom:1,padding:.1})},[e,t]),null},vr=()=>{let e=ve(),t=be(e=>e.width),n=(0,R.useRef)(t);return(0,R.useEffect)(()=>{let r=n.current;if(n.current=t,r===0||t===0||t===r)return;let{x:i,y:a,zoom:o}=e.getViewport();e.setViewport({x:i+(t-r)/2,y:a,zoom:o})},[t,e]),null},yr=({laidOut:e,ids:t})=>{let n=Ee();return(0,R.useEffect)(()=>{e&&n(t)},[e]),null},br=new Map,xr=({definition:e,problems:t,warnings:n,selected:r,onSelect:o,onChange:s,edits:c,onAddAt:l,traces:d,types:f,schemas:p,fills:h=!1,layout:g,onLayoutChange:_})=>{let v=s&&c&&{onChange:s,edits:c},y=(0,R.useMemo)(()=>ht(e),[e]),ee=(0,R.useRef)(null),[b,ne]=Bn(),x=dr(e,y,b===`pins`?p:void 0,v,ee),C=mr(y,x.layout),w=(0,R.useMemo)(()=>new Map(y.nodes.map(e=>[e.id,e])),[y]),T=JSON.stringify(g??{}),ae=(0,R.useMemo)(()=>re(T),[T]),E=ae[b],D=e=>_?.({...ae,[b]:e}),O=(0,R.useMemo)(()=>new Map([...y.nodes.map(e=>[e.id,ie(e.id)]),...(x.data?.pure??[]).map(e=>[e.id,ie(e.id,e)])]),[y,x.data]),k=(0,R.useMemo)(()=>new Map([...O].flatMap(([e,t])=>Object.hasOwn(E,t)?[[e,E[t]]]:[])),[O,E]),A=(0,R.useMemo)(()=>{if(!C)return;let e=new Map((x.data?.pure??[]).map(e=>[e.id,e]));return te(C,k,t=>{let n=w.get(t);return e.has(t)?Jt(y,e.get(t)):n?.kind===`state`?n.parent:void 0})},[C,k,w,y,x.data]),j=!!_,[M,oe]=(0,R.useState)(br),[se,N]=(0,R.useState)(0),P=ce(e)===`data`,[F,le]=(0,R.useState)(()=>new Set(r===void 0?[]:[K(r)]));(0,R.useEffect)(()=>{le(e=>r===void 0?e.size===1&&!q([...e][0])?new Set:e:e.has(K(r))?e:new Set([K(r)]))},[r]);let ue=(0,R.useMemo)(()=>[...Zt(y,A,t,r,d,f,n,x.data&&{data:x.data,open:x.open},P),...x.data?rn(y,x.data,A,x.open):[]].map(e=>{let t=M.get(e.id),n=k.has(J(e.id));return{...e,selected:F.has(e.id),draggable:j,...t&&{position:t},...n&&{data:{...e.data,moved:!0},...e.ariaLabel&&{ariaLabel:`${e.ariaLabel}, ${S(`movedByHand`)}`}}}}),[y,A,t,r,d,f,n,x.data,x.open,P,F,M,k,j]),[de,fe]=(0,R.useState)(),pe=(0,R.useMemo)(()=>[...P&&x.data?an(y,x.data):nn(y,P),...x.data?on(x.data):[]].map(e=>({...e,selected:e.id===de})),[y,x.data,de,P]),me=!!v,he=e=>{if(Q(e.sourceHandle)||Q(e.targetHandle))return Q(e.sourceHandle)&&Q(e.targetHandle)&&x.isValid(e);if(e.targetHandle!==`in`)return!1;let t=w.get(J(e.target)),n=w.get(J(e.source));return t?.kind===`state`&&gr(n)===gr(t)},ge=e=>{oe(br);let t=[...e].flatMap(([e,t])=>{let n=J(e),r=O.get(n),i=A?.get(n),a={x:Math.round(t.x),y:Math.round(t.y)};return r===void 0||!k.has(n)&&i&&Math.round(i.x)===a.x&&Math.round(i.y)===a.y?[]:[[r,a]]});t.length>0&&D({...E,...Object.fromEntries(t)})},_e=_&&(e=>{let t=O.get(J(e));t!==void 0&&D(m(E,t))}),ve=()=>{D({}),N(e=>e+1)},I=e=>{let t=new Map;for(let n of e){if(n.type!==`position`||!n.position||!j)continue;let e=n.position;n.dragging?oe(t=>new Map(t).set(n.id,e)):t.set(n.id,e)}t.size>0&&ge(t);let n=e.filter(e=>e.type===`select`);if(n.length===0)return;let i=new Set(F);for(let e of n)e.selected?i.add(e.id):i.delete(e.id);le(i);let[a]=i.size===1?[...i]:[],s=a===void 0||q(a)?void 0:J(a);if(s!==void 0&&(be||Ce.current))return r===void 0?void 0:o(void 0);s!==r&&o(s)},be=we(`Shift`),Ce=(0,R.useRef)(!1);return(0,H.jsx)(sn.Provider,{value:v?l:void 0,children:(0,H.jsx)(bn.Provider,{value:_e,children:(0,H.jsx)(ln.Provider,{value:x.actions,children:(0,H.jsx)(fr.Provider,{value:x.check,children:(0,H.jsxs)(`div`,{ref:ee,className:`relative h-full w-full`,children:[(0,H.jsxs)(Se,{className:`pb-workflow`,nodes:ue,edges:pe,nodeTypes:hr,nodesDraggable:j,nodeDragThreshold:4,selectNodesOnDrag:!1,nodesConnectable:me,connectOnClick:!1,connectionDragThreshold:4,edgesFocusable:me,elementsSelectable:!0,deleteKeyCode:me?[`Backspace`,`Delete`]:null,onNodesChange:I,onEdgesChange:e=>{for(let t of e)t.type===`select`&&(t.selected?fe(t.id):fe(e=>e===t.id?void 0:e))},isValidConnection:he,onConnect:t=>{if(v&&t.sourceHandle){if(Q(t.sourceHandle))return x.connect(t);v.onChange(v.edits.connect(e,t.sourceHandle,J(t.source),J(t.target)))}},onConnectEnd:x.connectEnd,connectionLineComponent:pr,onDelete:({nodes:t,edges:n})=>{if(!v)return;let r=t.filter(e=>!q(e.id)).map(e=>J(e.id)).filter(e=>e!==``),i=x.remove(e,t,n);for(let e of n){let t=e.data;t.kind!==`data`&&!r.includes(t.source)&&!r.includes(J(e.target))&&(i=v.edits.disconnect(i,t))}for(let e of r)r.some(t=>e.startsWith(`${t}/`))||(i=v.edits.removeState(i,e));v.onChange(i)},multiSelectionKeyCode:`Shift`,onSelectionStart:()=>void(Ce.current=!0),onSelectionEnd:()=>void(Ce.current=!1),onNodeClick:(e,t)=>!e.shiftKey&&!q(t.id)&&o(J(t.id)),onPaneClick:()=>o(void 0),zoomOnScroll:!0,panOnScroll:!1,panOnDrag:[0,1,2],selectionOnDrag:!1,selectionKeyCode:`Shift`,preventScrolling:!0,onPaneContextMenu:e=>e.preventDefault(),minZoom:.2,maxZoom:1.5,"aria-label":S(`canvas`),children:[(0,H.jsx)(Te,{gap:16}),p&&(0,H.jsx)(ye,{position:`top-left`,children:(0,H.jsx)(a,{label:S(`graphView`),value:b,onChange:ne,options:[{value:`pins`,label:S(`viewPins`)},{value:`simple`,label:S(`viewSimple`)}]})}),j&&Object.keys(E).length>0&&(0,H.jsx)(ye,{position:`top-right`,children:(0,H.jsxs)(i,{title:S(`tidyUpHelp`),onClick:ve,children:[(0,H.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),S(`tidyUp`)]})}),(0,H.jsx)(xe,{showInteractive:!1}),(0,H.jsx)(_r,{laidOut:C,tidied:se}),h&&(0,H.jsx)(vr,{}),(0,H.jsx)(yr,{laidOut:A,ids:ue.map(e=>e.id)})]}),x.offer&&(0,H.jsx)($n,{offer:x.offer,onClose:x.closeOffer})]})})})})})},Sr=e=>(0,H.jsx)(_e,{children:(0,H.jsx)(xr,{...e})});export{it as a,Le as c,Pe as d,je as f,ze as g,Be as h,ot as i,Ue as l,Ve as m,cn as n,at as o,Me as p,lt as r,Ke as s,Sr as t,Fe as u};
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=b59c6a62-e706-4f4c-9821-b045a5918caf
|
package/dist/shell/assets/{workflow-graph-editor-QT-3e-M9.js → workflow-graph-editor-DAJa4lq6.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{
|
|
2
|
-
//# debugId=
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{v as r}from"./api-provider-BJJrOoO4.js";import{vn as i}from"./app-VoTi41IN.js";import{E as a,S as o,_ as s,a as c,b as l,g as u,i as d,k as f,m as p,n as m,t as h,w as g,y as _}from"./step-catalog-CZY0ZpCC.js";import{E as v,S as y,b,n as x,v as S}from"./checkbox-DFfK432Y.js";import{t as C}from"./workflow-canvas-C1nGpi5w.js";import{t as w}from"./search-picker-BGpvJQRD.js";import{n as T,t as E}from"./graph-frame-PVfWqgbJ.js";var D=e(t(),1),O=e(n(),1),k=(e,t)=>{if(t===void 0||t===``)return[];let n=t.split(`/`);return b(v(e,t))?n:n.slice(0,-1)},A=({value:e,types:t,onChange:n,notice:b,layout:A,onLayoutChange:j})=>{let M=JSON.stringify(e??null),N=(0,D.useMemo)(()=>S(JSON.parse(M)),[M]),P=d(t),F=(0,D.useMemo)(()=>_(s(N,t,P)),[N,t,P]),I=(0,D.useMemo)(()=>l(N),[N]),[L,R]=(0,D.useState)(),[z,B]=(0,D.useState)(),V=(0,D.useMemo)(()=>m(t),[t]),H=L===``||L!==void 0&&v(N,L)?L:void 0,U=k(N,H),W=(e,t)=>{if(!n)return;let r=a(N,x(`newStep`));n(t?g(N,e,r,x(`newStep`),t):o(N,U,e,r,x(`newStep`))),R(y(t?f(t):U,r)),B(void 0)};return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(r,{onClick:()=>B(z?void 0:{}),"aria-expanded":!!z,children:[(0,O.jsx)(i,{className:`size-3.5`,"aria-hidden":!0}),U.length>0?x(`addStepInside`,{map:U.join(`/`)}):x(`addStep`)]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x(`connectHelp`)})]}),(0,O.jsx)(u,{problems:F.whole}),(0,O.jsx)(E,{canvas:(0,O.jsx)(C,{definition:N,problems:F.byNode,warnings:I,selected:H,onSelect:R,onChange:n,edits:c,onAddAt:e=>B({at:e}),types:t,schemas:P,layout:A,onLayoutChange:j}),panel:(0,O.jsxs)(O.Fragment,{children:[b,z?(0,O.jsx)(w,{autoFocus:!0,groups:V,onPick:e=>W(h(e.id),z.at)}):H===void 0?(0,O.jsx)(T,{children:x(`pickNode`)}):(0,O.jsx)(p,{definition:N,types:t,selected:H,problems:F.byNode.get(H)??[],warnings:I.get(H)??[],onChange:n,onSelect:R})]})})]})};export{A as WorkflowGraphEditor};
|
|
2
|
+
//# debugId=c025ae25-aba5-42fb-8a77-b164e59d537a
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{B as r,F as i,V as a,n as o,t as s}from"./use-app-address-B4Uk3nWy.js";import{rt as c}from"./vendor-3etemhgS.js";import{S as l,h as u,r as d,v as f,y as p}from"./api-provider-BJJrOoO4.js";import{En as m,Ft as h,It as g,Mt as _,Nt as v,Pt as y,Qt as b,Rt as x,Sn as S,Ut as C,Vt as w,_ as T,_n as E,a as D,c as O,d as ee,en as k,fn as te,hn as ne,in as A,jt as j,kt as re,nn as M,o as ie,rn as N,s as P,vn as F,yn as I,zt as ae}from"./app-VoTi41IN.js";import{B as oe,U as se,_ as L}from"./display-value-CIH2qfgQ.js";import{t as ce}from"./value-badge-Dpd8dRqq.js";import{A as le,C as ue,D as de,E as fe,O as pe,T as me,_ as he,a as ge,b as _e,c as ve,d as R,f as ye,g as be,h as xe,i as Se,k as Ce,l as we,m as Te,n as Ee,o as z,p as B,r as V,s as H,t as U,u as De,v as Oe,w as ke,x as Ae,y as je}from"./step-catalog-CZY0ZpCC.js";import{t as W}from"./createLucideIcon-DGm8SdFI.js";import{D as G,E as K,N as q,S as Me,T as J,_ as Ne,b as Pe,n as Y,v as Fe,w as Ie,y as Le}from"./checkbox-DFfK432Y.js";import{h as Re,m as ze,t as Be}from"./workflow-canvas-C1nGpi5w.js";import{t as X}from"./badge-OU9hb6yQ.js";import{d as Ve,f as He,p as Ue}from"./workflows-DlvOln9v.js";import{T as Z,a as We,w as Ge}from"./workflows-start-QUKfwFqf.js";import{t as Ke}from"./search-picker-BGpvJQRD.js";import{t as qe}from"./in-place-form-RWSQGEg4.js";import{a as Je,o as Ye,r as Xe,t as Ze}from"./step-panel-DhD80lsJ.js";var Qe={name:`shuffle`,size:24,node:[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]};Qe.node;var $e=W(Qe),Q=e(t(),1),$=e(n(),1),et=({types:e,placement:t,onAdd:n,onClose:r})=>{let i=(0,Q.useMemo)(()=>Ee(e),[e]);return(0,$.jsx)(P,{title:V(`addStepTitle`),onClose:r,takesFocus:!0,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,$.jsx)(Ke,{autoFocus:!0,groups:i,onPick:e=>n(U(e.id))})]})})},tt=`$states.context.Execution.Input`,nt=e=>(e.description??``).split(` · `)[0],rt=({definition:e,path:t,target:n,run:r,onAssign:i,onBack:a,onTestRun:o})=>{let s=x(r===void 0?void 0:String(r.id),!1),c=(0,Q.useMemo)(()=>s.data??[],[s.data]),l=(0,Q.useMemo)(()=>z(e,t),[e,t]),u=(0,Q.useMemo)(()=>l.filter(t=>!we(e,t)),[l,e]),d=l.filter(t=>we(e,t)),p=e=>c.filter(t=>Ye(t.scope,t.state)===e).at(-1)?.output,h=(0,Q.useMemo)(()=>r?[{title:V(`runInputGroup`),items:ve(r.input??{}).map(({path:e,sample:t})=>({id:`input:${e}`,title:e===``?V(`wholeValue`):e,description:t}))},...u.flatMap(t=>{let n=p(t);if(n==null)return[];let r=J(t).name;return[{title:r,items:ve(n).map(({path:n,sample:i})=>({id:`step:${t}\n${n}`,title:n===``?V(`wholeValue`):n,description:De(e,t).added?`${i} · ${V(`addsVariable`,{step:r})}`:i}))}]})]:[],[r,c,u,e]),g=(t,r)=>{if(t.startsWith(`input:`)){n.set(R(n.value,H(tt,t.slice(6)))),a();return}let[o,s]=t.slice(5).split(`
|
|
2
|
+
`),{variable:c,added:l}=De(e,o);l&&i(o,c,r),n.set(R(n.value,H(`$${c}`,s))),a()},_=u.filter(t=>K(e,t)&&p(t)==null);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(f,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:a,children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),V(`back`)]}),(0,$.jsx)(`h3`,{className:`font-semibold`,children:V(`insertInto`,{field:n.label})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:V(`valuesFrom`,{when:L(Date.parse(String(r.created_at)))})}),(0,$.jsx)(Ke,{autoFocus:!0,groups:h,onPick:e=>g(e.id,nt(e))}),_.length>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[_.map(e=>J(e).name).join(`, `),`: `,V(`noSample`)]}),d.length>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[d.map(e=>J(e).name).join(`, `),`: `,V(`outputShaped`)]})]}):(0,$.jsxs)(`div`,{className:`grid justify-items-start gap-2 text-body`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:V(`noRunYet`)}),(0,$.jsx)(f,{onClick:o,children:V(`testRun`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:V(`typeByHand`)})]})]})},it=(e,t)=>{let n=w(),r=d(),{go:i}=o(),[a,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1);return{start:async a=>{p(!0),s(void 0),l(!1);try{if(n.dirty&&!await n.save()){l(!0);return}let{record:o}=await r.create(`workflow_runs`,{workflow_id:e.workflow,rerun_of:e.run,...a}),{record:s}=await r.get(g,e.workflow);t(),i(v(e.workflow,String(o.id),Number(o.version),Number(s.version)))}catch(e){if(!u(e))throw e;s(e)}finally{p(!1)}},failure:a,refused:c,busy:f}},at=e=>e.map(e=>V(`stepActs`,e)).join(`, `),ot=({failure:e,refused:t})=>(0,$.jsxs)($.Fragment,{children:[e!==void 0&&(0,$.jsx)(k,{title:V(`notRerun`),error:e}),t&&(0,$.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:V(`rerunRefused`)})]}),st=({view:e,page:t,definition:n,types:r,step:i,onStep:a,onClose:o})=>{let s=w(),c=it(e,o),l=t.trace.steps.filter(e=>e.scope===``),u=Math.max(l.findIndex(e=>e.state===i),0),d=B(n,r,i),p=new Set(l.map(e=>e.state)),m=d.filter(e=>p.has(e.name)),h=d.filter(e=>!p.has(e.name)),g=(t.latest??0)+ +!!s.dirty,_=l.slice(0,u).find(e=>ye(t.trace.definition,n,e.state))?.state;return(0,$.jsx)(P,{title:V(`rerunTitle`,{step:i}),onClose:o,takesFocus:!0,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 text-body`,children:[(0,$.jsx)(ot,{failure:c.failure,refused:c.refused}),(0,$.jsx)(`p`,{children:u===0?V(`rerunFromStart`,{version:g}):V(`rerunKeeps`,{count:u,version:g})}),m.length>0&&(0,$.jsx)(`p`,{children:V(`rerunActsAgain`,{steps:at(m)})}),h.length>0&&(0,$.jsx)(`p`,{children:V(`stepsAct`,{steps:at(h)})}),_&&(0,$.jsx)(`p`,{children:V(`rerunChanged`,{changed:_,step:i})}),_&&(0,$.jsx)(f,{variant:`primary`,className:`max-md:min-h-11`,onClick:()=>a(_),children:V(`rerunFromInstead`,{step:_})}),(0,$.jsx)(f,{variant:_?`secondary`:`primary`,className:`max-md:min-h-11`,loading:c.busy,onClick:()=>void c.start({rerun_from:i}),children:_?V(`rerunWithOldResult`,{step:i}):s.dirty?V(`saveAndRerunShort`):V(`rerunStart`)})]})})},ct=({view:e,page:t,onClose:n})=>{let r=it(e,n);return(0,$.jsx)(P,{title:V(`replayTitle`),onClose:n,takesFocus:!0,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 text-body`,children:[(0,$.jsx)(ot,{failure:r.failure,refused:r.refused}),(0,$.jsx)(`p`,{children:V(`replayLine`,{version:t.latest??0})}),(0,$.jsx)(f,{variant:`primary`,className:`max-md:min-h-11`,loading:r.busy,onClick:()=>void r.start({replay:!0}),children:V(`replayStart`)})]})})},lt=()=>{let e=r().views.workflow_runs?.fields.status;return{hints:e,label:t=>se(String(t),e?.valueLabels)}},ut=e=>e==null?void 0:L(Date.parse(String(e))),dt=({trace:e,valueActions:t,onReplay:n,onClose:r})=>{let i=lt(),{run:a,id:o}=e;if(!a||!o)return null;let c=[{label:V(`status`),value:(0,$.jsx)(ce,{value:a.status,hints:i.hints,children:i.label(a.status)})},{label:V(`started`),value:ut(a.created_at)},{label:V(`startedBy`),value:a.started_by==null?void 0:String(a.started_by)},{label:V(`goesOnAt`),value:ut(a.resume_at)},{label:V(`finished`),value:ut(a.finished_at)},{label:V(`duration`),value:a.duration_ms==null?void 0:V(`durationMs`,{ms:Number(a.duration_ms)})}].flatMap(e=>e.value===void 0?[]:[e]);return(0,$.jsx)(P,{title:V(`runDetails`),onClose:r,...n&&{footer:(0,$.jsx)(f,{className:`w-full max-md:min-h-11`,onClick:n,children:V(`replay`)})},children:(0,$.jsxs)(`div`,{className:`grid gap-4`,children:[(0,$.jsx)(M,{title:V(`runDetails`),rows:c}),!e.going&&e.steps.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:V(`runNoTrace`)}),a.error!=null&&(0,$.jsx)(Xe,{title:V(`error`),children:(0,$.jsxs)(`p`,{className:`text-body text-danger-text`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:String(a.error)}),a.cause!=null&&(0,$.jsxs)(`span`,{children:[`: `,String(a.cause)]})]})}),a.input!=null&&(0,$.jsxs)(Xe,{title:V(`input`),children:[(0,$.jsx)(C,{value:a.input}),t(a.input,`input`)]}),a.output!=null&&(0,$.jsxs)(Xe,{title:V(`output`),children:[(0,$.jsx)(C,{value:a.output}),t(a.output,`output`)]}),(0,$.jsx)(s,{to:{kind:`record`,resource:`workflow_runs`,key:o,standard:!0},className:`text-body font-medium text-primary-text hover:underline`,children:V(`runPage`)})]})})},ft=({value:e,onUse:t})=>{let[n,r]=(0,Q.useState)(!1),i=async()=>{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),r(!0)};return(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[t&&(0,$.jsx)(f,{size:`sm`,onClick:t,children:V(`useAsTestInput`)}),(0,$.jsx)(f,{size:`sm`,onClick:()=>void i(),children:V(`copyJson`)}),(0,$.jsx)(`span`,{role:`status`,className:`text-xs text-muted-foreground`,children:n&&V(`copied`)})]})},pt=e=>e.Type===`Map`?{...e,ItemProcessor:{...e.ItemProcessor,States:Object.keys(e.ItemProcessor.States)}}:e.Type===`Block`?{...e,Processor:{...e.Processor,States:Object.keys(e.Processor.States)}}:e,mt=e=>Object.entries(e.States).flatMap(([e,t])=>[[e,pt(t)],...Z(t)?mt(Z(t)):[]]),ht=(e,t)=>{let n=new Map(mt(e.stateMachine).map(([e,t])=>[e,JSON.stringify(t)])),r=mt(t.stateMachine),i=r.filter(([e])=>!n.has(e)).length;return{changed:r.filter(([e,t])=>n.has(e)&&n.get(e)!==JSON.stringify(t)).length,added:i,removed:n.size-(r.length-i)}},gt=e=>{let t=d(),n=c();return async r=>{await t.update(g,e,{enabled_version:r},`*`),await n.invalidateQueries({queryKey:l.record(g,e)})}},_t=({view:e,page:t,definition:n,types:r,newVersion:i,onClose:a})=>{let o=w(),s=d(),c=gt(e.workflow),[l,u]=(0,Q.useState)(),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=e.version===void 0&&o.dirty,v=e.version??(t.latest??0)+(_&&i?1:0),{enabled:y,latest:b}=t,x=ae(`workflow_versions`,[e.workflow,y??0],y!==void 0),S=!_&&b!==void 0&&v<b,C=t.runs.some(e=>Number(e.version)===v),T=x.data?ht(Ie(x.data.record),n):void 0,E=Re(n.trigger),D=async()=>{if(m(!0),g(!1),u(void 0),_&&!await o.save()){m(!1),g(!0);return}let t=e.version??Number((await s.get(`workflows`,e.workflow)).record.version);await c(t).then(a,u),m(!1)},O=_?V(`saveAndPublish`):y===void 0&&E!==`manual`?V(`publishAndTurnOn`):V(`publishVersion`,{version:v});return(0,$.jsx)(P,{title:V(S?`goBackTo`:`publishVersion`,{version:v}),onClose:a,takesFocus:!0,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 text-body`,children:[l!==void 0&&(0,$.jsx)(k,{title:V(`notPublished`),error:l}),h&&(0,$.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:V(`notPublishedSave`)}),_&&(0,$.jsx)(`p`,{children:V(`savesThenPublishes`,{version:v})}),S&&(0,$.jsx)(`p`,{children:V(`rollback`,{latest:b,version:v})}),!S&&y!==void 0&&(0,$.jsx)(`p`,{children:V(`publishChange`,{live:y,version:v})}),y===void 0&&(E===`manual`?(0,$.jsx)(`p`,{children:V(`publishManual`,{version:v})}):(0,$.jsx)(`p`,{children:V(`startsTrigger`,{trigger:ze(n.trigger,r)})})),T&&(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:V(`publishDiff`,{...T,version:y??0})}),!C&&(0,$.jsx)(`p`,{className:`text-warning-text`,children:V(`untested`,{version:v})}),(0,$.jsx)(f,{variant:`primary`,className:`max-md:min-h-11`,loading:p,onClick:()=>void D(),children:O})]})})},vt=({view:e,onClose:t})=>{let n=gt(e.workflow),[r,i]=(0,Q.useState)(),[a,o]=(0,Q.useState)(!1),s=async()=>{o(!0),await n(null).then(t,i),o(!1)};return(0,$.jsx)(P,{title:V(`turnOffTitle`),onClose:t,takesFocus:!0,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 text-body`,children:[r!==void 0&&(0,$.jsx)(k,{title:V(`notTurnedOff`),error:r}),(0,$.jsx)(`p`,{children:V(`turnOffLine`)}),(0,$.jsx)(f,{variant:`danger`,className:`max-md:min-h-11`,loading:a,onClick:()=>void s(),children:V(`turnOff`)})]})})},yt=({view:e,page:t,failed:n,changed:r,gone:i,onOpenFailed:a})=>{let{latest:o,trace:c}=t,l=c.run,u=e.version!==void 0&&e.version!==o,d=h({workflow:e.workflow,...e.run&&{run:e.run}}),m=(0,$.jsx)(s,{to:d,className:p({size:`sm`}),children:V(`editLatest`)}),g=(0,$.jsx)(s,{to:_(e,o),className:p({size:`sm`}),children:V(`hideRun`)});if(e.run===void 0)return u?(0,$.jsxs)(ie,{level:`info`,actions:m,children:[V(`olderVersion`,{version:e.version??0,latest:o??0}),t.enabled!==void 0&&` ${V(`versionIsLive`,{version:t.enabled})}`]}):null;if(!l)return null;let y=L(Date.parse(String(l.created_at))),b=Number(l.version),x=!u&&b!==o&&(0,$.jsx)(s,{to:v(e.workflow,e.run,b,o),className:p({size:`sm`}),children:V(`showRunVersion`,{version:b})}),S=typeof l.block_state==`string`?l.block_state:void 0,C=typeof l.block_of==`string`&&(0,$.jsx)(s,{to:v(e.workflow,l.block_of,b,o),className:p({size:`sm`}),children:V(`openReachingRun`)});return(0,$.jsxs)(ie,{level:`info`,actions:(0,$.jsxs)($.Fragment,{children:[n&&a&&(0,$.jsx)(f,{size:`sm`,onClick:a,children:V(`openFailed`)}),C,u&&m,x,g]}),children:[S===void 0?u?V(`runOlder`,{when:y,version:e.version??0,latest:o??0}):r?V(`runChanged`,{when:y,version:b}):b===o?n?V(`runFailedAt`,{when:y,step:n,version:b}):V(`runSame`,{when:y,version:b}):V(`runUsed`,{when:y,version:b,latest:o??0}):V(`blockRun`,{when:y,block:S,version:b}),i>0&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,V(`stepsGone`,{count:i})]})]})},bt=e=>e<1e3?V(`durationMs`,{ms:e}):V(`durationSeconds`,{seconds:Math.round(e/100)/10}),xt=e=>e==null?void 0:JSON.stringify(e),St=({view:e,page:t,onTestRun:n,onClose:r})=>{let[i,a]=(0,Q.useState)(`all`),o=lt(),c=t.runs.filter(e=>i===`all`||e.status===`failed`);return(0,$.jsx)(P,{title:V(`runs`),onClose:r,takesFocus:!0,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(A,{value:i,label:V(`runs`),options:[{value:`all`,label:V(`filterAll`)},{value:`failed`,label:V(`filterFailed`)}],onChange:a}),t.runs.length===0&&(0,$.jsxs)(`div`,{className:`grid gap-2 justify-items-start`,children:[(0,$.jsx)(`p`,{className:`text-body text-muted-foreground`,children:V(`noRuns`)}),n&&(0,$.jsx)(f,{onClick:n,children:V(`testRun`)})]}),(0,$.jsx)(`ul`,{className:`grid gap-1`,children:c.map(n=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(s,{to:v(e.workflow,String(n.id),Number(n.version),t.latest),"aria-current":e.run===n.id?`true`:void 0,onClick:r,className:`grid gap-0.5 rounded-md px-2 py-2 hover:bg-muted aria-[current]:bg-muted max-md:min-h-11`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(ce,{value:n.status,hints:o.hints,children:o.label(n.status)}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:L(Date.parse(String(n.created_at)))}),(0,$.jsx)(`span`,{children:V(`versionShort`,{version:Number(n.version)})}),n.duration_ms!=null&&(0,$.jsx)(`span`,{className:`tabular-nums`,children:bt(Number(n.duration_ms))}),(0,$.jsx)(`span`,{children:n.started_by==null?V(`startedByTrigger`):V(`startedByTest`)})]}),xt(n.input)&&(0,$.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,children:xt(n.input)})]})},String(n.id)))})]})})},Ct=({title:e,settings:t,run:n,state:r,block:i,tab:a,onTab:o,valueActions:s,footer:c,onClose:l})=>(0,$.jsx)(P,{title:e,onClose:l,footer:c,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[n&&(0,$.jsx)(A,{value:a,label:e,options:[{value:`data`,label:V(`tabData`)},{value:`settings`,label:V(`tabSettings`)}],onChange:o}),n&&a===`data`?r===void 0?(0,$.jsxs)(Xe,{title:V(`input`),children:[(0,$.jsx)(C,{value:n.input??null}),s?.(n.input,`input`)]}):(0,$.jsx)(Ze,{run:n,name:r,...i!==void 0&&{block:i},...s&&{valueActions:s}}):t]})}),wt=(e,t)=>e.slice(0,t).split(`
|
|
3
|
+
`).length,Tt=e=>{try{JSON.parse(e);return}catch(t){if(!(t instanceof SyntaxError))throw t;let n=/position (\d+)/.exec(t.message)?.[1],r=/line (\d+)/.exec(t.message)?.[1]??(n===void 0?void 0:wt(e,Number(n)));return r===void 0?V(`notJson`):V(`notJsonLine`,{line:Number(r)})}},Et=e=>JSON.stringify(e??{},null,2),Dt=({view:e,page:t,definition:n,types:r,seed:i,onClose:a})=>{let s=w(),c=d(),{go:l}=o(),u=lt(),f=t.runs.filter(e=>e.input!=null).slice(0,5),[p,m]=(0,Q.useState)(()=>Et(i?i.value:f[0]?.input)),[h,g]=(0,Q.useState)(!1),_=T({resource:`workflow_runs`,feedback:`button`,onCreated:n=>{n&&(a(),l(v(e.workflow,String(n.id),Number(n.version),e.version===void 0?Number(n.version):t.latest)))}}),y=Tt(p),x=e.version===void 0&&s.dirty,S=e.version??t.latest??0,C=async()=>{if(g(!1),x&&!await s.save())return g(!0);let t=e.version??Number((await c.get(`workflows`,e.workflow)).record.version);await _.submit({workflow_id:e.workflow,input:JSON.parse(p),version:t})},E=B(n,r);return(0,$.jsx)(P,{title:V(`testRun`),onClose:a,takesFocus:!0,children:(0,$.jsxs)(qe,{form:_,fields:[],submit:V(x?`saveAndStart`:`startRun`),disabled:y!==void 0,onSubmit:()=>void C(),children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i?i.from:f[0]?V(`inputOfRun`,{when:L(Date.parse(String(f[0].created_at)))}):V(`noRunInput`)}),(0,$.jsx)(N,{label:V(`inputJson`),error:y,children:(0,$.jsx)(b,{rows:8,className:`font-mono text-xs`,value:p,invalid:y!==void 0,onChange:e=>m(e.target.value)})}),f.length>0&&(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:V(`startFromEarlier`)}),f.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`truncate rounded-md px-2 py-1 text-left text-xs hover:bg-muted max-md:min-h-11`,onClick:()=>m(Et(e.input)),children:V(`earlierRun`,{when:L(Date.parse(String(e.created_at))),status:u.label(e.status)})},String(e.id)))]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x?V(`savesThenRuns`,{version:S+1}):e.version===void 0?V(`runsLatest`,{version:S}):V(`runsVersion`,{version:S})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E.length>0?V(`stepsAct`,{steps:E.map(e=>V(`stepActs`,{name:e.name,kind:e.kind})).join(`, `)}):V(`nothingActs`)}),h&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger-text`,children:V(`notStarted`)})]})})},Ot=(e,{latest:t,enabled:n})=>V(e===t?e===n?`versionLatestLive`:`versionLatestDraft`:e===n?`versionLive`:`versionNumber`,{version:e}),kt=({page:e,draftOnly:t})=>{let n=w(),r=ee()?.size,[i,a]=(0,Q.useState)(),o=(0,Q.useRef)(e.latest);(0,Q.useEffect)(()=>{if(e.latest===o.current)return;let t=o.current===void 0;if(o.current=e.latest,t)return;a(e.latest);let n=setTimeout(()=>a(void 0),At);return()=>clearTimeout(n)},[e.latest]);let s=n.saving?V(`saving`):n.refused?V(`saveRefused`):n.dirty&&t?V(`draftHere`):n.dirty?V(r===`wide`?`unsaved`:`unsavedShort`):i===void 0?void 0:V(`savedAs`,{version:i});return s?(0,$.jsx)(O,{zone:`state`,children:(0,$.jsx)(`span`,{role:`status`,className:`truncate`,children:s})}):null},At=4e3,jt=({view:e,page:t,editable:n,newVersion:r,empty:s,problems:c,missing:l,onAddStep:u,onProblems:d,onRuns:p,onTestRun:m,onPublish:h,onTurnOff:g,runActions:_,orderSwitch:v})=>{let b=w(),{go:x}=o(),S=ee()?.size,C=i(),T=re(a(`workflow_runs`),`create`),{latest:k,enabled:A}=t,j=e.version??k,M=A!==void 0&&A===j,ie=(0,Q.useMemo)(()=>j===void 0||t.versions.some(e=>e.version===j)?t.versions:[...t.versions,{version:j,savedAt:``}],[t.versions,j]),N=s?V(`noStepsToRun`):M&&!r?V(`alreadyLive`,{version:j??0}):void 0,P=S===`compact`,ae=T?{name:V(`testRun`),icon:I,onRun:m,inBar:!0,...s&&{blocked:V(`noStepsToRun`)}}:void 0,oe={name:V(`publish`),icon:te,onRun:h,...N&&{blocked:N}},se=[...ae&&!P?[ae]:[],...P&&b.mayUpdate?[oe]:[],..._??[],...A!==void 0&&b.mayUpdate?[{name:V(`turnOff`),icon:E,onRun:g}]:[],...n&&v?[{name:Y(`orderSwitchTitle`,{order:v.to}),icon:$e,onRun:v.onRun,...v.refused!==void 0&&{blocked:Y(`orderSwitchRefused`,{reason:v.refused})}}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(O,{zone:`mode`,children:[(0,$.jsx)(X,{tone:A===void 0?`neutral`:`green`,children:A===void 0?V(`off`):V(`live`,{version:A})}),S!==`compact`&&(0,$.jsx)(G,{"aria-label":V(`version`),className:`w-auto`,value:j??``,onChange:t=>x(y(e.workflow,Number(t.target.value),k)),children:ie.map(({version:e})=>(0,$.jsx)(`option`,{value:e,children:Ot(e,{latest:k,enabled:A})},e))})]}),(0,$.jsxs)(O,{zone:`controls`,children:[n&&C&&(0,$.jsxs)(f,{onClick:u,"aria-label":V(`addStep`),children:[(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),S!==`narrow`&&V(`addStep`)]}),(0,$.jsxs)(f,{onClick:p,className:`max-md:min-h-11`,children:[(0,$.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),V(`runs`)]}),c>0&&(0,$.jsxs)(f,{onClick:d,className:`text-danger-text`,children:[(0,$.jsx)(q,{className:`size-3.5`,"aria-hidden":!0}),V(`problems`,{count:c})]}),l>0&&c===0&&(0,$.jsx)(f,{onClick:d,children:V(`fieldsToFill`,{count:l})})]}),(0,$.jsx)(kt,{page:t,draftOnly:l>0}),(0,$.jsx)(D,{actions:se}),b.mayUpdate&&!P&&(0,$.jsx)(O,{zone:`primary`,children:(0,$.jsx)(f,{variant:b.dirty?`secondary`:`primary`,"aria-disabled":N!==void 0,title:N,onClick:()=>N===void 0&&h(),children:V(`publish`)})}),P&&ae&&!b.dirty&&!s&&(0,$.jsx)(O,{zone:`primary`,children:(0,$.jsx)(f,{variant:`primary`,className:`min-h-11`,onClick:m,children:V(`testRun`)})})]})},Mt=e=>[`Task`,`Pass`,`Wait`,`Map`,`Block`].includes(e.Type),Nt=e=>{let t=new Set;for(let[,n]of Ge(e))for(let e of Ue(n)){if(t.has(e))return e;t.add(e)}},Pt=e=>(e.Type===`Pass`||e.Type===`Succeed`)&&e.Output===void 0,Ft=(e,t,n)=>{let r=new Set(Object.values(e.States).flatMap(e=>e.Next===void 0?[]:[e.Next]));for(let[i,a]of Object.entries(e.States)){if(Pt(a)&&(t?r.has(i):i!==n))return i;let e=Z(a),o=e&&Ft(e,t,t?void 0:Bt(e).StartAt);if(o)return o}},It=e=>{for(let t of Object.keys(e.States)){let n=new Set;for(let r=t;r!==void 0&&e.States[r];r=e.States[r].Next){if(n.has(r))return r;n.add(r)}}for(let t of Object.values(e.States)){let e=Z(t),n=e&&It(e);if(n)return n}},Lt=e=>{let t=new Set;for(let n=e.StartAt;n!==void 0&&e.States[n]&&!t.has(n);n=e.States[n].Next)t.add(n);let n=Object.keys(e.States).find(e=>!t.has(e));if(n!==void 0)return n;for(let t of Object.values(e.States)){let e=Z(t),n=e&&Lt(e);if(n)return n}},Rt=e=>`{% ${e.map(e=>`$states.context.Steps.${le(e)}.Status = 'SUCCEEDED'`).join(` and `)} %}`,zt=e=>{let t=He(e),n=new Map;for(let[r,i]of Object.entries(e.States)){let e=i.Next;e!==void 0&&!t.get(e)?.data.has(r)&&n.set(e,[...n.get(e)??[],r])}let{StartAt:r,...i}=e,a=Object.fromEntries(Object.entries(e.States).map(([e,t])=>{let{Next:r,End:i,...a}=t,o=t.Type===`Succeed`?{...a,Type:`Pass`}:a,s=Z(o),c=s?{...o,...o.Type===`Map`?{ItemProcessor:zt(s)}:{Processor:zt(s)}}:o,l=n.get(e);return[e,l?{...c,Condition:Rt(l)}:c]}));return{...i,States:a}},Bt=e=>{let t=He(e),n=[],r=new Set(Object.keys(e.States));for(;r.size>0;){let e=[...r].filter(e=>[...Ve(t.get(e))].every(e=>n.includes(e))).sort()[0]??[...r].sort()[0];n.push(e),r.delete(e)}let i=Object.fromEntries(n.map((t,r)=>{let i=e.States[t],a=Z(i),o=a?{...i,...i.Type===`Map`?{ItemProcessor:Bt(a)}:{Processor:Bt(a)}}:i;if(!Mt(i))return[t,o];let s=n[r+1];return[t,s===void 0?{...o,End:!0}:{...o,Next:s}]}));return{...e,StartAt:n[0]??``,States:i}},Vt=e=>{let t=Ge(e.stateMachine),n=t.find(([,e])=>e.Type===`Choice`);if(n)return{refused:Y(`switchChoice`,{state:n[0]})};let r=t.find(([,e])=>`Catch`in e&&(e.Catch??[]).some(e=>e.Next!==void 0));if(r)return{refused:Y(`switchCatchNext`,{state:r[0]})};let i=Nt(e.stateMachine);if(i!==void 0)return{refused:Y(`switchAssignedTwice`,{variable:i})};let a=Lt(e.stateMachine);if(a!==void 0)return{refused:Y(`switchUnreached`,{state:a})};let o=It(e.stateMachine);if(o!==void 0)return{refused:Y(`switchLoop`,{state:o})};let s=Ft(e.stateMachine,!0);return s===void 0?{definition:{...e,order:`data`,stateMachine:{...zt(e.stateMachine),QueryLanguage:`JSONata`}}}:{refused:Y(`switchPassThroughData`,{state:s})}},Ht=e=>{let t=Ge(e.stateMachine),n=t.find(([,e])=>e.Condition!==void 0);if(n)return{refused:Y(`switchCondition`,{state:n[0]})};let r=t.find(([,e])=>`Catch`in e&&(e.Catch??[]).some(e=>e.Next===void 0));if(r)return{refused:Y(`switchCatchNoNext`,{state:r[0]})};let i=Bt(e.stateMachine),a=Ft(e.stateMachine,!1,i.StartAt);return a===void 0?{definition:{...e,order:`sequence`,stateMachine:{...i,QueryLanguage:`JSONata`}}}:{refused:Y(`switchPassThroughSequence`,{state:a})}},Ut=e=>We(e)===`data`?Ht(e):Vt(e),Wt=new Map,Gt=(e,t)=>{let n=Ut(e),r=We(e)===`data`?`sequence`:`data`;return`refused`in n?{to:r,refused:n.refused,onRun:()=>{}}:{to:r,onRun:()=>t(n.definition)}},Kt=(e,t)=>{if(t===void 0||t===``)return[];let n=t.split(`/`);return Pe(K(e,t))?n:n.slice(0,-1)},qt=({view:e,value:t,types:n,onChange:r,layout:s,onLayoutChange:c})=>{let l=w(),u=j(e),d=i(),p=(0,Q.useRef)(void 0),m=JSON.stringify(t??null),h=(0,Q.useMemo)(()=>Fe(JSON.parse(m)),[m]),g=(0,Q.useMemo)(()=>u.pastDefinition===void 0?void 0:Fe(u.pastDefinition),[u.pastDefinition]),_=e.version!==void 0&&e.version!==u.latest,v=_?g:h,y=(0,Q.useMemo)(()=>JSON.stringify(Le(Ie(l.record))),[l.record]),b=l.dirty&&JSON.stringify(Le(h))!==y,x=_?u.pastLayout:s,C=_||!r||l.readOnly?void 0:c,T=_||!r?void 0:e=>{let t=p.current;p.current=void 0,t||we(void 0),r(t?t(e):e)},E=Se(n),D=(0,Q.useMemo)(()=>je(v?he(v,n,E):[]),[v,n,E]),O=(0,Q.useMemo)(()=>v?_e(v):Wt,[v]),{address:ee}=o(),te=ee?.kind===`record`?ee.panel:void 0,ne=Ne(h.stateMachine).length===0,[A,M]=(0,Q.useState)(te===`test_run`?{kind:`test`}:te===`replay`?{kind:`replay`}:ne&&d&&r?{kind:`add`}:void 0),[ie,N]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(),[ae,se]=(0,Q.useState)(`data`),[ce,le]=(0,Q.useState)(!1),[ve,R]=(0,Q.useState)(),[ye,we]=(0,Q.useState)(),Ee=re(a(`workflow_runs`),`create`);(0,Q.useEffect)(()=>{I(void 0),se(`data`),le(!1)},[e.run]),(0,Q.useEffect)(()=>{l.refused&&N(!0)},[l.refused]);let{trace:z}=u,B=e.run===void 0||!z.run||!z.id?void 0:{...z.run,id:z.id,created_at:String(z.run.created_at)},H=(0,Q.useMemo)(()=>{if(!z.definition||!z.place)return;let e=Je(z.steps,{inProgress:z.going,...z.place});return v?new Map([...e].map(([e,t])=>[e,{...t,changed:JSON.stringify(K(z.definition,e))!==JSON.stringify(K(v,e))}])):e},[z.definition,z.place,z.steps,z.going,v]),U=H&&[...H].filter(([,e])=>e.status===`failed`).map(([e])=>e).sort((e,t)=>t.split(`/`).length-e.split(`/`).length)[0],W=v&&(F===``||typeof F==`string`&&K(v,F))?F:F===void 0&&U!==void 0&&v&&K(v,U)?U:void 0;if((0,Q.useEffect)(()=>R(void 0),[W]),u.pastError)return(0,$.jsx)(k,{title:V(`versionFailed`),error:u.pastError});if(u.versionsError)return(0,$.jsx)(k,{title:V(`versionsFailed`),error:u.versionsError});if(u.runsError)return(0,$.jsx)(k,{title:V(`runsFailed`),error:u.runsError});if(!v)return(0,$.jsx)(oe,{className:`h-full w-full`});let G=()=>M(void 0),q=Kt(v,W),Pe=e=>{let t=de(v,e);if(e.kind===`start`)return t===void 0?V(`addsFirst`):V(`addsBetween`,{step:Y(`trigger`),next:t});let n=J(e.source).name;return t===void 0?e.kind===`rule`?V(`addsRule`,{step:n}):e.kind==="default"?V(`addsOtherwise`,{step:n}):e.kind===`catch`?V(`addsOnError`,{step:n}):V(`addsAfter`,{step:n}):V(`addsBetween`,{step:n,next:t})},Re=()=>{if(W===``||Ne(v.stateMachine).length===0)return V(`addsFirst`);if(q.length>0&&W===q.join(`/`))return V(`addsInside`,{map:J(W).name});let e=pe(v,q,W);return e===void 0?V(`addsUnconnected`):V(`addsAfter`,{step:e})},ze=(e,t)=>{if(!T)return;let n=fe(v,Y(`newStep`)),r=Y(`newStep`),i=t?ke(v,e,n,r,t):W===``?me(v,e,n,r):ue(v,q,e,n,r,pe(v,q,W));T(i),I(Me(t?Ce(t):q,n)),se(`settings`),G()},X=Ne(v.stateMachine).length===0,Ve=[...D.whole,...[...D.byNode.values()].flat()],He=X?0:Ve.filter(Oe).length,Ue=X?0:Ve.length-He,Z=ie?D.byNode:Ae(D.byNode),We=()=>{if(He===0)return!1;N(!0);let e=[...D.byNode].find(([,e])=>e.some(Oe))?.[0];return e!==void 0&&I(e),se(`settings`),M(void 0),!0},Ge=z.definition?Ne(z.definition.stateMachine).filter(e=>!Ne(v.stateMachine).includes(e)).length:0,Ke=B&&L(Date.parse(B.created_at)),qe=(e,t)=>t===`output`||e===void 0||e===z.definition?.stateMachine.StartAt,Ye=e=>(t,n)=>(0,$.jsx)(ft,{value:t,...Ee&&qe(e,n)&&{onUse:()=>M({kind:`test`,seed:{value:t,from:V(n===`output`?`seedOutput`:`seedInput`,{step:e??Y(`trigger`),when:Ke??``})}})}}),Xe=B!==void 0&&!z.going,Ze=(e,t)=>{if(!Xe)return V(`runNotEnded`);if(e===void 0)return;if(z.place&&z.place.within.length>0)return V(`rerunInBlock`);let n=J(t).scope[0];return n===void 0?K(h,t)?void 0:V(`stepNotInVersion`,{version:u.latest??0}):K(h,n)?.Type===`Block`?V(`rerunInBlockStep`,{block:n}):V(`rerunInMap`,{map:n})},Qe=e=>{let t=J(e).scope,n=z.place?.within.length??0,r=z.definition??v,i=t.findIndex((e,i)=>i>=n&&K(r,t.slice(0,i+1).join(`/`))?.Type===`Block`);return i===-1?void 0:t[i]},$e=(e,t)=>{if(!B||!Ee||e===void 0)return;let n=Ze(e,t);return(0,$.jsx)(f,{variant:`primary`,className:`w-full max-md:min-h-11`,"aria-disabled":n!==void 0,title:n,onClick:()=>n===void 0&&M({kind:`rerun`,step:e}),children:l.dirty?V(`saveAndRerun`):V(`rerunFromStep`)})},tt=()=>{if(W===void 0)return null;let e=W===``?void 0:J(W).name,t=(0,$.jsx)(Te,{definition:v,types:n,selected:W,problems:Z.get(W)??[],warnings:O.get(W)??[],...T&&!l.readOnly&&{onChange:T},onSelect:e=>I(e??null)}),r=B??u.runs.find(e=>e.status===`succeeded`||e.status===`failed`),i=ve?(0,$.jsx)(rt,{definition:v,path:W,target:ve,run:r,onAssign:(e,t,n)=>{we({message:`${V(`addedVariable`,{variable:t,step:J(e).name})} ${V(`inThisRun`,{value:n})}`,undo:v}),p.current=t=>De(t,e).definition},onBack:()=>R(void 0),onTestRun:()=>{R(void 0),M({kind:`test`})}}):(0,$.jsxs)($.Fragment,{children:[ye&&(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 rounded-md bg-muted px-3 py-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:ye.message}),(0,$.jsx)(f,{size:`sm`,onClick:()=>{T?.(ye.undo),we(void 0)},children:V(`undo`)})]}),t]});return(0,$.jsx)(Ct,{title:e??Y(`trigger`),tab:B?ae:`settings`,onTab:se,run:B,state:e,block:Qe(W),valueActions:Ye(e),footer:$e(e,W),onClose:()=>I(null),settings:i})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jt,{view:e,page:u,editable:!!T&&!l.readOnly,newVersion:b,empty:X,problems:Ue,missing:He,onAddStep:()=>M({kind:`add`}),onProblems:()=>{We()||M({kind:`problems`})},onRuns:()=>M({kind:`runs`}),onTestRun:()=>{We()||M({kind:`test`})},onPublish:()=>{We()||M({kind:`publish`})},onTurnOff:()=>M({kind:`off`}),...T&&!l.readOnly&&{orderSwitch:Gt(v,T)},runActions:B&&[...W!==void 0||ce?[{name:V(`runDetails`),icon:S,onRun:()=>{I(null),le(!1)}}]:[]]}),(0,$.jsx)(yt,{view:e,page:u,failed:U&&J(U).name,changed:l.dirty,gone:Ge,...U!==void 0&&U!==W&&{onOpenFailed:()=>I(U)}}),(0,$.jsx)(`div`,{className:`h-full`,children:(0,$.jsx)(Be,{fills:!0,definition:v,problems:B||X?Wt:Z,warnings:B||X?Wt:O,selected:W,onSelect:e=>I(e??null),...T&&!l.readOnly&&{onChange:T,edits:ge,onAddAt:e=>M({kind:`add`,at:e})},...H&&B&&{traces:H},types:n,schemas:E,layout:x,onLayoutChange:C})}),X&&A===void 0&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-[60%] flex justify-center`,children:(0,$.jsx)(`div`,{className:`pointer-events-auto grid justify-items-center gap-2 rounded-lg border bg-background p-6 text-center shadow-sm`,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h2`,{className:`font-semibold`,children:V(`noSteps`)}),(0,$.jsx)(`p`,{className:`text-body text-muted-foreground`,children:V(`noStepsLine`)}),T&&!l.readOnly&&(0,$.jsx)(f,{variant:`primary`,onClick:()=>M({kind:`add`}),children:V(`addStep`)})]}):(0,$.jsx)(`p`,{className:`text-body text-muted-foreground`,children:V(`noStepsMobile`)})})}),A?.kind===`add`&&(0,$.jsx)(et,{types:n,placement:A.at?Pe(A.at):Re(),onAdd:e=>ze(e,A.at),onClose:G}),A?.kind===`test`&&(0,$.jsx)(Dt,{view:e,page:u,definition:v,types:n,seed:A.seed,onClose:G}),A?.kind===`runs`&&(0,$.jsx)(St,{view:e,page:u,onTestRun:()=>M({kind:`test`}),onClose:G}),A?.kind===`publish`&&(0,$.jsx)(_t,{view:e,page:u,definition:v,types:n,newVersion:b,onClose:G}),A?.kind===`off`&&(0,$.jsx)(vt,{view:e,onClose:G}),A?.kind===`problems`&&(0,$.jsx)(P,{title:V(`problemsTitle`),onClose:G,takesFocus:!0,children:(0,$.jsx)(be,{problems:[...D.whole,...[...D.byNode.values()].flat()]})}),A?.kind===`rerun`&&(0,$.jsx)(st,{view:e,page:u,definition:h,types:n,step:A.step,onStep:e=>M({kind:`rerun`,step:e}),onClose:G}),A?.kind===`replay`&&(0,$.jsx)(ct,{view:e,page:u,onClose:G}),A===void 0&&(0,$.jsx)(xe.Provider,{value:T&&!l.readOnly?R:void 0,children:W===void 0&&B&&!ce?(0,$.jsx)(dt,{trace:z,valueActions:Ye(void 0),onReplay:Xe&&Ee?()=>M({kind:`replay`}):void 0,onClose:()=>le(!0)}):tt()})]})};export{qt as WorkflowWorkbench};
|
|
4
|
+
//# debugId=07ada995-6442-49f9-8ccd-98d8e846bdd7
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{A as e,D as t,E as n,M as r,O as i,S as a,T as o,a as s,b as c,c as l,d as u,f as d,g as f,i as p,j as m,k as h,p as ee,s as te,u as ne,v as g,w as _,x as v,y as re}from"./workflows-start-kl7rSSay.js";var y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ie=[`InputPath`,`Parameters`,`ResultSelector`,`ResultPath`,`OutputPath`,`ItemsPath`],ae={ItemReader:`is a distributed Map's reader, which does not run here; give the Map its Items`,ItemBatcher:`is a distributed Map's batcher, which does not run here`,ResultWriter:`is a distributed Map's writer, which does not run here`,ToleratedFailureCount:`is a distributed Map's, which does not run here`,ToleratedFailurePercentage:`is a distributed Map's, which does not run here`,Credentials:`does not run here: a step signs in through the connection its type declares`},b=(e,t)=>y(e)?Object.entries(e).flatMap(([e,n])=>{if(!y(n))return[];let r=[...t,e].join(`/`),i=[];n.Type===`Parallel`&&i.push({state:r,field:`Type`,message:`is Parallel, which does not run here yet; in data order, states that read nothing of each other run at once`}),typeof n.Resource==`string`&&n.Resource.startsWith(`arn:`)&&i.push({state:r,field:`Resource`,message:`is a Step Functions service (${n.Resource}), which does not run here: write the step with one of this app's step types, such as app:http for an HTTP request`});for(let e of ie)n[e]!==void 0&&i.push({state:r,field:e,message:`is JSONPath, which does not run here; write the state in JSONata, with Arguments, Output and Assign`});for(let[e,t]of Object.entries(ae))n[e]!==void 0&&i.push({state:r,field:e,message:t});let a=y(n.ItemProcessor)?n.ItemProcessor.ProcessorConfig:void 0;y(a)&&a.Mode===`DISTRIBUTED`&&i.push({state:r,field:`ItemProcessor.ProcessorConfig.Mode`,message:`is DISTRIBUTED, which does not run here; a Map runs its items inline`});for(let r of[`ItemProcessor`,`Processor`,`Iterator`])y(n[r])&&i.push(...b(n[r].States,[...t,e]));return i}):[],oe=e=>{let t=y(e)&&y(e.stateMachine)?e.stateMachine:void 0;if(!t)return[];let n=[];return t.QueryLanguage!==`JSONata`&&n.push({field:`stateMachine.QueryLanguage`,message:`is ${t.QueryLanguage===void 0?`missing, so the machine is JSONPath, the default of Step Functions`:JSON.stringify(t.QueryLanguage)}; only JSONata machines run here: set "QueryLanguage": "JSONata" and write its states in JSONata`}),t.TimeoutSeconds!==void 0&&n.push({field:`stateMachine.TimeoutSeconds`,message:`is a whole run's timeout, which does not run here; give each Task its TimeoutSeconds`}),[...n,...b(t.States,[])]},se=r(),x={type:`string`,pattern:`^\\{%[\\s\\S]*%\\}$`},S={type:`string`,minLength:1,maxLength:80},C={type:`array`,minItems:1,items:{type:`string`,minLength:1}},w={type:`object`,propertyNames:{pattern:`^[A-Za-z][A-Za-z0-9_]*$`}},ce={type:`object`,additionalProperties:!1,required:[`ErrorEquals`],properties:{ErrorEquals:C,IntervalSeconds:{type:`integer`,minimum:1,maximum:m.retryDelaySeconds},MaxAttempts:{type:`integer`,minimum:0,maximum:m.retryAttempts},BackoffRate:{type:`number`,minimum:1,maximum:10},MaxDelaySeconds:{type:`integer`,minimum:1,maximum:m.retryDelaySeconds}}},T=e=>{let t=e===`sequence`,n={Type:{},Comment:{type:`string`},Output:{},Assign:w,QueryLanguage:{const:`JSONata`},...!t&&{Condition:x}},r=t?{Next:S,End:{const:!0}}:{},i=t?{oneOf:[{required:[`Next`],not:{required:[`End`]}},{required:[`End`],not:{required:[`Next`]}}]}:{},a={type:`object`,additionalProperties:!1,required:[`ErrorEquals`,...t?[`Next`]:[]],properties:{ErrorEquals:C,...t&&{Next:S},Output:{},Assign:w}},o={Retry:{type:`array`,items:ce},Catch:{type:`array`,items:a}},s=(e,t,{required:r=[],...i}={})=>({type:`object`,additionalProperties:!1,required:[`Type`,...r],...i,properties:{...n,Type:{const:e},...t}}),c=t?{type:`object`,required:[`StartAt`,`States`],properties:{StartAt:S,Comment:{type:`string`},States:{type:`object`,minProperties:1,propertyNames:S,additionalProperties:{$ref:`#/definitions/state`}}}}:{type:`object`,required:[`States`],properties:{Comment:{type:`string`},States:{type:`object`,minProperties:1,propertyNames:S,additionalProperties:{$ref:`#/definitions/state`}}}},l={...t&&{StartAt:{}},States:{},Comment:{},Version:{type:`string`}},u=[s(`Pass`,r,i),s(`Task`,{...r,...o,Resource:S,Arguments:{},TimeoutSeconds:{type:`integer`,minimum:1,maximum:m.waitingTaskTimeoutSeconds},HeartbeatSeconds:{type:`integer`,minimum:1,maximum:m.waitingTaskTimeoutSeconds},Cache:{type:`boolean`}},{required:[`Resource`],...i}),s(`Wait`,{...r,Seconds:{anyOf:[{type:`integer`,minimum:0,maximum:m.waitSeconds},x]},Timestamp:{type:`string`}},{allOf:[i,{oneOf:[{required:[`Seconds`]},{required:[`Timestamp`]}]}]}),{type:`object`,additionalProperties:!1,required:[`Type`],properties:{Type:{const:`Fail`},Comment:{type:`string`},QueryLanguage:{const:`JSONata`},...!t&&{Condition:x},Error:{type:`string`},Cause:{type:`string`}}},s(`Map`,{...r,...o,Items:{},ItemProcessor:{$ref:`#/definitions/processor`},MaxConcurrency:{type:`integer`,minimum:0,maximum:m.mapConcurrency}},{required:[`ItemProcessor`,`Items`],...i}),s(`Block`,{...r,...o,Arguments:{},Processor:{$ref:`#/definitions/machine`},Cache:{type:`object`,additionalProperties:!1,required:[`Ttl`],properties:{Ttl:{type:[`integer`,`string`]},Key:{}}}},{required:[`Processor`,`Cache`],...i})],d=t?[s(`Choice`,{Choices:{type:`array`,minItems:1,items:{type:`object`,additionalProperties:!1,required:[`Condition`,`Next`],properties:{Condition:x,Next:S,Comment:{type:`string`},Output:{},Assign:w}}},Default:S},{required:[`Choices`]}),{type:`object`,additionalProperties:!1,required:[`Type`],properties:{Type:{const:`Succeed`},Comment:{type:`string`},Output:{},QueryLanguage:{const:`JSONata`}}}]:[];return{$schema:`http://json-schema.org/draft-07/schema#`,$id:`https://docs.protobase.net/schemas/workflow-definition${t?``:`-data`}.json`,$ref:`#/definitions/definition`,definitions:{machine:c,definition:{type:`object`,additionalProperties:!1,required:[`trigger`,`stateMachine`],properties:{trigger:{$ref:`#/definitions/trigger`},order:{enum:[`sequence`,`data`]},stateMachine:{$ref:`#/definitions/stateMachine`},connections:{$ref:`#/definitions/connections`},trace:{enum:[`all`,`failed`,`none`]}}},connections:{type:`object`,propertyNames:{pattern:`^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$`},additionalProperties:{type:`string`,minLength:1,maxLength:255}},trigger:{type:`object`,minProperties:1,maxProperties:1,propertyNames:{pattern:`^(manual|[a-z][a-z0-9_]*:[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*)$`},properties:{manual:{type:`object`,maxProperties:0}},additionalProperties:{type:`object`}},stateMachine:{allOf:[{$ref:`#/definitions/machine`}],required:[`QueryLanguage`],properties:{QueryLanguage:{const:`JSONata`},...l},additionalProperties:!1},processor:{allOf:[{$ref:`#/definitions/machine`}],properties:{ProcessorConfig:{type:`object`,additionalProperties:!1,properties:{Mode:{const:`INLINE`}}},...l},additionalProperties:!1},state:{type:`object`,required:[`Type`],discriminator:{propertyName:`Type`},oneOf:[...u,...d]}}}},le=T(`sequence`),ue=T(`data`),E=e=>e.reduce((e,t)=>typeof t==`number`||/^\d+$/.test(t)?`${e}[${t}]`:e?`${e}.${t}`:t,``),D=new se.Ajv({allErrors:!0,discriminator:!0,strict:!1}),O={sequence:D.compile(le),data:D.compile(ue)},de=e=>{let t=e.split(`/`).slice(1).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`)),n=t[0]===`stateMachine`&&t[1]===`States`?t.slice(1):t,r=[],i=[];for(let e=0;e<n.length;e++){let t=n[e];if(t===`States`&&e+1<n.length)r.push(n[++e]),i=[];else if((t===`ItemProcessor`||t===`Processor`)&&n[e+1]===`States`)continue;else i.push(t)}return{...r.length>0&&{state:r.join(`/`)},...i.length>0&&{field:E(i)}}},fe=(e,t)=>e.keyword===`additionalProperties`&&t&&[`Next`,`End`,`StartAt`].includes(String(e.params.additionalProperty))?`${e.params.additionalProperty} is not a field in dataflow order, where a state runs once the states it reads from have ended`:e.keyword===`additionalProperties`&&!t&&e.params.additionalProperty===`Condition`?`Condition is a field only in dataflow order ("order": "data"); in sequence order a Choice decides`:e.keyword===`additionalProperties`?`${e.params.additionalProperty} is not a field here`:e.keyword===`required`?`${e.params.missingProperty} is missing`:e.keyword===`minItems`?`is missing; it needs at least ${String(e.params.limit)}`:e.keyword===`const`?`must be ${JSON.stringify(e.params.allowedValue)}`:e.keyword===`discriminator`?t?`must be one of Task, Pass, Map, Block, Wait and Fail; in dataflow order a Condition takes the place of Choice, and the run ends when no state is left to run`:`must be one of Task, Choice, Pass, Map, Block, Wait, Succeed and Fail`:e.keyword===`pattern`&&e.instancePath===`/trigger`?`names a trigger type <plugin>:<key>, such as app:record, or manual`:e.keyword===`pattern`&&e.instancePath.endsWith(`/Assign`)?`names a variable with letters, digits and _, starting with a letter`:e.keyword===`pattern`?`must be an expression written as {% ... %}`:e.keyword===`maxProperties`&&e.instancePath===`/trigger/manual`?`takes no input`:e.keyword===`maxProperties`||e.keyword===`minProperties`?e.instancePath===`/trigger`?`holds exactly one trigger: a trigger type such as app:record, or manual`:e.message??`is not valid`:e.keyword===`oneOf`&&e.schemaPath.endsWith(`/oneOf`)?`needs exactly one of these`:e.message??`is not valid`,pe={Next:`needs either Next or End`,Seconds:`needs either Seconds or Timestamp`},me=e=>{let t=typeof e==`object`&&!!e&&e.order===`data`,n=t?O.data:O.sequence;if(n(e))return[];let r=[],i=new Set,a=n.errors??[];for(let e of a){if(e.keyword===`required`&&/(oneOf|allOf)\/\d+\/oneOf\/\d+\/required$/.test(e.schemaPath)||e.keyword===`not`)continue;let n={...de(e.instancePath),...e.keyword===`discriminator`&&{field:`Type`}},o=fe(e,t);if(e.keyword===`oneOf`){let t=a.find(t=>t.instancePath===e.instancePath&&t.schemaPath.startsWith(e.schemaPath.replace(/\/oneOf$/,`/oneOf/`))&&t.keyword===`required`);o=pe[String(t?.params.missingProperty)]??o}let s=`${n.state}|${n.field}|${o}`;i.has(s)||(i.add(s),r.push({...n,message:o}))}return r},he=(e,t,n={})=>{let[r,i]=Object.entries(e)[0];if(r===`manual`)return Object.keys(i).length===0?[]:[{field:`trigger.manual`,message:`takes no input`}];if(Object.hasOwn(n,r))return[{field:`trigger`,message:`"${r}" cannot run in this app: ${n[r]}`}];let a=t[r];return a?a(i).map(e=>({field:`trigger.${r}${e.field?`.${e.field}`:``}`,message:e.message})):[{field:`trigger`,message:`"${r}" is not a trigger type; use manual or one of ${Object.keys(t).join(`, `)}`}]},k=t=>{let n=[],r=(t,r,i)=>{for(let{path:a,source:o}of e(t,r))n.push({field:E(a),source:o,place:i})},i=t.Type===`Task`||t.Type===`Map`||t.Type===`Block`?`result`:`state`;return r(t.Condition,[`Condition`],`state`),t.Type===`Fail`?(r(t.Error,[`Error`],`state`),r(t.Cause,[`Cause`],`state`),n):(r(t.Output,[`Output`],i),`Assign`in t&&r(t.Assign,[`Assign`],i),t.Type===`Task`&&r(t.Arguments,[`Arguments`],`state`),t.Type===`Map`&&r(t.Items,[`Items`],`state`),t.Type===`Block`&&(r(t.Arguments,[`Arguments`],`state`),r(t.Cache?.Key,[`Cache`,`Key`],`state`)),t.Type===`Wait`&&(r(t.Seconds,[`Seconds`],`state`),r(t.Timestamp,[`Timestamp`],`state`)),t.Type===`Choice`&&t.Choices.forEach((e,t)=>{r(e.Condition,[`Choices`,t,`Condition`],`state`),r(e.Output,[`Choices`,t,`Output`],`state`),r(e.Assign,[`Choices`,t,`Assign`],`state`)}),`Catch`in t&&t.Catch?.forEach((e,t)=>{r(e.Output,[`Catch`,t,`Output`],`error`),r(e.Assign,[`Catch`,t,`Assign`],`error`)}),n)},A=e=>{let t=[];if(`Assign`in e&&e.Assign&&t.push(...Object.keys(e.Assign)),e.Type===`Choice`)for(let n of e.Choices)t.push(...Object.keys(n.Assign??{}));if(`Catch`in e)for(let n of e.Catch??[])t.push(...Object.keys(n.Assign??{}));return t},j=e=>{let t=[];return`Next`in e&&e.Next!==void 0&&t.push({field:`Next`,target:e.Next}),e.Type===`Choice`&&(e.Choices.forEach((e,n)=>t.push({field:`Choices[${n}].Next`,target:e.Next})),e.Default!==void 0&&t.push({field:`Default`,target:e.Default})),`Catch`in e&&e.Catch?.forEach((e,n)=>e.Next!==void 0&&t.push({field:`Catch[${n}].Next`,target:e.Next})),t},ge=e=>{let t=new Set,n=[e.StartAt];for(;n.length>0;){let r=n.pop(),i=e.States[r];if(!t.has(r)&&i){t.add(r);for(let e of j(i))n.push(e.target)}}return t},_e=(e,t)=>{let n=new Set,r=[t];for(;r.length>0;){let t=r.pop(),i=e.States[t];!n.has(t)&&i&&(n.add(t),r.push(...j(i).map(e=>e.target)))}return n},ve=new Set([`states`]),ye=[[`Execution`,`Input`],[`Execution`,`StartTime`],[`Secrets`]],M={state:``,result:`result`,error:`errorOutput`},N=(e,t)=>t.every((t,n)=>e[n]===t),be=(e,t,n)=>{let r=e.slice(1);if(N(r,[`Secrets`]))return r.length>=2?void 0:`reads $states.context.Secrets as a whole; read one secret by its name, such as $states.context.Secrets.API_TOKEN`;if(ye.some(e=>N(r,e)))return;if(N(r,[`Task`]))return n?N(r,[`Task`,`Token`])&&r.length===2?void 0:`reads $states.context.Task, whose only field is Token`:`reads $states.context.Task, which only the Arguments of a Task whose Resource ends in .waitForTaskToken read, as $states.context.Task.Token`;if(t&&N(r,[`Steps`]))return r[1]===void 0?`reads $states.context.Steps as a whole; read one state's status by its name, such as $states.context.Steps.Save.Status`:t.has(r[1])?void 0:`reads $states.context.Steps.${r[1]}, but there is no state ${r[1]} here or around it`;let i=t?`Execution.Input, Execution.StartTime, Secrets.<NAME> and Steps.<state>`:`Execution.Input, Execution.StartTime and Secrets.<NAME>`;return`reads $states.${e.join(`.`)}; $states.context holds only ${i}`},P=e=>{let n=h(e);return`error`in n?void 0:t(n.expression)},xe=(e,{place:n,visible:r,firstOfItem:i,inBlock:a=!1,steps:o,token:s=!1})=>{if(e.length>m.expressionLength)return[`is ${e.length} characters long, more than the ${m.expressionLength} an expression may be`];let c=h(e);if(`error`in c)return[`does not parse: ${c.error.message}${c.error.position===void 0?``:` (at character ${c.error.position})`}`];let l=t(c.expression),u=[];l.input&&u.push(`reads the state's input; read the run's input as $states.context.Execution.Input and an earlier result by the variable a state assigned it to`);for(let e of l.states){let[t=``]=e;if(!(t===`input`&&i)&&(t===``||t!==M[n])){if(t===`context`&&a&&N(e,[`context`,`Execution`,`StartTime`]))u.push(`reads $states.context.Execution.StartTime, which inside a Block is its own run's start, not part of what it is cached by`);else if(t===`context`){let t=be(e,o,s);t&&u.push(t)}else t===`input`?u.push(`reads $states.input, which only the first state of a Map's item processor may read (as the item)`):t===``?u.push(`reads $states as a whole; read one of its fields`):u.push(`reads $states.${t}, which is not there${n===`state`?``:` (here: $states.${M[n]})`}`)}}for(let e of l.variables)r.has(e)||u.push(`reads $${e}, which no state that can run before it assigns`);return l.evaluates&&u.push(`uses $eval, whose reads cannot be checked`),[...new Set(u)]},Se=e=>_(e).flatMap(([,e])=>e.Type===`Task`?[a(e.Resource).type]:[]),Ce=(e,t)=>{let n=[Object.keys(e.trigger)[0],...Se(e.stateMachine)];return new Set(n.flatMap(e=>Object.hasOwn(t,e)?[t[e]]:[]))},we=(e,t)=>{let n=Ce(e,t);return Object.keys(e.connections??{}).filter(e=>!n.has(e)).map(e=>({field:`connections.${e}`,message:`no trigger or step of this workflow signs in with "${e}"; remove it`}))},Te=e=>{let t=Object.keys(`Assign`in e&&e.Assign||{}),n=[];if(`Next`in e&&e.Next!==void 0&&n.push({target:e.Next,names:t}),e.Type===`Choice`){for(let t of e.Choices)n.push({target:t.Next,names:Object.keys(t.Assign??e.Assign??{})});e.Default!==void 0&&n.push({target:e.Default,names:t})}if(`Catch`in e)for(let t of e.Catch??[])t.Next!==void 0&&n.push({target:t.Next,names:Object.keys(t.Assign??{})});return n},Ee=(e,t)=>{let n=new Map(Object.keys(e.States).map(e=>[e,new Set(t)]));for(let t of Object.values(e.States))for(let{target:r,names:i}of Te(t))if(i.length!==0)for(let t of _e(e,r))for(let e of i)n.get(t)?.add(e);return n},De={second:1,minute:60,hour:3600,day:86400},F=e=>{if(typeof e==`number`)return Number.isFinite(e)&&e>=1?Math.min(Math.floor(e),m.cacheMaxSeconds):void 0;if(typeof e!=`string`)return;let t=/^(\d+) (second|minute|hour|day)s?$/.exec(e.trim());if(t)return F(Number(t[1])*De[t[2]])},Oe=(t,n)=>[...e(t.Arguments,[`Arguments`]),...e(t.Cache.Key,[`Cache`,`Key`])].flatMap(({path:e,source:t})=>P(t)?.states.some(e=>e[0]===`context`&&e[1]===`Secrets`)?[{state:n,field:E(e),message:`reads a secret, which a block would keep in its run; read it inside the block as $states.context.Secrets.<NAME>`}]:[]),ke=(e,t,n)=>{let r=[];return F(e.Cache.Ttl)===void 0&&r.push({state:t,field:`Cache.Ttl`,message:`is no time to live: give seconds from 1, or text such as "10 minutes", "1 hour" or "2 days", at most ${m.cacheMaxSeconds/86400} days`}),n>m.blockDepth&&r.push({state:t,message:`is inside ${n-1} other Blocks, more than the ${m.blockDepth-1} a Block may be in`}),[...r,...Oe(e,t)]},Ae=(e,t)=>{let n=0,r=[[e,0]];for(;r.length>0;){let[e,i]=r.pop();if(typeof e==`object`&&e){if(i+1>t)return t+1;n=Math.max(n,i+1);for(let t of Object.values(e))r.push([t,i+1])}}return n},je=e=>Ae(e,m.definitionDepth)<=m.definitionDepth?[]:[{message:`The definition nests more than ${m.definitionDepth} levels of arrays and objects`}],Me=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ne=(e,t)=>[...f(e.stateMachine).flatMap(({path:n,state:r})=>{let i=d(r,t);if(!i)return[];let a=(r,i,a)=>{let o=te(r);if(!o||!i)return[];let s=c(ee(e,o,t)),u=c(i);return re(s,u)?[]:[{state:n,field:[`Arguments`,...a].join(`.`),message:`reads ${l(o)}, ${v(s)}, where ${a.join(`.`)} takes ${v(u)}`}]},o=(e,t,n)=>Me(e)?Object.entries(e).flatMap(([e,r])=>o(r,g(t,[e]),[...n,e])):a(e,t,n);return Object.entries(ne(r)).flatMap(([e,t])=>o(t,g(i,[e]),[e]))}),...u(e.stateMachine).flatMap(({path:e,state:n})=>Ne({trigger:{manual:{}},stateMachine:{...n.Processor,QueryLanguage:`JSONata`}},t).map(t=>({...t,...t.state!==void 0&&{state:`${e}/${t.state}`}})))],I=e=>{let n=[];for(let{field:r,source:i}of k(e)){let e=h(i);if(`error`in e)continue;let a=t(e.expression),o=a.states.filter(e=>e[0]===`context`&&e[1]===`Steps`&&e[2]!==void 0).map(e=>e[2]);n.push({variables:[...a.variables],steps:o,condition:r===`Condition`})}let r=e.Type===`Map`?o(e):void 0;if(r){let e=new Set(Object.values(r.States).flatMap(A)),t=new Set(Object.keys(r.States));for(let i of Object.values(r.States).flatMap(I))n.push({variables:i.variables.filter(t=>!e.has(t)),steps:i.steps.filter(e=>!t.has(e)),condition:i.condition})}return n},Pe=e=>{let t=new Map;for(let[n,r]of Object.entries(e.States))for(let e of A(r))t.has(e)||t.set(e,n);return t},L=e=>{let t=Pe(e);return new Map(Object.entries(e.States).map(([n,r])=>{let i={data:new Set,status:new Set,handled:new Set};for(let n of I(r)){for(let e of n.variables){let n=t.get(e);n!==void 0&&i.data.add(n)}for(let t of n.steps)Object.hasOwn(e.States,t)&&(i.status.add(t),n.condition&&i.handled.add(t))}return[n,i]}))},R=e=>new Set([...e.data,...e.status]),Fe=e=>{let t=new Map,n=[],r=i=>{if(t.get(i)!==`done`){if(t.get(i)===`open`)return[...n.slice(n.indexOf(i)),i];t.set(i,`open`),n.push(i);for(let t of R(e.get(i)??{data:new Set,status:new Set,handled:new Set})){let e=r(t);if(e)return e}n.pop(),t.set(i,`done`)}};for(let t of e.keys()){let e=r(t);if(e)return e}},Ie=(e,t)=>{let n=Object.entries(e.States).map(([e,t])=>[e,A(t)]);return new Map(n.map(([e,r])=>[e,new Set([...t,...n.flatMap(([t,n])=>t===e?[]:n).filter(e=>!r.includes(e))])]))},Le=(e,t)=>{let n=[],r=new Map;for(let[i,a]of Object.entries(e.States))for(let e of new Set(A(a))){let a=r.get(e);a===void 0?r.set(e,i):n.push({state:t(i),field:`Assign`,message:`assigns $${e}, which ${a} assigns already; in dataflow order each variable has one state that assigns it`})}let i=Fe(L(e));return i&&n.push({state:t(i[0]),message:`runs after itself: ${i.join(` reads `)}; a state cannot read what runs after it`}),n},Re=(e,t)=>{let n=t.required?.[a(e.Resource).type]??[];if(i(e.Arguments)!==void 0)return[];let r=typeof e.Arguments==`object`&&e.Arguments!==null?e.Arguments:{};return n.filter(e=>r[e]===void 0||r[e]===``)},ze=e=>{let{type:t,waits:n}=a(e.Resource),r=p(t)!==void 0;if(r&&n)return[{field:`Resource`,message:`ends in .waitForTaskToken, but ${t} is a custom step, which waits for the runner that runs it already: write ${t}`}];if(!n&&!r)return[...e.TimeoutSeconds!==void 0&&e.TimeoutSeconds>m.taskTimeoutSeconds?[{field:`TimeoutSeconds`,message:`is ${e.TimeoutSeconds}, more than the ${m.taskTimeoutSeconds} seconds a step type runs; only a Task whose Resource ends in .waitForTaskToken waits longer`}]:[],...e.HeartbeatSeconds===void 0?[]:[{field:`HeartbeatSeconds`,message:`is for a Task whose Resource ends in .waitForTaskToken, whose outside executor sends heartbeats; this step type ends or fails within its TimeoutSeconds`}]];let i=e.TimeoutSeconds??(r?m.taskTimeoutSeconds:m.waitingTaskTimeoutSeconds);return[...e.HeartbeatSeconds!==void 0&&e.HeartbeatSeconds>=i?[{field:`HeartbeatSeconds`,message:`is ${e.HeartbeatSeconds}, which must be less than the Task's TimeoutSeconds (${i})`}]:[],...e.Cache===!0?[{field:`Cache`,message:r?`is true, but a custom step runs on a runner on every try and caches nothing`:`is true, but a Task that waits for an outside result hands its work off on every try and caches nothing`}]:[]]},z=(e,t,r)=>{let i=[],o=e=>[...t.path,e].join(`/`),s=t.path.length>0?{state:t.path.join(`/`)}:{},c=Object.keys(e.States),{data:l}=t,u=e.StartAt===void 0?void 0:e.States[e.StartAt];!l&&!u&&i.push({...s,field:`StartAt`,message:`names "${e.StartAt}", which is not a state here`});let d=l?Ie(e,t.outer):Ee(e,t.outer),f=l?void 0:ge(e),p=new Set([...t.steps,...c]);for(let s of c){let c=e.States[s];f&&!f.has(s)&&u&&i.push({state:o(s),message:`is never reached from "${e.StartAt}"`});for(let t of j(c))e.States[t.target]||i.push({state:o(s),field:t.field,message:`names "${t.target}", which is not a state here`});for(let e of A(c))(ve.has(e)||n.has(e))&&i.push({state:o(s),field:`Assign`,message:`cannot assign $${e}, a name the runner or JSONata keeps`}),t.outer.has(e)&&i.push({state:o(s),field:`Assign`,message:`cannot assign $${e}, which an outer state assigns already`});let m=c.Type===`Task`?a(c.Resource):void 0;if(m&&r.unavailable&&Object.hasOwn(r.unavailable,m.type)?i.push({state:o(s),field:`Resource`,message:`"${m.type}" cannot run in this app: ${r.unavailable[m.type]}`}):m&&r.versioned&&Object.hasOwn(r.versioned,m.type)?i.push({state:o(s),field:`Resource`,message:`"${m.type}" names no version: write ${r.versioned[m.type]}`}):m&&!r.resources.includes(m.type)&&i.push({state:o(s),field:`Resource`,message:`"${m.type}" is not a step type; use one of ${r.resources.join(`, `)}${m.waits?`, followed by .waitForTaskToken`:``}`}),c.Type===`Task`)for(let e of Re(c,r))i.push({state:o(s),field:`Arguments.${e}`,message:`is missing; ${m.type} needs it`});if(c.Type===`Task`)for(let e of ze(c))i.push({state:o(s),...e});let h=t.item&&(l||s===e.StartAt);for(let{field:e,source:n,place:r}of k(c)){let a=!!m?.waits&&/^Arguments($|[.[])/.test(e);for(let c of xe(n,{place:r,visible:d.get(s),firstOfItem:h,inBlock:t.blocks>0,token:a,...l&&{steps:p}}))i.push({state:o(s),field:e,message:c})}c.Type===`Map`&&i.push(...z(c.ItemProcessor,{...t,path:[...t.path,s],outer:d.get(s),item:!0,steps:p},r)),c.Type===`Block`&&(i.push(...ke(c,o(s),t.blocks+1)),i.push(...z(c.Processor,{path:[...t.path,s],outer:new Set,item:!1,blocks:t.blocks+1,data:l,steps:new Set},r)))}return l&&i.push(...Le(e,o)),i},Be=e=>{let t=_(e.stateMachine).map(([e])=>e),n=[];t.length>m.states&&n.push({field:`stateMachine.States`,message:`holds ${t.length} states, more than the ${m.states} a workflow may have`});let r=new Set;for(let e of t)r.has(e)&&n.push({state:e,message:`is a state name used twice; names are unique across the whole state machine, Maps and Blocks included`}),r.add(e);return n},Ve=(e,t)=>{let n=new TextEncoder().encode(JSON.stringify(e)??``).length;if(n>m.definitionBytes)return[{message:`The definition is ${n} bytes as JSON, more than the ${m.definitionBytes} a workflow may have`}];let r=je(e);if(r.length>0)return r;let i=oe(e);if(i.length>0)return i;let a=me(e);if(a.length>0)return a;let o=e;return[...he(o.trigger,t.triggers,t.unavailable),...t.connections?we(o,t.connections):[],...Be(o),...z(o.stateMachine,{path:[],outer:new Set,item:!1,blocks:0,data:s(o)===`data`,steps:new Set},t),...t.pins?Ne(o,t.pins):[]]},He=[`SUCCEEDED`,`FAILED`,`TIMED_OUT`,`ABORTED`,`SKIPPED`],Ue=[`=`,`!=`,`>`,`<`],B=e=>`kind`in e,V=e=>Object.keys(e).every(e=>e===`type`||e===`value`||e===`position`),We=e=>{if(e.type===`variable`&&V(e)&&typeof e.value==`string`&&e.value!==``&&e.value!==`states`)return{base:{variable:e.value},path:[]};if(e.type!==`path`||!e.steps||!e.steps.every(V))return;let[t,...n]=e.steps;if(t?.type!==`variable`||typeof t.value!=`string`||!n.every(e=>e.type===`name`&&typeof e.value==`string`))return;let r=n.map(e=>e.value);if(t.value!==`states`)return t.value===``?void 0:{base:{variable:t.value},path:r};if(r[0]===`context`&&r[1]===`Steps`&&r.length>2)return{base:{step:r[2]},path:r.slice(3)};if(r[0]===`context`&&r[1]===`Execution`&&r[2]===`Input`)return{base:{input:!0},path:r.slice(3)}},H=e=>{if(e.type===`string`||e.type===`number`||e.type===`value`&&typeof e.value==`boolean`)return{value:e.value};let t=We(e);return t&&{read:t}},U=(e,t)=>e.type===`binary`&&e.value===t?[...U(e.lhs,t),e.rhs]:[e],Ge=e=>e instanceof RegExp,W=e=>{if(e.type===`block`&&e.expressions?.length===1)return W(e.expressions[0]);if(e.type===`binary`&&(e.value===`and`||e.value===`or`)){let t=U(e,e.value).map(G);return t.every(e=>e!==void 0)?{kind:`logic`,op:e.value,sides:t}:void 0}let[t,n]=e.arguments??[];if(e.type===`function`&&e.procedure?.type===`variable`&&e.procedure.value===`contains`&&e.arguments?.length===2&&n?.type===`regex`&&Ge(n.value)){let e=H(t);return e&&{kind:`matches`,sides:[e,{pattern:n.value.source,flags:n.value.flags.replace(`g`,``)}]}}if(e.type===`binary`&&Ue.includes(e.value)){let[t,n]=[H(e.lhs),H(e.rhs)];return t&&n&&{kind:`compare`,op:e.value,sides:[t,n]}}if(e.type===`function`&&e.procedure?.type===`variable`&&e.procedure.value===`not`&&e.arguments?.length===1){let t=G(e.arguments[0]);return t&&{kind:`not`,sides:[t]}}},G=e=>{let t=W(e);if(t)return t;let n=H(e);return n&&(`read`in n||typeof n.value==`boolean`)?n:void 0},Ke=e=>/^[^'\\\x00-\x1f]*$/.test(e)?`'${e}'`:JSON.stringify(e),K=e=>`read`in e?l(e.read):typeof e.value==`string`?Ke(e.value):String(e.value),qe=(e,t)=>{if(!B(e))return K(e);let n=q(e);return e.kind===`logic`&&(e.op===t||t===`and`&&e.op===`or`)?`(${n})`:n},q=e=>{if(e.kind===`compare`)return`${K(e.sides[0])} ${e.op} ${K(e.sides[1])}`;if(e.kind===`matches`)return`$contains(${K(e.sides[0])}, /${e.sides[1].pattern}/${e.sides[1].flags})`;if(e.kind===`logic`)return e.sides.map(t=>qe(t,e.op)).join(` ${e.op} `);let[t]=e.sides;return`$not(${B(t)?q(t):K(t)})`},J=e=>`{% ${q(e)} %}`,Je=e=>{let t=i(e);if(t===void 0)return;let n=h(t);if(`error`in n)return;let r=W(n.expression.ast());return r&&J(r)===e?r:void 0},Y=e=>{if(!e)return;let t=H(e);return t&&`value`in t?t.value:void 0},Ye=e=>{let t=[],n,r=e;for(;r?.type===`condition`;){let e=r.condition;if(e?.type!==`binary`||e.value!==`=`)return;let i=H(e.lhs),[a,o]=[Y(e.rhs),Y(r.then)];if(!i||a===void 0||o===void 0||n&&K(n)!==K(i))return;n=i,t.push({when:a,then:o}),r=r.else}let i=Y(r);return n&&i!==void 0?{operand:n,cases:t,otherwise:i}:void 0},X=({operand:e,cases:t,otherwise:n})=>{let r=K(e),i=e=>K({value:e});return`{% ${[...t.map(({when:e,then:t})=>`${r} = ${i(e)} ? ${i(t)}`),i(n)].join(` : `)} %}`},Xe=e=>{let t=i(e);if(t===void 0)return;let n=h(t);if(`error`in n)return;let r=Ye(n.expression.ast());return r&&X(r)===e?r:void 0},Z=(e,t,n)=>{let r=new Set,i=[t];for(;i.length>0;){let t=i.pop(),a=e.States[t];!r.has(t)&&t!==n&&a&&(r.add(t),i.push(...j(a).map(e=>e.target)))}return r},Q=e=>{let t=new Set(k(e).flatMap(({source:e})=>[...P(e)?.variables??[]]));if(e.Type===`Map`)for(let n of Object.values(e.ItemProcessor?.States??{}))for(let e of Q(n))t.add(e);return t},$=(e,t)=>{let n=e=>[...t,e].join(`/`),r=[];for(let[i,a]of Object.entries(e.States)){let s=o(a);if(s&&r.push(...$(s,[...t,i])),a.Type!==`Block`||a.Next===void 0||!a.Assign)continue;let c=new Set(Object.keys(a.Assign)),l=[...Z(e,a.Next,i)].filter(t=>e.States[t].Type===`Wait`),u=new Set;for(let t of l){let a=e.States[t];if(`Next`in a&&a.Next!==void 0)for(let o of Z(e,a.Next,i)){let a=[...Q(e.States[o])].filter(e=>c.has(e));if(a.length===0||u.has(o))continue;u.add(o);let s=a.map(e=>`$${e}`).join(`, `);r.push({state:n(o),message:`reads ${s} after the Wait "${t}", and the Block "${i}" set it before that Wait. If it holds something that expires, such as a signed link, it may have expired by then: set it after the Wait instead. If it holds what the block stored, you can leave it.`})}}}return r},Ze=e=>$(e.stateMachine,[]),Qe=`{% $states.result %}`,$e=`Not sent: replay`;export{J as a,X as c,R as d,L as f,Je as i,He as l,Qe as n,B as o,A as p,Ze as r,Xe as s,$e as t,Ve as u};
|
|
2
|
-
//# debugId=
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{A as e,D as t,E as n,M as r,O as i,S as a,T as o,a as s,b as c,c as l,d as u,f as d,g as f,i as p,j as m,k as h,p as ee,s as te,u as ne,v as g,w as _,x as v,y as re}from"./workflows-start-QUKfwFqf.js";var y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ie=[`InputPath`,`Parameters`,`ResultSelector`,`ResultPath`,`OutputPath`,`ItemsPath`],ae={ItemReader:`is a distributed Map's reader, which does not run here; give the Map its Items`,ItemBatcher:`is a distributed Map's batcher, which does not run here`,ResultWriter:`is a distributed Map's writer, which does not run here`,ToleratedFailureCount:`is a distributed Map's, which does not run here`,ToleratedFailurePercentage:`is a distributed Map's, which does not run here`,Credentials:`does not run here: a step signs in through the connection its type declares`},b=(e,t)=>y(e)?Object.entries(e).flatMap(([e,n])=>{if(!y(n))return[];let r=[...t,e].join(`/`),i=[];n.Type===`Parallel`&&i.push({state:r,field:`Type`,message:`is Parallel, which does not run here yet; in data order, states that read nothing of each other run at once`}),typeof n.Resource==`string`&&n.Resource.startsWith(`arn:`)&&i.push({state:r,field:`Resource`,message:`is a Step Functions service (${n.Resource}), which does not run here: write the step with one of this app's step types, such as app:http for an HTTP request`});for(let e of ie)n[e]!==void 0&&i.push({state:r,field:e,message:`is JSONPath, which does not run here; write the state in JSONata, with Arguments, Output and Assign`});for(let[e,t]of Object.entries(ae))n[e]!==void 0&&i.push({state:r,field:e,message:t});let a=y(n.ItemProcessor)?n.ItemProcessor.ProcessorConfig:void 0;y(a)&&a.Mode===`DISTRIBUTED`&&i.push({state:r,field:`ItemProcessor.ProcessorConfig.Mode`,message:`is DISTRIBUTED, which does not run here; a Map runs its items inline`});for(let r of[`ItemProcessor`,`Processor`,`Iterator`])y(n[r])&&i.push(...b(n[r].States,[...t,e]));return i}):[],oe=e=>{let t=y(e)&&y(e.stateMachine)?e.stateMachine:void 0;if(!t)return[];let n=[];return t.QueryLanguage!==`JSONata`&&n.push({field:`stateMachine.QueryLanguage`,message:`is ${t.QueryLanguage===void 0?`missing, so the machine is JSONPath, the default of Step Functions`:JSON.stringify(t.QueryLanguage)}; only JSONata machines run here: set "QueryLanguage": "JSONata" and write its states in JSONata`}),t.TimeoutSeconds!==void 0&&n.push({field:`stateMachine.TimeoutSeconds`,message:`is a whole run's timeout, which does not run here; give each Task its TimeoutSeconds`}),[...n,...b(t.States,[])]},se=r(),x={type:`string`,pattern:`^\\{%[\\s\\S]*%\\}$`},S={type:`string`,minLength:1,maxLength:80},C={type:`array`,minItems:1,items:{type:`string`,minLength:1}},w={type:`object`,propertyNames:{pattern:`^[A-Za-z][A-Za-z0-9_]*$`}},ce={type:`object`,additionalProperties:!1,required:[`ErrorEquals`],properties:{ErrorEquals:C,IntervalSeconds:{type:`integer`,minimum:1,maximum:m.retryDelaySeconds},MaxAttempts:{type:`integer`,minimum:0,maximum:m.retryAttempts},BackoffRate:{type:`number`,minimum:1,maximum:10},MaxDelaySeconds:{type:`integer`,minimum:1,maximum:m.retryDelaySeconds}}},T=e=>{let t=e===`sequence`,n={Type:{},Comment:{type:`string`},Output:{},Assign:w,QueryLanguage:{const:`JSONata`},...!t&&{Condition:x}},r=t?{Next:S,End:{const:!0}}:{},i=t?{oneOf:[{required:[`Next`],not:{required:[`End`]}},{required:[`End`],not:{required:[`Next`]}}]}:{},a={type:`object`,additionalProperties:!1,required:[`ErrorEquals`,...t?[`Next`]:[]],properties:{ErrorEquals:C,...t&&{Next:S},Output:{},Assign:w}},o={Retry:{type:`array`,items:ce},Catch:{type:`array`,items:a}},s=(e,t,{required:r=[],...i}={})=>({type:`object`,additionalProperties:!1,required:[`Type`,...r],...i,properties:{...n,Type:{const:e},...t}}),c=t?{type:`object`,required:[`StartAt`,`States`],properties:{StartAt:S,Comment:{type:`string`},States:{type:`object`,minProperties:1,propertyNames:S,additionalProperties:{$ref:`#/definitions/state`}}}}:{type:`object`,required:[`States`],properties:{Comment:{type:`string`},States:{type:`object`,minProperties:1,propertyNames:S,additionalProperties:{$ref:`#/definitions/state`}}}},l={...t&&{StartAt:{}},States:{},Comment:{},Version:{type:`string`}},u=[s(`Pass`,r,i),s(`Task`,{...r,...o,Resource:S,Arguments:{},TimeoutSeconds:{type:`integer`,minimum:1,maximum:m.waitingTaskTimeoutSeconds},HeartbeatSeconds:{type:`integer`,minimum:1,maximum:m.waitingTaskTimeoutSeconds},Cache:{type:`boolean`}},{required:[`Resource`],...i}),s(`Wait`,{...r,Seconds:{anyOf:[{type:`integer`,minimum:0,maximum:m.waitSeconds},x]},Timestamp:{type:`string`}},{allOf:[i,{oneOf:[{required:[`Seconds`]},{required:[`Timestamp`]}]}]}),{type:`object`,additionalProperties:!1,required:[`Type`],properties:{Type:{const:`Fail`},Comment:{type:`string`},QueryLanguage:{const:`JSONata`},...!t&&{Condition:x},Error:{type:`string`},Cause:{type:`string`}}},s(`Map`,{...r,...o,Items:{},ItemProcessor:{$ref:`#/definitions/processor`},MaxConcurrency:{type:`integer`,minimum:0,maximum:m.mapConcurrency}},{required:[`ItemProcessor`,`Items`],...i}),s(`Block`,{...r,...o,Arguments:{},Processor:{$ref:`#/definitions/machine`},Cache:{type:`object`,additionalProperties:!1,required:[`Ttl`],properties:{Ttl:{type:[`integer`,`string`]},Key:{}}}},{required:[`Processor`,`Cache`],...i})],d=t?[s(`Choice`,{Choices:{type:`array`,minItems:1,items:{type:`object`,additionalProperties:!1,required:[`Condition`,`Next`],properties:{Condition:x,Next:S,Comment:{type:`string`},Output:{},Assign:w}}},Default:S},{required:[`Choices`]}),{type:`object`,additionalProperties:!1,required:[`Type`],properties:{Type:{const:`Succeed`},Comment:{type:`string`},Output:{},QueryLanguage:{const:`JSONata`}}}]:[];return{$schema:`http://json-schema.org/draft-07/schema#`,$id:`https://docs.protobase.net/schemas/workflow-definition${t?``:`-data`}.json`,$ref:`#/definitions/definition`,definitions:{machine:c,definition:{type:`object`,additionalProperties:!1,required:[`trigger`,`stateMachine`],properties:{trigger:{$ref:`#/definitions/trigger`},order:{enum:[`sequence`,`data`]},stateMachine:{$ref:`#/definitions/stateMachine`},connections:{$ref:`#/definitions/connections`},trace:{enum:[`all`,`failed`,`none`]}}},connections:{type:`object`,propertyNames:{pattern:`^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$`},additionalProperties:{type:`string`,minLength:1,maxLength:255}},trigger:{type:`object`,minProperties:1,maxProperties:1,propertyNames:{pattern:`^(manual|[a-z][a-z0-9_]*:[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*)$`},properties:{manual:{type:`object`,maxProperties:0}},additionalProperties:{type:`object`}},stateMachine:{allOf:[{$ref:`#/definitions/machine`}],required:[`QueryLanguage`],properties:{QueryLanguage:{const:`JSONata`},...l},additionalProperties:!1},processor:{allOf:[{$ref:`#/definitions/machine`}],properties:{ProcessorConfig:{type:`object`,additionalProperties:!1,properties:{Mode:{const:`INLINE`}}},...l},additionalProperties:!1},state:{type:`object`,required:[`Type`],discriminator:{propertyName:`Type`},oneOf:[...u,...d]}}}},le=T(`sequence`),ue=T(`data`),E=e=>e.reduce((e,t)=>typeof t==`number`||/^\d+$/.test(t)?`${e}[${t}]`:e?`${e}.${t}`:t,``),D=new se.Ajv({allErrors:!0,discriminator:!0,strict:!1}),O={sequence:D.compile(le),data:D.compile(ue)},de=e=>{let t=e.split(`/`).slice(1).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`)),n=t[0]===`stateMachine`&&t[1]===`States`?t.slice(1):t,r=[],i=[];for(let e=0;e<n.length;e++){let t=n[e];if(t===`States`&&e+1<n.length)r.push(n[++e]),i=[];else if((t===`ItemProcessor`||t===`Processor`)&&n[e+1]===`States`)continue;else i.push(t)}return{...r.length>0&&{state:r.join(`/`)},...i.length>0&&{field:E(i)}}},fe=(e,t)=>e.keyword===`additionalProperties`&&t&&[`Next`,`End`,`StartAt`].includes(String(e.params.additionalProperty))?`${e.params.additionalProperty} is not a field in dataflow order, where a state runs once the states it reads from have ended`:e.keyword===`additionalProperties`&&!t&&e.params.additionalProperty===`Condition`?`Condition is a field only in dataflow order ("order": "data"); in sequence order a Choice decides`:e.keyword===`additionalProperties`?`${e.params.additionalProperty} is not a field here`:e.keyword===`required`?`${e.params.missingProperty} is missing`:e.keyword===`minItems`?`is missing; it needs at least ${String(e.params.limit)}`:e.keyword===`const`?`must be ${JSON.stringify(e.params.allowedValue)}`:e.keyword===`discriminator`?t?`must be one of Task, Pass, Map, Block, Wait and Fail; in dataflow order a Condition takes the place of Choice, and the run ends when no state is left to run`:`must be one of Task, Choice, Pass, Map, Block, Wait, Succeed and Fail`:e.keyword===`pattern`&&e.instancePath===`/trigger`?`names a trigger type <plugin>:<key>, such as app:record, or manual`:e.keyword===`pattern`&&e.instancePath.endsWith(`/Assign`)?`names a variable with letters, digits and _, starting with a letter`:e.keyword===`pattern`?`must be an expression written as {% ... %}`:e.keyword===`maxProperties`&&e.instancePath===`/trigger/manual`?`takes no input`:e.keyword===`maxProperties`||e.keyword===`minProperties`?e.instancePath===`/trigger`?`holds exactly one trigger: a trigger type such as app:record, or manual`:e.message??`is not valid`:e.keyword===`oneOf`&&e.schemaPath.endsWith(`/oneOf`)?`needs exactly one of these`:e.message??`is not valid`,pe={Next:`needs either Next or End`,Seconds:`needs either Seconds or Timestamp`},me=e=>{let t=typeof e==`object`&&!!e&&e.order===`data`,n=t?O.data:O.sequence;if(n(e))return[];let r=[],i=new Set,a=n.errors??[];for(let e of a){if(e.keyword===`required`&&/(oneOf|allOf)\/\d+\/oneOf\/\d+\/required$/.test(e.schemaPath)||e.keyword===`not`)continue;let n={...de(e.instancePath),...e.keyword===`discriminator`&&{field:`Type`}},o=fe(e,t);if(e.keyword===`oneOf`){let t=a.find(t=>t.instancePath===e.instancePath&&t.schemaPath.startsWith(e.schemaPath.replace(/\/oneOf$/,`/oneOf/`))&&t.keyword===`required`);o=pe[String(t?.params.missingProperty)]??o}let s=`${n.state}|${n.field}|${o}`;i.has(s)||(i.add(s),r.push({...n,message:o}))}return r},he=(e,t,n={})=>{let[r,i]=Object.entries(e)[0];if(r===`manual`)return Object.keys(i).length===0?[]:[{field:`trigger.manual`,message:`takes no input`}];if(Object.hasOwn(n,r))return[{field:`trigger`,message:`"${r}" cannot run in this app: ${n[r]}`}];let a=t[r];return a?a(i).map(e=>({field:`trigger.${r}${e.field?`.${e.field}`:``}`,message:e.message})):[{field:`trigger`,message:`"${r}" is not a trigger type; use manual or one of ${Object.keys(t).join(`, `)}`}]},k=t=>{let n=[],r=(t,r,i)=>{for(let{path:a,source:o}of e(t,r))n.push({field:E(a),source:o,place:i})},i=t.Type===`Task`||t.Type===`Map`||t.Type===`Block`?`result`:`state`;return r(t.Condition,[`Condition`],`state`),t.Type===`Fail`?(r(t.Error,[`Error`],`state`),r(t.Cause,[`Cause`],`state`),n):(r(t.Output,[`Output`],i),`Assign`in t&&r(t.Assign,[`Assign`],i),t.Type===`Task`&&r(t.Arguments,[`Arguments`],`state`),t.Type===`Map`&&r(t.Items,[`Items`],`state`),t.Type===`Block`&&(r(t.Arguments,[`Arguments`],`state`),r(t.Cache?.Key,[`Cache`,`Key`],`state`)),t.Type===`Wait`&&(r(t.Seconds,[`Seconds`],`state`),r(t.Timestamp,[`Timestamp`],`state`)),t.Type===`Choice`&&t.Choices.forEach((e,t)=>{r(e.Condition,[`Choices`,t,`Condition`],`state`),r(e.Output,[`Choices`,t,`Output`],`state`),r(e.Assign,[`Choices`,t,`Assign`],`state`)}),`Catch`in t&&t.Catch?.forEach((e,t)=>{r(e.Output,[`Catch`,t,`Output`],`error`),r(e.Assign,[`Catch`,t,`Assign`],`error`)}),n)},A=e=>{let t=[];if(`Assign`in e&&e.Assign&&t.push(...Object.keys(e.Assign)),e.Type===`Choice`)for(let n of e.Choices)t.push(...Object.keys(n.Assign??{}));if(`Catch`in e)for(let n of e.Catch??[])t.push(...Object.keys(n.Assign??{}));return t},j=e=>{let t=[];return`Next`in e&&e.Next!==void 0&&t.push({field:`Next`,target:e.Next}),e.Type===`Choice`&&(e.Choices.forEach((e,n)=>t.push({field:`Choices[${n}].Next`,target:e.Next})),e.Default!==void 0&&t.push({field:`Default`,target:e.Default})),`Catch`in e&&e.Catch?.forEach((e,n)=>e.Next!==void 0&&t.push({field:`Catch[${n}].Next`,target:e.Next})),t},ge=e=>{let t=new Set,n=[e.StartAt];for(;n.length>0;){let r=n.pop(),i=e.States[r];if(!t.has(r)&&i){t.add(r);for(let e of j(i))n.push(e.target)}}return t},_e=(e,t)=>{let n=new Set,r=[t];for(;r.length>0;){let t=r.pop(),i=e.States[t];!n.has(t)&&i&&(n.add(t),r.push(...j(i).map(e=>e.target)))}return n},ve=new Set([`states`]),ye=[[`Execution`,`Input`],[`Execution`,`StartTime`],[`Secrets`]],M={state:``,result:`result`,error:`errorOutput`},N=(e,t)=>t.every((t,n)=>e[n]===t),be=(e,t,n)=>{let r=e.slice(1);if(N(r,[`Secrets`]))return r.length>=2?void 0:`reads $states.context.Secrets as a whole; read one secret by its name, such as $states.context.Secrets.API_TOKEN`;if(ye.some(e=>N(r,e)))return;if(N(r,[`Task`]))return n?N(r,[`Task`,`Token`])&&r.length===2?void 0:`reads $states.context.Task, whose only field is Token`:`reads $states.context.Task, which only the Arguments of a Task whose Resource ends in .waitForTaskToken read, as $states.context.Task.Token`;if(t&&N(r,[`Steps`]))return r[1]===void 0?`reads $states.context.Steps as a whole; read one state's status by its name, such as $states.context.Steps.Save.Status`:t.has(r[1])?void 0:`reads $states.context.Steps.${r[1]}, but there is no state ${r[1]} here or around it`;let i=t?`Execution.Input, Execution.StartTime, Secrets.<NAME> and Steps.<state>`:`Execution.Input, Execution.StartTime and Secrets.<NAME>`;return`reads $states.${e.join(`.`)}; $states.context holds only ${i}`},P=e=>{let n=h(e);return`error`in n?void 0:t(n.expression)},xe=(e,{place:n,visible:r,firstOfItem:i,inBlock:a=!1,steps:o,token:s=!1})=>{if(e.length>m.expressionLength)return[`is ${e.length} characters long, more than the ${m.expressionLength} an expression may be`];let c=h(e);if(`error`in c)return[`does not parse: ${c.error.message}${c.error.position===void 0?``:` (at character ${c.error.position})`}`];let l=t(c.expression),u=[];l.input&&u.push(`reads the state's input; read the run's input as $states.context.Execution.Input and an earlier result by the variable a state assigned it to`);for(let e of l.states){let[t=``]=e;if(!(t===`input`&&i)&&(t===``||t!==M[n])){if(t===`context`&&a&&N(e,[`context`,`Execution`,`StartTime`]))u.push(`reads $states.context.Execution.StartTime, which inside a Block is its own run's start, not part of what it is cached by`);else if(t===`context`){let t=be(e,o,s);t&&u.push(t)}else t===`input`?u.push(`reads $states.input, which only the first state of a Map's item processor may read (as the item)`):t===``?u.push(`reads $states as a whole; read one of its fields`):u.push(`reads $states.${t}, which is not there${n===`state`?``:` (here: $states.${M[n]})`}`)}}for(let e of l.variables)r.has(e)||u.push(`reads $${e}, which no state that can run before it assigns`);return l.evaluates&&u.push(`uses $eval, whose reads cannot be checked`),[...new Set(u)]},Se=e=>_(e).flatMap(([,e])=>e.Type===`Task`?[a(e.Resource).type]:[]),Ce=(e,t)=>{let n=[Object.keys(e.trigger)[0],...Se(e.stateMachine)];return new Set(n.flatMap(e=>Object.hasOwn(t,e)?[t[e]]:[]))},we=(e,t)=>{let n=Ce(e,t);return Object.keys(e.connections??{}).filter(e=>!n.has(e)).map(e=>({field:`connections.${e}`,message:`no trigger or step of this workflow signs in with "${e}"; remove it`}))},Te=e=>{let t=Object.keys(`Assign`in e&&e.Assign||{}),n=[];if(`Next`in e&&e.Next!==void 0&&n.push({target:e.Next,names:t}),e.Type===`Choice`){for(let t of e.Choices)n.push({target:t.Next,names:Object.keys(t.Assign??e.Assign??{})});e.Default!==void 0&&n.push({target:e.Default,names:t})}if(`Catch`in e)for(let t of e.Catch??[])t.Next!==void 0&&n.push({target:t.Next,names:Object.keys(t.Assign??{})});return n},Ee=(e,t)=>{let n=new Map(Object.keys(e.States).map(e=>[e,new Set(t)]));for(let t of Object.values(e.States))for(let{target:r,names:i}of Te(t))if(i.length!==0)for(let t of _e(e,r))for(let e of i)n.get(t)?.add(e);return n},De={second:1,minute:60,hour:3600,day:86400},F=e=>{if(typeof e==`number`)return Number.isFinite(e)&&e>=1?Math.min(Math.floor(e),m.cacheMaxSeconds):void 0;if(typeof e!=`string`)return;let t=/^(\d+) (second|minute|hour|day)s?$/.exec(e.trim());if(t)return F(Number(t[1])*De[t[2]])},Oe=(t,n)=>[...e(t.Arguments,[`Arguments`]),...e(t.Cache.Key,[`Cache`,`Key`])].flatMap(({path:e,source:t})=>P(t)?.states.some(e=>e[0]===`context`&&e[1]===`Secrets`)?[{state:n,field:E(e),message:`reads a secret, which a block would keep in its run; read it inside the block as $states.context.Secrets.<NAME>`}]:[]),ke=(e,t,n)=>{let r=[];return F(e.Cache.Ttl)===void 0&&r.push({state:t,field:`Cache.Ttl`,message:`is no time to live: give seconds from 1, or text such as "10 minutes", "1 hour" or "2 days", at most ${m.cacheMaxSeconds/86400} days`}),n>m.blockDepth&&r.push({state:t,message:`is inside ${n-1} other Blocks, more than the ${m.blockDepth-1} a Block may be in`}),[...r,...Oe(e,t)]},Ae=(e,t)=>{let n=0,r=[[e,0]];for(;r.length>0;){let[e,i]=r.pop();if(typeof e==`object`&&e){if(i+1>t)return t+1;n=Math.max(n,i+1);for(let t of Object.values(e))r.push([t,i+1])}}return n},je=e=>Ae(e,m.definitionDepth)<=m.definitionDepth?[]:[{message:`The definition nests more than ${m.definitionDepth} levels of arrays and objects`}],Me=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ne=(e,t)=>[...f(e.stateMachine).flatMap(({path:n,state:r})=>{let i=d(r,t);if(!i)return[];let a=(r,i,a)=>{let o=te(r);if(!o||!i)return[];let s=c(ee(e,o,t)),u=c(i);return re(s,u)?[]:[{state:n,field:[`Arguments`,...a].join(`.`),message:`reads ${l(o)}, ${v(s)}, where ${a.join(`.`)} takes ${v(u)}`}]},o=(e,t,n)=>Me(e)?Object.entries(e).flatMap(([e,r])=>o(r,g(t,[e]),[...n,e])):a(e,t,n);return Object.entries(ne(r)).flatMap(([e,t])=>o(t,g(i,[e]),[e]))}),...u(e.stateMachine).flatMap(({path:e,state:n})=>Ne({trigger:{manual:{}},stateMachine:{...n.Processor,QueryLanguage:`JSONata`}},t).map(t=>({...t,...t.state!==void 0&&{state:`${e}/${t.state}`}})))],I=e=>{let n=[];for(let{field:r,source:i}of k(e)){let e=h(i);if(`error`in e)continue;let a=t(e.expression),o=a.states.filter(e=>e[0]===`context`&&e[1]===`Steps`&&e[2]!==void 0).map(e=>e[2]);n.push({variables:[...a.variables],steps:o,condition:r===`Condition`})}let r=e.Type===`Map`?o(e):void 0;if(r){let e=new Set(Object.values(r.States).flatMap(A)),t=new Set(Object.keys(r.States));for(let i of Object.values(r.States).flatMap(I))n.push({variables:i.variables.filter(t=>!e.has(t)),steps:i.steps.filter(e=>!t.has(e)),condition:i.condition})}return n},Pe=e=>{let t=new Map;for(let[n,r]of Object.entries(e.States))for(let e of A(r))t.has(e)||t.set(e,n);return t},L=e=>{let t=Pe(e);return new Map(Object.entries(e.States).map(([n,r])=>{let i={data:new Set,status:new Set,handled:new Set};for(let n of I(r)){for(let e of n.variables){let n=t.get(e);n!==void 0&&i.data.add(n)}for(let t of n.steps)Object.hasOwn(e.States,t)&&(i.status.add(t),n.condition&&i.handled.add(t))}return[n,i]}))},R=e=>new Set([...e.data,...e.status]),Fe=e=>{let t=new Map,n=[],r=i=>{if(t.get(i)!==`done`){if(t.get(i)===`open`)return[...n.slice(n.indexOf(i)),i];t.set(i,`open`),n.push(i);for(let t of R(e.get(i)??{data:new Set,status:new Set,handled:new Set})){let e=r(t);if(e)return e}n.pop(),t.set(i,`done`)}};for(let t of e.keys()){let e=r(t);if(e)return e}},Ie=(e,t)=>{let n=Object.entries(e.States).map(([e,t])=>[e,A(t)]);return new Map(n.map(([e,r])=>[e,new Set([...t,...n.flatMap(([t,n])=>t===e?[]:n).filter(e=>!r.includes(e))])]))},Le=(e,t)=>{let n=[],r=new Map;for(let[i,a]of Object.entries(e.States))for(let e of new Set(A(a))){let a=r.get(e);a===void 0?r.set(e,i):n.push({state:t(i),field:`Assign`,message:`assigns $${e}, which ${a} assigns already; in dataflow order each variable has one state that assigns it`})}let i=Fe(L(e));return i&&n.push({state:t(i[0]),message:`runs after itself: ${i.join(` reads `)}; a state cannot read what runs after it`}),n},Re=(e,t)=>{let n=t.required?.[a(e.Resource).type]??[];if(i(e.Arguments)!==void 0)return[];let r=typeof e.Arguments==`object`&&e.Arguments!==null?e.Arguments:{};return n.filter(e=>r[e]===void 0||r[e]===``)},ze=e=>{let{type:t,waits:n}=a(e.Resource),r=p(t)!==void 0;if(r&&n)return[{field:`Resource`,message:`ends in .waitForTaskToken, but ${t} is a custom step, which waits for the runner that runs it already: write ${t}`}];if(!n&&!r)return[...e.TimeoutSeconds!==void 0&&e.TimeoutSeconds>m.taskTimeoutSeconds?[{field:`TimeoutSeconds`,message:`is ${e.TimeoutSeconds}, more than the ${m.taskTimeoutSeconds} seconds a step type runs; only a Task whose Resource ends in .waitForTaskToken waits longer`}]:[],...e.HeartbeatSeconds===void 0?[]:[{field:`HeartbeatSeconds`,message:`is for a Task whose Resource ends in .waitForTaskToken, whose outside executor sends heartbeats; this step type ends or fails within its TimeoutSeconds`}]];let i=e.TimeoutSeconds??(r?m.taskTimeoutSeconds:m.waitingTaskTimeoutSeconds);return[...e.HeartbeatSeconds!==void 0&&e.HeartbeatSeconds>=i?[{field:`HeartbeatSeconds`,message:`is ${e.HeartbeatSeconds}, which must be less than the Task's TimeoutSeconds (${i})`}]:[],...e.Cache===!0?[{field:`Cache`,message:r?`is true, but a custom step runs on a runner on every try and caches nothing`:`is true, but a Task that waits for an outside result hands its work off on every try and caches nothing`}]:[]]},z=(e,t,r)=>{let i=[],o=e=>[...t.path,e].join(`/`),s=t.path.length>0?{state:t.path.join(`/`)}:{},c=Object.keys(e.States),{data:l}=t,u=e.StartAt===void 0?void 0:e.States[e.StartAt];!l&&!u&&i.push({...s,field:`StartAt`,message:`names "${e.StartAt}", which is not a state here`});let d=l?Ie(e,t.outer):Ee(e,t.outer),f=l?void 0:ge(e),p=new Set([...t.steps,...c]);for(let s of c){let c=e.States[s];f&&!f.has(s)&&u&&i.push({state:o(s),message:`is never reached from "${e.StartAt}"`});for(let t of j(c))e.States[t.target]||i.push({state:o(s),field:t.field,message:`names "${t.target}", which is not a state here`});for(let e of A(c))(ve.has(e)||n.has(e))&&i.push({state:o(s),field:`Assign`,message:`cannot assign $${e}, a name the runner or JSONata keeps`}),t.outer.has(e)&&i.push({state:o(s),field:`Assign`,message:`cannot assign $${e}, which an outer state assigns already`});let m=c.Type===`Task`?a(c.Resource):void 0;if(m&&r.unavailable&&Object.hasOwn(r.unavailable,m.type)?i.push({state:o(s),field:`Resource`,message:`"${m.type}" cannot run in this app: ${r.unavailable[m.type]}`}):m&&r.versioned&&Object.hasOwn(r.versioned,m.type)?i.push({state:o(s),field:`Resource`,message:`"${m.type}" names no version: write ${r.versioned[m.type]}`}):m&&!r.resources.includes(m.type)&&i.push({state:o(s),field:`Resource`,message:`"${m.type}" is not a step type; use one of ${r.resources.join(`, `)}${m.waits?`, followed by .waitForTaskToken`:``}`}),c.Type===`Task`)for(let e of Re(c,r))i.push({state:o(s),field:`Arguments.${e}`,message:`is missing; ${m.type} needs it`});if(c.Type===`Task`)for(let e of ze(c))i.push({state:o(s),...e});let h=t.item&&(l||s===e.StartAt);for(let{field:e,source:n,place:r}of k(c)){let a=!!m?.waits&&/^Arguments($|[.[])/.test(e);for(let c of xe(n,{place:r,visible:d.get(s),firstOfItem:h,inBlock:t.blocks>0,token:a,...l&&{steps:p}}))i.push({state:o(s),field:e,message:c})}c.Type===`Map`&&i.push(...z(c.ItemProcessor,{...t,path:[...t.path,s],outer:d.get(s),item:!0,steps:p},r)),c.Type===`Block`&&(i.push(...ke(c,o(s),t.blocks+1)),i.push(...z(c.Processor,{path:[...t.path,s],outer:new Set,item:!1,blocks:t.blocks+1,data:l,steps:new Set},r)))}return l&&i.push(...Le(e,o)),i},Be=e=>{let t=_(e.stateMachine).map(([e])=>e),n=[];t.length>m.states&&n.push({field:`stateMachine.States`,message:`holds ${t.length} states, more than the ${m.states} a workflow may have`});let r=new Set;for(let e of t)r.has(e)&&n.push({state:e,message:`is a state name used twice; names are unique across the whole state machine, Maps and Blocks included`}),r.add(e);return n},Ve=(e,t)=>{let n=new TextEncoder().encode(JSON.stringify(e)??``).length;if(n>m.definitionBytes)return[{message:`The definition is ${n} bytes as JSON, more than the ${m.definitionBytes} a workflow may have`}];let r=je(e);if(r.length>0)return r;let i=oe(e);if(i.length>0)return i;let a=me(e);if(a.length>0)return a;let o=e;return[...he(o.trigger,t.triggers,t.unavailable),...t.connections?we(o,t.connections):[],...Be(o),...z(o.stateMachine,{path:[],outer:new Set,item:!1,blocks:0,data:s(o)===`data`,steps:new Set},t),...t.pins?Ne(o,t.pins):[]]},He=[`SUCCEEDED`,`FAILED`,`TIMED_OUT`,`ABORTED`,`SKIPPED`],Ue=[`=`,`!=`,`>`,`<`],B=e=>`kind`in e,V=e=>Object.keys(e).every(e=>e===`type`||e===`value`||e===`position`),We=e=>{if(e.type===`variable`&&V(e)&&typeof e.value==`string`&&e.value!==``&&e.value!==`states`)return{base:{variable:e.value},path:[]};if(e.type!==`path`||!e.steps||!e.steps.every(V))return;let[t,...n]=e.steps;if(t?.type!==`variable`||typeof t.value!=`string`||!n.every(e=>e.type===`name`&&typeof e.value==`string`))return;let r=n.map(e=>e.value);if(t.value!==`states`)return t.value===``?void 0:{base:{variable:t.value},path:r};if(r[0]===`context`&&r[1]===`Steps`&&r.length>2)return{base:{step:r[2]},path:r.slice(3)};if(r[0]===`context`&&r[1]===`Execution`&&r[2]===`Input`)return{base:{input:!0},path:r.slice(3)}},H=e=>{if(e.type===`string`||e.type===`number`||e.type===`value`&&typeof e.value==`boolean`)return{value:e.value};let t=We(e);return t&&{read:t}},U=(e,t)=>e.type===`binary`&&e.value===t?[...U(e.lhs,t),e.rhs]:[e],Ge=e=>e instanceof RegExp,W=e=>{if(e.type===`block`&&e.expressions?.length===1)return W(e.expressions[0]);if(e.type===`binary`&&(e.value===`and`||e.value===`or`)){let t=U(e,e.value).map(G);return t.every(e=>e!==void 0)?{kind:`logic`,op:e.value,sides:t}:void 0}let[t,n]=e.arguments??[];if(e.type===`function`&&e.procedure?.type===`variable`&&e.procedure.value===`contains`&&e.arguments?.length===2&&n?.type===`regex`&&Ge(n.value)){let e=H(t);return e&&{kind:`matches`,sides:[e,{pattern:n.value.source,flags:n.value.flags.replace(`g`,``)}]}}if(e.type===`binary`&&Ue.includes(e.value)){let[t,n]=[H(e.lhs),H(e.rhs)];return t&&n&&{kind:`compare`,op:e.value,sides:[t,n]}}if(e.type===`function`&&e.procedure?.type===`variable`&&e.procedure.value===`not`&&e.arguments?.length===1){let t=G(e.arguments[0]);return t&&{kind:`not`,sides:[t]}}},G=e=>{let t=W(e);if(t)return t;let n=H(e);return n&&(`read`in n||typeof n.value==`boolean`)?n:void 0},Ke=e=>/^[^'\\\x00-\x1f]*$/.test(e)?`'${e}'`:JSON.stringify(e),K=e=>`read`in e?l(e.read):typeof e.value==`string`?Ke(e.value):String(e.value),qe=(e,t)=>{if(!B(e))return K(e);let n=q(e);return e.kind===`logic`&&(e.op===t||t===`and`&&e.op===`or`)?`(${n})`:n},q=e=>{if(e.kind===`compare`)return`${K(e.sides[0])} ${e.op} ${K(e.sides[1])}`;if(e.kind===`matches`)return`$contains(${K(e.sides[0])}, /${e.sides[1].pattern}/${e.sides[1].flags})`;if(e.kind===`logic`)return e.sides.map(t=>qe(t,e.op)).join(` ${e.op} `);let[t]=e.sides;return`$not(${B(t)?q(t):K(t)})`},J=e=>`{% ${q(e)} %}`,Je=e=>{let t=i(e);if(t===void 0)return;let n=h(t);if(`error`in n)return;let r=W(n.expression.ast());return r&&J(r)===e?r:void 0},Y=e=>{if(!e)return;let t=H(e);return t&&`value`in t?t.value:void 0},Ye=e=>{let t=[],n,r=e;for(;r?.type===`condition`;){let e=r.condition;if(e?.type!==`binary`||e.value!==`=`)return;let i=H(e.lhs),[a,o]=[Y(e.rhs),Y(r.then)];if(!i||a===void 0||o===void 0||n&&K(n)!==K(i))return;n=i,t.push({when:a,then:o}),r=r.else}let i=Y(r);return n&&i!==void 0?{operand:n,cases:t,otherwise:i}:void 0},X=({operand:e,cases:t,otherwise:n})=>{let r=K(e),i=e=>K({value:e});return`{% ${[...t.map(({when:e,then:t})=>`${r} = ${i(e)} ? ${i(t)}`),i(n)].join(` : `)} %}`},Xe=e=>{let t=i(e);if(t===void 0)return;let n=h(t);if(`error`in n)return;let r=Ye(n.expression.ast());return r&&X(r)===e?r:void 0},Z=(e,t,n)=>{let r=new Set,i=[t];for(;i.length>0;){let t=i.pop(),a=e.States[t];!r.has(t)&&t!==n&&a&&(r.add(t),i.push(...j(a).map(e=>e.target)))}return r},Q=e=>{let t=new Set(k(e).flatMap(({source:e})=>[...P(e)?.variables??[]]));if(e.Type===`Map`)for(let n of Object.values(e.ItemProcessor?.States??{}))for(let e of Q(n))t.add(e);return t},$=(e,t)=>{let n=e=>[...t,e].join(`/`),r=[];for(let[i,a]of Object.entries(e.States)){let s=o(a);if(s&&r.push(...$(s,[...t,i])),a.Type!==`Block`||a.Next===void 0||!a.Assign)continue;let c=new Set(Object.keys(a.Assign)),l=[...Z(e,a.Next,i)].filter(t=>e.States[t].Type===`Wait`),u=new Set;for(let t of l){let a=e.States[t];if(`Next`in a&&a.Next!==void 0)for(let o of Z(e,a.Next,i)){let a=[...Q(e.States[o])].filter(e=>c.has(e));if(a.length===0||u.has(o))continue;u.add(o);let s=a.map(e=>`$${e}`).join(`, `);r.push({state:n(o),message:`reads ${s} after the Wait "${t}", and the Block "${i}" set it before that Wait. If it holds something that expires, such as a signed link, it may have expired by then: set it after the Wait instead. If it holds what the block stored, you can leave it.`})}}}return r},Ze=e=>$(e.stateMachine,[]),Qe=`{% $states.result %}`,$e=`Not sent: replay`;export{J as a,X as c,R as d,L as f,Je as i,He as l,Qe as n,B as o,A as p,Ze as r,Xe as s,$e as t,Ve as u};
|
|
2
|
+
//# debugId=e5bce967-f6f6-4512-a650-8436f61c6d09
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DFwUHQ4A.js";import{W as a}from"./vendor-WWp_xlp2.js";var o=i((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;var 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})),s=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=o(),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 i=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=i;var a=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=a;var s=(0,t._)`\n`;e.ValueScope=class extends i{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 a(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}}})),c=i((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;var t=o(),n=s(),r=o();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 i=s();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.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 a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},c=class extends a{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 a{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 a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},f=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},p=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},m=class extends a{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 a{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?`
|
|
1
|
+
(function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DFwUHQ4A.js";import{W as a}from"./vendor-3etemhgS.js";var o=i((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;var 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})),s=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=o(),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 i=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=i;var a=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=a;var s=(0,t._)`\n`;e.ValueScope=class extends i{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 a(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}}})),c=i((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;var t=o(),n=s(),r=o();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 i=s();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.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 a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},c=class extends a{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 a{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 a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},f=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},p=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},m=class extends a{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 a{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
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){return e instanceof t.Name?i(e):a(e)?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),[])):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;var P=R(e.operators.AND);function F(...e){return e.reduce(P)}e.and=F;var 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})`}})),l=i((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;var t=c(),n=o();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!s(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(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=a;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=s;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||{...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,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!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;var 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})),u=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=c();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`)}})),d=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=c(),n=l(),r=u();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 o(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=o;function s({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=s;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))}var 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])}})),f=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=d(),n=c(),r=u(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(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 o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(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)}})),p=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;var 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})),m=i((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})),h=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=p(),n=m(),r=d(),i=c(),a=l(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=u(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=s;function u(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=u;function f(e,t){let{gen:r,data:i,opts:a}=e,s=g(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=b(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?_(e,t,s):S(e)})}return c}e.coerceAndCheckDataType=f;var 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
3
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
4
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"
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
missingProperty: ${i},
|
|
7
7
|
depsCount: ${n},
|
|
8
8
|
deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(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 o(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=o;function s(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=s,e.default=i})),ge=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=c(),n=l();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)}}})),_e=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=_(),n=c(),r=u(),i=l();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)}}}})),ve=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=C(),n=_(),r=l(),i=_e();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)}}}})),ye=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=_(),n=c(),r=l(),i=l();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())})})}}}})),be=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=l();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`}}})),xe=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:_().validateUnion,error:{message:`must match a schema in anyOf`}}})),Se=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=c(),n=l();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)})})}}}})),Ce=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=l();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)})}}})),we=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=c(),n=l(),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})),Te=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=l();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`)}}})),Ee=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ue(),n=fe(),r=de(),i=pe(),a=me(),o=he(),s=ge(),c=_e(),l=ve(),u=ye(),d=be(),f=xe(),p=Se(),m=Ce(),h=we(),g=Te();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=_})),De=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=c();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})`}}}}})),Oe=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[De().default]})),ke=i((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`]})),Ae=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=te(),n=le(),r=Ee(),i=Oe(),a=ke();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),je=i((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={}))})),Me=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=c(),n=je(),r=E(),i=T(),a=l();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}}}}})),Ne=r({$id:()=>Fe,$schema:()=>Pe,default:()=>Be,definitions:()=>Le,properties:()=>ze,title:()=>Ie,type:()=>Re}),Pe,Fe,Ie,Le,Re,ze,Be,Ve=t((()=>{Pe=`http://json-schema.org/draft-07/schema#`,Fe=`http://json-schema.org/draft-07/schema#`,Ie=`Core schema meta-schema`,Le={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:[]}},Re=[`object`,`boolean`],ze={$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:`#`}},Be={$schema:Pe,$id:Fe,title:Ie,definitions:Le,type:Re,properties:ze,default:!0}})),He=i(((t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;var r=z(),i=Ae(),a=Me(),o=(Ve(),e(Ne).default),s=[`/properties`],l=`http://json-schema.org/draft-07/schema`,u=class extends r.default{_addVocabularies(){super._addVocabularies(),i.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(a.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(o,s):o;this.addMetaSchema(e,l,!1),this.refs[`http://json-schema.org/schema`]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};t.Ajv=u,n.exports=t=u,n.exports.Ajv=u,Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var d=C();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var f=c();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return f._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return f.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return f.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return f.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return f.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return f.CodeGen}});var p=w();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return p.default}});var m=T();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})),K={definitionBytes:262144,definitionDepth:256,expressionLength:4096,states:100,taskTimeoutSeconds:300,defaultTaskTimeoutSeconds:300,waitingTaskTimeoutSeconds:31622400,taskErrorLength:256,taskCauseLength:32768,waitSeconds:31622400,retryAttempts:19,retryDelaySeconds:86400,mapConcurrency:20,blockDepth:4,blockRuns:1e3,blockWaitSeconds:86400,mapItems:1e4,runSteps:5e4,valueBytes:262144,logLines:100,logLineLength:1e3,expressionMs:1e3,expressionDepth:300,segmentMs:6e4,inputBytes:262144,inputDepth:64,cacheMaxSeconds:2592e3,cacheForcedSeconds:3600,cacheValueBytes:262144,cacheEntries:1e3,cacheLookupMs:2e3},Ue=n(a(),1),We=/^\{%([\s\S]*)%\}$/,q=e=>typeof e==`string`?We.exec(e)?.[1]:void 0,Ge=(e,t=[])=>{let n=q(e);return n===void 0?Array.isArray(e)?e.flatMap((e,n)=>Ge(e,[...t,n])):typeof e==`object`&&e?Object.entries(e).flatMap(([e,n])=>Ge(n,[...t,e])):[]:[{path:t,source:n}]},Ke=e=>typeof e==`object`&&!!e&&typeof e.code==`string`&&typeof e.message==`string`,qe=e=>(0,Ue.default)(e,{timeout:K.expressionMs,stack:K.expressionDepth,sequence:K.mapItems*10}),Je=e=>{try{return{expression:qe(e)}}catch(e){if(!Ke(e))throw e;return{error:e}}},J=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,Ye=new Set([`stages`,`predicate`,`group`,`terms`]),Xe=new Set([`name`,`wildcard`,`descendant`,`parent`]),Ze=new Set(`sum count max min average string substring substringBefore substringAfter lowercase uppercase length trim pad match contains replace split join formatNumber formatBase formatInteger parseInteger number floor ceil round abs sqrt power random boolean not map zip filter single reduce sift keys lookup append exists spread merge reverse each error assert type sort shuffle distinct base64encode base64decode encodeUrlComponent encodeUrl decodeUrlComponent decodeUrl eval toMillis fromMillis clone now millis`.split(` `)),Qe=e=>J(e)&&(e.type===`block`||e.type===`lambda`),Y=(e,t=new Set,n=!0)=>{if(Array.isArray(e)){for(let n of e)Y(n,t,!1);return t}if(!J(e)||!n&&Qe(e))return t;e.type===`bind`&&J(e.lhs)&&e.lhs.type===`variable`&&t.add(String(e.lhs.value));for(let[n,r]of Object.entries(e))n!==`position`&&n!==`value`&&n!==`type`&&Y(r,t,!1);return t},$e=(e,t)=>{if(!J(e)||!Qe(e))return t;let n=e.type===`lambda`&&Array.isArray(e.arguments)?e.arguments.map(e=>String(e.value)):[];return new Set([...t,...n,...Y(e)])},et=e=>Y(e),tt=e=>{let t=new Set,n=[],r=!1,i=new WeakSet,a=(e,o,s)=>{if(Array.isArray(e))return e.forEach(e=>a(e,o,s));if(!J(e))return;let c=$e(e,s);if(e.type===`variable`){let n=String(e.value);n===``||n===`$`?r||=o:c.has(n)||t.add(n)}if(Xe.has(e.type)&&o&&(r=!0),e.type===`path`&&Array.isArray(e.steps)){let[t]=e.steps;if(t?.type===`variable`&&t.value===`states`){i.add(t);let r=e.steps.slice(1),a=r.findIndex(e=>e.type!==`name`||e.stages!==void 0||e.predicate!==void 0);n.push(r.slice(0,a===-1?r.length:a+ +(r[a]?.type===`name`)).map(e=>String(e.value)))}e.steps.forEach((e,t)=>a(e,t===0&&o,c))}else e.type===`variable`&&e.value===`states`&&!i.has(e)&&n.push([]);for(let[t,n]of Object.entries(e))(t!==`steps`||e.type!==`path`)&&t!==`position`&&t!==`value`&&t!==`type`&&a(n,Ye.has(t)||e.type===`filter`||e.type===`sort`?!1:o,c)},o=e.ast();a(o,!0,Y(o));let s=t.has(`eval`);for(let e of Ze)t.delete(e);return t.delete(`states`),{variables:t,states:n,input:r,evaluates:s}},X=e=>{if(e?.Type===`Map`)return e.ItemProcessor;if(e?.Type===`Block`)return e.Processor},nt=e=>Object.entries(e.States).flatMap(([e,t])=>{let n=X(t);return[[e,t],...n?nt(n):[]]}),rt=`.waitForTaskToken`,it=e=>e.endsWith(`.waitForTaskToken`)?{type:e.slice(0,-17),waits:!0}:{type:e,waits:!1},at=[`string`,`integer`,`number`,`boolean`,`object`,`array`,`null`],ot=e=>typeof e==`object`&&!!e&&!Array.isArray(e),st=e=>(Array.isArray(e.type)?e.type:e.type===void 0?[]:[e.type]).filter(e=>at.includes(e)),ct=e=>{let t=st(e),n=[e.anyOf,e.oneOf].find(Array.isArray);if(n){let e=n.filter(ot).map(ct);if(e.includes(`any`))return t.length>0?t:`any`;let r=[...new Set(e.flat())];return t.length>0?r.filter(e=>t.includes(e)||e===`integer`&&t.includes(`number`)):r}return t.length>0?t:Array.isArray(e.enum)&&e.enum.every(e=>typeof e==`string`)?[`string`]:ot(e.properties)?[`object`]:`any`},lt=e=>{if(!e)return{kinds:`any`};let t=typeof e.title==`string`?e.title:void 0;return{kinds:ct(e),...t!==void 0&&{title:t}}},ut=(e,t)=>{if(e.kinds===`any`||t.kinds===`any`)return!0;let n=t.kinds;return e.kinds.every(e=>n.includes(e)||e===`integer`&&n.includes(`number`))},dt={string:`text`,integer:`a whole number`,number:`a number`,boolean:`true or false`,object:`an object`,array:`a list`,null:`null`},ft=e=>e.title===void 0?e.kinds===`any`?`any value`:e.kinds.map(e=>dt[e]).join(` or `):e.title,pt={type:`object`,required:[`configuration`,`path`,`name`,`type`,`size`],description:`a stored file, { configuration, node?, path, name, type, size }, as a storage step or the http step gave it`,properties:{configuration:{type:`string`},node:{type:`string`},path:{type:`string`},name:{type:`string`},type:{type:`string`},size:{type:`integer`}}},Z=e=>typeof e==`object`&&!!e&&!Array.isArray(e),mt=(e,t,n,r=()=>void 0)=>{let i=e=>{if(Array.isArray(e))return e.map(i);if(!Z(e))return e;if(e[`x-file`]===!0)return{...pt,...ht(e,[`title`,`description`])};let a=e[`x-record-of`];if(typeof a==`string`){let r=t[a],i=e[`x-record-use`]===`write`?`write`:`read`;return(typeof r==`string`&&!r.startsWith(`{%`)?n(r,i):void 0)??Q(e,[`x-record-of`,`x-record-use`])}let o=e[`x-email-of`];if(typeof o==`string`){let n=t[o],i=typeof n==`string`&&!n.startsWith(`{%`)?r(n):void 0,a=Q(e,[`x-email-of`,`x-email-use`]);return e[`x-email-use`]===`locale`?i&&i.languages.length>0?{...a,enum:[...i.languages]}:a:i?.schema??a}let s=e[`x-one-or-many-of`];if(typeof s==`string`&&Array.isArray(e.anyOf)&&e.anyOf.length===2){let n=t[s];return Array.isArray(n)?i(e.anyOf[1]):Z(n)?i(e.anyOf[0]):i(Q(e,[`x-one-or-many-of`]))}let c=e[`x-schema-of`];if(typeof c==`string`){let n=t[c];return Z(n)?n:Q(e,[`x-schema-of`])}return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,i(t)]))};return i(e)},Q=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),ht=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e))),$=(e,t)=>{let n=e;for(let e of t){if(!n)return;n=gt(n,e)}return n},gt=(e,t)=>{let n=[e.anyOf,e.oneOf].find(Array.isArray);if(n){if(n.some(e=>!Z(e)))return;let e=n.filter(Z).map(e=>gt(e,t));return e.length===0||e.some(e=>e===void 0)?void 0:e.length===1?e[0]:{anyOf:e}}if(Z(e.properties)&&Z(e.properties[t]))return e.properties[t];if(Z(e.additionalProperties))return e.additionalProperties},_t=e=>{let t=`Arguments`in e?e.Arguments:void 0;return typeof t==`object`&&t&&!Array.isArray(t)?t:{}},vt=e=>Object.entries(e.States).flatMap(([e,t])=>{let n=t.Type===`Map`?X(t):void 0;return[[e,t],...n?vt(n):[]]}),yt=(e,t)=>{let n=vt(e).filter(([,e])=>(`Assign`in e?e.Assign:void 0)?.[t]!==void 0);if(n.length!==1)return;let[r,i]=n[0];return q(i.Assign[t])?.trim()===`$states.result`?[r,i]:void 0},bt=(e,t)=>{if(e.Type!==`Task`)return;let{type:n,waits:r}=it(e.Resource);return!r&&t.outputs[n]?mt(t.outputs[n],_t(e),t.records,t.emails):void 0},xt=(e,t)=>{let[n,r]=Object.entries(e.trigger??{})[0]??[];if(n!==void 0&&n!==`manual`&&t.outputs[n])return mt(t.outputs[n],r??{},t.records,t.emails)},St={type:`object`,title:`Step status`,properties:{Status:{enum:[`SUCCEEDED`,`FAILED`,`TIMED_OUT`,`ABORTED`,`SKIPPED`]},Error:{type:[`string`,`null`]},Cause:{type:[`string`,`null`]}}},Ct=(e,t,n)=>{let{base:r,path:i}=t;if(`input`in r)return $(xt(e,n),i);if(`step`in r)return $(St,i);let a=yt(e.stateMachine,r.variable);return a&&$(bt(a[1],n),i)},wt=(e,t)=>{if(e.Type!==`Task`)return;let{type:n}=it(e.Resource);return t.inputs[n]?mt(t.inputs[n],_t(e),t.records,t.emails):void 0},Tt=(e,t=[])=>Object.entries(e.States).flatMap(([e,n])=>{if(n.Type===`Block`)return[{path:[...t,e].join(`/`),state:n}];let r=n.Type===`Map`?X(n):void 0;return r?Tt(r,[...t,e]):[]}),Et=(e,t=[])=>Object.entries(e.States).flatMap(([e,n])=>{let r=[{path:[...t,e].join(`/`),state:n}],i=n.Type===`Map`?X(n):void 0;return[...r,...i?Et(i,[...t,e]):[]]}).filter(({state:e})=>e.Type===`Task`),Dt=`$states.context.Execution.Input`,Ot=`$states.context.Steps`,kt=/^[A-Za-z_][A-Za-z0-9_]*$/,At=/^\.(?:([A-Za-z_][A-Za-z0-9_]*)|`([^`]+)`)/,jt=e=>{let t=[],n=e;for(;n!==``;){let e=At.exec(n);if(!e)return;t.push(e[1]??e[2]),n=n.slice(e[0].length)}return t},Mt=e=>{let t=q(e)?.trim();if(t===void 0)return;if(t===Dt||t.startsWith(`${Dt}.`)){let e=jt(t.slice(31));return e&&{base:{input:!0},path:e}}if(t.startsWith(`${Ot}.`)){let e=jt(t.slice(21));return e&&e.length>0?{base:{step:e[0]},path:e.slice(1)}:void 0}let n=/^\$([A-Za-z_][A-Za-z0-9_]*)/.exec(t);if(!n||n[1]===`states`)return;let r=jt(t.slice(n[0].length));return r&&{base:{variable:n[1]},path:r}},Nt=e=>kt.test(e)&&![`true`,`false`,`null`].includes(e)?e:`\`${e}\``,Pt=({base:e,path:t})=>[`input`in e?Dt:`step`in e?`${Ot}.${Nt(e.step)}`:`$${e.variable}`,...t.map(Nt)].join(`.`),Ft=e=>`{% ${Pt(e)} %}`,It=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,Lt=e=>{let t=[];for(let n of e){if(n.type!==`name`||n.stages!==void 0||n.predicate!==void 0)break;t.push(String(n.value))}return t},Rt=e=>{if(e[0]===`context`){if(e[1]===`Execution`&&e[2]===`Input`)return{base:{input:!0},path:e.slice(3)};if(e[1]===`Steps`&&e[2]!==void 0)return{base:{step:e[2]},path:e.slice(3)}}},zt=e=>{let t=q(e);if(t===void 0)return[];let n=Je(t);if(`error`in n)return[];let r=tt(n.expression).variables,i=new Map,a=e=>e&&i.set(Pt(e),e),o=new WeakSet,s=(e,t)=>{if(Array.isArray(e))return e.forEach(e=>s(e,t));if(!It(e))return;let n=$e(e,t),i=e=>r.has(e)&&!n.has(e);if(e.type===`path`&&Array.isArray(e.steps)&&e.steps[0]?.type===`variable`){let[t,...n]=e.steps;o.add(t);let r=String(t.value);r===`states`?a(Rt(Lt(n))):i(r)&&a({base:{variable:r},path:Lt(n)})}else e.type===`variable`&&!o.has(e)&&i(String(e.value))&&a({base:{variable:String(e.value)},path:[]});for(let[t,r]of Object.entries(e))t!==`position`&&t!==`value`&&t!==`type`&&s(r,n)},c=n.expression.ast();return s(c,et(c)),[...i.values()]},Bt=e=>e.order??`sequence`,Vt=`custom`,Ht=/^custom:([a-z][a-z0-9_]*):([1-9][0-9]*)$/,Ut=e=>{let t=Ht.exec(e);return t?{name:t[1],version:Number(t[2])}:void 0},Wt=`Test`,Gt=e=>({trigger:{manual:{}},order:`sequence`,stateMachine:{QueryLanguage:`JSONata`,StartAt:Wt,States:{[Wt]:{Type:`Task`,Resource:e,Arguments:`{% $states.context.Execution.Input %}`,End:!0}}}}),Kt=e=>{let t=new Map;for(let n of e){let e=Ut(n);e&&e.version>(t.get(e.name)?.version??0)&&t.set(e.name,{id:n,version:e.version})}return Object.fromEntries([...t].map(([e,t])=>[`${Vt}:${e}`,t.id]))};export{Ge as A,rt as C,tt as D,Ze as E,He as M,q as O,it as S,X as T,xt as _,Bt as a,lt as b,Pt as c,Tt as d,wt as f,Et as g,St as h,Ut as i,K as j,Je as k,Ft as l,bt as m,Kt as n,zt as o,Ct as p,Vt as r,Mt as s,Gt as t,_t as u,$ as v,nt as w,ft as x,ut as y};
|
|
9
|
-
//# debugId=
|
|
9
|
+
//# debugId=1050a7f0-16a7-4d64-85f8-75b8fb5389f0
|