okengine 0.19.8 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/AGENTS.md +1 -1
  2. package/package.json +1 -1
  3. package/site/content/docs/client/auth.mdx +1 -2
  4. package/site/content/docs/client/calling.mdx +8 -8
  5. package/site/content/docs/client/index.mdx +4 -4
  6. package/site/content/docs/client/react.mdx +5 -0
  7. package/site/content/docs/elements/channel/email.mdx +25 -36
  8. package/site/content/docs/elements/channel/index.mdx +88 -46
  9. package/site/content/docs/elements/channel/push.mdx +7 -9
  10. package/site/content/docs/elements/channel/sms.mdx +6 -4
  11. package/site/content/docs/elements/channel/whatsapp.mdx +11 -9
  12. package/site/content/docs/elements/clock/index.mdx +14 -25
  13. package/site/content/docs/elements/flow/http.mdx +24 -8
  14. package/site/content/docs/elements/flow/index.mdx +15 -12
  15. package/site/content/docs/elements/flow/routing.mdx +166 -122
  16. package/site/content/docs/elements/gate/rls.mdx +2 -2
  17. package/site/content/docs/elements/store/index.mdx +11 -3
  18. package/site/content/docs/elements/store/search.mdx +5 -5
  19. package/site/content/docs/elements/store/sql.mdx +91 -33
  20. package/site/content/docs/elements/vault/index.mdx +3 -5
  21. package/site/content/docs/plugins/magic-link.mdx +4 -3
  22. package/site/content/docs/plugins/otp.mdx +4 -3
  23. package/site/content/docs/plugins/two-factor.mdx +4 -0
  24. package/site/content/docs/providers/index.mdx +1 -1
  25. package/site/content/docs/recipes/index.mdx +1 -1
  26. package/site/content/docs/reference/cli.mdx +13 -4
  27. package/site/content/docs/reference/configuration.mdx +7 -7
  28. package/site/content/docs/reference/errors.mdx +30 -30
  29. package/site/content/docs/reference/fx.mdx +16 -8
  30. package/site/content/docs/reference/i18n.mdx +4 -4
  31. package/site/content/docs/reference/plugins.mdx +4 -4
  32. package/site/content/docs/understand/try-it.mdx +2 -0
  33. package/src/cli/ai-setup/ai-setup.test.ts +40 -0
  34. package/src/cli/ai-setup/apply.ts +28 -46
  35. package/src/cli/ask-vault-gaps.test.ts +60 -4
  36. package/src/cli/ask-vault-gaps.ts +59 -3
  37. package/src/cli/build.test.ts +3 -3
  38. package/src/cli/build.ts +5 -5
  39. package/src/cli/db-auto-push.test.ts +11 -0
  40. package/src/cli/db-auto-push.ts +6 -2
  41. package/src/cli/db.test.ts +1 -1
  42. package/src/cli/db.ts +6 -6
  43. package/src/cli/dev-app-runner.ts +12 -4
  44. package/src/cli/dev-db-push.test.ts +6 -2
  45. package/src/cli/dev-schema-sync.ts +1 -1
  46. package/src/cli/dev.test.ts +10 -7
  47. package/src/cli/dev.ts +18 -12
  48. package/src/cli/ensure-drizzle-config.ts +4 -3
  49. package/src/client-react/browser.test.ts +23 -0
  50. package/src/client-react/use-live-query.ts +1 -1
  51. package/src/compiler/flow-path.test.ts +1 -0
  52. package/src/compiler/flow-path.ts +1 -1
  53. package/src/compiler/generate-adopt.test.ts +55 -1
  54. package/src/compiler/generate-adopt.ts +111 -21
  55. package/src/config/index.ts +6 -4
  56. package/src/console/ui-next/dist/assets/{access-page-C5yG4aS2.js → access-page-DFLu0wTA.js} +1 -1
  57. package/src/console/ui-next/dist/assets/{agent-disclosure-D2ToVK86.js → agent-disclosure-DGscxaF5.js} +1 -1
  58. package/src/console/ui-next/dist/assets/{cache-glyph-7HUR0kCz.js → cache-glyph-BGmRZk7d.js} +1 -1
  59. package/src/console/ui-next/dist/assets/{call-pii-button-D0ky3aXt.js → call-pii-button--feUYxvG.js} +1 -1
  60. package/src/console/ui-next/dist/assets/{collapsible-BLUHH2dB.js → collapsible-JWvpaiGY.js} +1 -1
  61. package/src/console/ui-next/dist/assets/{duration-tone-BgHEFMtm.js → duration-tone-D9yCJG4n.js} +1 -1
  62. package/src/console/ui-next/dist/assets/{flows-page-DDybqshQ.js → flows-page-Bs6MD9GB.js} +1 -1
  63. package/src/console/ui-next/dist/assets/{highlighted-json-BFiJKYV4.js → highlighted-json-xH8MrEnv.js} +1 -1
  64. package/src/console/ui-next/dist/assets/{http-method-BVAcB0bI.js → http-method-C4vB6ZIw.js} +1 -1
  65. package/src/console/ui-next/dist/assets/{index-BID6LSYI.js → index-yTCY4AcS.js} +3 -3
  66. package/src/console/ui-next/dist/assets/{observability-page-CANo_mMK.js → observability-page-BxJ3R6dU.js} +1 -1
  67. package/src/console/ui-next/dist/assets/{replica-lag-CqQGCshp.js → replica-lag-QRKB_IE8.js} +1 -1
  68. package/src/console/ui-next/dist/assets/{request-meta-DyUDkEt4.js → request-meta-DqZ-fMu5.js} +1 -1
  69. package/src/console/ui-next/dist/assets/{store-page-CA0rJ_Ow.js → store-page-Dixb6L7a.js} +1 -1
  70. package/src/console/ui-next/dist/assets/{trace-detail-sheet-DjH_fMzI.js → trace-detail-sheet-CazhjtiU.js} +1 -1
  71. package/src/console/ui-next/dist/assets/{tree-expand-toggle-CWSomIeQ.js → tree-expand-toggle-DlnqYKfr.js} +1 -1
  72. package/src/console/ui-next/dist/assets/{units-page-Cz9TIViw.js → units-page-BXTLjU2-.js} +1 -1
  73. package/src/console/ui-next/dist/assets/{vault-page-Bb1o1O9p.js → vault-page-39KR__bc.js} +1 -1
  74. package/src/console/ui-next/dist/index.html +1 -1
  75. package/src/drivers/clock-postgres.test.ts +10 -2
  76. package/src/drivers/clock-postgres.ts +18 -2
  77. package/src/drivers/vault-driver-removal.test.ts +2 -2
  78. package/src/elements/channel/declare.ts +66 -3
  79. package/src/elements/channel/runtime.ts +9 -11
  80. package/src/elements/channel.test.ts +42 -0
  81. package/src/elements/channel.ts +4 -2
  82. package/src/elements/clock/reconcile.ts +45 -24
  83. package/src/elements/clock.test.ts +33 -0
  84. package/src/elements/store/emit-drizzle.ts +285 -65
  85. package/src/elements/store/load-plugin-tables.ts +1 -1
  86. package/src/elements/store/prepare-row.test.ts +57 -4
  87. package/src/elements/store/schema-decl.test.ts +178 -0
  88. package/src/elements/store/sql-session.ts +44 -2
  89. package/src/elements/store/table.ts +8 -6
  90. package/src/kernel/adopt-barrel-fresh.test.ts +1 -1
  91. package/src/kernel/app.ts +26 -32
  92. package/src/kernel/auto-registry.test.ts +26 -1
  93. package/src/kernel/boot.ts +2 -2
  94. package/src/kernel/boundary-contract.ts +6 -1
  95. package/src/kernel/errors.ts +3 -3
  96. package/src/kernel/flow-units.ts +3 -3
  97. package/src/kernel/fx.ts +12 -2
  98. package/src/kernel/mutation-id.ts +8 -0
  99. package/src/kernel/plugin.ts +4 -3
  100. package/src/kernel/project-out.test.ts +176 -0
  101. package/src/kernel/project-out.ts +91 -0
  102. package/src/kernel/realtime-bind.ts +2 -3
  103. package/src/kernel/router/linear.ts +12 -6
  104. package/src/kernel/router.test.ts +13 -0
  105. package/src/plugins/magic-link.ts +25 -24
  106. package/src/plugins/otp.ts +35 -24
  107. package/src/plugins/two-factor.ts +15 -0
  108. package/src/runs/duckdb.test.ts +2 -2
@@ -1 +1 @@
1
- import{A as e}from"./xyflow-yApv7D4e.js";import{Dr as t,Er as n,x as r}from"./shortcut-keys-3ILd8oGn.js";import{h as i,s as a}from"./element-icons-BI8cJgdh.js";import{nt as o,ot as s,tt as c}from"./index-BID6LSYI.js";var l=[[`path`,{d:`M4.31802 19.682C3 18.364 3 16.2426 3 12C3 7.75736 3 5.63604 4.31802 4.31802C5.63604 3 7.75736 3 12 3C16.2426 3 18.364 3 19.682 4.31802C21 5.63604 21 7.75736 21 12C21 16.2426 21 18.364 19.682 19.682C18.364 21 16.2426 21 12 21C7.75736 21 5.63604 21 4.31802 19.682Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M6 12H8.5L10.5 8L13.5 16L15.5 12H18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],u=[[`path`,{d:`M5.92089 5.92089C8.15836 3.68342 9.2771 2.56468 10.5857 2.19562C11.5105 1.93479 12.4895 1.93479 13.4143 2.19562C14.7229 2.56468 15.8416 3.68342 18.0791 5.92089C20.3166 8.15836 21.4353 9.2771 21.8044 10.5857C22.0652 11.5105 22.0652 12.4895 21.8044 13.4143C21.4353 14.7229 20.3166 15.8416 18.0791 18.0791C15.8416 20.3166 14.7229 21.4353 13.4143 21.8044C12.4895 22.0652 11.5105 22.0652 10.5857 21.8044C9.2771 21.4353 8.15836 20.3166 5.92089 18.0791C3.68342 15.8416 2.56468 14.7229 2.19562 13.4143C1.93479 12.4895 1.93479 11.5105 2.19562 10.5857C2.56468 9.2771 3.68342 8.15836 5.92089 5.92089Z`,stroke:`currentColor`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],d=[[`path`,{d:`M14.9961 17H16.9961C19.7575 17 21.9961 14.7614 21.9961 12C21.9961 9.23858 19.7575 7 16.9961 7H14.9961M8.99609 17H6.99609C4.23467 17 1.99609 14.7614 1.99609 12C1.99609 9.23858 4.23467 7 6.99609 7H8.99609`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M8.49609 12H15.4961`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],f=[[`path`,{d:`M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z`,stroke:`currentColor`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],p=e();function m({kind:e,className:r,hex:a,inferred:o}){return e===`pk`?(0,p.jsx)(t,{icon:i,className:n(`size-3 shrink-0 text-amber-500`,r),"aria-label":`Primary key`}):e===`unique`?(0,p.jsx)(t,{icon:u,className:n(`size-3 shrink-0 text-violet-500`,r),"aria-label":`Unique`}):e===`none`?(0,p.jsx)(t,{icon:s,className:n(`size-3 shrink-0 text-muted-foreground/35`,r),"aria-label":`No key`}):(0,p.jsx)(t,{icon:d,className:n(`size-3 shrink-0`,!a&&`text-sky-500`,r),style:a?{color:a}:void 0,"aria-label":o?`Inferred foreign key`:`Foreign key`})}function h({primaryKey:e,foreignKey:t,unique:n,inferred:r,hex:i,empty:a=`spacer`}){let o=n===!0&&e!==!0;return!e&&!t&&!o?a===`none`?(0,p.jsx)(`span`,{className:`inline-flex shrink-0 items-center`,title:`None`,children:(0,p.jsx)(m,{kind:`none`})}):(0,p.jsx)(`span`,{className:`inline-flex w-3 shrink-0`,"aria-hidden":!0}):(0,p.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-px`,children:[e?(0,p.jsx)(m,{kind:`pk`}):null,t?(0,p.jsx)(m,{kind:`fk`,hex:i,inferred:r}):null,o?(0,p.jsx)(m,{kind:`unique`}):null]})}var g=`[redacted]`;function _(e){let t=[e],n=x(e),r=S(e);return n!==e&&t.push(n),r!==e&&t.push(r),t}function v(e,t){for(let n of _(t))e.add(n)}function y(e){let t=new Set;for(let n of e)v(t,n);return t}function b(e){let t=new Set;for(let n of e)t.add(x(n));return t.size}function x(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function S(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}function C({piiMasked:e,disabled:i,onToggle:s}){return(0,p.jsx)(a,{label:e?`PII hidden. Click to include cleartext (audited).`:`PII included. Click to remask.`,className:`flex self-stretch`,children:(0,p.jsxs)(r,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:n(`h-full rounded-none px-2 text-[11px]`,!e&&`text-amber-800 dark:text-amber-300`),"aria-pressed":!e,"aria-label":e?`Include PII: disabled`:`Include PII: enabled`,onClick:s,"data-slot":`call-api-pii`,children:[(0,p.jsx)(t,{icon:e?o:c,"data-icon":`inline-start`,className:`size-3.5`}),`PII`]})})}export{b as a,f as c,y as i,l,g as n,h as o,v as r,m as s,C as t};
1
+ import{A as e}from"./xyflow-yApv7D4e.js";import{Dr as t,Er as n,x as r}from"./shortcut-keys-3ILd8oGn.js";import{h as i,s as a}from"./element-icons-BI8cJgdh.js";import{nt as o,ot as s,tt as c}from"./index-yTCY4AcS.js";var l=[[`path`,{d:`M4.31802 19.682C3 18.364 3 16.2426 3 12C3 7.75736 3 5.63604 4.31802 4.31802C5.63604 3 7.75736 3 12 3C16.2426 3 18.364 3 19.682 4.31802C21 5.63604 21 7.75736 21 12C21 16.2426 21 18.364 19.682 19.682C18.364 21 16.2426 21 12 21C7.75736 21 5.63604 21 4.31802 19.682Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M6 12H8.5L10.5 8L13.5 16L15.5 12H18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],u=[[`path`,{d:`M5.92089 5.92089C8.15836 3.68342 9.2771 2.56468 10.5857 2.19562C11.5105 1.93479 12.4895 1.93479 13.4143 2.19562C14.7229 2.56468 15.8416 3.68342 18.0791 5.92089C20.3166 8.15836 21.4353 9.2771 21.8044 10.5857C22.0652 11.5105 22.0652 12.4895 21.8044 13.4143C21.4353 14.7229 20.3166 15.8416 18.0791 18.0791C15.8416 20.3166 14.7229 21.4353 13.4143 21.8044C12.4895 22.0652 11.5105 22.0652 10.5857 21.8044C9.2771 21.4353 8.15836 20.3166 5.92089 18.0791C3.68342 15.8416 2.56468 14.7229 2.19562 13.4143C1.93479 12.4895 1.93479 11.5105 2.19562 10.5857C2.56468 9.2771 3.68342 8.15836 5.92089 5.92089Z`,stroke:`currentColor`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],d=[[`path`,{d:`M14.9961 17H16.9961C19.7575 17 21.9961 14.7614 21.9961 12C21.9961 9.23858 19.7575 7 16.9961 7H14.9961M8.99609 17H6.99609C4.23467 17 1.99609 14.7614 1.99609 12C1.99609 9.23858 4.23467 7 6.99609 7H8.99609`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M8.49609 12H15.4961`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],f=[[`path`,{d:`M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z`,stroke:`currentColor`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],p=e();function m({kind:e,className:r,hex:a,inferred:o}){return e===`pk`?(0,p.jsx)(t,{icon:i,className:n(`size-3 shrink-0 text-amber-500`,r),"aria-label":`Primary key`}):e===`unique`?(0,p.jsx)(t,{icon:u,className:n(`size-3 shrink-0 text-violet-500`,r),"aria-label":`Unique`}):e===`none`?(0,p.jsx)(t,{icon:s,className:n(`size-3 shrink-0 text-muted-foreground/35`,r),"aria-label":`No key`}):(0,p.jsx)(t,{icon:d,className:n(`size-3 shrink-0`,!a&&`text-sky-500`,r),style:a?{color:a}:void 0,"aria-label":o?`Inferred foreign key`:`Foreign key`})}function h({primaryKey:e,foreignKey:t,unique:n,inferred:r,hex:i,empty:a=`spacer`}){let o=n===!0&&e!==!0;return!e&&!t&&!o?a===`none`?(0,p.jsx)(`span`,{className:`inline-flex shrink-0 items-center`,title:`None`,children:(0,p.jsx)(m,{kind:`none`})}):(0,p.jsx)(`span`,{className:`inline-flex w-3 shrink-0`,"aria-hidden":!0}):(0,p.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-px`,children:[e?(0,p.jsx)(m,{kind:`pk`}):null,t?(0,p.jsx)(m,{kind:`fk`,hex:i,inferred:r}):null,o?(0,p.jsx)(m,{kind:`unique`}):null]})}var g=`[redacted]`;function _(e){let t=[e],n=x(e),r=S(e);return n!==e&&t.push(n),r!==e&&t.push(r),t}function v(e,t){for(let n of _(t))e.add(n)}function y(e){let t=new Set;for(let n of e)v(t,n);return t}function b(e){let t=new Set;for(let n of e)t.add(x(n));return t.size}function x(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function S(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}function C({piiMasked:e,disabled:i,onToggle:s}){return(0,p.jsx)(a,{label:e?`PII hidden. Click to include cleartext (audited).`:`PII included. Click to remask.`,className:`flex self-stretch`,children:(0,p.jsxs)(r,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:n(`h-full rounded-none px-2 text-[11px]`,!e&&`text-amber-800 dark:text-amber-300`),"aria-pressed":!e,"aria-label":e?`Include PII: disabled`:`Include PII: enabled`,onClick:s,"data-slot":`call-api-pii`,children:[(0,p.jsx)(t,{icon:e?o:c,"data-icon":`inline-start`,className:`size-3.5`}),`PII`]})})}export{b as a,f as c,y as i,l,g as n,h as o,v as r,m as s,C as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n}from"./xyflow-yApv7D4e.js";import{Dt as r,Er as i,Et as a,Gn as o,Gt as s,Jt as c,S as l,Sn as u,T as d,Tt as f,W as p,Wn as m,Xt as h,Yt as g,Zt as _,bn as v,ct as y,in as b,jn as x,k as S,ln as C,lt as w,qt as T,st as E}from"./shortcut-keys-3ILd8oGn.js";import{i as D}from"./index-BID6LSYI.js";var O=[[`path`,{d:`M13.9248 21H10.0752C5.44476 21 3.12955 21 2.27636 19.4939C1.42317 17.9879 2.60736 15.9914 4.97574 11.9985L6.90057 8.75333C9.17559 4.91778 10.3131 3 12 3C13.6869 3 14.8244 4.91777 17.0994 8.75332L19.0243 11.9985C21.3926 15.9914 22.5768 17.9879 21.7236 19.4939C20.8704 21 18.5552 21 13.9248 21Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 9V13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12.125 16.75H12M12.25 16.75C12.25 16.8881 12.1381 17 12 17C11.8619 17 11.75 16.8881 11.75 16.75C11.75 16.6119 11.8619 16.5 12 16.5C12.1381 16.5 12.25 16.6119 12.25 16.75Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],k=[[`path`,{d:`M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],A=[[`path`,{d:`M17 8L18.8398 9.85008C19.6133 10.6279 20 11.0168 20 11.5C20 11.9832 19.6133 12.3721 18.8398 13.1499L17 15`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M7 8L5.16019 9.85008C4.38673 10.6279 4 11.0168 4 11.5C4 11.9832 4.38673 12.3721 5.16019 13.1499L7 15`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M14.5 4L9.5 20`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],j=d(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function M({className:e,variant:t=`default`,render:n,...r}){return D({defaultTagName:`span`,props:a({className:i(j({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}var N=e(t(),1);function P(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=S({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=w(a,!0,!0),u=p(),[d,f]=N.useState(),m=d===null?void 0:d??u,h=T(e=>{let t=!a,n=_(C,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return N.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:m,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,h,s,a,m,c,o,f,l])}var F=N.createContext(void 0);function I(){let e=N.useContext(F);if(e===void 0)throw Error(m(15));return e}var L=`data-open`,R=`data-closed`,z=u,B=`data-panel-open`,V={[L]:``},H={[R]:``},U={open(e){return e?{[B]:``}:null}},W={open(e){return e?V:H},...v},G=n(),K=N.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=T(o),d=P({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),p=N.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),m=N.useMemo(()=>({...d,onOpenChange:u,state:p}),[d,u,p]),h=f(`div`,e,{state:p,ref:t,props:l,stateAttributesMapping:W});return(0,G.jsx)(F.Provider,{value:m,children:h})}),q={...U,...v},J=N.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=I(),{className:s,disabled:c=o,render:u,nativeButton:d=!0,style:p,...m}=e,{getButtonProps:h,buttonRef:g}=l({disabled:c,focusableWhenDisabled:!0,native:d});return f(`button`,e,{state:a,ref:[t,g],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},m,h],stateAttributesMapping:q})}),Y={height:void 0,width:void 0};function X(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:l,open:u,setMounted:d,setOpen:f,transitionStatus:p}=e,m=N.useRef(null),v=N.useRef(null),[x,S]=N.useState(Y),C=N.useRef(Y),w=N.useRef(!1),D=N.useRef(u),O=N.useRef(!1),[k,A]=N.useState(!1),j=N.useRef(null),M=g(t,m),P=c(u),F=y(m),I=!u&&!a,L=k?`idle`:p,R=u&&(D.current||O.current),B=!u&&a&&v.current===`css-animation`&&x.height===void 0&&x.width===void 0?C.current:x,V=n&&I&&v.current!==`css-animation`,H=T((e,t=!0)=>{t&&(C.current=e),S(e)}),U=T(()=>{j.current?.(),j.current=null}),W=T(e=>{U(),j.current=()=>{j.current=null,e()}}),G=T(()=>{u&&a&&v.current===`css-animation`&&(O.current=!0)});o(()=>{k&&p!==`starting`&&A(!1)},[k,p]),N.useEffect(()=>()=>{G(),U()},[G,U]),o(()=>{let e=m.current;if(!e)return;!u&&j.current&&U();let t=ee(e,R);if(v.current=t,u&&p===`idle`&&D.current&&t===`css-animation`){C.current=Z(e);return}if(u&&p===`starting`){let n=w.current;if(w.current=!1,t===`none`){H(Z(e)),A(!0);return}if(t===`css-transition`){let t=te(e);if(H(Z(e)),!n)return t;let r=$(e,`transition-duration`,`0s`);return W(r),A(!0),t}H(Z(e));let r=$(e,`animation-name`,`none`);if(!n){r();return}let i=$(e,`animation-duration`,`0s`);r(),W(i),A(!0);return}if(!u&&a&&(p===`idle`||p===`starting`)){if(D.current=!1,O.current=!1,t===`none`){H(Y,!1),d(!1);return}H(Z(e));return}if(p!==`ending`)return;if(t===`none`){d(!1);return}let n=Z(e);if(!(n.height>0||n.width>0)){d(!1);return}H(n),t===`css-animation`&&$(e,`animation-name`,`none`)()},[a,u,U,H,d,W,R,p]),E({enabled:u&&a&&L===`idle`,open:!0,ref:m,onComplete(){u&&H(Y,!1)}}),N.useEffect(()=>{if(u||!a||L!==`ending`||!m.current)return;let e=new AbortController,t=-1;function n(){P.current||(d(!1),H(Y,!1))}return t=s.request(()=>{F(n,e.signal)}),()=>{s.cancel(t),e.abort()}},[P,a,u,L,F,H,d]),o(()=>{let e=m.current;e&&n&&I&&e.setAttribute(`hidden`,`until-found`)},[I,n]),N.useEffect(function(){let e=m.current;if(!e)return;function t(e){let t=_(b,e);l(!0,t),!t.isCanceled&&(w.current=!0,f(!0))}return h(e,`beforematch`,t)},[l,f]);let K=i||n||a||u;return{height:B.height,props:{...V?{[z]:``}:void 0,hidden:I,id:r},ref:M,shouldPreventOpenAnimation:R,shouldRender:K,transitionStatus:L,width:B.width}}function Z(e){return{height:e.scrollHeight,width:e.scrollWidth}}function ee(e,t){let n=x(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&Q(n.animationDuration),i=Q(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function Q(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function $(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function te(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=s.request(n);return()=>{s.cancel(r),n()}}var ne=`--collapsible-panel-height`,re=`--collapsible-panel-width`,ie=N.forwardRef(function(e,t){let{className:n,hiddenUntilFound:i,keepMounted:a,render:s,id:c,style:l,...u}=e,{defaultPanelId:d,mounted:p,onOpenChange:m,open:h,setMounted:g,setPanelIdState:_,setOpen:v,state:y,transitionStatus:b}=I(),x=i??!1,S=a??!1,C=c||void 0,w=C??d;o(()=>(_(e=>C??(e===null?void 0:e)),()=>{_(e=>e===C?null:e)}),[C,_]);let{height:T,props:E,ref:D,shouldPreventOpenAnimation:O,shouldRender:k,transitionStatus:A,width:j}=X({externalRef:t,hiddenUntilFound:x,id:w,keepMounted:S,mounted:p,onOpenChange:m,open:h,setMounted:g,setOpen:v,transitionStatus:b}),M={...y,transitionStatus:A},N=r(l,M),P=f(`div`,{...e,style:void 0},{state:M,ref:D,props:[E,{style:{[ne]:T===void 0?`auto`:`${T}px`,[re]:j===void 0?`auto`:`${j}px`}},u,N?{style:N}:void 0,O?{style:{animationName:`none`}}:void 0],stateAttributesMapping:W});return k?P:null});function ae({...e}){return(0,G.jsx)(K,{"data-slot":`collapsible`,...e})}function oe({...e}){return(0,G.jsx)(J,{"data-slot":`collapsible-trigger`,...e})}function se({...e}){return(0,G.jsx)(ie,{"data-slot":`collapsible-content`,...e})}export{A as a,M as i,se as n,k as o,oe as r,O as s,ae as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n}from"./xyflow-yApv7D4e.js";import{Dt as r,Er as i,Et as a,Gn as o,Gt as s,Jt as c,S as l,Sn as u,T as d,Tt as f,W as p,Wn as m,Xt as h,Yt as g,Zt as _,bn as v,ct as y,in as b,jn as x,k as S,ln as C,lt as w,qt as T,st as E}from"./shortcut-keys-3ILd8oGn.js";import{i as D}from"./index-yTCY4AcS.js";var O=[[`path`,{d:`M13.9248 21H10.0752C5.44476 21 3.12955 21 2.27636 19.4939C1.42317 17.9879 2.60736 15.9914 4.97574 11.9985L6.90057 8.75333C9.17559 4.91778 10.3131 3 12 3C13.6869 3 14.8244 4.91777 17.0994 8.75332L19.0243 11.9985C21.3926 15.9914 22.5768 17.9879 21.7236 19.4939C20.8704 21 18.5552 21 13.9248 21Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 9V13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12.125 16.75H12M12.25 16.75C12.25 16.8881 12.1381 17 12 17C11.8619 17 11.75 16.8881 11.75 16.75C11.75 16.6119 11.8619 16.5 12 16.5C12.1381 16.5 12.25 16.6119 12.25 16.75Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],k=[[`path`,{d:`M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],A=[[`path`,{d:`M17 8L18.8398 9.85008C19.6133 10.6279 20 11.0168 20 11.5C20 11.9832 19.6133 12.3721 18.8398 13.1499L17 15`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M7 8L5.16019 9.85008C4.38673 10.6279 4 11.0168 4 11.5C4 11.9832 4.38673 12.3721 5.16019 13.1499L7 15`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M14.5 4L9.5 20`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],j=d(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function M({className:e,variant:t=`default`,render:n,...r}){return D({defaultTagName:`span`,props:a({className:i(j({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}var N=e(t(),1);function P(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=S({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=w(a,!0,!0),u=p(),[d,f]=N.useState(),m=d===null?void 0:d??u,h=T(e=>{let t=!a,n=_(C,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return N.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:m,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,h,s,a,m,c,o,f,l])}var F=N.createContext(void 0);function I(){let e=N.useContext(F);if(e===void 0)throw Error(m(15));return e}var L=`data-open`,R=`data-closed`,z=u,B=`data-panel-open`,V={[L]:``},H={[R]:``},U={open(e){return e?{[B]:``}:null}},W={open(e){return e?V:H},...v},G=n(),K=N.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=T(o),d=P({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),p=N.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),m=N.useMemo(()=>({...d,onOpenChange:u,state:p}),[d,u,p]),h=f(`div`,e,{state:p,ref:t,props:l,stateAttributesMapping:W});return(0,G.jsx)(F.Provider,{value:m,children:h})}),q={...U,...v},J=N.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=I(),{className:s,disabled:c=o,render:u,nativeButton:d=!0,style:p,...m}=e,{getButtonProps:h,buttonRef:g}=l({disabled:c,focusableWhenDisabled:!0,native:d});return f(`button`,e,{state:a,ref:[t,g],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},m,h],stateAttributesMapping:q})}),Y={height:void 0,width:void 0};function X(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:l,open:u,setMounted:d,setOpen:f,transitionStatus:p}=e,m=N.useRef(null),v=N.useRef(null),[x,S]=N.useState(Y),C=N.useRef(Y),w=N.useRef(!1),D=N.useRef(u),O=N.useRef(!1),[k,A]=N.useState(!1),j=N.useRef(null),M=g(t,m),P=c(u),F=y(m),I=!u&&!a,L=k?`idle`:p,R=u&&(D.current||O.current),B=!u&&a&&v.current===`css-animation`&&x.height===void 0&&x.width===void 0?C.current:x,V=n&&I&&v.current!==`css-animation`,H=T((e,t=!0)=>{t&&(C.current=e),S(e)}),U=T(()=>{j.current?.(),j.current=null}),W=T(e=>{U(),j.current=()=>{j.current=null,e()}}),G=T(()=>{u&&a&&v.current===`css-animation`&&(O.current=!0)});o(()=>{k&&p!==`starting`&&A(!1)},[k,p]),N.useEffect(()=>()=>{G(),U()},[G,U]),o(()=>{let e=m.current;if(!e)return;!u&&j.current&&U();let t=ee(e,R);if(v.current=t,u&&p===`idle`&&D.current&&t===`css-animation`){C.current=Z(e);return}if(u&&p===`starting`){let n=w.current;if(w.current=!1,t===`none`){H(Z(e)),A(!0);return}if(t===`css-transition`){let t=te(e);if(H(Z(e)),!n)return t;let r=$(e,`transition-duration`,`0s`);return W(r),A(!0),t}H(Z(e));let r=$(e,`animation-name`,`none`);if(!n){r();return}let i=$(e,`animation-duration`,`0s`);r(),W(i),A(!0);return}if(!u&&a&&(p===`idle`||p===`starting`)){if(D.current=!1,O.current=!1,t===`none`){H(Y,!1),d(!1);return}H(Z(e));return}if(p!==`ending`)return;if(t===`none`){d(!1);return}let n=Z(e);if(!(n.height>0||n.width>0)){d(!1);return}H(n),t===`css-animation`&&$(e,`animation-name`,`none`)()},[a,u,U,H,d,W,R,p]),E({enabled:u&&a&&L===`idle`,open:!0,ref:m,onComplete(){u&&H(Y,!1)}}),N.useEffect(()=>{if(u||!a||L!==`ending`||!m.current)return;let e=new AbortController,t=-1;function n(){P.current||(d(!1),H(Y,!1))}return t=s.request(()=>{F(n,e.signal)}),()=>{s.cancel(t),e.abort()}},[P,a,u,L,F,H,d]),o(()=>{let e=m.current;e&&n&&I&&e.setAttribute(`hidden`,`until-found`)},[I,n]),N.useEffect(function(){let e=m.current;if(!e)return;function t(e){let t=_(b,e);l(!0,t),!t.isCanceled&&(w.current=!0,f(!0))}return h(e,`beforematch`,t)},[l,f]);let K=i||n||a||u;return{height:B.height,props:{...V?{[z]:``}:void 0,hidden:I,id:r},ref:M,shouldPreventOpenAnimation:R,shouldRender:K,transitionStatus:L,width:B.width}}function Z(e){return{height:e.scrollHeight,width:e.scrollWidth}}function ee(e,t){let n=x(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&Q(n.animationDuration),i=Q(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function Q(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function $(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function te(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=s.request(n);return()=>{s.cancel(r),n()}}var ne=`--collapsible-panel-height`,re=`--collapsible-panel-width`,ie=N.forwardRef(function(e,t){let{className:n,hiddenUntilFound:i,keepMounted:a,render:s,id:c,style:l,...u}=e,{defaultPanelId:d,mounted:p,onOpenChange:m,open:h,setMounted:g,setPanelIdState:_,setOpen:v,state:y,transitionStatus:b}=I(),x=i??!1,S=a??!1,C=c||void 0,w=C??d;o(()=>(_(e=>C??(e===null?void 0:e)),()=>{_(e=>e===C?null:e)}),[C,_]);let{height:T,props:E,ref:D,shouldPreventOpenAnimation:O,shouldRender:k,transitionStatus:A,width:j}=X({externalRef:t,hiddenUntilFound:x,id:w,keepMounted:S,mounted:p,onOpenChange:m,open:h,setMounted:g,setOpen:v,transitionStatus:b}),M={...y,transitionStatus:A},N=r(l,M),P=f(`div`,{...e,style:void 0},{state:M,ref:D,props:[E,{style:{[ne]:T===void 0?`auto`:`${T}px`,[re]:j===void 0?`auto`:`${j}px`}},u,N?{style:N}:void 0,O?{style:{animationName:`none`}}:void 0],stateAttributesMapping:W});return k?P:null});function ae({...e}){return(0,G.jsx)(K,{"data-slot":`collapsible`,...e})}function oe({...e}){return(0,G.jsx)(J,{"data-slot":`collapsible-trigger`,...e})}function se({...e}){return(0,G.jsx)(ie,{"data-slot":`collapsible-content`,...e})}export{A as a,M as i,se as n,k as o,oe as r,O as s,ae as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n}from"./xyflow-yApv7D4e.js";import{B as r,C as i,F as a,G as o,H as s,I as c,J as l,K as u,M as d,O as f,P as p,S as m,T as h,U as g,V as _,W as v,Y as y,_ as b,b as x,d as S,f as C,g as w,h as T,j as ee,k as te,m as E,p as D,q as O,u as k,v as A,w as j,x as ne,y as re,z as M}from"./index-BID6LSYI.js";var N=[[`path`,{d:`M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],ie=[[`path`,{d:`M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],ae=[[`path`,{d:`M8 5.5L20 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M8 12.5L20 12.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M8 19.5L20 19.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}],[`path`,{d:`M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`4`}],[`path`,{d:`M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`5`}]],oe=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function P(e,t){return M(e)?e[oe(0,e.length,t)]:e}var se=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get state(){return this.getAll(`state`)}get startTime(){return this.getAll(`startTime`)}get duration(){return F(this.animations,`duration`)}get iterationDuration(){return F(this.animations,`iterationDuration`)}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}};function F(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r][t];i!==null&&i>n&&(n=i)}return n}var ce=class extends se{then(e,t){return this.finished.finally(e).then(()=>{})}},I=[];function le(e){g(typeof e.test==`function`&&typeof e.read==`function`,`Effects passed to animate.addEffect() need test() and read().`,`effect-missing-test`),L(e),I.unshift(e)}function L(e){o(I,e)}function ue(e){return I.find(t=>t.test(e))}function de(e,t,n,r={}){let i=[];for(let a in n){let o=n[a],s=e.get(t,a);if(!s){let n=e.read(t,a,o)??fe(o);g(n!==void 0,`"${a}" can't be read from the animated subject. Provide [from, to] keyframes.`,`effect-unreadable-value`),s=f(n),e(t,{[a]:s})}s.start(j(a,s,o,h(r,a))),s.animation&&i.push(s.animation)}return i}function fe(e){let t=Array.isArray(e)?e[0]:void 0;return t===null?void 0:t}function pe(e,t){return e in t}var R=class extends T{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(pe(t,e)){let n=e[t];if(typeof n==`string`||typeof n==`number`)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return b()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}},z=n(),B=e(t(),1);function V(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function me(...e){return t=>{let n=!1,r=e.map(e=>{let r=V(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():V(e[t],null)}}}}function he(...e){return B.useCallback(me(...e),e)}var ge=class extends B.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(x(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=x(e)&&e.offsetWidth||0,r=x(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function _e({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,B.useId)(),s=(0,B.useRef)(null),c=(0,B.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,B.useContext)(S),u=he(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,B.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n}from"./xyflow-yApv7D4e.js";import{B as r,C as i,F as a,G as o,H as s,I as c,J as l,K as u,M as d,O as f,P as p,S as m,T as h,U as g,V as _,W as v,Y as y,_ as b,b as x,d as S,f as C,g as w,h as T,j as ee,k as te,m as E,p as D,q as O,u as k,v as A,w as j,x as ne,y as re,z as M}from"./index-yTCY4AcS.js";var N=[[`path`,{d:`M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],ie=[[`path`,{d:`M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],ae=[[`path`,{d:`M8 5.5L20 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M8 12.5L20 12.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M8 19.5L20 19.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}],[`path`,{d:`M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`4`}],[`path`,{d:`M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`5`}]],oe=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function P(e,t){return M(e)?e[oe(0,e.length,t)]:e}var se=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get state(){return this.getAll(`state`)}get startTime(){return this.getAll(`startTime`)}get duration(){return F(this.animations,`duration`)}get iterationDuration(){return F(this.animations,`iterationDuration`)}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}};function F(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r][t];i!==null&&i>n&&(n=i)}return n}var ce=class extends se{then(e,t){return this.finished.finally(e).then(()=>{})}},I=[];function le(e){g(typeof e.test==`function`&&typeof e.read==`function`,`Effects passed to animate.addEffect() need test() and read().`,`effect-missing-test`),L(e),I.unshift(e)}function L(e){o(I,e)}function ue(e){return I.find(t=>t.test(e))}function de(e,t,n,r={}){let i=[];for(let a in n){let o=n[a],s=e.get(t,a);if(!s){let n=e.read(t,a,o)??fe(o);g(n!==void 0,`"${a}" can't be read from the animated subject. Provide [from, to] keyframes.`,`effect-unreadable-value`),s=f(n),e(t,{[a]:s})}s.start(j(a,s,o,h(r,a))),s.animation&&i.push(s.animation)}return i}function fe(e){let t=Array.isArray(e)?e[0]:void 0;return t===null?void 0:t}function pe(e,t){return e in t}var R=class extends T{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(pe(t,e)){let n=e[t];if(typeof n==`string`||typeof n==`number`)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return b()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}},z=n(),B=e(t(),1);function V(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function me(...e){return t=>{let n=!1,r=e.map(e=>{let r=V(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():V(e[t],null)}}}}function he(...e){return B.useCallback(me(...e),e)}var ge=class extends B.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(x(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=x(e)&&e.offsetWidth||0,r=x(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function _e({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,B.useId)(),s=(0,B.useRef)(null),c=(0,B.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,B.useContext)(S),u=he(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,B.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
2
2
  [data-motion-pop-id="${o}"] {
3
3
  position: absolute !important;
4
4
  width: ${e}px !important;
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n,a as r,c as i,d as a,o,p as s,r as c,s as l,t as u}from"./xyflow-yApv7D4e.js";import{Cr as d,Dr as f,E as p,Er as m,F as h,I as g,R as _,_r as v,br as y,cr as b,dr as x,ha as S,kr as C,vr as w,x as T,xr as E,yr as D}from"./shortcut-keys-3ILd8oGn.js";import{a as O,b as k,c as ee,d as te,f as ne,i as re,l as ie,n as ae,o as oe,p as se,r as ce,t as A,u as le}from"./element-icons-BI8cJgdh.js";import{s as ue}from"./collapsible-BLUHH2dB.js";import{t as de}from"./duration-tone-BgHEFMtm.js";import{a as fe,c as pe,i as me,l as he,o as ge,s as _e}from"./highlighted-json-BFiJKYV4.js";import{C as ve,S as ye,_ as j,b as be,d as xe,f as Se,g as M,h as Ce,p as we,v as N,y as P}from"./request-meta-DyUDkEt4.js";import{n as Te}from"./dagre.esm-B1_XeuLP.js";import{a as Ee,i as De,n as Oe,o as ke,r as Ae,t as je}from"./trace-detail-sheet-DjH_fMzI.js";import{a as Me,c as Ne,l as Pe,o as Fe,vt as Ie}from"./index-BID6LSYI.js";import{a as Le,c as F,i as Re,n as ze,o as Be,r as Ve,t as He}from"./cache-glyph-7HUR0kCz.js";import{t as Ue}from"./agent-disclosure-D2ToVK86.js";var We=[[`path`,{d:`M4 5L20 5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M4 12L20 12`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M4 19L20 19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],I=e(t(),1),L=[`flow`,`signal`,`store`,`clock`,`gate`,`vault`,`channel`,`ai`];function R(e,t,n){return{x:j.cx+t*Math.cos(e)-n.width/2,y:j.cy+t*Math.sin(e)-n.height/2}}function Ge(e){if(e<=0)return[];let t=2*Math.PI/e;return Array.from({length:e},(e,n)=>-Math.PI/2+n*t)}var Ke=2*Math.PI/L.length;function z(e,t,n=j.typeRing){if(t<=0)return[];if(t===1)return[e];let r=(N.type.width+10)/n,i=Math.min(r*(t-1),Ke*.7);return Array.from({length:t},(n,r)=>e-i/2+r/(t-1)*i)}function qe(e,t){if(t<=0)return[];let n=j.typeRing,r=j.typeRing+j.typeRow;if(t===1)return[{angle:e,radius:n}];if(t===4)return Ye(e,n,r);if(t<=3)return z(e,t,n).map(e=>({angle:e,radius:n}));let i=Math.ceil(t/2),a=t-i;return[...z(e,i,n).map(e=>({angle:e,radius:n})),...z(e,a,r).map(e=>({angle:e,radius:r}))]}function Je(e){return Math.abs(Math.cos(e))*N.type.height+Math.abs(Math.sin(e))*N.type.width}function Ye(e,t,n){let r=(Je(e)+24)/t;return[{angle:e-r/2,radius:t},{angle:e+r/2,radius:t},{angle:e-r/2,radius:n},{angle:e+r/2,radius:n}]}function B(e){let t=new Set([`flow`]),n=e.trigger;(n?.cron||n?.every)&&t.add(`clock`),n?.signal&&t.add(`signal`),(e.gates?.length??0)>0&&t.add(`gate`);let r=e.effects;return((r?.reads?.length??0)>0||(r?.writes?.length??0)>0)&&t.add(`store`),(r?.emits?.length??0)>0&&t.add(`signal`),(r?.sends?.length??0)>0&&t.add(`channel`),(r?.asks?.length??0)>0&&t.add(`ai`),(r?.secrets?.length??0)>0&&t.add(`vault`),L.filter(e=>t.has(e))}function Xe(e){let t=new Set([`flow`]);(e.trigger===`cron`||e.trigger===`every`)&&t.add(`clock`),e.trigger===`signal`&&t.add(`signal`),e.gates.length>0&&t.add(`gate`);for(let n of e.effects)switch(n.kind){case`read`:case`write`:t.add(`store`);break;case`emit`:t.add(`signal`);break;case`send`:case`fetch`:t.add(`channel`);break;case`ask`:case`embed`:t.add(`ai`);break;case`secret`:t.add(`vault`)}return L.filter(e=>t.has(e))}function Ze(e,t){let n=new Map,r=(e,t,r)=>{n.has(e)||n.set(e,r===void 0?{id:e,label:t}:{id:e,label:t,badge:r})};switch(t){case`flow`:for(let t of Object.keys(e.flows??{}).sort())r(`flow:${t}`,Ve(t),F(t));break;case`signal`:for(let t of Object.keys(e.signals??{}).sort())r(`signal:${t}`,t,`signal`);for(let t of Object.values(e.flows??{})){t.trigger?.signal&&r(`signal:${t.trigger.signal}`,t.trigger.signal,`signal`);for(let e of t.effects?.emits??[])r(`signal:${e}`,e,`signal`)}break;case`store`:for(let[t,n]of Object.entries(e.stores??{})){let e=n.facet;for(let t of Object.keys(n.tables??{}).sort())r(`${e}:${t}`,t,e);let i=n.namespaces&&n.namespaces.length>0?n.namespaces:[];e===`kv`&&i.length===0&&r(`kv:${t}`,t,`kv`);for(let e of[...i].sort())r(`kv:${e}`,e,`kv`);for(let e of[...n.buckets??[]].sort())r(`files:${e}`,e,`files`);for(let e of[...n.indexes??[]].sort())r(`index:${e}`,e,`index`)}for(let t of Object.values(e.flows??{}))for(let e of[...t.effects?.reads??[],...t.effects?.writes??[]]){let t=Qe(e);t&&r(t.id,t.label,t.badge)}break;case`clock`:for(let[t,n]of Object.entries(e.clocks??{}).sort(([e],[t])=>e.localeCompare(t)))r(`clock:${t}`,t,n.cron?`cron`:n.every?`every`:`clock`);for(let[t,n]of Object.entries(e.flows??{}))n.trigger?.cron&&r(`clock:${t}`,n.trigger.cron,`cron`),n.trigger?.every&&r(`clock:${t}`,n.trigger.every,`every`);break;case`gate`:for(let t of Object.keys(e.gates??{}).sort())r(`gate:${t}`,t,`gate`);for(let t of Object.values(e.flows??{}))for(let e of t.gates??[])r(`gate:${e}`,e,`gate`);break;case`vault`:for(let t of Object.keys(e.vault??{}).sort())r(`vault:${t}`,t,`vault`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.secrets??[])r(`vault:${e}`,e,`vault`);break;case`channel`:for(let t of Object.keys(e.channels??{}).sort())r(`channel:${t}`,t,`channel`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.sends??[])r(`channel:${e}`,e,`channel`);break;case`ai`:for(let t of Object.keys(e.ai?.prompts??{}).sort())r(`ai:${t}`,t,`prompt`);for(let t of Object.keys(e.ai?.agents??{}).sort())r(`ai:${t}`,t,`agent`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.asks??[])r(`ai:${e}`,e,`prompt`)}return[...n.values()].sort((e,t)=>e.label.localeCompare(t.label))}function Qe(e){return e.startsWith(`sql:`)?{id:e,label:e.slice(4),badge:`sql`}:e.startsWith(`kv:`)?{id:e,label:e.slice(3),badge:`kv`}:e.startsWith(`files:`)?{id:e,label:e.slice(6),badge:`files`}:e.startsWith(`index:`)?{id:e,label:e.slice(6),badge:`index`}:null}var $e={flow:xe.map(e=>({kind:e,label:Se[e].label})),signal:[{kind:`once`,label:`once`},{kind:`broadcast`,label:`broadcast`},{kind:`live`,label:`live`}],store:[{kind:`sql`,label:`SQL`},{kind:`kv`,label:`KV`},{kind:`files`,label:`Files`},{kind:`index`,label:`Index`}],clock:[{kind:`cron`,label:`cron`},{kind:`every`,label:`every`}],gate:[{kind:`policy`,label:`policy`},{kind:`scope`,label:`scope`},{kind:`rate`,label:`rate`},{kind:`public`,label:`public`}],vault:[{kind:`secret`,label:`secret`},{kind:`config`,label:`config`},{kind:`env`,label:`env`}],channel:[{kind:`email`,label:`email`},{kind:`sms`,label:`SMS`},{kind:`whatsapp`,label:`WA`},{kind:`push`,label:`Push`}],ai:[{kind:`model`,label:`model`},{kind:`prompt`,label:`prompt`},{kind:`embed`,label:`embed`},{kind:`agent`,label:`agent`}]};function et(e,t){return $e[t].map(e=>({id:`type:${t}:${e.kind}`,label:e.label,badge:e.kind}))}function tt(e,t){return t?.kind===`rate`||e.startsWith(`rate:`)?`rate`:e===`public`?`public`:(t?.scopes?.length??0)>0?`scope`:`policy`}function nt(e){return e?.sensitive===!1?`config`:`secret`}function rt(e,t){let n=t.split(`@`)[0]??t;return e.ai?.agents?.[n]?`agent`:e.ai?.models?.[n]?`model`:`prompt`}function it(e,t,n){let r=`type:${n}:`;switch(n){case`flow`:return[`${r}${we(t.trigger)}`];case`store`:{let e=new Set;for(let n of[...t.effects?.reads??[],...t.effects?.writes??[]]){let t=Qe(n);t?.badge&&e.add(t.badge)}return[...e].map(e=>`${r}${e}`)}case`signal`:{let n=[...t.trigger?.signal?[t.trigger.signal]:[],...t.effects?.emits??[]],i=new Set;for(let t of n){let n=e.signals?.[t]?.delivery;n&&i.add(n)}return[...i].map(e=>`${r}${e}`)}case`clock`:{let e=[];return t.trigger?.cron&&e.push(`${r}cron`),t.trigger?.every&&e.push(`${r}every`),e}case`gate`:return[...new Set((t.gates??[]).map(t=>tt(t,e.gates?.[t])))].map(e=>`${r}${e}`);case`vault`:return[...new Set((t.effects?.secrets??[]).map(t=>nt(e.vault?.[t])))].map(e=>`${r}${e}`);case`channel`:{let n=new Set;for(let r of t.effects?.sends??[]){let t=e.channels?.[r]?.medium;t&&t!==`any`&&n.add(t)}return[...n].map(e=>`${r}${e}`)}case`ai`:return[...new Set((t.effects?.asks??[]).map(t=>rt(e,t)))].map(e=>`${r}${e}`)}}function at(e){let t=e?.flows??{},n=new Map;for(let e of Object.keys(t).sort()){let t=F(e),r=n.get(t)??[];r.push(e),n.set(t,r)}let r=new Map,i=new Map,a=new Map;for(let[e,o]of n){let n=new Set;for(let i of o){let o=t[i];if(o)for(let t of B(o)){n.add(t);let o=`${e}\0${t}`;r.set(o,(r.get(o)??0)+1);let s=a.get(t)??new Set;s.add(i),a.set(t,s)}}i.set(e,n)}let o=[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({unit:e,flowCount:t.length,elements:L.filter(t=>i.get(e)?.has(t)),live:0,errors:0})),s=L.map(t=>({element:t,resourceCount:e?Ze(e,t).length:0,flowCount:a.get(t)?.size??0,live:0,errors:0})),c=[];for(let e of o)for(let t of e.elements)c.push({unit:e.unit,element:t,flowCount:r.get(`${e.unit}\0${t}`)??0});return{units:o,hubs:s,couplings:c}}function ot(e,t){let n=new Map,r=new Map,i=new Map,a=new Map;for(let e of t){let t=e.unit??F(e.flow);n.set(t,(n.get(t)??0)+1),e.error&&r.set(t,(r.get(t)??0)+1);for(let t of Xe(e))i.set(t,(i.get(t)??0)+1),e.error&&a.set(t,(a.get(t)??0)+1)}return{couplings:e.couplings,units:e.units.map(e=>({...e,live:n.get(e.unit)??0,errors:r.get(e.unit)??0})),hubs:e.hubs.map(e=>({...e,live:i.get(e.element)??0,errors:a.get(e.element)??0}))}}function st(e,t=[],n=null){if(!e||Object.keys(e.flows??{}).length===0)return{nodes:[],edges:[],units:[],hubs:[]};let r=ot(at(e),t),i=n?.element,a=r.hubs.find(e=>e.element===`flow`)?.live??0,o=r.hubs.find(e=>e.element===`flow`)?.errors??0,s=[],c=[];s.push(V(`orbit:elements`,j.elementRing)),s.push(V(`orbit:types`,j.typeRing)),s.push(V(`orbit:spokes`,j.spokeRing)),s.push({id:`law:oke`,type:`law`,position:{x:j.cx-N.law.width/2,y:j.cy-N.law.height/2},data:{kind:`law`,label:e.app,refId:`oke`,badge:String(r.units.reduce((e,t)=>e+t.flowCount,0)),live:a,errors:o},selectable:!1,draggable:!1,zIndex:M.leaf,width:N.law.width,height:N.law.height,style:{width:N.law.width,height:N.law.height,overflow:`visible`}});let l=Ge(L.length);if(r.hubs.forEach((e,t)=>{let n=l[t]??0,r=N.hub;s.push({id:`element:${e.element}`,type:`element`,position:R(n,j.elementRing,r),data:{kind:`element`,label:A[e.element].symbol,refId:e.element,badge:String(e.resourceCount),live:e.live,errors:e.errors,dimmed:i!=null&&e.element!==i},draggable:!1,zIndex:M.leaf,width:r.width,height:r.height,style:{width:r.width,height:r.height}}),c.push(U(`element:${e.element}`,`law:oke`,e.element,1,!0))}),!i||i===`flow`){let t=N.type;r.hubs.forEach((n,r)=>{let i=l[r]??0,a=et(e,n.element),o=qe(i,a.length);a.forEach((e,r)=>{let a=o[r]??{angle:i,radius:j.typeRing};s.push({id:e.id,type:`typeChip`,position:R(a.angle,a.radius,t),data:{kind:n.element,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:M.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}}),c.push(U(e.id,`element:${n.element}`,n.element,1))})})}if(i&&i!==`flow`){let t=Ze(e,i),n=be.store,r=Ge(t.length);t.forEach((e,t)=>{let a=r[t]??0;s.push({id:e.id,type:i,position:R(a,j.spokeRing,n),data:{kind:i,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:M.leaf,width:n.width,height:n.height,style:{width:n.width,height:n.height}}),c.push(U(e.id,`element:${i}`,i,1))})}else{let t=N.unit,n=Ge(r.units.length);r.units.forEach((e,r)=>{let i=n[r]??0;s.push({id:`unit:${e.unit}`,type:`unitChip`,position:R(i,j.spokeRing,t),data:{kind:`unit`,label:e.unit,refId:e.unit,badge:String(e.flowCount),elements:e.elements.filter(e=>e!==`flow`),live:e.live,errors:e.errors},draggable:!1,zIndex:M.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}})});let a=new Map;for(let t of Object.keys(e.flows??{}).sort()){let e=F(t),n=a.get(e)??[];n.push(t),a.set(e,n)}for(let t of r.units){let n=new Map,r=new Set;for(let o of a.get(t.unit)??[]){let t=e.flows?.[o];if(t)for(let a of B(t)){if(i===`flow`&&a!==`flow`)continue;let o=it(e,t,a);o.length===0&&r.add(a);for(let e of o)n.set(e,(n.get(e)??0)+1)}}for(let[e,r]of n){let n=e.slice(5).split(`:`)[0];n&&n in P&&c.push(U(`unit:${t.unit}`,e,n,r))}for(let e of r)c.push(U(`unit:${t.unit}`,`element:${e}`,e,1))}}return{nodes:s,edges:c,units:r.units,hubs:r.hubs}}function V(e,t){let n=t*2;return{id:e,type:`orbit`,position:{x:j.cx-t,y:j.cy-t},data:{kind:`law`,label:``,refId:e},selectable:!1,draggable:!1,zIndex:M.edge,width:n,height:n,style:{width:n,height:n}}}function ct(e,t){return t===`law:oke`?`trunk`:e.startsWith(`type:`)&&t.startsWith(`element:`)?`bind`:`spoke`}function H(e){return e===`trunk`?.14:e===`bind`?.2:0}function U(e,t,n,r,i=!1){let a=i?`trunk`:ct(e,t),o=a===`trunk`?1.15:1+Math.min(1.25,Math.log2(1+r)*.45);return{id:`couple:${e}->${t}`,source:e,target:t,sourceHandle:`center`,targetHandle:`center`,type:`straight`,data:{kind:`couple`},style:{stroke:Ce.couple,strokeWidth:o,opacity:H(a)},zIndex:M.edge}}function lt(e){if(e.startsWith(`element:`)){let t=e.slice(8);return t in P?t:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&t in P?t:null}return null}function ut(e,t){for(let n of[t,e]){let e=lt(n);if(e)return P[e].accent}return Ce.couple}function dt(e,t){let n=new Set,r=new Set,i=(e,t)=>{r.add(`couple:${e}->${t}`)};if(!e)return{nodeIds:n,edgeIds:r};for(let r of t){let t=e.flows?.[r];if(!t)continue;let a=`unit:${F(r)}`;n.add(a);for(let r of B(t)){let o=`element:${r}`;n.add(o),n.add(`law:oke`),i(o,`law:oke`);let s=it(e,t,r);s.length===0&&i(a,o);for(let e of s)n.add(e),i(a,e),i(e,o)}}return{nodeIds:n,edgeIds:r}}function ft(e,t,n={}){let r=n.hoverNodeId??null,i=n.highlightedFlowIds??new Set,a=n.highlightedNodeIds??new Set,o=dt(n.manifest,i),s=o.nodeIds.size>0||a.size>0,c=r!=null,l=r==null?null:pt(r,t);return{nodes:e.map(e=>{if(e.type===`orbit`)return{...e,data:{...e.data,highlighted:!1,dimmed:!1}};let t=o.nodeIds.has(e.id)||a.has(e.id)||i.has(e.data.refId),n=l?.has(e.id)===!0;return{...e,data:{...e.data,highlighted:t||c&&e.id===r,dimmed:e.id===`law:oke`?!1:s&&!t||c&&!n}}}),edges:t.map(e=>{let t=l!=null&&l.has(e.source)&&l.has(e.target),n=s&&o.edgeIds.has(e.id),r=c?t:n,i=ct(e.source,e.target),a=c||s?r?1:H(i)*.35:H(i);return{...e,animated:r,style:{...e.style,stroke:r?ut(e.source,e.target):Ce.couple,opacity:a,strokeWidth:r?2.25:e.style?.strokeWidth}}})}}function W(e,t){let n=[];for(let r of e)r.source===t?n.push(r.target):r.target===t&&n.push(r.source);return n}function pt(e,t){let n=new Set([e]),r=e=>n.add(e);if(e.startsWith(`unit:`)){for(let n of W(t,e)){if(r(n),n.startsWith(`type:`)){for(let e of W(t,n))if(e.startsWith(`element:`)){r(e);for(let n of W(t,e))n===`law:oke`&&r(n)}}if(n.startsWith(`element:`))for(let e of W(t,n))e===`law:oke`&&r(e)}return n}if(e.startsWith(`type:`)){for(let n of W(t,e))r(n);let i=[...n].find(e=>e.startsWith(`element:`));if(i)for(let e of W(t,i))e===`law:oke`&&r(e);return n}if(e.startsWith(`element:`)||e===`law:oke`)for(let n of W(t,e))r(n);return n}var G=n(),mt={flow:A.flow.icon,signal:A.signal.icon,store:A.store.icon,clock:A.clock.icon,gate:A.gate.icon,vault:A.vault.icon,channel:A.channel.icon,ai:A.ai.icon},ht={flow:`rounded-xl`,store:`rounded-md`,signal:`rounded-full`,clock:`rounded-lg`,gate:`rounded-md`,vault:`rounded-md`,channel:`rounded-xl`,ai:`rounded-2xl`};function K(e,t){return m(`group relative flex h-full w-full items-center gap-2.5 border-2 px-2.5 text-xs transition-[opacity,filter,box-shadow,border-color] duration-200`,ht[t],e.dimmed&&`opacity-30 saturate-[0.35]`,e.highlighted&&`z-10`,e.focused&&`z-10`)}function q(e,t){let n=P[e],r=`color-mix(in oklab, ${n.accent} 20%, var(--card))`;return t.highlighted||t.focused?{borderColor:n.accent,background:`color-mix(in oklab, ${n.accent} 26%, var(--card))`,boxShadow:`0 0 0 1px ${n.accent}, 0 0 22px ${n.glow}`}:{borderColor:`color-mix(in oklab, ${n.accent} 78%, var(--border))`,background:r,boxShadow:`inset 3px 0 0 ${n.accent}`}}function J({data:e,kind:t,className:n,style:r,children:i,...a}){let o=Pe(),s=P[t];return(0,G.jsx)(Ne.div,{className:n,style:r,initial:!1,whileHover:o?void 0:{scale:1.04},whileTap:o?void 0:{scale:.97},animate:{scale:o?1:e.active?[1,1.08,1]:e.highlighted?1.02:1,boxShadow:e.active?`0 0 0 2px ${s.accent}, 0 0 30px ${s.glow}`:void 0},transition:e.active?{duration:.5,ease:`easeInOut`}:{type:`spring`,stiffness:400,damping:28},...a,children:i})}function gt({kind:e,size:t=`sm`}){let n=P[e];return(0,G.jsx)(`span`,{className:m(`flex shrink-0 items-center justify-center border`,t===`md`?`size-9`:`size-7`,e===`signal`?`rounded-full`:e===`store`||e===`gate`||e===`vault`?`rounded-md`:`rounded-full`),style:{color:n.accent,background:n.well,borderColor:`color-mix(in oklab, ${n.accent} 55%, transparent)`},"aria-hidden":!0,children:(0,G.jsx)(f,{icon:mt[e],size:t===`md`?17:15,strokeWidth:1.9})})}function _t({text:e}){return(0,G.jsx)(`span`,{className:`rounded border border-border/70 bg-background/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e})}function vt({type:e,kind:t}){let n=P[t];return(0,G.jsx)(r,{type:e,position:e===`source`?s.Right:s.Left,className:`!size-2 !border-0`,style:{background:n.accent}})}function Y({type:e}){return(0,G.jsx)(r,{id:`center`,type:e,position:e===`source`?s.Right:s.Left,isConnectable:!1,className:`oke-center-handle !top-1/2 !left-1/2 !size-px !-translate-x-1/2 !-translate-y-1/2 !border-0 !bg-transparent !opacity-0`})}function yt({live:e,errors:t}){return e<=0?null:(0,G.jsx)(`span`,{className:m(`size-2 shrink-0 rounded-full`,t>0?`bg-rose-400`:`bg-emerald-400`,e>0&&`animate-pulse`),title:t>0?`${e} live · ${t} failed`:`${e} live`})}function bt({elements:e}){return e.length===0?null:(0,G.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1`,"aria-hidden":!0,children:e.map(e=>(0,G.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:P[e].accent},title:A[e].label},e))})}function xt({data:e}){return(0,G.jsx)(`div`,{className:`h-full w-full rounded-xl border border-dashed border-foreground/25 bg-muted/35 px-3 pt-1.5`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.label}),e.badge?(0,G.jsx)(_t,{text:e.badge}):null]})})}function St({data:e}){let t=e.kind in P?e.kind:`flow`;return(0,G.jsxs)(J,{data:e,kind:t,className:m(K(e,t),`justify-center gap-0 rounded-full px-2`),style:q(t,e),"data-slot":`type-chip`,"data-type":e.refId,children:[(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(Y,{type:`target`}),(0,G.jsx)(`div`,{className:`min-w-0 truncate text-center text-[10px] leading-none font-medium tracking-wide text-foreground`,children:e.label})]})}function Ct({data:e}){return(0,G.jsxs)(J,{data:e,kind:`flow`,className:m(K(e,`flow`),`rounded-full px-2.5`),style:q(`flow`,e),"data-slot":`unit-chip`,"data-unit":e.refId,children:[(0,G.jsx)(Y,{type:`source`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium tracking-wide text-foreground uppercase`,children:e.label}),(0,G.jsx)(yt,{live:e.live??0,errors:e.errors??0})]}),(0,G.jsx)(bt,{elements:e.elements??[]})]}),e.badge?(0,G.jsx)(_t,{text:e.badge}):null]})}function wt({data:e}){let t=Ot(e.refId)??`flow`,n=P[t];return(0,G.jsxs)(J,{data:e,kind:t,className:m(K(e,t),`flex-col justify-center gap-0.5 rounded-full px-1.5 text-center`),style:{...q(t,e),boxShadow:e.highlighted?`0 0 0 1px ${n.accent}, 0 0 22px ${n.glow}`:`0 0 0 1px color-mix(in oklab, ${n.accent} 55%, transparent)`},"data-slot":`element-hub`,"data-element":t,children:[(0,G.jsx)(Y,{type:`target`}),(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(`span`,{className:`text-[18px] font-semibold tracking-tight text-foreground`,title:A[t].label,children:e.label})]})}function Tt(e){return e>=40?1.05:e>=12?1.55:2.2}function Et({data:e}){let t=Pe(),n=e.live??0,r=e.errors??0,[i,a]=(0,I.useState)(0),o=(0,I.useRef)(n);(0,I.useEffect)(()=>{n>o.current&&a(e=>e+1),o.current=n},[n]);let s=n>0,c=Tt(n),l=r>0?`var(--color-rose-400)`:`var(--foreground)`;return(0,G.jsxs)(`div`,{className:m(`relative flex h-full w-full items-center justify-center overflow-visible`,e.highlighted&&`z-10`),"data-slot":`law-hub`,"data-live":n,children:[(0,G.jsx)(Y,{type:`target`}),!t&&s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,color:l}}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,animationDelay:`${c/2}s`,color:l}})]}):null,i>0&&!t?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-hit`,style:{color:l}},i):null,(0,G.jsx)(Ne.div,{className:`flex h-full w-full items-center justify-center rounded-full border-4 bg-card px-4 text-center`,style:{borderColor:`color-mix(in oklab, var(--foreground) 82%, var(--border))`,boxShadow:e.highlighted?`0 0 0 1px ${l}, 0 0 36px color-mix(in oklab, ${l} 28%, transparent)`:`inset 0 0 28px color-mix(in oklab, var(--foreground) 7%, transparent), 0 0 22px color-mix(in oklab, ${l} ${s?16:6}%, transparent)`},animate:t||!s?{scale:1}:{scale:[1,1.045,1]},transition:t||!s?{duration:0}:{duration:c,repeat:1/0,ease:`easeInOut`},children:(0,G.jsx)(Me,{className:`h-7 w-auto text-foreground`})})]})}function Dt(){return(0,G.jsx)(`div`,{className:`pointer-events-none h-full w-full rounded-full border border-dashed border-foreground/15`,"data-slot":`orbit`})}function Ot(e){return e in P?e:null}function X({data:e,kind:t,slot:n}){return(0,G.jsxs)(J,{data:e,kind:t,className:K(e,t),style:q(t,e),"data-slot":n,"data-flow-id":t===`flow`?e.refId:void 0,"data-highlighted":e.highlighted?`true`:`false`,children:[(0,G.jsx)(vt,{type:`target`,kind:t}),(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(gt,{kind:t}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:e.label}),(0,G.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:(0,G.jsx)(_t,{text:e.badge??e.plane??e.facet??t})})]}),t===`flow`||t===`signal`?(0,G.jsx)(vt,{type:`source`,kind:t}):null]})}function kt({data:e}){return(0,G.jsx)(X,{data:e,kind:`flow`,slot:`flow-node`})}function At({data:e}){return(0,G.jsx)(X,{data:e,kind:`store`,slot:`store-node`})}function jt({data:e}){return(0,G.jsx)(X,{data:e,kind:`signal`,slot:`signal-node`})}function Mt({data:e}){return(0,G.jsx)(X,{data:e,kind:`ai`,slot:`ai-node`})}function Nt({data:e}){return(0,G.jsx)(X,{data:e,kind:`clock`,slot:`clock-node`})}function Pt({data:e}){return(0,G.jsx)(X,{data:e,kind:`gate`,slot:`gate-node`})}function Ft({data:e}){return(0,G.jsx)(X,{data:e,kind:`vault`,slot:`vault-node`})}function It({data:e}){return(0,G.jsx)(X,{data:e,kind:`channel`,slot:`channel-node`})}var Lt={unit:xt,unitChip:Ct,typeChip:St,element:wt,law:Et,orbit:Dt,flow:kt,store:At,signal:jt,ai:Mt,clock:Nt,gate:Pt,vault:Ft,channel:It};function Rt(e,t){let n=e.flows??{},r=new Set;if(t.kind===`unit`){for(let e of Object.keys(n))F(e)===t.unit&&r.add(e);let e=[];for(let t of r)for(let r of n[t]?.effects?.calls??[])ve(r)||e.push(r);for(let t of e)r.add(t)}else if(t.kind===`flow`){r.add(t.flowId);let e=n[t.flowId];for(let t of e?.effects?.calls??[])ve(t)||r.add(t);for(let[e,i]of Object.entries(n))i.effects?.calls?.includes(t.flowId)&&r.add(e)}else for(let[e,i]of Object.entries(n))zt(i,e,t.nodeId)&&r.add(e);let i={};for(let e of r){let t=n[e];t&&(i[e]=t)}return{...e,flows:i}}function zt(e,t,n){if(n===`flow:${t}`||n===`clock:${t}`&&(e.trigger?.cron||e.trigger?.every)||e.trigger?.signal&&n===`signal:${e.trigger.signal}`||e.gates?.some(e=>n===`gate:${e}`))return!0;let r=e.effects;return r?!!(r.reads?.some(e=>e===n)||r.writes?.some(e=>e===n)||r.emits?.some(e=>n===`signal:${e}`)||r.sends?.some(e=>n===`channel:${e}`)||r.asks?.some(e=>n===`ai:${e}`)||r.secrets?.some(e=>n===`vault:${e}`)||r.calls?.some(e=>{let t=ve(e);return t?n===ye(t.server):n===`flow:${e}`})):!1}var Bt=[`!=`,`>=`,`<=`,`=`,`>`,`<`],Vt={clauses:[]},Ht=[`flow`,`unit`,`trigger`,`plane`,`tenant`,`principal`,`cache`,`replica`,`error`,`buildVersion`,`promptVersion`,`duration`];function Ut(e){if(!e||!e.trim())return Vt;let t=e.split(/\s+AND\s+/i).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t){let t=en(e);t&&n.push(t)}return{clauses:n}}function Z(e,t){return{clauses:[...e.clauses.filter(e=>e.dimension!==t.dimension),t]}}function Wt(e,t){return{clauses:e.clauses.filter(e=>e.dimension!==t)}}function Gt(e,t){return e.dimension===t.dimension&&e.op===t.op&&e.value===t.value}function Kt(e,t){return e.clauses.some(e=>Gt(e,t))}function qt(e,t){return Kt(e,t)?Wt(e,t.dimension):Z(e,t)}function Jt(e){let t=rn(e.dimension,e.value);return`${e.dimension} ${e.op} ${t}`}function Yt(e,t){for(let n of t.clauses)if(!an(e,n))return!1;return!0}function Xt(e,t){return t.clauses.length===0?[...e]:e.filter(e=>Yt(e,t))}function Zt(e){let t=/^(-?\d+(?:\.\d+)?)\s*(ms|s|m)?$/i.exec(e.trim());if(!t)return;let n=Number(t[1]),r=(t[2]??`ms`).toLowerCase();if(r===`ms`)return n;if(r===`s`)return n*1e3;if(r===`m`)return n*6e4}function Qt(e,t){switch(t){case`flow`:return e.flow;case`unit`:return e.unit??null;case`trigger`:return e.trigger;case`plane`:return e.plane;case`tenant`:return e.tenant??null;case`principal`:return e.principal??null;case`cache`:return e.cache;case`replica`:return e.replica??null;case`replicaLagMs`:case`replica_lag_ms`:return e.replicaLagMs??null;case`error`:case`error_code`:return e.error??null;case`buildVersion`:case`build_version`:return e.buildVersion??null;case`promptVersion`:case`prompt_version`:return e.promptVersion??null;case`cost`:return e.cost??null;case`duration`:case`duration_ms`:return e.durationMs;case`gates`:return e.gates.join(`,`);default:return e.dimensions[t]}}function $t(e){let t=new Set(Ht);for(let n of e)for(let e of Object.keys(n.dimensions))t.add(e);return[...t].sort()}function en(e){let t=null,n=-1;for(let r of Bt){let i=e.indexOf(` ${r} `);if(i!==-1){t=r,n=i;break}}if(t===null||n<0)return null;let r=e.slice(0,n).trim(),i=e.slice(n+t.length+2).trim();if(!r||!i)return null;let a=tn(r,i);return a===void 0?null:{dimension:r,op:t,value:a}}function tn(e,t){return e===`duration`||e===`duration_ms`?Zt(t):t===`true`?!0:t===`false`?!1:t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):/^-?\d+(\.\d+)?$/.test(t)?Number(t):t}function nn(e,t){return rn(e,t)}function rn(e,t){if(e===`duration`||e===`duration_ms`){let e=typeof t==`number`?t:Number(t);return Number.isFinite(e)?e>=6e4&&e%6e4==0?`${e/6e4}m`:e>=1e3&&e%1e3==0?`${e/1e3}s`:`${e}ms`:String(t)}return typeof t==`string`&&/\s/.test(t)?`"${t}"`:String(t)}function an(e,t){let n=Qt(e,t.dimension);if(n==null)return t.op===`!=`;let r=t.value;if(t.op===`=`)return on(n,r);if(t.op===`!=`)return!on(n,r);let i=Q(n),a=Q(r);return i===void 0||a===void 0?!1:t.op===`>`?i>a:t.op===`<`?i<a:t.op===`>=`?i>=a:t.op===`<=`&&i<=a}function on(e,t){if(typeof e==`number`||typeof t==`number`){let n=Q(e),r=Q(t);if(n!==void 0&&r!==void 0)return n===r}return String(e)===String(t)}function Q(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`boolean`)return;let t=Number(e);return Number.isFinite(t)?t:void 0}var sn=new Set(Object.keys(A));function cn(e){if(e.startsWith(`flow:`))return{kind:`flow`,flowId:e.slice(5)};if(e.startsWith(`signal:`))return{kind:`signal`,signal:e.slice(7)};if(e.startsWith(`unit:`))return{kind:`unit`,unit:e.slice(5)};if(e.startsWith(`element:`)){let t=e.slice(8);return sn.has(t)?{kind:`element`,element:t}:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&sn.has(t)?{kind:`element`,element:t}:null}return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)||e.startsWith(`vault:`)||e.startsWith(`channel:`)||e.startsWith(`gate:`)||e.startsWith(`clock:`)||e.startsWith(`ai:`)?{kind:`resource`,nodeId:e}:null}function ln(e){switch(e.kind){case`flow`:return e.flowId;case`signal`:return`signal:${e.signal}`;case`unit`:return e.unit;case`element`:return A[e.element].label;case`resource`:return e.nodeId}}function un(e,t){return t?.kind===`flow`?Z(e,{dimension:`flow`,op:`=`,value:t.flowId}):t?.kind===`unit`?Z(e,{dimension:`unit`,op:`=`,value:t.unit}):e}function dn(e,t,n){if(t.kind===`flow`)return Yt(e,{clauses:[{dimension:`flow`,op:`=`,value:t.flowId}]});if(t.kind===`unit`)return(e.unit??F(e.flow))===t.unit;if(t.kind===`element`)return t.element===`flow`||Xe(e).includes(t.element);if(t.kind===`resource`)return fn(e,t.nodeId,n);let r=n?.flows??{};for(let[n,i]of Object.entries(r))if(n===e.flow&&(i.trigger?.signal===t.signal||i.effects?.emits?.includes(t.signal)))return!0;return!1}function fn(e,t,n){let r=t.includes(`:`)?t.slice(t.indexOf(`:`)+1):t;if(e.effects.some(e=>e.resource===t||e.resource===r)||e.gates.some(e=>t===`gate:${e}`))return!0;let i=n?.flows?.[e.flow];return!!(i&&zt(i,e.flow,t))}function pn(e,t,n){return t?e.filter(e=>dn(e,t,n)):[...e]}function mn(e){return e?e.kind===`unit`||e.kind===`flow`||e.kind===`resource`?e:e.kind===`signal`?{kind:`resource`,nodeId:`signal:${e.signal}`}:null:null}function hn({manifest:e,runs:t=[],graphFilter:n,highlightedFlowIds:r,highlightedNodeIds:s,follow:l,activeNodeId:d=null,focusedNodeId:f=null,orchestraLabel:p=null,onNodeClick:m,onPaneClick:h}){let{fitView:g}=a(),{theme:_}=Fe(),[v,y]=(0,I.useState)(null),b=_===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:_,x=mn(n),S=n?.kind===`element`?n.element:null,C=x===null,w=(0,I.useMemo)(()=>st(e,t,S?{kind:`element`,element:S}:null),[e,t,S]),T=(0,I.useMemo)(()=>Be(!x||!e?e:Rt(e,x)),[e,x]),E=(0,I.useMemo)(()=>ft(w.nodes,w.edges,{hoverNodeId:v,highlightedFlowIds:r,highlightedNodeIds:s,manifest:e}),[w.nodes,w.edges,v,r,s,e]),D=(0,I.useMemo)(()=>Re(T.nodes,r,s,{activeNodeId:d,focusedNodeId:f}),[T.nodes,r,s,d,f]),O=(0,I.useMemo)(()=>Le(T.edges,D),[T.edges,D]),k=C?E.nodes:D,ee=C?E.edges:O;return(0,I.useEffect)(()=>{g({duration:280,padding:.18})},[C,n,e,g]),(0,I.useEffect)(()=>{if(!l||C||r.size===0)return;let e=[...r].map(e=>`flow:${e}`);g({nodes:e.map(e=>({id:e})),duration:300,padding:.2})},[l,C,r,g]),(0,G.jsxs)(`div`,{className:`relative h-full w-full`,children:[n?(0,G.jsxs)(`button`,{type:`button`,"data-slot":`flow-graph-map`,onClick:()=>h?.(),className:`absolute top-2 left-2 z-10 inline-flex max-w-[min(100%-1rem,20rem)] items-center gap-1.5 truncate rounded-md border border-border/70 bg-card/90 px-2 py-1 text-[10px] font-medium text-muted-foreground shadow-sm backdrop-blur-sm transition-colors hover:border-border hover:text-foreground`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:`Map`}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,G.jsx)(`span`,{className:`truncate`,children:ln(n)})]}):(0,G.jsx)(`div`,{className:`pointer-events-none absolute top-2 left-2 z-10 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:p?(0,G.jsxs)(G.Fragment,{children:[`Orchestra `,(0,G.jsx)(`span`,{className:`text-foreground normal-case`,children:p})]}):`Hover a unit — spokes light the elements it touches`}),(0,G.jsxs)(i,{nodes:k,edges:ee,nodeTypes:Lt,colorMode:b,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},minZoom:.15,maxZoom:1.6,defaultEdgeOptions:{type:`smoothstep`,zIndex:M.edge},zIndexMode:`manual`,onNodeClick:(e,t)=>m?.(t.id),onPaneClick:()=>h?.(),onNodeMouseEnter:(e,t)=>y(t.id),onNodeMouseLeave:()=>y(null),children:[(0,G.jsx)(u,{gap:24,size:1,color:`color-mix(in oklab, var(--foreground) 14%, transparent)`}),(0,G.jsx)(c,{showInteractive:!1}),(0,G.jsx)(o,{pannable:!0,zoomable:!0,ariaLabel:`Flow graph overview`,bgColor:`var(--card)`,maskColor:`color-mix(in oklab, var(--background) 55%, transparent)`,nodeColor:gn,nodeStrokeColor:_n,nodeStrokeWidth:12,nodeBorderRadius:10})]})]})}function gn(e){if(e.type===`orbit`)return`transparent`;let t=e.data.kind;if(t===`law`)return`color-mix(in oklab, var(--foreground) 45%, transparent)`;if(t===`unit`)return`color-mix(in oklab, var(--foreground) 8%, transparent)`;if(t===`element`){let t=e.data.refId;return P[t]?.accent??`#64748B`}return t in P?P[t].accent:`#64748B`}function _n(e){return e.data.kind===`unit`?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`transparent`}function vn(e){let{leading:t,...n}=e;return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,"data-slot":`flow-graph`,children:[t?(0,G.jsxs)(`header`,{className:w,children:[t,(0,G.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})]}):null,(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(l,{children:(0,G.jsx)(hn,{...n})})})]})}var yn=`orch-`;function bn(e){return e.startsWith(yn)}function xn(e,t){return e&&t}function Sn(e,t=Math.random){let n=e.filter(e=>!bn(e.id)&&e.flow.length>0);return n.length===0?null:n[Math.floor(t()*n.length)]??null}function Cn(e,t,n){let r=t-e.startedAt,i=e.flow.replaceAll(`.`,`-`);return{...e,id:`${yn}${n}-${i}`,parentId:null,startedAt:t,endedAt:t+e.durationMs,effects:e.effects.map(e=>({...e,timestamp:e.timestamp+r})),logs:e.logs.map(e=>({...e,at:e.at+r}))}}function wn(e=Math.random){return 1800+Math.floor(e()*1600)}var Tn=1400;function En(e){let t=S(),[n,r]=(0,I.useState)(null),i=(0,I.useRef)(0),a=(0,I.useRef)(null),o=(0,I.useRef)(null),s=(0,I.useRef)(e.paused);return s.current=e.paused,(0,I.useEffect)(()=>{if(!xn(!1,e.enabled))return;let n=()=>{a.current&&=(clearTimeout(a.current),null)},c=()=>{if(s.current||document.hidden)return;let e=Sn(t.getQueryData(ge)??[]);if(!e)return;i.current+=1;let o=Cn(e,Date.now(),i.current);t.setQueryData(ge,e=>he(e??[],o)),r({flowId:o.flow,runId:o.id}),n(),a.current=setTimeout(()=>{r(null),a.current=null},Tn)},l=e=>{o.current=setTimeout(()=>{c(),l(wn())},e)};l(700);let u=()=>{document.hidden&&(r(null),n())};return document.addEventListener(`visibilitychange`,u),()=>{document.removeEventListener(`visibilitychange`,u),o.current&&clearTimeout(o.current),n(),r(null)}},[e.enabled,t]),e.paused?null:n}function Dn(e,t){let n=new Set;if(!t)return n;let r=new Map,i=new Map;for(let t of e)r.set(t.id,t);for(let t of e){if(!t.parentId)continue;let e=i.get(t.parentId)??[];e.push(t),i.set(t.parentId,e)}let a=r.get(t);if(!a)return n;let o=a,s=new Set;for(;o&&!s.has(o.id);)s.add(o.id),n.add(o.flow),o=o.parentId?r.get(o.parentId):void 0;let c=[a];for(;c.length>0;){let e=c.shift();if(!e)break;for(let t of i.get(e.id)??[])s.has(t.id)||(s.add(t.id),n.add(t.flow),c.push(t))}return n}var On=[{id:`signal`,label:`Signal`,expr:`trigger = signal`},{id:`clock`,label:`Clock`,expr:`trigger = cron`},{id:`cache-miss`,label:`Cache miss`,expr:`cache = miss`},{id:`slow`,label:`Slow`,expr:`duration > 100ms`}],kn=`h-7 min-w-0 rounded-none border-0 bg-transparent px-0 font-mono text-[11px] text-foreground shadow-none outline-none focus-visible:ring-0 dark:bg-transparent`,$=`rounded-none border-0 bg-transparent px-1.5 py-1 text-[11px] text-foreground/70 shadow-none transition-colors hover:bg-muted/50 hover:text-foreground`,An=`grid grid-cols-[minmax(0,1fr)_1.25rem_minmax(0,1fr)_1.25rem] items-center gap-x-1`;function jn({query:e,runs:t,onChange:n}){let r=(0,I.useMemo)(()=>$t(t),[t]),i=(0,I.useMemo)(()=>[...new Set([...Ht,...r])].sort(),[r]),[a,o]=(0,I.useState)(`trigger`),[s,c]=(0,I.useState)(`=`),[l,u]=(0,I.useState)(`signal`),[d,f]=(0,I.useState)(!1),h=()=>{let t=Ut(`${a} ${s} ${l}`).clauses[0];t&&(n(Z(e,t)),f(!1))};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-b border-border/60 px-2 py-1.5`,"data-slot":`traces-advanced-filters`,children:[e.clauses.length>0?(0,G.jsx)(`ul`,{"aria-label":`Active filters`,className:`flex flex-col gap-0.5`,children:e.clauses.map(t=>(0,G.jsx)(`li`,{children:(0,G.jsx)(Mn,{clause:t,onRemove:()=>n(Wt(e,t.dimension))})},t.dimension))}):null,d?(0,G.jsxs)(`div`,{className:An,"data-slot":`traces-advanced-composer`,children:[(0,G.jsx)(`select`,{"aria-label":`Filter dimension`,className:kn,value:a,onChange:e=>o(e.target.value),children:i.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`select`,{"aria-label":`Filter operator`,className:m(kn,`text-center text-foreground/70`),value:s,onChange:e=>c(e.target.value),children:[`=`,`!=`,`>`,`<`,`>=`,`<=`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(p,{"aria-label":`Filter value`,flat:!0,className:`h-7 px-0 font-mono text-[11px]`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()}}),(0,G.jsx)(`button`,{type:`button`,className:$,onClick:h,children:`Add`})]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[On.map(t=>{let r=Ut(t.expr).clauses[0],i=r!==void 0&&Kt(e,r);return(0,G.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:r===void 0,onClick:()=>{r&&n(qt(e,r))},className:m($,i?`font-medium text-foreground`:`text-foreground/70`),children:t.label},t.id)}),(0,G.jsx)(`button`,{type:`button`,"aria-expanded":d,className:m($,`ml-auto`,d&&`text-foreground`),onClick:()=>f(e=>!e),children:d?`Cancel`:`Add clause`}),e.clauses.length>0?(0,G.jsx)(`button`,{type:`button`,className:$,onClick:()=>n(Ut(``)),children:`Clear`}):null]})]})}function Mn({clause:e,onRemove:t}){let n=Jt(e);return(0,G.jsxs)(`div`,{className:An,"data-slot":`traces-advanced-clause`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground/80`,children:e.dimension}),(0,G.jsx)(`span`,{className:`text-center font-mono text-[11px] text-foreground/65`,"aria-hidden":!0,children:e.op}),(0,G.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground`,children:nn(e.dimension,e.value)}),(0,G.jsx)(`button`,{type:`button`,className:m($,`flex size-5 items-center justify-center text-foreground/55 hover:text-destructive`),"aria-label":`Remove ${n}`,onClick:t,children:(0,G.jsx)(f,{icon:C,className:`size-3`})})]})}var Nn={query:``,status:`all`,advanced:Vt};function Pn(e,t){let n=t.trim().toLowerCase();return!n||[e.flow,e.unit??``,e.trigger,e.cache,e.id,e.error??``,e.errorMessage??``].some(e=>e.toLowerCase().includes(n))}function Fn(e,t){return Xt(e.filter(e=>!(!Pn(e,t.query)||t.status===`errors`&&e.error===null)),t.advanced)}function In(e,t=Date.now()){let n=t-e;return n<1e3?`just now`:n<6e4?`${Math.floor(n/1e3)}s ago`:n<36e5?`${Math.floor(n/6e4)}m ago`:`${Math.floor(n/36e5)}h ago`}function Ln(e,t=Date.now()){let n=In(e.startedAt,t),r=e.error!==null;return{text:n,title:r?e.errorMessage?`${e.error} — ${e.errorMessage}`:e.error??n:n,failed:r}}function Rn({run:e,selected:t,onSelect:n,copyText:r=async e=>{await navigator.clipboard.writeText(e)}}){let i=Ln(e),a=i.failed,o=Oe(e.trigger),s=e.cache,[c,l]=(0,I.useState)(null),u=async t=>{t.stopPropagation();try{await r(Ae(e)),l(`Copied run id`)}catch{l(`Copy failed`)}};return(0,G.jsxs)(`div`,{"data-slot":`trace-row`,"data-run-id":e.id,"data-selected":t?`true`:`false`,"data-failed":a?`true`:`false`,"data-cache":e.cache,className:m(`group relative flex w-full items-stretch border-b border-border/60 text-xs transition-colors`,`hover:bg-muted/50 focus-within:bg-muted/50`,t&&`bg-muted/70`,a&&`bg-destructive/[0.04]`),children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:m(`absolute inset-y-0 left-0 w-0.5`,t&&!a&&`bg-sky-500`,a&&`bg-destructive`)}),(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>n(e.id),className:`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-1 pl-0 text-left outline-none`,children:[(0,G.jsx)(`span`,{className:m(`ml-2.5 size-1.5 shrink-0 rounded-full`,a?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:o.label,"aria-hidden":!0,children:(0,G.jsx)(f,{icon:o.icon,className:`size-3.5`})}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.flow}),(0,G.jsx)(He,{cache:s,dataSlot:`trace-row-cache`}),(0,G.jsx)(`span`,{className:m(`w-10 shrink-0 text-right tabular-nums font-medium`,de(e.durationMs)),children:me(e.durationMs)}),(0,G.jsx)(`span`,{className:`w-14 shrink-0 truncate text-right tabular-nums text-muted-foreground`,title:i.title,"data-slot":`trace-row-meta`,children:i.text})]}),(0,G.jsx)(`div`,{className:m(`flex shrink-0 items-center gap-0.5 pr-1.5 opacity-0 transition-opacity`,`group-hover:opacity-100 group-focus-within:opacity-100`,c&&`opacity-100`),children:(0,G.jsxs)(h,{children:[(0,G.jsx)(_,{render:e=>(0,G.jsx)(T,{...e,type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Copy run ID`,"data-slot":`trace-copy-id`,onClick:t=>{e.onClick?.(t),u(t)},children:(0,G.jsx)(f,{icon:k,className:`size-3`})})}),(0,G.jsx)(g,{side:`top`,children:`Copy run ID`})]})}),c?(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:c}):null]})}var zn=[{value:`all`,label:`All`,icon:We},{value:`errors`,label:`Errors`,icon:ue}];function Bn({runs:e,selectedRunId:t,onSelect:n,liveStatus:r,manifest:i,graphFilter:a,onGraphFilterChange:o,focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u,selectedRun:p}){let[v,x]=(0,I.useState)(Nn),[S,C]=(0,I.useState)(!1);(0,I.useEffect)(()=>{(a?.kind===`flow`||a?.kind===`unit`)&&x(e=>({...e,advanced:un(e.advanced,a)}))},[a]);let T=(0,I.useMemo)(()=>pn(Fn(e,v),a,i),[e,v,a,i]),O=(0,I.useMemo)(()=>p===void 0?t?e.find(e=>e.id===t)??null:null:p,[p,e,t]),k=v.advanced.clauses.length>0,re=e=>{x(t=>({...t,query:e}))},ae=e=>{x(t=>({...t,status:e}))};return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`traces-pane`,children:[(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,G.jsxs)(`div`,{className:m(d,`border-b-0`),children:[(0,G.jsx)(ee,{value:v.query,onChange:e=>re(e.target.value),placeholder:`Search traces…`,"aria-label":`Search traces`,"data-slot":`traces-search`}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[e.length>0?(0,G.jsxs)(h,{children:[(0,G.jsx)(_,{render:e=>(0,G.jsxs)(`button`,{...e,type:`button`,"aria-expanded":S,"aria-controls":`traces-advanced-panel`,"aria-label":k?`Advanced filters, ${v.advanced.clauses.length} active`:`Advanced filters`,"data-slot":`traces-advanced-toggle`,onClick:t=>{e.onClick?.(t),C(e=>!e)},className:m(b,`relative`,(S||k)&&`text-foreground`),children:[(0,G.jsx)(f,{icon:Te,className:`size-3`,"aria-hidden":!0}),k?(0,G.jsx)(`span`,{className:`absolute -top-0.5 -inset-e-0.5 flex size-3.5 items-center justify-center rounded-full bg-foreground text-[8px] font-medium text-background`,"aria-hidden":!0,children:v.advanced.clauses.length}):null]})}),(0,G.jsx)(g,{side:`bottom`,children:`Advanced`})]}):null,e.length>0?(0,G.jsx)(`span`,{className:`mx-0.5 h-3 w-px bg-border/60`,"aria-hidden":!0}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-0.5 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:r===`open`?`size-1.5 rounded-full bg-emerald-500`:`size-1.5 rounded-full bg-muted-foreground`,"aria-hidden":!0}),r===`open`?`live`:`polling`]})]})]}),e.length>0?(0,G.jsx)(`div`,{className:m(w,`border-t border-b-0`),"data-slot":`traces-filters`,children:(0,G.jsx)(`div`,{className:`flex shrink-0 items-stretch`,role:`group`,"aria-label":`Status filter`,children:zn.map(({value:e,label:t,icon:n})=>{let r=v.status===e;return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ae(e),className:m(y,`font-semibold tracking-[0.08em] uppercase`,r?e===`errors`?`text-destructive`:D:E),children:[(0,G.jsx)(f,{icon:n,className:`size-3`,"aria-hidden":!0}),t]},e)})})}):null,e.length>0&&a?(0,G.jsxs)(`button`,{type:`button`,"data-slot":`traces-graph-filter`,onClick:()=>o(null),title:`Clear graph filter`,className:`mx-2 mb-1.5 inline-flex max-w-full items-center gap-1 self-start truncate rounded-md border border-sky-500/40 bg-sky-500/10 px-2 py-0.5 text-[10px] font-medium text-sky-700 transition-colors hover:bg-sky-500/20 dark:text-sky-400`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:ln(a)}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`×`})]}):null]}),e.length>0?(0,G.jsx)(Ue,{id:`traces-advanced-panel`,role:`region`,"aria-label":`Advanced filters`,open:S,className:`shrink-0`,children:(0,G.jsx)(jn,{query:v.advanced,runs:e,onChange:e=>{x(t=>({...t,advanced:e}))}})}):null,(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:e.length===0?(0,G.jsx)(ie,{className:`border-none`,children:(0,G.jsxs)(te,{children:[(0,G.jsx)(ne,{variant:`icon`,children:(0,G.jsx)(f,{icon:A.flow.icon})}),(0,G.jsx)(se,{children:`No traces yet`}),(0,G.jsx)(le,{children:`No runs for the flows on this graph yet. Trigger a flow to see live activity here.`})]})}):T.length===0?(0,G.jsx)(ie,{className:`border-none`,children:(0,G.jsxs)(te,{children:[(0,G.jsx)(se,{children:`No matching traces`}),(0,G.jsx)(le,{children:`Nothing in this list matches the current search, status, or advanced filters.`})]})}):T.map(e=>(0,G.jsx)(Rn,{run:e,selected:e.id===t,onSelect:e=>n(e===t?null:e)},e.id))}),(0,G.jsx)(je,{run:O,onClose:()=>n(null),focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u})]})}function Vn(){let e=pe(),t=_e(),n=fe(!0),{selectedRunId:r,selectedFlowId:i,follow:a,setSelectedRun:o,setSelectedFlow:s}=Ie(),c=ae(),l=(0,G.jsx)(oe,{open:c.open,onToggle:c.toggle,noun:`traces`,controlsId:`overview-traces`,dataSlot:`overview-traces-toggle`}),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(0),[g,_]=(0,I.useState)(null),y=(0,I.useRef)(null),b=(0,I.useMemo)(()=>new Set(Object.keys(e.data?.flows??{})),[e.data]),S=(0,I.useMemo)(()=>ze(t.data??[],b),[t.data,b]),C=En({enabled:!!e.data&&S.length>0,paused:r!=null||u!=null});(0,I.useEffect)(()=>{i&&d(e=>e?.kind===`flow`&&e.flowId===i?e:{kind:`flow`,flowId:i})},[i]);let w=(0,I.useCallback)(e=>{d(e),e?.kind===`flow`?s(e.flowId):s(null)},[s]),T=(0,I.useMemo)(()=>{let e=Dn(t.data??[],r);return e.size>0?e:i?new Set([i]):C?.flowId?new Set([C.flowId]):e},[t.data,r,i,C?.flowId]),E=(0,I.useMemo)(()=>{let t=new Set,n=e.data?.flows??{};for(let e of T){let r=n[e];if(r){r.trigger?.signal&&t.add(`signal:${r.trigger.signal}`),(r.trigger?.cron||r.trigger?.every)&&t.add(`clock:${e}`);for(let e of r.gates??[])t.add(`gate:${e}`);for(let e of r.effects?.reads??[])t.add(e);for(let e of r.effects?.writes??[])t.add(e);for(let e of r.effects?.emits??[])t.add(`signal:${e}`);for(let e of r.effects?.sends??[])t.add(`channel:${e}`);for(let e of r.effects?.asks??[])t.add(`ai:${e}`);for(let e of r.effects?.secrets??[])t.add(`vault:${e}`)}}return t},[T,e.data]),D=(0,I.useMemo)(()=>r?t.data?.find(e=>e.id===r)??null:null,[t.data,r]),k=(0,I.useCallback)(e=>{let t=cn(e);t&&w(u&&u.kind===t.kind&&JSON.stringify(u)===JSON.stringify(t)?null:t)},[w,u]),ee=(0,I.useCallback)(()=>{w(null)},[w]),te=(0,I.useCallback)(()=>{h(e=>e+1)},[]);return(0,I.useEffect)(()=>{if(m===0||!D)return;let n=ke(Dn(t.data??[],D.id),e.data??null);if(n.length===0)return;let r=Ee(D.durationMs),i=performance.now();return _(n[0]??null),y.current=setInterval(()=>{let e=Math.min(1,(performance.now()-i)/r);_(De(n,e)),e>=1&&y.current&&(clearInterval(y.current),y.current=null,setTimeout(()=>_(null),400))},60),()=>{y.current&&=(clearInterval(y.current),null),_(null)}},[m,D,t.data,e.data]),(0,G.jsx)(`div`,{className:x,"data-slot":`flows-page`,children:(0,G.jsxs)(O,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,G.jsx)(re,{panelRef:c.panelRef,collapsible:!0,collapsedSize:0,defaultSize:v.start.defaultSize,minSize:v.start.minSize,maxSize:`50%`,onResize:c.onResize,className:`min-h-0`,children:(0,G.jsx)(`div`,{id:`overview-traces`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`overview-traces`,children:(0,G.jsx)(Bn,{runs:S,selectedRunId:r,onSelect:o,liveStatus:n,manifest:e.data??null,graphFilter:u,onGraphFilterChange:w,focusEffectIndex:f,onFocusEffectChange:p,playbackKey:m,onReplayStart:te,selectedRun:D})})}),c.open?(0,G.jsx)(ce,{withHandle:!0}):null,(0,G.jsx)(re,{defaultSize:v.end.defaultSize,minSize:v.end.minSize,className:`min-h-0`,children:(0,G.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:(0,G.jsx)(vn,{manifest:e.data??null,runs:S,graphFilter:u,highlightedFlowIds:T,highlightedNodeIds:E,orchestraLabel:C?.flowId??null,follow:a,activeNodeId:g,onNodeClick:k,onPaneClick:ee,leading:l})})})]})})}export{Vn as FlowsPage};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n,a as r,c as i,d as a,o,p as s,r as c,s as l,t as u}from"./xyflow-yApv7D4e.js";import{Cr as d,Dr as f,E as p,Er as m,F as h,I as g,R as _,_r as v,br as y,cr as b,dr as x,ha as S,kr as C,vr as w,x as T,xr as E,yr as D}from"./shortcut-keys-3ILd8oGn.js";import{a as O,b as k,c as ee,d as te,f as ne,i as re,l as ie,n as ae,o as oe,p as se,r as ce,t as A,u as le}from"./element-icons-BI8cJgdh.js";import{s as ue}from"./collapsible-JWvpaiGY.js";import{t as de}from"./duration-tone-D9yCJG4n.js";import{a as fe,c as pe,i as me,l as he,o as ge,s as _e}from"./highlighted-json-xH8MrEnv.js";import{C as ve,S as ye,_ as j,b as be,d as xe,f as Se,g as M,h as Ce,p as we,v as N,y as P}from"./request-meta-DqZ-fMu5.js";import{n as Te}from"./dagre.esm-B1_XeuLP.js";import{a as Ee,i as De,n as Oe,o as ke,r as Ae,t as je}from"./trace-detail-sheet-CazhjtiU.js";import{a as Me,c as Ne,l as Pe,o as Fe,vt as Ie}from"./index-yTCY4AcS.js";import{a as Le,c as F,i as Re,n as ze,o as Be,r as Ve,t as He}from"./cache-glyph-BGmRZk7d.js";import{t as Ue}from"./agent-disclosure-DGscxaF5.js";var We=[[`path`,{d:`M4 5L20 5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M4 12L20 12`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M4 19L20 19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],I=e(t(),1),L=[`flow`,`signal`,`store`,`clock`,`gate`,`vault`,`channel`,`ai`];function R(e,t,n){return{x:j.cx+t*Math.cos(e)-n.width/2,y:j.cy+t*Math.sin(e)-n.height/2}}function Ge(e){if(e<=0)return[];let t=2*Math.PI/e;return Array.from({length:e},(e,n)=>-Math.PI/2+n*t)}var Ke=2*Math.PI/L.length;function z(e,t,n=j.typeRing){if(t<=0)return[];if(t===1)return[e];let r=(N.type.width+10)/n,i=Math.min(r*(t-1),Ke*.7);return Array.from({length:t},(n,r)=>e-i/2+r/(t-1)*i)}function qe(e,t){if(t<=0)return[];let n=j.typeRing,r=j.typeRing+j.typeRow;if(t===1)return[{angle:e,radius:n}];if(t===4)return Ye(e,n,r);if(t<=3)return z(e,t,n).map(e=>({angle:e,radius:n}));let i=Math.ceil(t/2),a=t-i;return[...z(e,i,n).map(e=>({angle:e,radius:n})),...z(e,a,r).map(e=>({angle:e,radius:r}))]}function Je(e){return Math.abs(Math.cos(e))*N.type.height+Math.abs(Math.sin(e))*N.type.width}function Ye(e,t,n){let r=(Je(e)+24)/t;return[{angle:e-r/2,radius:t},{angle:e+r/2,radius:t},{angle:e-r/2,radius:n},{angle:e+r/2,radius:n}]}function B(e){let t=new Set([`flow`]),n=e.trigger;(n?.cron||n?.every)&&t.add(`clock`),n?.signal&&t.add(`signal`),(e.gates?.length??0)>0&&t.add(`gate`);let r=e.effects;return((r?.reads?.length??0)>0||(r?.writes?.length??0)>0)&&t.add(`store`),(r?.emits?.length??0)>0&&t.add(`signal`),(r?.sends?.length??0)>0&&t.add(`channel`),(r?.asks?.length??0)>0&&t.add(`ai`),(r?.secrets?.length??0)>0&&t.add(`vault`),L.filter(e=>t.has(e))}function Xe(e){let t=new Set([`flow`]);(e.trigger===`cron`||e.trigger===`every`)&&t.add(`clock`),e.trigger===`signal`&&t.add(`signal`),e.gates.length>0&&t.add(`gate`);for(let n of e.effects)switch(n.kind){case`read`:case`write`:t.add(`store`);break;case`emit`:t.add(`signal`);break;case`send`:case`fetch`:t.add(`channel`);break;case`ask`:case`embed`:t.add(`ai`);break;case`secret`:t.add(`vault`)}return L.filter(e=>t.has(e))}function Ze(e,t){let n=new Map,r=(e,t,r)=>{n.has(e)||n.set(e,r===void 0?{id:e,label:t}:{id:e,label:t,badge:r})};switch(t){case`flow`:for(let t of Object.keys(e.flows??{}).sort())r(`flow:${t}`,Ve(t),F(t));break;case`signal`:for(let t of Object.keys(e.signals??{}).sort())r(`signal:${t}`,t,`signal`);for(let t of Object.values(e.flows??{})){t.trigger?.signal&&r(`signal:${t.trigger.signal}`,t.trigger.signal,`signal`);for(let e of t.effects?.emits??[])r(`signal:${e}`,e,`signal`)}break;case`store`:for(let[t,n]of Object.entries(e.stores??{})){let e=n.facet;for(let t of Object.keys(n.tables??{}).sort())r(`${e}:${t}`,t,e);let i=n.namespaces&&n.namespaces.length>0?n.namespaces:[];e===`kv`&&i.length===0&&r(`kv:${t}`,t,`kv`);for(let e of[...i].sort())r(`kv:${e}`,e,`kv`);for(let e of[...n.buckets??[]].sort())r(`files:${e}`,e,`files`);for(let e of[...n.indexes??[]].sort())r(`index:${e}`,e,`index`)}for(let t of Object.values(e.flows??{}))for(let e of[...t.effects?.reads??[],...t.effects?.writes??[]]){let t=Qe(e);t&&r(t.id,t.label,t.badge)}break;case`clock`:for(let[t,n]of Object.entries(e.clocks??{}).sort(([e],[t])=>e.localeCompare(t)))r(`clock:${t}`,t,n.cron?`cron`:n.every?`every`:`clock`);for(let[t,n]of Object.entries(e.flows??{}))n.trigger?.cron&&r(`clock:${t}`,n.trigger.cron,`cron`),n.trigger?.every&&r(`clock:${t}`,n.trigger.every,`every`);break;case`gate`:for(let t of Object.keys(e.gates??{}).sort())r(`gate:${t}`,t,`gate`);for(let t of Object.values(e.flows??{}))for(let e of t.gates??[])r(`gate:${e}`,e,`gate`);break;case`vault`:for(let t of Object.keys(e.vault??{}).sort())r(`vault:${t}`,t,`vault`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.secrets??[])r(`vault:${e}`,e,`vault`);break;case`channel`:for(let t of Object.keys(e.channels??{}).sort())r(`channel:${t}`,t,`channel`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.sends??[])r(`channel:${e}`,e,`channel`);break;case`ai`:for(let t of Object.keys(e.ai?.prompts??{}).sort())r(`ai:${t}`,t,`prompt`);for(let t of Object.keys(e.ai?.agents??{}).sort())r(`ai:${t}`,t,`agent`);for(let t of Object.values(e.flows??{}))for(let e of t.effects?.asks??[])r(`ai:${e}`,e,`prompt`)}return[...n.values()].sort((e,t)=>e.label.localeCompare(t.label))}function Qe(e){return e.startsWith(`sql:`)?{id:e,label:e.slice(4),badge:`sql`}:e.startsWith(`kv:`)?{id:e,label:e.slice(3),badge:`kv`}:e.startsWith(`files:`)?{id:e,label:e.slice(6),badge:`files`}:e.startsWith(`index:`)?{id:e,label:e.slice(6),badge:`index`}:null}var $e={flow:xe.map(e=>({kind:e,label:Se[e].label})),signal:[{kind:`once`,label:`once`},{kind:`broadcast`,label:`broadcast`},{kind:`live`,label:`live`}],store:[{kind:`sql`,label:`SQL`},{kind:`kv`,label:`KV`},{kind:`files`,label:`Files`},{kind:`index`,label:`Index`}],clock:[{kind:`cron`,label:`cron`},{kind:`every`,label:`every`}],gate:[{kind:`policy`,label:`policy`},{kind:`scope`,label:`scope`},{kind:`rate`,label:`rate`},{kind:`public`,label:`public`}],vault:[{kind:`secret`,label:`secret`},{kind:`config`,label:`config`},{kind:`env`,label:`env`}],channel:[{kind:`email`,label:`email`},{kind:`sms`,label:`SMS`},{kind:`whatsapp`,label:`WA`},{kind:`push`,label:`Push`}],ai:[{kind:`model`,label:`model`},{kind:`prompt`,label:`prompt`},{kind:`embed`,label:`embed`},{kind:`agent`,label:`agent`}]};function et(e,t){return $e[t].map(e=>({id:`type:${t}:${e.kind}`,label:e.label,badge:e.kind}))}function tt(e,t){return t?.kind===`rate`||e.startsWith(`rate:`)?`rate`:e===`public`?`public`:(t?.scopes?.length??0)>0?`scope`:`policy`}function nt(e){return e?.sensitive===!1?`config`:`secret`}function rt(e,t){let n=t.split(`@`)[0]??t;return e.ai?.agents?.[n]?`agent`:e.ai?.models?.[n]?`model`:`prompt`}function it(e,t,n){let r=`type:${n}:`;switch(n){case`flow`:return[`${r}${we(t.trigger)}`];case`store`:{let e=new Set;for(let n of[...t.effects?.reads??[],...t.effects?.writes??[]]){let t=Qe(n);t?.badge&&e.add(t.badge)}return[...e].map(e=>`${r}${e}`)}case`signal`:{let n=[...t.trigger?.signal?[t.trigger.signal]:[],...t.effects?.emits??[]],i=new Set;for(let t of n){let n=e.signals?.[t]?.delivery;n&&i.add(n)}return[...i].map(e=>`${r}${e}`)}case`clock`:{let e=[];return t.trigger?.cron&&e.push(`${r}cron`),t.trigger?.every&&e.push(`${r}every`),e}case`gate`:return[...new Set((t.gates??[]).map(t=>tt(t,e.gates?.[t])))].map(e=>`${r}${e}`);case`vault`:return[...new Set((t.effects?.secrets??[]).map(t=>nt(e.vault?.[t])))].map(e=>`${r}${e}`);case`channel`:{let n=new Set;for(let r of t.effects?.sends??[]){let t=e.channels?.[r]?.medium;t&&t!==`any`&&n.add(t)}return[...n].map(e=>`${r}${e}`)}case`ai`:return[...new Set((t.effects?.asks??[]).map(t=>rt(e,t)))].map(e=>`${r}${e}`)}}function at(e){let t=e?.flows??{},n=new Map;for(let e of Object.keys(t).sort()){let t=F(e),r=n.get(t)??[];r.push(e),n.set(t,r)}let r=new Map,i=new Map,a=new Map;for(let[e,o]of n){let n=new Set;for(let i of o){let o=t[i];if(o)for(let t of B(o)){n.add(t);let o=`${e}\0${t}`;r.set(o,(r.get(o)??0)+1);let s=a.get(t)??new Set;s.add(i),a.set(t,s)}}i.set(e,n)}let o=[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({unit:e,flowCount:t.length,elements:L.filter(t=>i.get(e)?.has(t)),live:0,errors:0})),s=L.map(t=>({element:t,resourceCount:e?Ze(e,t).length:0,flowCount:a.get(t)?.size??0,live:0,errors:0})),c=[];for(let e of o)for(let t of e.elements)c.push({unit:e.unit,element:t,flowCount:r.get(`${e.unit}\0${t}`)??0});return{units:o,hubs:s,couplings:c}}function ot(e,t){let n=new Map,r=new Map,i=new Map,a=new Map;for(let e of t){let t=e.unit??F(e.flow);n.set(t,(n.get(t)??0)+1),e.error&&r.set(t,(r.get(t)??0)+1);for(let t of Xe(e))i.set(t,(i.get(t)??0)+1),e.error&&a.set(t,(a.get(t)??0)+1)}return{couplings:e.couplings,units:e.units.map(e=>({...e,live:n.get(e.unit)??0,errors:r.get(e.unit)??0})),hubs:e.hubs.map(e=>({...e,live:i.get(e.element)??0,errors:a.get(e.element)??0}))}}function st(e,t=[],n=null){if(!e||Object.keys(e.flows??{}).length===0)return{nodes:[],edges:[],units:[],hubs:[]};let r=ot(at(e),t),i=n?.element,a=r.hubs.find(e=>e.element===`flow`)?.live??0,o=r.hubs.find(e=>e.element===`flow`)?.errors??0,s=[],c=[];s.push(V(`orbit:elements`,j.elementRing)),s.push(V(`orbit:types`,j.typeRing)),s.push(V(`orbit:spokes`,j.spokeRing)),s.push({id:`law:oke`,type:`law`,position:{x:j.cx-N.law.width/2,y:j.cy-N.law.height/2},data:{kind:`law`,label:e.app,refId:`oke`,badge:String(r.units.reduce((e,t)=>e+t.flowCount,0)),live:a,errors:o},selectable:!1,draggable:!1,zIndex:M.leaf,width:N.law.width,height:N.law.height,style:{width:N.law.width,height:N.law.height,overflow:`visible`}});let l=Ge(L.length);if(r.hubs.forEach((e,t)=>{let n=l[t]??0,r=N.hub;s.push({id:`element:${e.element}`,type:`element`,position:R(n,j.elementRing,r),data:{kind:`element`,label:A[e.element].symbol,refId:e.element,badge:String(e.resourceCount),live:e.live,errors:e.errors,dimmed:i!=null&&e.element!==i},draggable:!1,zIndex:M.leaf,width:r.width,height:r.height,style:{width:r.width,height:r.height}}),c.push(U(`element:${e.element}`,`law:oke`,e.element,1,!0))}),!i||i===`flow`){let t=N.type;r.hubs.forEach((n,r)=>{let i=l[r]??0,a=et(e,n.element),o=qe(i,a.length);a.forEach((e,r)=>{let a=o[r]??{angle:i,radius:j.typeRing};s.push({id:e.id,type:`typeChip`,position:R(a.angle,a.radius,t),data:{kind:n.element,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:M.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}}),c.push(U(e.id,`element:${n.element}`,n.element,1))})})}if(i&&i!==`flow`){let t=Ze(e,i),n=be.store,r=Ge(t.length);t.forEach((e,t)=>{let a=r[t]??0;s.push({id:e.id,type:i,position:R(a,j.spokeRing,n),data:{kind:i,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:M.leaf,width:n.width,height:n.height,style:{width:n.width,height:n.height}}),c.push(U(e.id,`element:${i}`,i,1))})}else{let t=N.unit,n=Ge(r.units.length);r.units.forEach((e,r)=>{let i=n[r]??0;s.push({id:`unit:${e.unit}`,type:`unitChip`,position:R(i,j.spokeRing,t),data:{kind:`unit`,label:e.unit,refId:e.unit,badge:String(e.flowCount),elements:e.elements.filter(e=>e!==`flow`),live:e.live,errors:e.errors},draggable:!1,zIndex:M.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}})});let a=new Map;for(let t of Object.keys(e.flows??{}).sort()){let e=F(t),n=a.get(e)??[];n.push(t),a.set(e,n)}for(let t of r.units){let n=new Map,r=new Set;for(let o of a.get(t.unit)??[]){let t=e.flows?.[o];if(t)for(let a of B(t)){if(i===`flow`&&a!==`flow`)continue;let o=it(e,t,a);o.length===0&&r.add(a);for(let e of o)n.set(e,(n.get(e)??0)+1)}}for(let[e,r]of n){let n=e.slice(5).split(`:`)[0];n&&n in P&&c.push(U(`unit:${t.unit}`,e,n,r))}for(let e of r)c.push(U(`unit:${t.unit}`,`element:${e}`,e,1))}}return{nodes:s,edges:c,units:r.units,hubs:r.hubs}}function V(e,t){let n=t*2;return{id:e,type:`orbit`,position:{x:j.cx-t,y:j.cy-t},data:{kind:`law`,label:``,refId:e},selectable:!1,draggable:!1,zIndex:M.edge,width:n,height:n,style:{width:n,height:n}}}function ct(e,t){return t===`law:oke`?`trunk`:e.startsWith(`type:`)&&t.startsWith(`element:`)?`bind`:`spoke`}function H(e){return e===`trunk`?.14:e===`bind`?.2:0}function U(e,t,n,r,i=!1){let a=i?`trunk`:ct(e,t),o=a===`trunk`?1.15:1+Math.min(1.25,Math.log2(1+r)*.45);return{id:`couple:${e}->${t}`,source:e,target:t,sourceHandle:`center`,targetHandle:`center`,type:`straight`,data:{kind:`couple`},style:{stroke:Ce.couple,strokeWidth:o,opacity:H(a)},zIndex:M.edge}}function lt(e){if(e.startsWith(`element:`)){let t=e.slice(8);return t in P?t:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&t in P?t:null}return null}function ut(e,t){for(let n of[t,e]){let e=lt(n);if(e)return P[e].accent}return Ce.couple}function dt(e,t){let n=new Set,r=new Set,i=(e,t)=>{r.add(`couple:${e}->${t}`)};if(!e)return{nodeIds:n,edgeIds:r};for(let r of t){let t=e.flows?.[r];if(!t)continue;let a=`unit:${F(r)}`;n.add(a);for(let r of B(t)){let o=`element:${r}`;n.add(o),n.add(`law:oke`),i(o,`law:oke`);let s=it(e,t,r);s.length===0&&i(a,o);for(let e of s)n.add(e),i(a,e),i(e,o)}}return{nodeIds:n,edgeIds:r}}function ft(e,t,n={}){let r=n.hoverNodeId??null,i=n.highlightedFlowIds??new Set,a=n.highlightedNodeIds??new Set,o=dt(n.manifest,i),s=o.nodeIds.size>0||a.size>0,c=r!=null,l=r==null?null:pt(r,t);return{nodes:e.map(e=>{if(e.type===`orbit`)return{...e,data:{...e.data,highlighted:!1,dimmed:!1}};let t=o.nodeIds.has(e.id)||a.has(e.id)||i.has(e.data.refId),n=l?.has(e.id)===!0;return{...e,data:{...e.data,highlighted:t||c&&e.id===r,dimmed:e.id===`law:oke`?!1:s&&!t||c&&!n}}}),edges:t.map(e=>{let t=l!=null&&l.has(e.source)&&l.has(e.target),n=s&&o.edgeIds.has(e.id),r=c?t:n,i=ct(e.source,e.target),a=c||s?r?1:H(i)*.35:H(i);return{...e,animated:r,style:{...e.style,stroke:r?ut(e.source,e.target):Ce.couple,opacity:a,strokeWidth:r?2.25:e.style?.strokeWidth}}})}}function W(e,t){let n=[];for(let r of e)r.source===t?n.push(r.target):r.target===t&&n.push(r.source);return n}function pt(e,t){let n=new Set([e]),r=e=>n.add(e);if(e.startsWith(`unit:`)){for(let n of W(t,e)){if(r(n),n.startsWith(`type:`)){for(let e of W(t,n))if(e.startsWith(`element:`)){r(e);for(let n of W(t,e))n===`law:oke`&&r(n)}}if(n.startsWith(`element:`))for(let e of W(t,n))e===`law:oke`&&r(e)}return n}if(e.startsWith(`type:`)){for(let n of W(t,e))r(n);let i=[...n].find(e=>e.startsWith(`element:`));if(i)for(let e of W(t,i))e===`law:oke`&&r(e);return n}if(e.startsWith(`element:`)||e===`law:oke`)for(let n of W(t,e))r(n);return n}var G=n(),mt={flow:A.flow.icon,signal:A.signal.icon,store:A.store.icon,clock:A.clock.icon,gate:A.gate.icon,vault:A.vault.icon,channel:A.channel.icon,ai:A.ai.icon},ht={flow:`rounded-xl`,store:`rounded-md`,signal:`rounded-full`,clock:`rounded-lg`,gate:`rounded-md`,vault:`rounded-md`,channel:`rounded-xl`,ai:`rounded-2xl`};function K(e,t){return m(`group relative flex h-full w-full items-center gap-2.5 border-2 px-2.5 text-xs transition-[opacity,filter,box-shadow,border-color] duration-200`,ht[t],e.dimmed&&`opacity-30 saturate-[0.35]`,e.highlighted&&`z-10`,e.focused&&`z-10`)}function q(e,t){let n=P[e],r=`color-mix(in oklab, ${n.accent} 20%, var(--card))`;return t.highlighted||t.focused?{borderColor:n.accent,background:`color-mix(in oklab, ${n.accent} 26%, var(--card))`,boxShadow:`0 0 0 1px ${n.accent}, 0 0 22px ${n.glow}`}:{borderColor:`color-mix(in oklab, ${n.accent} 78%, var(--border))`,background:r,boxShadow:`inset 3px 0 0 ${n.accent}`}}function J({data:e,kind:t,className:n,style:r,children:i,...a}){let o=Pe(),s=P[t];return(0,G.jsx)(Ne.div,{className:n,style:r,initial:!1,whileHover:o?void 0:{scale:1.04},whileTap:o?void 0:{scale:.97},animate:{scale:o?1:e.active?[1,1.08,1]:e.highlighted?1.02:1,boxShadow:e.active?`0 0 0 2px ${s.accent}, 0 0 30px ${s.glow}`:void 0},transition:e.active?{duration:.5,ease:`easeInOut`}:{type:`spring`,stiffness:400,damping:28},...a,children:i})}function gt({kind:e,size:t=`sm`}){let n=P[e];return(0,G.jsx)(`span`,{className:m(`flex shrink-0 items-center justify-center border`,t===`md`?`size-9`:`size-7`,e===`signal`?`rounded-full`:e===`store`||e===`gate`||e===`vault`?`rounded-md`:`rounded-full`),style:{color:n.accent,background:n.well,borderColor:`color-mix(in oklab, ${n.accent} 55%, transparent)`},"aria-hidden":!0,children:(0,G.jsx)(f,{icon:mt[e],size:t===`md`?17:15,strokeWidth:1.9})})}function _t({text:e}){return(0,G.jsx)(`span`,{className:`rounded border border-border/70 bg-background/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e})}function vt({type:e,kind:t}){let n=P[t];return(0,G.jsx)(r,{type:e,position:e===`source`?s.Right:s.Left,className:`!size-2 !border-0`,style:{background:n.accent}})}function Y({type:e}){return(0,G.jsx)(r,{id:`center`,type:e,position:e===`source`?s.Right:s.Left,isConnectable:!1,className:`oke-center-handle !top-1/2 !left-1/2 !size-px !-translate-x-1/2 !-translate-y-1/2 !border-0 !bg-transparent !opacity-0`})}function yt({live:e,errors:t}){return e<=0?null:(0,G.jsx)(`span`,{className:m(`size-2 shrink-0 rounded-full`,t>0?`bg-rose-400`:`bg-emerald-400`,e>0&&`animate-pulse`),title:t>0?`${e} live · ${t} failed`:`${e} live`})}function bt({elements:e}){return e.length===0?null:(0,G.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1`,"aria-hidden":!0,children:e.map(e=>(0,G.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:P[e].accent},title:A[e].label},e))})}function xt({data:e}){return(0,G.jsx)(`div`,{className:`h-full w-full rounded-xl border border-dashed border-foreground/25 bg-muted/35 px-3 pt-1.5`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.label}),e.badge?(0,G.jsx)(_t,{text:e.badge}):null]})})}function St({data:e}){let t=e.kind in P?e.kind:`flow`;return(0,G.jsxs)(J,{data:e,kind:t,className:m(K(e,t),`justify-center gap-0 rounded-full px-2`),style:q(t,e),"data-slot":`type-chip`,"data-type":e.refId,children:[(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(Y,{type:`target`}),(0,G.jsx)(`div`,{className:`min-w-0 truncate text-center text-[10px] leading-none font-medium tracking-wide text-foreground`,children:e.label})]})}function Ct({data:e}){return(0,G.jsxs)(J,{data:e,kind:`flow`,className:m(K(e,`flow`),`rounded-full px-2.5`),style:q(`flow`,e),"data-slot":`unit-chip`,"data-unit":e.refId,children:[(0,G.jsx)(Y,{type:`source`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium tracking-wide text-foreground uppercase`,children:e.label}),(0,G.jsx)(yt,{live:e.live??0,errors:e.errors??0})]}),(0,G.jsx)(bt,{elements:e.elements??[]})]}),e.badge?(0,G.jsx)(_t,{text:e.badge}):null]})}function wt({data:e}){let t=Ot(e.refId)??`flow`,n=P[t];return(0,G.jsxs)(J,{data:e,kind:t,className:m(K(e,t),`flex-col justify-center gap-0.5 rounded-full px-1.5 text-center`),style:{...q(t,e),boxShadow:e.highlighted?`0 0 0 1px ${n.accent}, 0 0 22px ${n.glow}`:`0 0 0 1px color-mix(in oklab, ${n.accent} 55%, transparent)`},"data-slot":`element-hub`,"data-element":t,children:[(0,G.jsx)(Y,{type:`target`}),(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(`span`,{className:`text-[18px] font-semibold tracking-tight text-foreground`,title:A[t].label,children:e.label})]})}function Tt(e){return e>=40?1.05:e>=12?1.55:2.2}function Et({data:e}){let t=Pe(),n=e.live??0,r=e.errors??0,[i,a]=(0,I.useState)(0),o=(0,I.useRef)(n);(0,I.useEffect)(()=>{n>o.current&&a(e=>e+1),o.current=n},[n]);let s=n>0,c=Tt(n),l=r>0?`var(--color-rose-400)`:`var(--foreground)`;return(0,G.jsxs)(`div`,{className:m(`relative flex h-full w-full items-center justify-center overflow-visible`,e.highlighted&&`z-10`),"data-slot":`law-hub`,"data-live":n,children:[(0,G.jsx)(Y,{type:`target`}),!t&&s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,color:l}}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,animationDelay:`${c/2}s`,color:l}})]}):null,i>0&&!t?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-hit`,style:{color:l}},i):null,(0,G.jsx)(Ne.div,{className:`flex h-full w-full items-center justify-center rounded-full border-4 bg-card px-4 text-center`,style:{borderColor:`color-mix(in oklab, var(--foreground) 82%, var(--border))`,boxShadow:e.highlighted?`0 0 0 1px ${l}, 0 0 36px color-mix(in oklab, ${l} 28%, transparent)`:`inset 0 0 28px color-mix(in oklab, var(--foreground) 7%, transparent), 0 0 22px color-mix(in oklab, ${l} ${s?16:6}%, transparent)`},animate:t||!s?{scale:1}:{scale:[1,1.045,1]},transition:t||!s?{duration:0}:{duration:c,repeat:1/0,ease:`easeInOut`},children:(0,G.jsx)(Me,{className:`h-7 w-auto text-foreground`})})]})}function Dt(){return(0,G.jsx)(`div`,{className:`pointer-events-none h-full w-full rounded-full border border-dashed border-foreground/15`,"data-slot":`orbit`})}function Ot(e){return e in P?e:null}function X({data:e,kind:t,slot:n}){return(0,G.jsxs)(J,{data:e,kind:t,className:K(e,t),style:q(t,e),"data-slot":n,"data-flow-id":t===`flow`?e.refId:void 0,"data-highlighted":e.highlighted?`true`:`false`,children:[(0,G.jsx)(vt,{type:`target`,kind:t}),(0,G.jsx)(Y,{type:`source`}),(0,G.jsx)(gt,{kind:t}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:e.label}),(0,G.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:(0,G.jsx)(_t,{text:e.badge??e.plane??e.facet??t})})]}),t===`flow`||t===`signal`?(0,G.jsx)(vt,{type:`source`,kind:t}):null]})}function kt({data:e}){return(0,G.jsx)(X,{data:e,kind:`flow`,slot:`flow-node`})}function At({data:e}){return(0,G.jsx)(X,{data:e,kind:`store`,slot:`store-node`})}function jt({data:e}){return(0,G.jsx)(X,{data:e,kind:`signal`,slot:`signal-node`})}function Mt({data:e}){return(0,G.jsx)(X,{data:e,kind:`ai`,slot:`ai-node`})}function Nt({data:e}){return(0,G.jsx)(X,{data:e,kind:`clock`,slot:`clock-node`})}function Pt({data:e}){return(0,G.jsx)(X,{data:e,kind:`gate`,slot:`gate-node`})}function Ft({data:e}){return(0,G.jsx)(X,{data:e,kind:`vault`,slot:`vault-node`})}function It({data:e}){return(0,G.jsx)(X,{data:e,kind:`channel`,slot:`channel-node`})}var Lt={unit:xt,unitChip:Ct,typeChip:St,element:wt,law:Et,orbit:Dt,flow:kt,store:At,signal:jt,ai:Mt,clock:Nt,gate:Pt,vault:Ft,channel:It};function Rt(e,t){let n=e.flows??{},r=new Set;if(t.kind===`unit`){for(let e of Object.keys(n))F(e)===t.unit&&r.add(e);let e=[];for(let t of r)for(let r of n[t]?.effects?.calls??[])ve(r)||e.push(r);for(let t of e)r.add(t)}else if(t.kind===`flow`){r.add(t.flowId);let e=n[t.flowId];for(let t of e?.effects?.calls??[])ve(t)||r.add(t);for(let[e,i]of Object.entries(n))i.effects?.calls?.includes(t.flowId)&&r.add(e)}else for(let[e,i]of Object.entries(n))zt(i,e,t.nodeId)&&r.add(e);let i={};for(let e of r){let t=n[e];t&&(i[e]=t)}return{...e,flows:i}}function zt(e,t,n){if(n===`flow:${t}`||n===`clock:${t}`&&(e.trigger?.cron||e.trigger?.every)||e.trigger?.signal&&n===`signal:${e.trigger.signal}`||e.gates?.some(e=>n===`gate:${e}`))return!0;let r=e.effects;return r?!!(r.reads?.some(e=>e===n)||r.writes?.some(e=>e===n)||r.emits?.some(e=>n===`signal:${e}`)||r.sends?.some(e=>n===`channel:${e}`)||r.asks?.some(e=>n===`ai:${e}`)||r.secrets?.some(e=>n===`vault:${e}`)||r.calls?.some(e=>{let t=ve(e);return t?n===ye(t.server):n===`flow:${e}`})):!1}var Bt=[`!=`,`>=`,`<=`,`=`,`>`,`<`],Vt={clauses:[]},Ht=[`flow`,`unit`,`trigger`,`plane`,`tenant`,`principal`,`cache`,`replica`,`error`,`buildVersion`,`promptVersion`,`duration`];function Ut(e){if(!e||!e.trim())return Vt;let t=e.split(/\s+AND\s+/i).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t){let t=en(e);t&&n.push(t)}return{clauses:n}}function Z(e,t){return{clauses:[...e.clauses.filter(e=>e.dimension!==t.dimension),t]}}function Wt(e,t){return{clauses:e.clauses.filter(e=>e.dimension!==t)}}function Gt(e,t){return e.dimension===t.dimension&&e.op===t.op&&e.value===t.value}function Kt(e,t){return e.clauses.some(e=>Gt(e,t))}function qt(e,t){return Kt(e,t)?Wt(e,t.dimension):Z(e,t)}function Jt(e){let t=rn(e.dimension,e.value);return`${e.dimension} ${e.op} ${t}`}function Yt(e,t){for(let n of t.clauses)if(!an(e,n))return!1;return!0}function Xt(e,t){return t.clauses.length===0?[...e]:e.filter(e=>Yt(e,t))}function Zt(e){let t=/^(-?\d+(?:\.\d+)?)\s*(ms|s|m)?$/i.exec(e.trim());if(!t)return;let n=Number(t[1]),r=(t[2]??`ms`).toLowerCase();if(r===`ms`)return n;if(r===`s`)return n*1e3;if(r===`m`)return n*6e4}function Qt(e,t){switch(t){case`flow`:return e.flow;case`unit`:return e.unit??null;case`trigger`:return e.trigger;case`plane`:return e.plane;case`tenant`:return e.tenant??null;case`principal`:return e.principal??null;case`cache`:return e.cache;case`replica`:return e.replica??null;case`replicaLagMs`:case`replica_lag_ms`:return e.replicaLagMs??null;case`error`:case`error_code`:return e.error??null;case`buildVersion`:case`build_version`:return e.buildVersion??null;case`promptVersion`:case`prompt_version`:return e.promptVersion??null;case`cost`:return e.cost??null;case`duration`:case`duration_ms`:return e.durationMs;case`gates`:return e.gates.join(`,`);default:return e.dimensions[t]}}function $t(e){let t=new Set(Ht);for(let n of e)for(let e of Object.keys(n.dimensions))t.add(e);return[...t].sort()}function en(e){let t=null,n=-1;for(let r of Bt){let i=e.indexOf(` ${r} `);if(i!==-1){t=r,n=i;break}}if(t===null||n<0)return null;let r=e.slice(0,n).trim(),i=e.slice(n+t.length+2).trim();if(!r||!i)return null;let a=tn(r,i);return a===void 0?null:{dimension:r,op:t,value:a}}function tn(e,t){return e===`duration`||e===`duration_ms`?Zt(t):t===`true`?!0:t===`false`?!1:t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):/^-?\d+(\.\d+)?$/.test(t)?Number(t):t}function nn(e,t){return rn(e,t)}function rn(e,t){if(e===`duration`||e===`duration_ms`){let e=typeof t==`number`?t:Number(t);return Number.isFinite(e)?e>=6e4&&e%6e4==0?`${e/6e4}m`:e>=1e3&&e%1e3==0?`${e/1e3}s`:`${e}ms`:String(t)}return typeof t==`string`&&/\s/.test(t)?`"${t}"`:String(t)}function an(e,t){let n=Qt(e,t.dimension);if(n==null)return t.op===`!=`;let r=t.value;if(t.op===`=`)return on(n,r);if(t.op===`!=`)return!on(n,r);let i=Q(n),a=Q(r);return i===void 0||a===void 0?!1:t.op===`>`?i>a:t.op===`<`?i<a:t.op===`>=`?i>=a:t.op===`<=`&&i<=a}function on(e,t){if(typeof e==`number`||typeof t==`number`){let n=Q(e),r=Q(t);if(n!==void 0&&r!==void 0)return n===r}return String(e)===String(t)}function Q(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`boolean`)return;let t=Number(e);return Number.isFinite(t)?t:void 0}var sn=new Set(Object.keys(A));function cn(e){if(e.startsWith(`flow:`))return{kind:`flow`,flowId:e.slice(5)};if(e.startsWith(`signal:`))return{kind:`signal`,signal:e.slice(7)};if(e.startsWith(`unit:`))return{kind:`unit`,unit:e.slice(5)};if(e.startsWith(`element:`)){let t=e.slice(8);return sn.has(t)?{kind:`element`,element:t}:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&sn.has(t)?{kind:`element`,element:t}:null}return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)||e.startsWith(`vault:`)||e.startsWith(`channel:`)||e.startsWith(`gate:`)||e.startsWith(`clock:`)||e.startsWith(`ai:`)?{kind:`resource`,nodeId:e}:null}function ln(e){switch(e.kind){case`flow`:return e.flowId;case`signal`:return`signal:${e.signal}`;case`unit`:return e.unit;case`element`:return A[e.element].label;case`resource`:return e.nodeId}}function un(e,t){return t?.kind===`flow`?Z(e,{dimension:`flow`,op:`=`,value:t.flowId}):t?.kind===`unit`?Z(e,{dimension:`unit`,op:`=`,value:t.unit}):e}function dn(e,t,n){if(t.kind===`flow`)return Yt(e,{clauses:[{dimension:`flow`,op:`=`,value:t.flowId}]});if(t.kind===`unit`)return(e.unit??F(e.flow))===t.unit;if(t.kind===`element`)return t.element===`flow`||Xe(e).includes(t.element);if(t.kind===`resource`)return fn(e,t.nodeId,n);let r=n?.flows??{};for(let[n,i]of Object.entries(r))if(n===e.flow&&(i.trigger?.signal===t.signal||i.effects?.emits?.includes(t.signal)))return!0;return!1}function fn(e,t,n){let r=t.includes(`:`)?t.slice(t.indexOf(`:`)+1):t;if(e.effects.some(e=>e.resource===t||e.resource===r)||e.gates.some(e=>t===`gate:${e}`))return!0;let i=n?.flows?.[e.flow];return!!(i&&zt(i,e.flow,t))}function pn(e,t,n){return t?e.filter(e=>dn(e,t,n)):[...e]}function mn(e){return e?e.kind===`unit`||e.kind===`flow`||e.kind===`resource`?e:e.kind===`signal`?{kind:`resource`,nodeId:`signal:${e.signal}`}:null:null}function hn({manifest:e,runs:t=[],graphFilter:n,highlightedFlowIds:r,highlightedNodeIds:s,follow:l,activeNodeId:d=null,focusedNodeId:f=null,orchestraLabel:p=null,onNodeClick:m,onPaneClick:h}){let{fitView:g}=a(),{theme:_}=Fe(),[v,y]=(0,I.useState)(null),b=_===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:_,x=mn(n),S=n?.kind===`element`?n.element:null,C=x===null,w=(0,I.useMemo)(()=>st(e,t,S?{kind:`element`,element:S}:null),[e,t,S]),T=(0,I.useMemo)(()=>Be(!x||!e?e:Rt(e,x)),[e,x]),E=(0,I.useMemo)(()=>ft(w.nodes,w.edges,{hoverNodeId:v,highlightedFlowIds:r,highlightedNodeIds:s,manifest:e}),[w.nodes,w.edges,v,r,s,e]),D=(0,I.useMemo)(()=>Re(T.nodes,r,s,{activeNodeId:d,focusedNodeId:f}),[T.nodes,r,s,d,f]),O=(0,I.useMemo)(()=>Le(T.edges,D),[T.edges,D]),k=C?E.nodes:D,ee=C?E.edges:O;return(0,I.useEffect)(()=>{g({duration:280,padding:.18})},[C,n,e,g]),(0,I.useEffect)(()=>{if(!l||C||r.size===0)return;let e=[...r].map(e=>`flow:${e}`);g({nodes:e.map(e=>({id:e})),duration:300,padding:.2})},[l,C,r,g]),(0,G.jsxs)(`div`,{className:`relative h-full w-full`,children:[n?(0,G.jsxs)(`button`,{type:`button`,"data-slot":`flow-graph-map`,onClick:()=>h?.(),className:`absolute top-2 left-2 z-10 inline-flex max-w-[min(100%-1rem,20rem)] items-center gap-1.5 truncate rounded-md border border-border/70 bg-card/90 px-2 py-1 text-[10px] font-medium text-muted-foreground shadow-sm backdrop-blur-sm transition-colors hover:border-border hover:text-foreground`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:`Map`}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,G.jsx)(`span`,{className:`truncate`,children:ln(n)})]}):(0,G.jsx)(`div`,{className:`pointer-events-none absolute top-2 left-2 z-10 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:p?(0,G.jsxs)(G.Fragment,{children:[`Orchestra `,(0,G.jsx)(`span`,{className:`text-foreground normal-case`,children:p})]}):`Hover a unit — spokes light the elements it touches`}),(0,G.jsxs)(i,{nodes:k,edges:ee,nodeTypes:Lt,colorMode:b,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},minZoom:.15,maxZoom:1.6,defaultEdgeOptions:{type:`smoothstep`,zIndex:M.edge},zIndexMode:`manual`,onNodeClick:(e,t)=>m?.(t.id),onPaneClick:()=>h?.(),onNodeMouseEnter:(e,t)=>y(t.id),onNodeMouseLeave:()=>y(null),children:[(0,G.jsx)(u,{gap:24,size:1,color:`color-mix(in oklab, var(--foreground) 14%, transparent)`}),(0,G.jsx)(c,{showInteractive:!1}),(0,G.jsx)(o,{pannable:!0,zoomable:!0,ariaLabel:`Flow graph overview`,bgColor:`var(--card)`,maskColor:`color-mix(in oklab, var(--background) 55%, transparent)`,nodeColor:gn,nodeStrokeColor:_n,nodeStrokeWidth:12,nodeBorderRadius:10})]})]})}function gn(e){if(e.type===`orbit`)return`transparent`;let t=e.data.kind;if(t===`law`)return`color-mix(in oklab, var(--foreground) 45%, transparent)`;if(t===`unit`)return`color-mix(in oklab, var(--foreground) 8%, transparent)`;if(t===`element`){let t=e.data.refId;return P[t]?.accent??`#64748B`}return t in P?P[t].accent:`#64748B`}function _n(e){return e.data.kind===`unit`?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`transparent`}function vn(e){let{leading:t,...n}=e;return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,"data-slot":`flow-graph`,children:[t?(0,G.jsxs)(`header`,{className:w,children:[t,(0,G.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})]}):null,(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(l,{children:(0,G.jsx)(hn,{...n})})})]})}var yn=`orch-`;function bn(e){return e.startsWith(yn)}function xn(e,t){return e&&t}function Sn(e,t=Math.random){let n=e.filter(e=>!bn(e.id)&&e.flow.length>0);return n.length===0?null:n[Math.floor(t()*n.length)]??null}function Cn(e,t,n){let r=t-e.startedAt,i=e.flow.replaceAll(`.`,`-`);return{...e,id:`${yn}${n}-${i}`,parentId:null,startedAt:t,endedAt:t+e.durationMs,effects:e.effects.map(e=>({...e,timestamp:e.timestamp+r})),logs:e.logs.map(e=>({...e,at:e.at+r}))}}function wn(e=Math.random){return 1800+Math.floor(e()*1600)}var Tn=1400;function En(e){let t=S(),[n,r]=(0,I.useState)(null),i=(0,I.useRef)(0),a=(0,I.useRef)(null),o=(0,I.useRef)(null),s=(0,I.useRef)(e.paused);return s.current=e.paused,(0,I.useEffect)(()=>{if(!xn(!1,e.enabled))return;let n=()=>{a.current&&=(clearTimeout(a.current),null)},c=()=>{if(s.current||document.hidden)return;let e=Sn(t.getQueryData(ge)??[]);if(!e)return;i.current+=1;let o=Cn(e,Date.now(),i.current);t.setQueryData(ge,e=>he(e??[],o)),r({flowId:o.flow,runId:o.id}),n(),a.current=setTimeout(()=>{r(null),a.current=null},Tn)},l=e=>{o.current=setTimeout(()=>{c(),l(wn())},e)};l(700);let u=()=>{document.hidden&&(r(null),n())};return document.addEventListener(`visibilitychange`,u),()=>{document.removeEventListener(`visibilitychange`,u),o.current&&clearTimeout(o.current),n(),r(null)}},[e.enabled,t]),e.paused?null:n}function Dn(e,t){let n=new Set;if(!t)return n;let r=new Map,i=new Map;for(let t of e)r.set(t.id,t);for(let t of e){if(!t.parentId)continue;let e=i.get(t.parentId)??[];e.push(t),i.set(t.parentId,e)}let a=r.get(t);if(!a)return n;let o=a,s=new Set;for(;o&&!s.has(o.id);)s.add(o.id),n.add(o.flow),o=o.parentId?r.get(o.parentId):void 0;let c=[a];for(;c.length>0;){let e=c.shift();if(!e)break;for(let t of i.get(e.id)??[])s.has(t.id)||(s.add(t.id),n.add(t.flow),c.push(t))}return n}var On=[{id:`signal`,label:`Signal`,expr:`trigger = signal`},{id:`clock`,label:`Clock`,expr:`trigger = cron`},{id:`cache-miss`,label:`Cache miss`,expr:`cache = miss`},{id:`slow`,label:`Slow`,expr:`duration > 100ms`}],kn=`h-7 min-w-0 rounded-none border-0 bg-transparent px-0 font-mono text-[11px] text-foreground shadow-none outline-none focus-visible:ring-0 dark:bg-transparent`,$=`rounded-none border-0 bg-transparent px-1.5 py-1 text-[11px] text-foreground/70 shadow-none transition-colors hover:bg-muted/50 hover:text-foreground`,An=`grid grid-cols-[minmax(0,1fr)_1.25rem_minmax(0,1fr)_1.25rem] items-center gap-x-1`;function jn({query:e,runs:t,onChange:n}){let r=(0,I.useMemo)(()=>$t(t),[t]),i=(0,I.useMemo)(()=>[...new Set([...Ht,...r])].sort(),[r]),[a,o]=(0,I.useState)(`trigger`),[s,c]=(0,I.useState)(`=`),[l,u]=(0,I.useState)(`signal`),[d,f]=(0,I.useState)(!1),h=()=>{let t=Ut(`${a} ${s} ${l}`).clauses[0];t&&(n(Z(e,t)),f(!1))};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-b border-border/60 px-2 py-1.5`,"data-slot":`traces-advanced-filters`,children:[e.clauses.length>0?(0,G.jsx)(`ul`,{"aria-label":`Active filters`,className:`flex flex-col gap-0.5`,children:e.clauses.map(t=>(0,G.jsx)(`li`,{children:(0,G.jsx)(Mn,{clause:t,onRemove:()=>n(Wt(e,t.dimension))})},t.dimension))}):null,d?(0,G.jsxs)(`div`,{className:An,"data-slot":`traces-advanced-composer`,children:[(0,G.jsx)(`select`,{"aria-label":`Filter dimension`,className:kn,value:a,onChange:e=>o(e.target.value),children:i.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`select`,{"aria-label":`Filter operator`,className:m(kn,`text-center text-foreground/70`),value:s,onChange:e=>c(e.target.value),children:[`=`,`!=`,`>`,`<`,`>=`,`<=`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(p,{"aria-label":`Filter value`,flat:!0,className:`h-7 px-0 font-mono text-[11px]`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()}}),(0,G.jsx)(`button`,{type:`button`,className:$,onClick:h,children:`Add`})]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[On.map(t=>{let r=Ut(t.expr).clauses[0],i=r!==void 0&&Kt(e,r);return(0,G.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:r===void 0,onClick:()=>{r&&n(qt(e,r))},className:m($,i?`font-medium text-foreground`:`text-foreground/70`),children:t.label},t.id)}),(0,G.jsx)(`button`,{type:`button`,"aria-expanded":d,className:m($,`ml-auto`,d&&`text-foreground`),onClick:()=>f(e=>!e),children:d?`Cancel`:`Add clause`}),e.clauses.length>0?(0,G.jsx)(`button`,{type:`button`,className:$,onClick:()=>n(Ut(``)),children:`Clear`}):null]})]})}function Mn({clause:e,onRemove:t}){let n=Jt(e);return(0,G.jsxs)(`div`,{className:An,"data-slot":`traces-advanced-clause`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground/80`,children:e.dimension}),(0,G.jsx)(`span`,{className:`text-center font-mono text-[11px] text-foreground/65`,"aria-hidden":!0,children:e.op}),(0,G.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground`,children:nn(e.dimension,e.value)}),(0,G.jsx)(`button`,{type:`button`,className:m($,`flex size-5 items-center justify-center text-foreground/55 hover:text-destructive`),"aria-label":`Remove ${n}`,onClick:t,children:(0,G.jsx)(f,{icon:C,className:`size-3`})})]})}var Nn={query:``,status:`all`,advanced:Vt};function Pn(e,t){let n=t.trim().toLowerCase();return!n||[e.flow,e.unit??``,e.trigger,e.cache,e.id,e.error??``,e.errorMessage??``].some(e=>e.toLowerCase().includes(n))}function Fn(e,t){return Xt(e.filter(e=>!(!Pn(e,t.query)||t.status===`errors`&&e.error===null)),t.advanced)}function In(e,t=Date.now()){let n=t-e;return n<1e3?`just now`:n<6e4?`${Math.floor(n/1e3)}s ago`:n<36e5?`${Math.floor(n/6e4)}m ago`:`${Math.floor(n/36e5)}h ago`}function Ln(e,t=Date.now()){let n=In(e.startedAt,t),r=e.error!==null;return{text:n,title:r?e.errorMessage?`${e.error} — ${e.errorMessage}`:e.error??n:n,failed:r}}function Rn({run:e,selected:t,onSelect:n,copyText:r=async e=>{await navigator.clipboard.writeText(e)}}){let i=Ln(e),a=i.failed,o=Oe(e.trigger),s=e.cache,[c,l]=(0,I.useState)(null),u=async t=>{t.stopPropagation();try{await r(Ae(e)),l(`Copied run id`)}catch{l(`Copy failed`)}};return(0,G.jsxs)(`div`,{"data-slot":`trace-row`,"data-run-id":e.id,"data-selected":t?`true`:`false`,"data-failed":a?`true`:`false`,"data-cache":e.cache,className:m(`group relative flex w-full items-stretch border-b border-border/60 text-xs transition-colors`,`hover:bg-muted/50 focus-within:bg-muted/50`,t&&`bg-muted/70`,a&&`bg-destructive/[0.04]`),children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:m(`absolute inset-y-0 left-0 w-0.5`,t&&!a&&`bg-sky-500`,a&&`bg-destructive`)}),(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>n(e.id),className:`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-1 pl-0 text-left outline-none`,children:[(0,G.jsx)(`span`,{className:m(`ml-2.5 size-1.5 shrink-0 rounded-full`,a?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:o.label,"aria-hidden":!0,children:(0,G.jsx)(f,{icon:o.icon,className:`size-3.5`})}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.flow}),(0,G.jsx)(He,{cache:s,dataSlot:`trace-row-cache`}),(0,G.jsx)(`span`,{className:m(`w-10 shrink-0 text-right tabular-nums font-medium`,de(e.durationMs)),children:me(e.durationMs)}),(0,G.jsx)(`span`,{className:`w-14 shrink-0 truncate text-right tabular-nums text-muted-foreground`,title:i.title,"data-slot":`trace-row-meta`,children:i.text})]}),(0,G.jsx)(`div`,{className:m(`flex shrink-0 items-center gap-0.5 pr-1.5 opacity-0 transition-opacity`,`group-hover:opacity-100 group-focus-within:opacity-100`,c&&`opacity-100`),children:(0,G.jsxs)(h,{children:[(0,G.jsx)(_,{render:e=>(0,G.jsx)(T,{...e,type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Copy run ID`,"data-slot":`trace-copy-id`,onClick:t=>{e.onClick?.(t),u(t)},children:(0,G.jsx)(f,{icon:k,className:`size-3`})})}),(0,G.jsx)(g,{side:`top`,children:`Copy run ID`})]})}),c?(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:c}):null]})}var zn=[{value:`all`,label:`All`,icon:We},{value:`errors`,label:`Errors`,icon:ue}];function Bn({runs:e,selectedRunId:t,onSelect:n,liveStatus:r,manifest:i,graphFilter:a,onGraphFilterChange:o,focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u,selectedRun:p}){let[v,x]=(0,I.useState)(Nn),[S,C]=(0,I.useState)(!1);(0,I.useEffect)(()=>{(a?.kind===`flow`||a?.kind===`unit`)&&x(e=>({...e,advanced:un(e.advanced,a)}))},[a]);let T=(0,I.useMemo)(()=>pn(Fn(e,v),a,i),[e,v,a,i]),O=(0,I.useMemo)(()=>p===void 0?t?e.find(e=>e.id===t)??null:null:p,[p,e,t]),k=v.advanced.clauses.length>0,re=e=>{x(t=>({...t,query:e}))},ae=e=>{x(t=>({...t,status:e}))};return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`traces-pane`,children:[(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,G.jsxs)(`div`,{className:m(d,`border-b-0`),children:[(0,G.jsx)(ee,{value:v.query,onChange:e=>re(e.target.value),placeholder:`Search traces…`,"aria-label":`Search traces`,"data-slot":`traces-search`}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[e.length>0?(0,G.jsxs)(h,{children:[(0,G.jsx)(_,{render:e=>(0,G.jsxs)(`button`,{...e,type:`button`,"aria-expanded":S,"aria-controls":`traces-advanced-panel`,"aria-label":k?`Advanced filters, ${v.advanced.clauses.length} active`:`Advanced filters`,"data-slot":`traces-advanced-toggle`,onClick:t=>{e.onClick?.(t),C(e=>!e)},className:m(b,`relative`,(S||k)&&`text-foreground`),children:[(0,G.jsx)(f,{icon:Te,className:`size-3`,"aria-hidden":!0}),k?(0,G.jsx)(`span`,{className:`absolute -top-0.5 -inset-e-0.5 flex size-3.5 items-center justify-center rounded-full bg-foreground text-[8px] font-medium text-background`,"aria-hidden":!0,children:v.advanced.clauses.length}):null]})}),(0,G.jsx)(g,{side:`bottom`,children:`Advanced`})]}):null,e.length>0?(0,G.jsx)(`span`,{className:`mx-0.5 h-3 w-px bg-border/60`,"aria-hidden":!0}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-0.5 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:r===`open`?`size-1.5 rounded-full bg-emerald-500`:`size-1.5 rounded-full bg-muted-foreground`,"aria-hidden":!0}),r===`open`?`live`:`polling`]})]})]}),e.length>0?(0,G.jsx)(`div`,{className:m(w,`border-t border-b-0`),"data-slot":`traces-filters`,children:(0,G.jsx)(`div`,{className:`flex shrink-0 items-stretch`,role:`group`,"aria-label":`Status filter`,children:zn.map(({value:e,label:t,icon:n})=>{let r=v.status===e;return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ae(e),className:m(y,`font-semibold tracking-[0.08em] uppercase`,r?e===`errors`?`text-destructive`:D:E),children:[(0,G.jsx)(f,{icon:n,className:`size-3`,"aria-hidden":!0}),t]},e)})})}):null,e.length>0&&a?(0,G.jsxs)(`button`,{type:`button`,"data-slot":`traces-graph-filter`,onClick:()=>o(null),title:`Clear graph filter`,className:`mx-2 mb-1.5 inline-flex max-w-full items-center gap-1 self-start truncate rounded-md border border-sky-500/40 bg-sky-500/10 px-2 py-0.5 text-[10px] font-medium text-sky-700 transition-colors hover:bg-sky-500/20 dark:text-sky-400`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:ln(a)}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`×`})]}):null]}),e.length>0?(0,G.jsx)(Ue,{id:`traces-advanced-panel`,role:`region`,"aria-label":`Advanced filters`,open:S,className:`shrink-0`,children:(0,G.jsx)(jn,{query:v.advanced,runs:e,onChange:e=>{x(t=>({...t,advanced:e}))}})}):null,(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:e.length===0?(0,G.jsx)(ie,{className:`border-none`,children:(0,G.jsxs)(te,{children:[(0,G.jsx)(ne,{variant:`icon`,children:(0,G.jsx)(f,{icon:A.flow.icon})}),(0,G.jsx)(se,{children:`No traces yet`}),(0,G.jsx)(le,{children:`No runs for the flows on this graph yet. Trigger a flow to see live activity here.`})]})}):T.length===0?(0,G.jsx)(ie,{className:`border-none`,children:(0,G.jsxs)(te,{children:[(0,G.jsx)(se,{children:`No matching traces`}),(0,G.jsx)(le,{children:`Nothing in this list matches the current search, status, or advanced filters.`})]})}):T.map(e=>(0,G.jsx)(Rn,{run:e,selected:e.id===t,onSelect:e=>n(e===t?null:e)},e.id))}),(0,G.jsx)(je,{run:O,onClose:()=>n(null),focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u})]})}function Vn(){let e=pe(),t=_e(),n=fe(!0),{selectedRunId:r,selectedFlowId:i,follow:a,setSelectedRun:o,setSelectedFlow:s}=Ie(),c=ae(),l=(0,G.jsx)(oe,{open:c.open,onToggle:c.toggle,noun:`traces`,controlsId:`overview-traces`,dataSlot:`overview-traces-toggle`}),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(0),[g,_]=(0,I.useState)(null),y=(0,I.useRef)(null),b=(0,I.useMemo)(()=>new Set(Object.keys(e.data?.flows??{})),[e.data]),S=(0,I.useMemo)(()=>ze(t.data??[],b),[t.data,b]),C=En({enabled:!!e.data&&S.length>0,paused:r!=null||u!=null});(0,I.useEffect)(()=>{i&&d(e=>e?.kind===`flow`&&e.flowId===i?e:{kind:`flow`,flowId:i})},[i]);let w=(0,I.useCallback)(e=>{d(e),e?.kind===`flow`?s(e.flowId):s(null)},[s]),T=(0,I.useMemo)(()=>{let e=Dn(t.data??[],r);return e.size>0?e:i?new Set([i]):C?.flowId?new Set([C.flowId]):e},[t.data,r,i,C?.flowId]),E=(0,I.useMemo)(()=>{let t=new Set,n=e.data?.flows??{};for(let e of T){let r=n[e];if(r){r.trigger?.signal&&t.add(`signal:${r.trigger.signal}`),(r.trigger?.cron||r.trigger?.every)&&t.add(`clock:${e}`);for(let e of r.gates??[])t.add(`gate:${e}`);for(let e of r.effects?.reads??[])t.add(e);for(let e of r.effects?.writes??[])t.add(e);for(let e of r.effects?.emits??[])t.add(`signal:${e}`);for(let e of r.effects?.sends??[])t.add(`channel:${e}`);for(let e of r.effects?.asks??[])t.add(`ai:${e}`);for(let e of r.effects?.secrets??[])t.add(`vault:${e}`)}}return t},[T,e.data]),D=(0,I.useMemo)(()=>r?t.data?.find(e=>e.id===r)??null:null,[t.data,r]),k=(0,I.useCallback)(e=>{let t=cn(e);t&&w(u&&u.kind===t.kind&&JSON.stringify(u)===JSON.stringify(t)?null:t)},[w,u]),ee=(0,I.useCallback)(()=>{w(null)},[w]),te=(0,I.useCallback)(()=>{h(e=>e+1)},[]);return(0,I.useEffect)(()=>{if(m===0||!D)return;let n=ke(Dn(t.data??[],D.id),e.data??null);if(n.length===0)return;let r=Ee(D.durationMs),i=performance.now();return _(n[0]??null),y.current=setInterval(()=>{let e=Math.min(1,(performance.now()-i)/r);_(De(n,e)),e>=1&&y.current&&(clearInterval(y.current),y.current=null,setTimeout(()=>_(null),400))},60),()=>{y.current&&=(clearInterval(y.current),null),_(null)}},[m,D,t.data,e.data]),(0,G.jsx)(`div`,{className:x,"data-slot":`flows-page`,children:(0,G.jsxs)(O,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,G.jsx)(re,{panelRef:c.panelRef,collapsible:!0,collapsedSize:0,defaultSize:v.start.defaultSize,minSize:v.start.minSize,maxSize:`50%`,onResize:c.onResize,className:`min-h-0`,children:(0,G.jsx)(`div`,{id:`overview-traces`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`overview-traces`,children:(0,G.jsx)(Bn,{runs:S,selectedRunId:r,onSelect:o,liveStatus:n,manifest:e.data??null,graphFilter:u,onGraphFilterChange:w,focusEffectIndex:f,onFocusEffectChange:p,playbackKey:m,onReplayStart:te,selectedRun:D})})}),c.open?(0,G.jsx)(ce,{withHandle:!0}):null,(0,G.jsx)(re,{defaultSize:v.end.defaultSize,minSize:v.end.minSize,className:`min-h-0`,children:(0,G.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:(0,G.jsx)(vn,{manifest:e.data??null,runs:S,graphFilter:u,highlightedFlowIds:T,highlightedNodeIds:E,orchestraLabel:C?.flowId??null,follow:a,activeNodeId:g,onNodeClick:k,onPaneClick:ee,leading:l})})})]})})}export{Vn as FlowsPage};