okengine 0.23.2 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -1
- package/manifest.v1.schema.json +53 -3
- package/package.json +2 -1
- package/site/content/docs/ai/mcp.mdx +1 -1
- package/site/content/docs/ai/skills.mdx +1 -1
- package/site/content/docs/elements/ai/decide.mdx +95 -417
- package/site/content/docs/elements/ai/deciders.mdx +154 -0
- package/site/content/docs/elements/ai/index.mdx +2 -1
- package/site/content/docs/elements/ai/meta.json +1 -1
- package/site/content/docs/reference/cli.mdx +2 -2
- package/site/content/docs/reference/configuration.mdx +2 -1
- package/site/content/docs/reference/fx.mdx +11 -9
- package/src/cli/agents-md.test.ts +8 -2
- package/src/cli/decide-certify.test.ts +166 -0
- package/src/cli/decide.ts +170 -3
- package/src/cli/decision-lock-watch.test.ts +4 -4
- package/src/cli/eval.ts +38 -59
- package/src/cli/mcp-from-console.ts +1 -1
- package/src/cli/registry.ts +45 -9
- package/src/compiler/decisions.extract.test.ts +86 -31
- package/src/compiler/effects-infer.ts +1 -0
- package/src/compiler/extract.ts +239 -24
- package/src/config/index.ts +6 -0
- package/src/console/server/decisions.test.ts +6 -1
- package/src/console/server/decisions.ts +32 -1
- package/src/console/ui-next/dist/assets/{access-page-zBMhZnFm.js → access-page-DX2dKLmq.js} +1 -1
- package/src/console/ui-next/dist/assets/{agent-disclosure-CBj9f7Ju.js → agent-disclosure-CiRvA3M9.js} +1 -1
- package/src/console/ui-next/dist/assets/{cache-glyph-D3MY49h3.js → cache-glyph-CC1yFJ8A.js} +1 -1
- package/src/console/ui-next/dist/assets/{call-pii-button-L9JxdBhp.js → call-pii-button-CLXQgIDD.js} +1 -1
- package/src/console/ui-next/dist/assets/{collapsible-BvFaX-Zt.js → collapsible-C0AThBZg.js} +1 -1
- package/src/console/ui-next/dist/assets/{decisions-page-DgB76m-X.js → decisions-page-Bf3AhTAa.js} +1 -1
- package/src/console/ui-next/dist/assets/{duration-tone-l1DSJ2Vz.js → duration-tone-Bptur2gX.js} +1 -1
- package/src/console/ui-next/dist/assets/{flows-page-Bb9t1lu6.js → flows-page-DRZVeTZU.js} +1 -1
- package/src/console/ui-next/dist/assets/{highlighted-json-DMvsi3Ti.js → highlighted-json-BKf0PjBK.js} +1 -1
- package/src/console/ui-next/dist/assets/{http-method-BwhJBTcQ.js → http-method-uhrnWrGC.js} +1 -1
- package/src/console/ui-next/dist/assets/{index-RhV2jT_7.js → index-Duxus_sG.js} +3 -3
- package/src/console/ui-next/dist/assets/{observability-page-BRfUILBq.js → observability-page-B-QM8X0O.js} +1 -1
- package/src/console/ui-next/dist/assets/{replica-lag-BsceAzIG.js → replica-lag-DuqHCANi.js} +1 -1
- package/src/console/ui-next/dist/assets/{request-meta-C6lTyCXp.js → request-meta-BTBZ3Ulc.js} +1 -1
- package/src/console/ui-next/dist/assets/{store-page-YmE806bJ.js → store-page-fpo7VxYb.js} +1 -1
- package/src/console/ui-next/dist/assets/{trace-detail-sheet-Di4irS49.js → trace-detail-sheet-DKtr1-K1.js} +1 -1
- package/src/console/ui-next/dist/assets/{tree-expand-toggle-DYeL6Rye.js → tree-expand-toggle-QeTceKKI.js} +1 -1
- package/src/console/ui-next/dist/assets/{units-page-07agasRA.js → units-page-ChCp8mOy.js} +1 -1
- package/src/console/ui-next/dist/assets/{vault-page-CHBck4n_.js → vault-page-CEYLXhUX.js} +1 -1
- package/src/console/ui-next/dist/index.html +1 -1
- package/src/console/ui-next/src/client.ts +8 -0
- package/src/console/ui-next/src/features/flows/decisions/decisions-page.tsx +16 -0
- package/src/elements/ai/deciders/presets.ts +182 -0
- package/src/elements/ai/decisions/bind.ts +6 -5
- package/src/elements/ai/decisions/catalog.ts +93 -0
- package/src/elements/ai/decisions/certificate.test.ts +47 -19
- package/src/elements/ai/decisions/certificate.ts +107 -24
- package/src/elements/ai/decisions/certify.ts +104 -9
- package/src/elements/ai/decisions/codec.test.ts +142 -0
- package/src/elements/ai/decisions/codec.ts +302 -0
- package/src/elements/ai/decisions/decide.test.ts +108 -31
- package/src/elements/ai/decisions/decider-runtime.test.ts +415 -0
- package/src/elements/ai/decisions/decider.types.test.ts +62 -0
- package/src/elements/ai/decisions/e2e.test.ts +20 -16
- package/src/elements/ai/decisions/http.ts +15 -7
- package/src/elements/ai/decisions/labels.test.ts +6 -1
- package/src/elements/ai/decisions/labels.ts +4 -3
- package/src/elements/ai/decisions/openai.live.test.ts +42 -0
- package/src/elements/ai/decisions/openrouter.live.test.ts +5 -1
- package/src/elements/ai/decisions/provider.ts +22 -1
- package/src/elements/ai/declare.ts +208 -51
- package/src/elements/ai.ts +1 -0
- package/src/index.ts +1 -0
- package/src/kernel/app.ts +8 -0
- package/src/kernel/decision-budget-entry.ts +11 -0
- package/src/kernel/element-registries.ts +3 -0
- package/src/kernel/fx-decide.ts +276 -88
- package/src/manifest/types.ts +38 -2
- package/src/release/measure.ts +47 -8
- package/src/test/create-test-app.ts +21 -1
package/src/console/ui-next/dist/assets/{call-pii-button-L9JxdBhp.js → call-pii-button-CLXQgIDD.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e}from"./xyflow-yApv7D4e.js";import{$n as t,Qn as n,x as r}from"./shortcut-keys-DTE1sjTC.js";import{h as i,s as a}from"./element-icons-C6t8Vlml.js";import{ft as o,pt as s,vt as c}from"./index-
|
|
1
|
+
import{A as e}from"./xyflow-yApv7D4e.js";import{$n as t,Qn as n,x as r}from"./shortcut-keys-DTE1sjTC.js";import{h as i,s as a}from"./element-icons-C6t8Vlml.js";import{ft as o,pt as s,vt as c}from"./index-Duxus_sG.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:c,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:c}){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:c,"data-slot":`call-api-pii`,children:[(0,p.jsx)(t,{icon:e?s:o,"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,Et as i,Gn as a,Gt as o,Jt as s,Qn 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-DTE1sjTC.js";import{i as D}from"./index-
|
|
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,Et as i,Gn as a,Gt as o,Jt as s,Qn 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-DTE1sjTC.js";import{i as D}from"./index-Duxus_sG.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:i({className:c(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:c,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=s(u),F=y(m),I=!u&&!c,L=k?`idle`:p,R=u&&(D.current||O.current),B=!u&&c&&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&&c&&v.current===`css-animation`&&(O.current=!0)});a(()=>{k&&p!==`starting`&&A(!1)},[k,p]),N.useEffect(()=>()=>{G(),U()},[G,U]),a(()=>{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&&c&&(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`)()},[c,u,U,H,d,W,R,p]),E({enabled:u&&c&&L===`idle`,open:!0,ref:m,onComplete(){u&&H(Y,!1)}}),N.useEffect(()=>{if(u||!c||L!==`ending`||!m.current)return;let e=new AbortController,t=-1;function n(){P.current||(d(!1),H(Y,!1))}return t=o.request(()=>{F(n,e.signal)}),()=>{o.cancel(t),e.abort()}},[P,c,u,L,F,H,d]),a(()=>{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||c||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=o.request(n);return()=>{o.cancel(r),n()}}var ne=`--collapsible-panel-height`,re=`--collapsible-panel-width`,ie=N.forwardRef(function(e,t){let{className:n,hiddenUntilFound:i,keepMounted:o,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=o??!1,C=c||void 0,w=C??d;a(()=>(_(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};
|
package/src/console/ui-next/dist/assets/{decisions-page-DgB76m-X.js → decisions-page-Bf3AhTAa.js}
RENAMED
|
@@ -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{D as r,J as i,Mt as a,Y as o,_ as s,c,m as l,q as u,x as d}from"./explorer-chrome-Dslh2yE8.js";import{jt as f}from"./index-
|
|
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{D as r,J as i,Mt as a,Y as o,_ as s,c,m as l,q as u,x as d}from"./explorer-chrome-Dslh2yE8.js";import{jt as f}from"./index-Duxus_sG.js";var p=e(t(),1);function m(e,t){if(Object.keys(t).length!==e.length)return!1;for(let n of e){let e=t[n.id];if(n.kind===`boolean`){if(typeof e!=`boolean`)return!1;continue}if(typeof e!=`string`)return!1;if(n.kind===`choice`){if(!n.options?.includes(e))return!1;continue}if(!n.levels?.includes(e))return!1}return!0}async function h(e,t,n=5){let r={};for(let i=0;i<n;i++){if(r=await e(t),r.error?.code!==`JournalLeaseBusy`)return r;let n=v(_(r.error?.data));n>0&&await new Promise(e=>setTimeout(e,n))}return r}function g(e){return e===`candidate`?`candidate ready`:e}function _(e){if(!e||typeof e!=`object`||!(`retryAfter`in e))return;let t=e.retryAfter;return typeof t==`number`||typeof t==`string`?t:void 0}function v(e){if(typeof e==`number`&&Number.isFinite(e))return Math.max(0,e)*1e3;if(typeof e!=`string`||e.length===0)return 0;let t=Number(e);if(Number.isFinite(t))return Math.max(0,t)*1e3;let n=Date.parse(e);return Number.isNaN(n)?0:Math.max(0,n-Date.now())}var y=n();function b(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m`}function x(){let[e,t]=(0,p.useState)([]),[n,_]=(0,p.useState)([]),[v,x]=(0,p.useState)([]),[S,C]=(0,p.useState)(null),w=a({strict:!1}).decision,[T,E]=(0,p.useState)({}),D=(0,p.useCallback)(async()=>{let e=await u();e.data&&(t(e.data.decisions),_(e.data.failures??[]));let n=await i();n.data&&x(n.data.rows)},[]);(0,p.useEffect)(()=>{D()},[D]);async function O(e){let t=T[e.id]??{},n={};for(let r of e.questions){let e=t[r.id];if(r.kind===`boolean`){if(e!==`true`&&e!==`false`)continue;n[r.id]=e===`true`}else e!==void 0&&(n[r.id]=e)}if(!m(e.questions,n)){C(`ValidationError`);return}let r=await h(o,{id:e.id,values:n,...e.labelOnly?{labelOnly:!0}:{}});r.error?.code===`Conflict`?C(`Conflict`):r.error?.code===`JournalLeaseBusy`?C(`JournalLeaseBusy`):r.error?C(r.error.code):C(null),await D()}return(0,y.jsxs)(`div`,{className:l,"data-slot":`decisions-page`,children:[(0,y.jsxs)(`div`,{className:d,children:[(0,y.jsx)(f,{to:`/flows`,className:`${r} px-2.5`,children:`Flows`}),(0,y.jsx)(`span`,{className:`${r} px-2.5`,children:`Decisions`})]}),n.length>0?(0,y.jsx)(`ul`,{children:n.map(e=>(0,y.jsxs)(`li`,{className:s,"data-slot":`decision-label-error`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.decision,` · `,e.question]}),(0,y.jsx)(`span`,{className:c,children:e.message})]},`${e.at}:${e.decision}:${e.question}`))}):null,(0,y.jsx)(`ul`,{children:e.map(e=>(0,y.jsxs)(`li`,{className:s,"data-state":g(e.state),"data-decision":e.name,"data-selected":w===e.name?`true`:`false`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,y.jsx)(`span`,{className:c,children:g(e.state)}),e.certificates?.map(e=>(0,y.jsxs)(`span`,{className:c,"data-slot":`decision-certificate`,"data-pinned":e.pinned?`true`:`false`,children:[e.decider,` `,e.model,e.pinned?``:` unpinned`]},e.decider)),e.metrics?(0,y.jsx)(`span`,{className:c,"data-slot":`decision-metrics`,children:Object.entries(e.metrics).map(([e,t])=>`${e} ${t}`).join(` · `)}):null,e.promote?(0,y.jsx)(`code`,{className:`text-xs`,"data-slot":`decision-promote`,children:e.promote}):null]},e.name))}),(0,y.jsx)(`div`,{className:d,children:(0,y.jsx)(`span`,{className:`${r} px-2.5`,children:`Review queue`})}),S?(0,y.jsx)(`p`,{className:`px-2.5 py-1 text-xs`,"data-slot":`decision-notice`,children:S}):null,(0,y.jsx)(`ul`,{children:v.map(e=>(0,y.jsxs)(`li`,{className:s,"data-label-only":e.labelOnly?`true`:`false`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.decision,e.labelOnly?` · label`:``,e.why===`refused`&&e.by?` · refused by ${e.by}`:e.why?` · ${e.why}`:``]}),(0,y.jsx)(`span`,{className:c,"data-slot":`decision-age`,children:b(e.ageMs)}),(0,y.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:t=>{t.preventDefault(),O(e)},children:[e.questions.map(t=>t.kind===`boolean`?(0,y.jsxs)(`select`,{"aria-label":t.id,value:T[e.id]?.[t.id]??``,onChange:n=>{let r=n.target.value;E(n=>({...n,[e.id]:{...n[e.id],[t.id]:r}}))},children:[(0,y.jsx)(`option`,{value:``,children:`Select`}),(0,y.jsx)(`option`,{value:`true`,children:`true`}),(0,y.jsx)(`option`,{value:`false`,children:`false`})]},t.id):(0,y.jsxs)(`select`,{"aria-label":t.id,value:T[e.id]?.[t.id]??``,onChange:n=>{let r=n.target.value;E(n=>({...n,[e.id]:{...n[e.id],[t.id]:r}}))},children:[(0,y.jsx)(`option`,{value:``,children:`Select`}),(t.kind===`choice`?t.options:t.levels)?.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))]},t.id)),(0,y.jsx)(`button`,{type:`submit`,className:`text-xs`,disabled:e.status!==`pending`,children:`Approve`})]})]},`${e.labelOnly?`label`:`park`}:${e.id}`))})]})}export{x as DecisionsPage};
|
package/src/console/ui-next/dist/assets/{duration-tone-l1DSJ2Vz.js → duration-tone-Bptur2gX.js}
RENAMED
|
@@ -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{$ as r,A as i,B as a,C as o,E as s,F as c,G as l,J as u,M as d,N as f,O as p,P as m,Q as h,S as g,U as _,V as v,W as y,X as b,Y as x,Z as S,_ as C,at as w,b as T,d as E,et as D,f as O,g as k,h as A,it as j,j as M,k as ee,m as te,nt as N,ot as ne,p as re,rt as ie,tt as ae,u as oe,v as P,w as se,x as ce,y as F}from"./index-RhV2jT_7.js";var le=[[`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`}]],ue=[[`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`}]],de=[[`path`,{d:`M17.9998 15C17.9998 15 13.5809 9.00001 11.9998 9C10.4187 8.99999 5.99985 15 5.99985 15`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],fe=[[`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`}]],pe=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function I(e,t){return x(e)?e[pe(0,e.length,t)]:e}var me=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 L(this.animations,`duration`)}get iterationDuration(){return L(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 L(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 he=class extends me{then(e,t){return this.finished.finally(e).then(()=>{})}},R=[];function ge(e){D(typeof e.test==`function`&&typeof e.read==`function`,`Effects passed to animate.addEffect() need test() and read().`,`effect-missing-test`),z(e),R.unshift(e)}function z(e){N(R,e)}function _e(e){return R.find(t=>t.test(e))}function B(e,t,n={},r){let i=[],{velocity:a}=n,s=n.reduceMotion??r?.shouldReduceMotion;for(let c in t){if(c===`transition`||c===`transitionEnd`)continue;let l=t[c];if(l===void 0)continue;let d=e(c),f=d.get();if(f!==void 0&&!d.isAnimating()&&!Array.isArray(l)&&l===f&&!a){u.update(()=>d.set(l));continue}d.start(se(c,d,l,s&&o.has(c)?{type:!1}:n,r)),d.animation&&i.push(d.animation)}let{transitionEnd:c}=t;if(c){let t=()=>u.update(()=>{for(let t in c)e(t).set(c[t])});i.length?Promise.all(i).then(t):t()}return i}function V(e,t,n,r,i){return B(r=>{let a=e.get(t,r);if(!a){let o;if(!i){let i=n[r];o=ve(i)??e.read(t,r,i),D(o!==void 0,`"${r}" can't be read from the animated subject. Provide [from, to] keyframes.`,`effect-unreadable-value`)}a=p(o,{owner:i}),e(t,{[r]:a})}return a},n,r,i)}function ve(e){let t=Array.isArray(e)?e[0]:void 0;return t===null?void 0:t}var ye=class{constructor(e=u.render){this.step=e,this.values=new Map,this.pending=[],this.numPending=0,this.flush=()=>{let{pending:e,numPending:t}=this;this.numPending=0;for(let n=0;n<t;n++)e[n]()}}set(e,t,n,r){if(this.values.get(e)?.onRemove(),r)for(let e of this.values.values())e.value===r&&(n=e.render);let i=()=>n&&this.schedule(n);t.get()!==void 0&&i();let a=t.on(`change`,i),o=()=>{a(),n&&!r&&this.cancel(n),this.values.delete(e)};return this.values.set(e,{value:t,render:r?void 0:n,onRemove:o}),o}get(e){return this.values.get(e)?.value}release(){let e=new Map;return this.values.forEach((t,n)=>{e.set(n,t.value),t.onRemove()}),this.transformKeys=this.transformValues=void 0,e}schedule(e){let{pending:t,numPending:n}=this;for(let r=0;r<n;r++)if(t[r]===e)return;n||this.step(this.flush),t[this.numPending++]=e}cancel(e){let{pending:t}=this;for(let n=0;n<this.numPending;n++)if(t[n]===e){t[n]=t[--this.numPending];return}}};function H(e,{step:t,...n}={}){let r=new WeakMap;return Object.assign((n,i)=>{let a=r.get(n)??new ye(t);r.set(n,a);let o=[];for(let t in i){let r=i[t],s=e(n,a,t,r);o.push(s)}return()=>{for(let e of o)e()}},n,{get:(e,t)=>r.get(e)?.get(t),flush:e=>r.get(e)?.flush(),state:e=>r.get(e)})}var be={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},U={};function xe(e){let t=``,{transformKeys:n=[],transformValues:r={}}=e;for(let e=0;e<n.length;e++){let i=n[e],a=r[i].get();a!==void 0&&(typeof a==`number`?a:parseFloat(a))!==+!!i.startsWith(`scale`)&&(t+=(t&&` `)+(U[i]||(U[i]=(be[i]||i)+`(`))+C(a,c[i])+`)`)}let i=e.get(`pathRotation`)?.get();return i&&(t+=(t&&` `)+`rotate(`+C(i,c.pathRotation)+`)`),t||`none`}var Se=new Set([`originX`,`originY`,`originZ`]),W=(e,t)=>C(e.get(t)?.get(),m[t]),G=(e,t,n,r)=>{let a,o;if(d.has(n)){if(n!==`pathRotation`){let e=t.transformKeys??=[];(t.transformValues??={})[n]=r,e.includes(n)||(e.push(n),e.sort((e,t)=>M.indexOf(e)-M.indexOf(t)))}t.get(`transform`)||(!F(e)&&!t.get(`transformBox`)&&G(e,t,`transformBox`,new s(`fill-box`)),t.set(`transform`,new s(`none`),()=>{e.style.transform=xe(t)})),o=t.get(`transform`)}else Se.has(n)?(t.get(`transformOrigin`)||t.set(`transformOrigin`,new s(``),()=>{let n=W(t,`originX`)??`50%`,r=W(t,`originY`)??`50%`,i=W(t,`originZ`)??0;e.style.transformOrigin=`${n} ${r} ${i}`}),o=t.get(`transformOrigin`)):a=i(n)?()=>{e.style.setProperty(n,r.get())}:()=>{e.style[n]=C(r.get(),m[n])};return t.set(n,r,a,o)},Ce=e=>F(e)||P(e),K=(e,t)=>{if(d.has(t))return f(e,t);let n=getComputedStyle(e),r=i(t)?n.getPropertyValue(t):n[t];return typeof r==`string`&&r.trim()||0},we=H(G,{test:Ce,read:K});function Te(e,t){if(!(t in e))return!1;let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||Object.getOwnPropertyDescriptor(e,t);return n&&typeof n.set==`function`}var Ee=(e,t,n,r,i=n)=>{let a=Te(e,i);!a&&(i.startsWith(`data`)||i.startsWith(`aria`))&&(i=ce(i));let o=m[n]||m[i],s=a?()=>{e[i]=C(r.get(),m[n])}:()=>{let t=C(r.get(),o);t==null?e.removeAttribute(i):e.setAttribute(i,String(t))};return t.set(n,r,s)};function De(e,t,n,r){return u.render(()=>e.setAttribute(`pathLength`,`1`)),n===`pathOffset`?t.set(n,r,()=>{let t=r.get();e.setAttribute(`stroke-dashoffset`,`${-t}`)}):(t.get(`stroke-dasharray`)||t.set(`stroke-dasharray`,new s(`1 1`),()=>{let n=t.get(`pathLength`)?.get()??1,r=t.get(`pathSpacing`)?.get();e.setAttribute(`stroke-dasharray`,`${n} ${r??1-Number(n)}`)}),t.set(n,r,void 0,t.get(`stroke-dasharray`)))}var Oe=H((e,t,n,r)=>n.startsWith(`path`)?De(e,t,n,r):n.startsWith(`attr`)?Ee(e,t,n,r,ke(n)):(i(n)||n in e.style?G:Ee)(e,t,n,r),{test:P,read:(e,t)=>d.has(t)?m[t]?.default||0:i(t)||A.includes(t)?K(e,t):(t=ke(t),e.getAttribute(ce(t))??e.getAttribute(t)??void 0)});function ke(e){return e.replace(/^attr([A-Z])/,(e,t)=>t.toLowerCase())}var Ae={},je=e=>P(e)?Oe:we,Me=class{constructor(e,t){this.effect=e,this.current=t,this.KeyframeResolver=T}getValue(e){return this.effect.get(this.current,e)}readValue(e,t){return this.effect.read(this.current,e,t)}render(){this.effect.flush(this.current)}measureViewportBox(){return te(this.current)}getProps(){return Ae}};function Ne(e,t,n,r){if(r)return B(e=>r.getValue(e,null),t,n,r);let i=je(e);return V(i,e,t,n,new Me(i,e))}var Pe=H((e,t,n,r)=>t.set(n,r,()=>{e[n]=r.get()}),{test:e=>r(e),read:(e,t)=>{let n=e[t];return typeof n==`string`||typeof n==`number`?n:void 0}}),q=n(),J=e(t(),1);function Fe(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Ie(...e){return t=>{let n=!1,r=e.map(e=>{let r=Fe(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():Fe(e[t],null)}}}}function Le(...e){return J.useCallback(Ie(...e),e)}var Re=class extends J.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(F(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=F(e)&&e.offsetWidth||0,r=F(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 ze({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,J.useId)(),s=(0,J.useRef)(null),c=(0,J.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,J.useContext)(E),u=Le(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,J.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{$ as r,A as i,B as a,C as o,E as s,F as c,G as l,J as u,M as d,N as f,O as p,P as m,Q as h,S as g,U as _,V as v,W as y,X as b,Y as x,Z as S,_ as C,at as w,b as T,d as E,et as D,f as O,g as k,h as A,it as j,j as M,k as ee,m as te,nt as N,ot as ne,p as re,rt as ie,tt as ae,u as oe,v as P,w as se,x as ce,y as F}from"./index-Duxus_sG.js";var le=[[`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`}]],ue=[[`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`}]],de=[[`path`,{d:`M17.9998 15C17.9998 15 13.5809 9.00001 11.9998 9C10.4187 8.99999 5.99985 15 5.99985 15`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]],fe=[[`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`}]],pe=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function I(e,t){return x(e)?e[pe(0,e.length,t)]:e}var me=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 L(this.animations,`duration`)}get iterationDuration(){return L(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 L(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 he=class extends me{then(e,t){return this.finished.finally(e).then(()=>{})}},R=[];function ge(e){D(typeof e.test==`function`&&typeof e.read==`function`,`Effects passed to animate.addEffect() need test() and read().`,`effect-missing-test`),z(e),R.unshift(e)}function z(e){N(R,e)}function _e(e){return R.find(t=>t.test(e))}function B(e,t,n={},r){let i=[],{velocity:a}=n,s=n.reduceMotion??r?.shouldReduceMotion;for(let c in t){if(c===`transition`||c===`transitionEnd`)continue;let l=t[c];if(l===void 0)continue;let d=e(c),f=d.get();if(f!==void 0&&!d.isAnimating()&&!Array.isArray(l)&&l===f&&!a){u.update(()=>d.set(l));continue}d.start(se(c,d,l,s&&o.has(c)?{type:!1}:n,r)),d.animation&&i.push(d.animation)}let{transitionEnd:c}=t;if(c){let t=()=>u.update(()=>{for(let t in c)e(t).set(c[t])});i.length?Promise.all(i).then(t):t()}return i}function V(e,t,n,r,i){return B(r=>{let a=e.get(t,r);if(!a){let o;if(!i){let i=n[r];o=ve(i)??e.read(t,r,i),D(o!==void 0,`"${r}" can't be read from the animated subject. Provide [from, to] keyframes.`,`effect-unreadable-value`)}a=p(o,{owner:i}),e(t,{[r]:a})}return a},n,r,i)}function ve(e){let t=Array.isArray(e)?e[0]:void 0;return t===null?void 0:t}var ye=class{constructor(e=u.render){this.step=e,this.values=new Map,this.pending=[],this.numPending=0,this.flush=()=>{let{pending:e,numPending:t}=this;this.numPending=0;for(let n=0;n<t;n++)e[n]()}}set(e,t,n,r){if(this.values.get(e)?.onRemove(),r)for(let e of this.values.values())e.value===r&&(n=e.render);let i=()=>n&&this.schedule(n);t.get()!==void 0&&i();let a=t.on(`change`,i),o=()=>{a(),n&&!r&&this.cancel(n),this.values.delete(e)};return this.values.set(e,{value:t,render:r?void 0:n,onRemove:o}),o}get(e){return this.values.get(e)?.value}release(){let e=new Map;return this.values.forEach((t,n)=>{e.set(n,t.value),t.onRemove()}),this.transformKeys=this.transformValues=void 0,e}schedule(e){let{pending:t,numPending:n}=this;for(let r=0;r<n;r++)if(t[r]===e)return;n||this.step(this.flush),t[this.numPending++]=e}cancel(e){let{pending:t}=this;for(let n=0;n<this.numPending;n++)if(t[n]===e){t[n]=t[--this.numPending];return}}};function H(e,{step:t,...n}={}){let r=new WeakMap;return Object.assign((n,i)=>{let a=r.get(n)??new ye(t);r.set(n,a);let o=[];for(let t in i){let r=i[t],s=e(n,a,t,r);o.push(s)}return()=>{for(let e of o)e()}},n,{get:(e,t)=>r.get(e)?.get(t),flush:e=>r.get(e)?.flush(),state:e=>r.get(e)})}var be={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},U={};function xe(e){let t=``,{transformKeys:n=[],transformValues:r={}}=e;for(let e=0;e<n.length;e++){let i=n[e],a=r[i].get();a!==void 0&&(typeof a==`number`?a:parseFloat(a))!==+!!i.startsWith(`scale`)&&(t+=(t&&` `)+(U[i]||(U[i]=(be[i]||i)+`(`))+C(a,c[i])+`)`)}let i=e.get(`pathRotation`)?.get();return i&&(t+=(t&&` `)+`rotate(`+C(i,c.pathRotation)+`)`),t||`none`}var Se=new Set([`originX`,`originY`,`originZ`]),W=(e,t)=>C(e.get(t)?.get(),m[t]),G=(e,t,n,r)=>{let a,o;if(d.has(n)){if(n!==`pathRotation`){let e=t.transformKeys??=[];(t.transformValues??={})[n]=r,e.includes(n)||(e.push(n),e.sort((e,t)=>M.indexOf(e)-M.indexOf(t)))}t.get(`transform`)||(!F(e)&&!t.get(`transformBox`)&&G(e,t,`transformBox`,new s(`fill-box`)),t.set(`transform`,new s(`none`),()=>{e.style.transform=xe(t)})),o=t.get(`transform`)}else Se.has(n)?(t.get(`transformOrigin`)||t.set(`transformOrigin`,new s(``),()=>{let n=W(t,`originX`)??`50%`,r=W(t,`originY`)??`50%`,i=W(t,`originZ`)??0;e.style.transformOrigin=`${n} ${r} ${i}`}),o=t.get(`transformOrigin`)):a=i(n)?()=>{e.style.setProperty(n,r.get())}:()=>{e.style[n]=C(r.get(),m[n])};return t.set(n,r,a,o)},Ce=e=>F(e)||P(e),K=(e,t)=>{if(d.has(t))return f(e,t);let n=getComputedStyle(e),r=i(t)?n.getPropertyValue(t):n[t];return typeof r==`string`&&r.trim()||0},we=H(G,{test:Ce,read:K});function Te(e,t){if(!(t in e))return!1;let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||Object.getOwnPropertyDescriptor(e,t);return n&&typeof n.set==`function`}var Ee=(e,t,n,r,i=n)=>{let a=Te(e,i);!a&&(i.startsWith(`data`)||i.startsWith(`aria`))&&(i=ce(i));let o=m[n]||m[i],s=a?()=>{e[i]=C(r.get(),m[n])}:()=>{let t=C(r.get(),o);t==null?e.removeAttribute(i):e.setAttribute(i,String(t))};return t.set(n,r,s)};function De(e,t,n,r){return u.render(()=>e.setAttribute(`pathLength`,`1`)),n===`pathOffset`?t.set(n,r,()=>{let t=r.get();e.setAttribute(`stroke-dashoffset`,`${-t}`)}):(t.get(`stroke-dasharray`)||t.set(`stroke-dasharray`,new s(`1 1`),()=>{let n=t.get(`pathLength`)?.get()??1,r=t.get(`pathSpacing`)?.get();e.setAttribute(`stroke-dasharray`,`${n} ${r??1-Number(n)}`)}),t.set(n,r,void 0,t.get(`stroke-dasharray`)))}var Oe=H((e,t,n,r)=>n.startsWith(`path`)?De(e,t,n,r):n.startsWith(`attr`)?Ee(e,t,n,r,ke(n)):(i(n)||n in e.style?G:Ee)(e,t,n,r),{test:P,read:(e,t)=>d.has(t)?m[t]?.default||0:i(t)||A.includes(t)?K(e,t):(t=ke(t),e.getAttribute(ce(t))??e.getAttribute(t)??void 0)});function ke(e){return e.replace(/^attr([A-Z])/,(e,t)=>t.toLowerCase())}var Ae={},je=e=>P(e)?Oe:we,Me=class{constructor(e,t){this.effect=e,this.current=t,this.KeyframeResolver=T}getValue(e){return this.effect.get(this.current,e)}readValue(e,t){return this.effect.read(this.current,e,t)}render(){this.effect.flush(this.current)}measureViewportBox(){return te(this.current)}getProps(){return Ae}};function Ne(e,t,n,r){if(r)return B(e=>r.getValue(e,null),t,n,r);let i=je(e);return V(i,e,t,n,new Me(i,e))}var Pe=H((e,t,n,r)=>t.set(n,r,()=>{e[n]=r.get()}),{test:e=>r(e),read:(e,t)=>{let n=e[t];return typeof n==`string`||typeof n==`number`?n:void 0}}),q=n(),J=e(t(),1);function Fe(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Ie(...e){return t=>{let n=!1,r=e.map(e=>{let r=Fe(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():Fe(e[t],null)}}}}function Le(...e){return J.useCallback(Ie(...e),e)}var Re=class extends J.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(F(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=F(e)&&e.offsetWidth||0,r=F(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 ze({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,J.useId)(),s=(0,J.useRef)(null),c=(0,J.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,J.useContext)(E),u=Le(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,J.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{$n as d,Cr as f,E as p,F as m,I as h,Qn as g,R as _,tr as v,x as y}from"./shortcut-keys-DTE1sjTC.js";import{C as b,E as x,S,b as C,d as w,m as T,w as E,x as D}from"./explorer-chrome-Dslh2yE8.js";import{a as O,b as k,c as ee,d as te,f as ne,i as A,l as re,n as ie,o as ae,p as oe,r as se,t as j,u as ce}from"./element-icons-C6t8Vlml.js";import{s as M}from"./collapsible-BvFaX-Zt.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./trace-detail-sheet-Di4irS49.js";import{t as he}from"./duration-tone-l1DSJ2Vz.js";import{a as ge,c as _e,i as ve,l as ye,o as be,s as xe}from"./highlighted-json-DMvsi3Ti.js";import{C as Se,_ as N,b as P,f as Ce,g as F,m as we,p as Te,v as I,w as Ee,x as De,y as L}from"./request-meta-C6lTyCXp.js";import{n as Oe}from"./dagre.esm-B1_XeuLP.js";import{At as ke,a as Ae,c as je,jt as Me,l as Ne,o as Pe}from"./index-RhV2jT_7.js";import{a as Fe,c as R,i as Ie,n as Le,o as Re,r as ze,t as Be}from"./cache-glyph-D3MY49h3.js";import{t as Ve}from"./agent-disclosure-CBj9f7Ju.js";var He=[[`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`}]],z=e(t(),1),B=[`flow`,`signal`,`store`,`clock`,`gate`,`vault`,`channel`,`ai`];function V(e,t,n){return{x:I.cx+t*Math.cos(e)-n.width/2,y:I.cy+t*Math.sin(e)-n.height/2}}function Ue(e){if(e<=0)return[];let t=2*Math.PI/e;return Array.from({length:e},(e,n)=>-Math.PI/2+n*t)}var We=2*Math.PI/B.length;function Ge(e,t,n=I.typeRing){if(t<=0)return[];if(t===1)return[e];let r=(L.type.width+10)/n,i=Math.min(r*(t-1),We*.7);return Array.from({length:t},(n,r)=>e-i/2+r/(t-1)*i)}function Ke(e,t){if(t<=0)return[];let n=I.typeRing,r=I.typeRing+I.typeRow;if(t===1)return[{angle:e,radius:n}];if(t===4)return Je(e,n,r);if(t<=3)return Ge(e,t,n).map(e=>({angle:e,radius:n}));let i=Math.ceil(t/2),a=t-i;return[...Ge(e,i,n).map(e=>({angle:e,radius:n})),...Ge(e,a,r).map(e=>({angle:e,radius:r}))]}function qe(e){return Math.abs(Math.cos(e))*L.type.height+Math.abs(Math.sin(e))*L.type.width}function Je(e,t,n){let r=(qe(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 Ye(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`),B.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`:case`decide`:t.add(`ai`);break;case`secret`:t.add(`vault`)}return B.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}`,ze(t),R(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:Ce.map(e=>({kind:e,label:Te[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=R(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 Ye(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:B.filter(t=>i.get(e)?.has(t)),live:0,errors:0})),s=B.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??R(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(ct(`orbit:elements`,I.elementRing)),s.push(ct(`orbit:types`,I.typeRing)),s.push(ct(`orbit:spokes`,I.spokeRing)),s.push({id:`law:oke`,type:`law`,position:{x:I.cx-L.law.width/2,y:I.cy-L.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:N.leaf,width:L.law.width,height:L.law.height,style:{width:L.law.width,height:L.law.height,overflow:`visible`}});let l=Ue(B.length);if(r.hubs.forEach((e,t)=>{let n=l[t]??0,r=L.hub;s.push({id:`element:${e.element}`,type:`element`,position:V(n,I.elementRing,r),data:{kind:`element`,label:j[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:N.leaf,width:r.width,height:r.height,style:{width:r.width,height:r.height}}),c.push(H(`element:${e.element}`,`law:oke`,e.element,1,!0))}),!i||i===`flow`){let t=L.type;r.hubs.forEach((n,r)=>{let i=l[r]??0,a=et(e,n.element),o=Ke(i,a.length);a.forEach((e,r)=>{let a=o[r]??{angle:i,radius:I.typeRing};s.push({id:e.id,type:`typeChip`,position:V(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:N.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}}),c.push(H(e.id,`element:${n.element}`,n.element,1))})})}if(i&&i!==`flow`){let t=Ze(e,i),n=De.store,r=Ue(t.length);t.forEach((e,t)=>{let a=r[t]??0;s.push({id:e.id,type:i,position:V(a,I.spokeRing,n),data:{kind:i,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:N.leaf,width:n.width,height:n.height,style:{width:n.width,height:n.height}}),c.push(H(e.id,`element:${i}`,i,1))})}else{let t=L.unit,n=Ue(r.units.length);r.units.forEach((e,r)=>{let i=n[r]??0;s.push({id:`unit:${e.unit}`,type:`unitChip`,position:V(i,I.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:N.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=R(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 Ye(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(H(`unit:${t.unit}`,e,n,r))}for(let e of r)c.push(H(`unit:${t.unit}`,`element:${e}`,e,1))}}return{nodes:s,edges:c,units:r.units,hubs:r.hubs}}function ct(e,t){let n=t*2;return{id:e,type:`orbit`,position:{x:I.cx-t,y:I.cy-t},data:{kind:`law`,label:``,refId:e},selectable:!1,draggable:!1,zIndex:N.edge,width:n,height:n,style:{width:n,height:n}}}function lt(e,t){return t===`law:oke`?`trunk`:e.startsWith(`type:`)&&t.startsWith(`element:`)?`bind`:`spoke`}function ut(e){return e===`trunk`?.14:e===`bind`?.2:0}function H(e,t,n,r,i=!1){let a=i?`trunk`:lt(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:F.couple,strokeWidth:o,opacity:ut(a)},zIndex:N.edge}}function dt(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 ft(e,t){for(let n of[t,e]){let e=dt(n);if(e)return P[e].accent}return F.couple}function pt(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:${R(r)}`;n.add(a);for(let r of Ye(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 mt(e,t,n={}){let r=n.hoverNodeId??null,i=n.highlightedFlowIds??new Set,a=n.highlightedNodeIds??new Set,o=pt(n.manifest,i),s=o.nodeIds.size>0||a.size>0,c=r!=null,l=r==null?null:ht(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=lt(e.source,e.target),a=c||s?r?1:ut(i)*.35:ut(i);return{...e,animated:r,style:{...e.style,stroke:r?ft(e.source,e.target):F.couple,opacity:a,strokeWidth:r?2.25:e.style?.strokeWidth}}})}}function U(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 ht(e,t){let n=new Set([e]),r=e=>n.add(e);if(e.startsWith(`unit:`)){for(let n of U(t,e)){if(r(n),n.startsWith(`type:`)){for(let e of U(t,n))if(e.startsWith(`element:`)){r(e);for(let n of U(t,e))n===`law:oke`&&r(n)}}if(n.startsWith(`element:`))for(let e of U(t,n))e===`law:oke`&&r(e)}return n}if(e.startsWith(`type:`)){for(let n of U(t,e))r(n);let i=[...n].find(e=>e.startsWith(`element:`));if(i)for(let e of U(t,i))e===`law:oke`&&r(e);return n}if(e.startsWith(`element:`)||e===`law:oke`)for(let n of U(t,e))r(n);return n}var W=n(),gt={flow:j.flow.icon,signal:j.signal.icon,store:j.store.icon,clock:j.clock.icon,gate:j.gate.icon,vault:j.vault.icon,channel:j.channel.icon,ai:j.ai.icon},_t={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 G(e,t){return g(`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`,_t[t],e.dimmed&&`opacity-30 saturate-[0.35]`,e.highlighted&&`z-10`,e.focused&&`z-10`)}function K(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 q({data:e,kind:t,className:n,style:r,children:i,...a}){let o=Ne(),s=P[t];return(0,W.jsx)(je.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 vt({kind:e,size:t=`sm`}){let n=P[e];return(0,W.jsx)(`span`,{className:g(`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,W.jsx)(d,{icon:gt[e],size:t===`md`?17:15,strokeWidth:1.9})})}function J({text:e}){return(0,W.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 yt({type:e,kind:t}){let n=P[t];return(0,W.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,W.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 bt({live:e,errors:t}){return e<=0?null:(0,W.jsx)(`span`,{className:g(`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 xt({elements:e}){return e.length===0?null:(0,W.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1`,"aria-hidden":!0,children:e.map(e=>(0,W.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:P[e].accent},title:j[e].label},e))})}function St({data:e}){return(0,W.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,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.label}),e.badge?(0,W.jsx)(J,{text:e.badge}):null]})})}function Ct({data:e}){let t=e.kind in P?e.kind:`flow`;return(0,W.jsxs)(q,{data:e,kind:t,className:g(G(e,t),`justify-center gap-0 rounded-full px-2`),style:K(t,e),"data-slot":`type-chip`,"data-type":e.refId,children:[(0,W.jsx)(Y,{type:`source`}),(0,W.jsx)(Y,{type:`target`}),(0,W.jsx)(`div`,{className:`min-w-0 truncate text-center text-[10px] leading-none font-medium tracking-wide text-foreground`,children:e.label})]})}function wt({data:e}){return(0,W.jsxs)(q,{data:e,kind:`flow`,className:g(G(e,`flow`),`rounded-full px-2.5`),style:K(`flow`,e),"data-slot":`unit-chip`,"data-unit":e.refId,children:[(0,W.jsx)(Y,{type:`source`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-medium tracking-wide text-foreground uppercase`,children:e.label}),(0,W.jsx)(bt,{live:e.live??0,errors:e.errors??0})]}),(0,W.jsx)(xt,{elements:e.elements??[]})]}),e.badge?(0,W.jsx)(J,{text:e.badge}):null]})}function Tt({data:e}){let t=kt(e.refId)??`flow`,n=P[t];return(0,W.jsxs)(q,{data:e,kind:t,className:g(G(e,t),`flex-col justify-center gap-0.5 rounded-full px-1.5 text-center`),style:{...K(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,W.jsx)(Y,{type:`target`}),(0,W.jsx)(Y,{type:`source`}),(0,W.jsx)(`span`,{className:`text-[18px] font-semibold tracking-tight text-foreground`,title:j[t].label,children:e.label})]})}function Et(e){return e>=40?1.05:e>=12?1.55:2.2}function Dt({data:e}){let t=Ne(),n=e.live??0,r=e.errors??0,[i,a]=(0,z.useState)(0),o=(0,z.useRef)(n);(0,z.useEffect)(()=>{n>o.current&&a(e=>e+1),o.current=n},[n]);let s=n>0,c=Et(n),l=r>0?`var(--color-rose-400)`:`var(--foreground)`;return(0,W.jsxs)(`div`,{className:g(`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,W.jsx)(Y,{type:`target`}),!t&&s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,color:l}}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,animationDelay:`${c/2}s`,color:l}})]}):null,i>0&&!t?(0,W.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-hit`,style:{color:l}},i):null,(0,W.jsx)(je.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,W.jsx)(Ae,{className:`h-7 w-auto text-foreground`})})]})}function Ot(){return(0,W.jsx)(`div`,{className:`pointer-events-none h-full w-full rounded-full border border-dashed border-foreground/15`,"data-slot":`orbit`})}function kt(e){return e in P?e:null}function X({data:e,kind:t,slot:n}){return(0,W.jsxs)(q,{data:e,kind:t,className:G(e,t),style:K(t,e),"data-slot":n,"data-flow-id":t===`flow`?e.refId:void 0,"data-highlighted":e.highlighted?`true`:`false`,children:[(0,W.jsx)(yt,{type:`target`,kind:t}),(0,W.jsx)(Y,{type:`source`}),(0,W.jsx)(vt,{kind:t}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:e.label}),(0,W.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:(0,W.jsx)(J,{text:e.badge??e.plane??e.facet??t})})]}),t===`flow`||t===`signal`?(0,W.jsx)(yt,{type:`source`,kind:t}):null]})}function At({data:e}){return(0,W.jsx)(X,{data:e,kind:`flow`,slot:`flow-node`})}function jt({data:e}){return(0,W.jsx)(X,{data:e,kind:`store`,slot:`store-node`})}function Mt({data:e}){return(0,W.jsx)(X,{data:e,kind:`signal`,slot:`signal-node`})}function Nt({data:e}){return(0,W.jsx)(X,{data:e,kind:`ai`,slot:`ai-node`})}function Pt({data:e}){return(0,W.jsx)(X,{data:e,kind:`clock`,slot:`clock-node`})}function Ft({data:e}){return(0,W.jsx)(X,{data:e,kind:`gate`,slot:`gate-node`})}function It({data:e}){return(0,W.jsx)(X,{data:e,kind:`vault`,slot:`vault-node`})}function Lt({data:e}){return(0,W.jsx)(X,{data:e,kind:`channel`,slot:`channel-node`})}var Rt={unit:St,unitChip:wt,typeChip:Ct,element:Tt,law:Dt,orbit:Ot,flow:At,store:jt,signal:Mt,ai:Nt,clock:Pt,gate:Ft,vault:It,channel:Lt};function zt(e,t){let n=e.flows??{},r=new Set;if(t.kind===`unit`){for(let e of Object.keys(n))R(e)===t.unit&&r.add(e);let e=[];for(let t of r)for(let r of n[t]?.effects?.calls??[])Ee(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??[])Ee(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))Bt(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 Bt(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=Ee(e);return t?n===Se(t.server):n===`flow:${e}`})):!1}var Vt=[`!=`,`>=`,`<=`,`=`,`>`,`<`],Ht={clauses:[]},Ut=[`flow`,`unit`,`trigger`,`plane`,`tenant`,`principal`,`cache`,`replica`,`error`,`buildVersion`,`promptVersion`,`duration`];function Wt(e){if(!e||!e.trim())return Ht;let t=e.split(/\s+AND\s+/i).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t){let t=tn(e);t&&n.push(t)}return{clauses:n}}function Z(e,t){return{clauses:[...e.clauses.filter(e=>e.dimension!==t.dimension),t]}}function Gt(e,t){return{clauses:e.clauses.filter(e=>e.dimension!==t)}}function Kt(e,t){return e.dimension===t.dimension&&e.op===t.op&&e.value===t.value}function qt(e,t){return e.clauses.some(e=>Kt(e,t))}function Jt(e,t){return qt(e,t)?Gt(e,t.dimension):Z(e,t)}function Yt(e){let t=an(e.dimension,e.value);return`${e.dimension} ${e.op} ${t}`}function Xt(e,t){for(let n of t.clauses)if(!on(e,n))return!1;return!0}function Zt(e,t){return t.clauses.length===0?[...e]:e.filter(e=>Xt(e,t))}function Qt(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 $t(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 en(e){let t=new Set(Ut);for(let n of e)for(let e of Object.keys(n.dimensions))t.add(e);return[...t].sort()}function tn(e){let t=null,n=-1;for(let r of Vt){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=nn(r,i);return a===void 0?null:{dimension:r,op:t,value:a}}function nn(e,t){return e===`duration`||e===`duration_ms`?Qt(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 rn(e,t){return an(e,t)}function an(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 on(e,t){let n=$t(e,t.dimension);if(n==null)return t.op===`!=`;let r=t.value;if(t.op===`=`)return sn(n,r);if(t.op===`!=`)return!sn(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 sn(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 cn=new Set(Object.keys(j));function ln(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 cn.has(t)?{kind:`element`,element:t}:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&cn.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 un(e){switch(e.kind){case`flow`:return e.flowId;case`signal`:return`signal:${e.signal}`;case`unit`:return e.unit;case`element`:return j[e.element].label;case`resource`:return e.nodeId}}function dn(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 fn(e,t,n){if(t.kind===`flow`)return Xt(e,{clauses:[{dimension:`flow`,op:`=`,value:t.flowId}]});if(t.kind===`unit`)return(e.unit??R(e.flow))===t.unit;if(t.kind===`element`)return t.element===`flow`||Xe(e).includes(t.element);if(t.kind===`resource`)return pn(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 pn(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&&Bt(i,e.flow,t))}function mn(e,t,n){return t?e.filter(e=>fn(e,t,n)):[...e]}function hn(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 gn({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:_}=Pe(),[v,y]=(0,z.useState)(null),b=_===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:_,x=hn(n),S=n?.kind===`element`?n.element:null,C=x===null,w=(0,z.useMemo)(()=>st(e,t,S?{kind:`element`,element:S}:null),[e,t,S]),T=(0,z.useMemo)(()=>Re(!x||!e?e:zt(e,x)),[e,x]),E=(0,z.useMemo)(()=>mt(w.nodes,w.edges,{hoverNodeId:v,highlightedFlowIds:r,highlightedNodeIds:s,manifest:e}),[w.nodes,w.edges,v,r,s,e]),D=(0,z.useMemo)(()=>Ie(T.nodes,r,s,{activeNodeId:d,focusedNodeId:f}),[T.nodes,r,s,d,f]),O=(0,z.useMemo)(()=>Fe(T.edges,D),[T.edges,D]),k=C?E.nodes:D,ee=C?E.edges:O;return(0,z.useEffect)(()=>{g({duration:280,padding:.18})},[C,n,e,g]),(0,z.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,W.jsxs)(`div`,{className:`relative h-full w-full`,children:[n?(0,W.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,W.jsx)(`span`,{className:`text-foreground`,children:`Map`}),(0,W.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,W.jsx)(`span`,{className:`truncate`,children:un(n)})]}):(0,W.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,W.jsxs)(W.Fragment,{children:[`Orchestra `,(0,W.jsx)(`span`,{className:`text-foreground normal-case`,children:p})]}):`Hover a unit — spokes light the elements it touches`}),(0,W.jsxs)(i,{nodes:k,edges:ee,nodeTypes:Rt,colorMode:b,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},minZoom:.15,maxZoom:1.6,defaultEdgeOptions:{type:`smoothstep`,zIndex:N.edge},zIndexMode:`manual`,onNodeClick:(e,t)=>m?.(t.id),onPaneClick:()=>h?.(),onNodeMouseEnter:(e,t)=>y(t.id),onNodeMouseLeave:()=>y(null),children:[(0,W.jsx)(u,{gap:24,size:1,color:`color-mix(in oklab, var(--foreground) 14%, transparent)`}),(0,W.jsx)(c,{showInteractive:!1}),(0,W.jsx)(o,{pannable:!0,zoomable:!0,ariaLabel:`Flow graph overview`,bgColor:`var(--card)`,maskColor:`color-mix(in oklab, var(--background) 55%, transparent)`,nodeColor:_n,nodeStrokeColor:vn,nodeStrokeWidth:12,nodeBorderRadius:10})]})]})}function _n(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 vn(e){return e.data.kind===`unit`?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`transparent`}function yn(e){let{leading:t,...n}=e;return(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,"data-slot":`flow-graph`,children:[t?(0,W.jsxs)(`header`,{className:D,children:[t,(0,W.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})]}):null,(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,W.jsx)(l,{children:(0,W.jsx)(gn,{...n})})})]})}var bn=`orch-`;function xn(e){return e.startsWith(bn)}function Sn(e,t){return e&&t}function Cn(e,t=Math.random){let n=e.filter(e=>!xn(e.id)&&e.flow.length>0);return n.length===0?null:n[Math.floor(t()*n.length)]??null}function wn(e,t,n){let r=t-e.startedAt,i=e.flow.replaceAll(`.`,`-`);return{...e,id:`${bn}${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 Tn(e=Math.random){return 1800+Math.floor(e()*1600)}var En=1400;function Dn(e){let t=f(),[n,r]=(0,z.useState)(null),i=(0,z.useRef)(0),a=(0,z.useRef)(null),o=(0,z.useRef)(null),s=(0,z.useRef)(e.paused);return s.current=e.paused,(0,z.useEffect)(()=>{if(!Sn(!1,e.enabled))return;let n=()=>{a.current&&=(clearTimeout(a.current),null)},c=()=>{if(s.current||document.hidden)return;let e=Cn(t.getQueryData(be)??[]);if(!e)return;i.current+=1;let o=wn(e,Date.now(),i.current);t.setQueryData(be,e=>ye(e??[],o)),r({flowId:o.flow,runId:o.id}),n(),a.current=setTimeout(()=>{r(null),a.current=null},En)},l=e=>{o.current=setTimeout(()=>{c(),l(Tn())},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 On(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 kn=[{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`}],An=`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`,jn=`grid grid-cols-[minmax(0,1fr)_1.25rem_minmax(0,1fr)_1.25rem] items-center gap-x-1`;function Mn({query:e,runs:t,onChange:n}){let r=(0,z.useMemo)(()=>en(t),[t]),i=(0,z.useMemo)(()=>[...new Set([...Ut,...r])].sort(),[r]),[a,o]=(0,z.useState)(`trigger`),[s,c]=(0,z.useState)(`=`),[l,u]=(0,z.useState)(`signal`),[d,f]=(0,z.useState)(!1),m=()=>{let t=Wt(`${a} ${s} ${l}`).clauses[0];t&&(n(Z(e,t)),f(!1))};return(0,W.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,W.jsx)(`ul`,{"aria-label":`Active filters`,className:`flex flex-col gap-0.5`,children:e.clauses.map(t=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Nn,{clause:t,onRemove:()=>n(Gt(e,t.dimension))})},t.dimension))}):null,d?(0,W.jsxs)(`div`,{className:jn,"data-slot":`traces-advanced-composer`,children:[(0,W.jsx)(`select`,{"aria-label":`Filter dimension`,className:An,value:a,onChange:e=>o(e.target.value),children:i.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}),(0,W.jsx)(`select`,{"aria-label":`Filter operator`,className:g(An,`text-center text-foreground/70`),value:s,onChange:e=>c(e.target.value),children:[`=`,`!=`,`>`,`<`,`>=`,`<=`].map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}),(0,W.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`&&m()}}),(0,W.jsx)(`button`,{type:`button`,className:$,onClick:m,children:`Add`})]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[kn.map(t=>{let r=Wt(t.expr).clauses[0],i=r!==void 0&&qt(e,r);return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:r===void 0,onClick:()=>{r&&n(Jt(e,r))},className:g($,i?`font-medium text-foreground`:`text-foreground/70`),children:t.label},t.id)}),(0,W.jsx)(`button`,{type:`button`,"aria-expanded":d,className:g($,`ml-auto`,d&&`text-foreground`),onClick:()=>f(e=>!e),children:d?`Cancel`:`Add clause`}),e.clauses.length>0?(0,W.jsx)(`button`,{type:`button`,className:$,onClick:()=>n(Wt(``)),children:`Clear`}):null]})]})}function Nn({clause:e,onRemove:t}){let n=Yt(e);return(0,W.jsxs)(`div`,{className:jn,"data-slot":`traces-advanced-clause`,children:[(0,W.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground/80`,children:e.dimension}),(0,W.jsx)(`span`,{className:`text-center font-mono text-[11px] text-foreground/65`,"aria-hidden":!0,children:e.op}),(0,W.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground`,children:rn(e.dimension,e.value)}),(0,W.jsx)(`button`,{type:`button`,className:g($,`flex size-5 items-center justify-center text-foreground/55 hover:text-destructive`),"aria-label":`Remove ${n}`,onClick:t,children:(0,W.jsx)(d,{icon:v,className:`size-3`})})]})}var Pn={query:``,status:`all`,advanced:Ht};function Fn(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 In(e,t){return Zt(e.filter(e=>!(!Fn(e,t.query)||t.status===`errors`&&e.error===null)),t.advanced)}function Ln(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 Rn(e,t=Date.now()){let n=Ln(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 zn({run:e,selected:t,onSelect:n,copyText:r=async e=>{await navigator.clipboard.writeText(e)}}){let i=Rn(e),a=i.failed,o=de(e.trigger),s=e.cache,[c,l]=(0,z.useState)(null),u=async t=>{t.stopPropagation();try{await r(pe(e)),l(`Copied run id`)}catch{l(`Copy failed`)}};return(0,W.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:g(`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,W.jsx)(`span`,{"aria-hidden":!0,className:g(`absolute inset-y-0 left-0 w-0.5`,t&&!a&&`bg-sky-500`,a&&`bg-destructive`)}),(0,W.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,W.jsx)(`span`,{className:g(`ml-2.5 size-1.5 shrink-0 rounded-full`,a?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:o.label,"aria-hidden":!0,children:(0,W.jsx)(d,{icon:o.icon,className:`size-3.5`})}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.flow}),(0,W.jsx)(Be,{cache:s,dataSlot:`trace-row-cache`}),(0,W.jsx)(`span`,{className:g(`w-10 shrink-0 text-right tabular-nums font-medium`,he(e.durationMs)),children:ve(e.durationMs)}),(0,W.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,W.jsx)(`div`,{className:g(`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,W.jsxs)(m,{children:[(0,W.jsx)(_,{render:e=>(0,W.jsx)(y,{...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,W.jsx)(d,{icon:k,className:`size-3`})})}),(0,W.jsx)(h,{side:`top`,children:`Copy run ID`})]})}),c?(0,W.jsx)(`span`,{className:`sr-only`,role:`status`,children:c}):null]})}var Bn=[{value:`all`,label:`All`,icon:He},{value:`errors`,label:`Errors`,icon:M}];function Vn({runs:e,selectedRunId:t,onSelect:n,liveStatus:r,manifest:i,graphFilter:a,onGraphFilterChange:o,focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u,selectedRun:f}){let[p,v]=(0,z.useState)(Pn),[y,C]=(0,z.useState)(!1);(0,z.useEffect)(()=>{(a?.kind===`flow`||a?.kind===`unit`)&&v(e=>({...e,advanced:dn(e.advanced,a)}))},[a]);let T=(0,z.useMemo)(()=>mn(In(e,p),a,i),[e,p,a,i]),O=(0,z.useMemo)(()=>t?T.some(e=>e.id===t)?T:e:T,[T,e,t]),k=(0,z.useMemo)(()=>f===void 0?t?e.find(e=>e.id===t)??null:null:f,[f,e,t]),A=p.advanced.clauses.length>0,ie=e=>{v(t=>({...t,query:e}))},ae=e=>{v(t=>({...t,status:e}))},se=e=>{v(t=>({...t,advanced:e}))},M=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(!t||!M.current)return;let e=M.current.querySelector(`[data-run-id="${CSS.escape(t)}"]`);e instanceof HTMLElement&&e.scrollIntoView({block:`nearest`})},[t]),(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`traces-pane`,children:[(0,W.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,W.jsxs)(`div`,{className:g(x,`border-b-0`),children:[(0,W.jsx)(ee,{value:p.query,onChange:e=>ie(e.target.value),placeholder:`Search traces…`,"aria-label":`Search traces`,"data-slot":`traces-search`}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[e.length>0?(0,W.jsxs)(m,{children:[(0,W.jsx)(_,{render:e=>(0,W.jsxs)(`button`,{...e,type:`button`,"aria-expanded":y,"aria-controls":`traces-advanced-panel`,"aria-label":A?`Advanced filters, ${p.advanced.clauses.length} active`:`Advanced filters`,"data-slot":`traces-advanced-toggle`,onClick:t=>{e.onClick?.(t),C(e=>!e)},className:g(w,`relative`,(y||A)&&`text-foreground`),children:[(0,W.jsx)(d,{icon:Oe,className:`size-3`,"aria-hidden":!0}),A?(0,W.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:p.advanced.clauses.length}):null]})}),(0,W.jsx)(h,{side:`bottom`,children:`Advanced`})]}):null,e.length>0?(0,W.jsx)(`span`,{className:`mx-0.5 h-3 w-px bg-border/60`,"aria-hidden":!0}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-0.5 text-[10px] text-muted-foreground`,children:[(0,W.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,W.jsx)(`div`,{className:g(D,`border-t border-b-0`),"data-slot":`traces-filters`,children:(0,W.jsx)(`div`,{className:`flex shrink-0 items-stretch`,role:`group`,"aria-label":`Status filter`,children:Bn.map(({value:e,label:t,icon:n})=>{let r=p.status===e;return(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ae(e),className:g(b,`font-semibold tracking-[0.08em] uppercase`,r?e===`errors`?`text-destructive`:S:E),children:[(0,W.jsx)(d,{icon:n,className:`size-3`,"aria-hidden":!0}),t]},e)})})}):null,e.length>0&&a?(0,W.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,W.jsx)(`span`,{className:`truncate`,children:un(a)}),(0,W.jsx)(`span`,{"aria-hidden":!0,children:`×`})]}):null]}),e.length>0?(0,W.jsx)(Ve,{id:`traces-advanced-panel`,role:`region`,"aria-label":`Advanced filters`,open:y,className:`shrink-0`,children:(0,W.jsx)(Mn,{query:p.advanced,runs:e,onChange:se})}):null,(0,W.jsx)(`div`,{ref:M,className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:e.length===0?(0,W.jsx)(re,{className:`border-none`,children:(0,W.jsxs)(te,{children:[(0,W.jsx)(ne,{variant:`icon`,children:(0,W.jsx)(d,{icon:j.flow.icon})}),(0,W.jsx)(oe,{children:`No traces yet`}),(0,W.jsx)(ce,{children:`No runs for the flows on this graph yet. Trigger a flow to see live activity here.`})]})}):T.length===0?(0,W.jsx)(re,{className:`border-none`,children:(0,W.jsxs)(te,{children:[(0,W.jsx)(oe,{children:`No matching traces`}),(0,W.jsx)(ce,{children:`Nothing in this list matches the current search, status, or advanced filters.`})]})}):T.map(e=>(0,W.jsx)(zn,{run:e,selected:e.id===t,onSelect:e=>n(e===t?null:e)},e.id))}),(0,W.jsx)(me,{run:k,onClose:()=>n(null),focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u,navigationRuns:O,onSelectRun:e=>n(e)})]})}function Hn(){let e=_e(),t=xe(),n=ge(!0),{selectedRunId:r,selectedFlowId:i,follow:a,setSelectedRun:o,setSelectedFlow:s}=ke(),c=ie(),l=(0,W.jsx)(ae,{open:c.open,onToggle:c.toggle,noun:`traces`,controlsId:`overview-traces`,dataSlot:`overview-traces-toggle`}),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null);(0,z.useEffect)(()=>{p(null)},[r]);let[m,h]=(0,z.useState)(0),[g,_]=(0,z.useState)(null),v=(0,z.useRef)(null),y=(0,z.useMemo)(()=>new Set(Object.keys(e.data?.flows??{})),[e.data]),b=(0,z.useMemo)(()=>Le(t.data??[],y),[t.data,y]),x=Dn({enabled:!!e.data&&b.length>0,paused:r!=null||u!=null});(0,z.useEffect)(()=>{i&&d(e=>e?.kind===`flow`&&e.flowId===i?e:{kind:`flow`,flowId:i})},[i]);let S=(0,z.useCallback)(e=>{d(e),e?.kind===`flow`?s(e.flowId):s(null)},[s]),w=(0,z.useMemo)(()=>{let e=On(t.data??[],r);return e.size>0?e:i?new Set([i]):x?.flowId?new Set([x.flowId]):e},[t.data,r,i,x?.flowId]),E=(0,z.useMemo)(()=>{let t=new Set,n=e.data?.flows??{};for(let e of w){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},[w,e.data]),D=(0,z.useMemo)(()=>r?t.data?.find(e=>e.id===r)??null:null,[t.data,r]),k=(0,z.useCallback)(e=>{let t=ln(e);t&&S(u&&u.kind===t.kind&&JSON.stringify(u)===JSON.stringify(t)?null:t)},[S,u]),ee=(0,z.useCallback)(()=>{S(null)},[S]),te=(0,z.useCallback)(()=>{h(e=>e+1)},[]);return(0,z.useEffect)(()=>{if(m===0||!D)return;let n=fe(On(t.data??[],D.id),e.data??null);if(n.length===0)return;let r=le(D.durationMs),i=performance.now();return _(n[0]??null),v.current=setInterval(()=>{let e=Math.min(1,(performance.now()-i)/r);_(ue(n,e)),e>=1&&v.current&&(clearInterval(v.current),v.current=null,setTimeout(()=>_(null),400))},60),()=>{v.current&&=(clearInterval(v.current),null),_(null)}},[m,D,t.data,e.data]),(0,W.jsxs)(`div`,{className:T,"data-slot":`flows-page`,children:[(0,W.jsx)(`div`,{className:`flex justify-end px-3 py-1`,children:(0,W.jsx)(Me,{to:`/flows/decisions`,className:`text-sm underline`,children:`Decisions`})}),(0,W.jsxs)(O,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,W.jsx)(A,{panelRef:c.panelRef,collapsible:!0,collapsedSize:0,defaultSize:C.start.defaultSize,minSize:C.start.minSize,maxSize:`50%`,onResize:c.onResize,className:`min-h-0`,children:(0,W.jsx)(`div`,{id:`overview-traces`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`overview-traces`,children:(0,W.jsx)(Vn,{runs:b,selectedRunId:r,onSelect:o,liveStatus:n,manifest:e.data??null,graphFilter:u,onGraphFilterChange:S,focusEffectIndex:f,onFocusEffectChange:p,playbackKey:m,onReplayStart:te,selectedRun:D})})}),c.open?(0,W.jsx)(se,{withHandle:!0}):null,(0,W.jsx)(A,{defaultSize:C.end.defaultSize,minSize:C.end.minSize,className:`min-h-0`,children:(0,W.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:(0,W.jsx)(yn,{manifest:e.data??null,runs:b,graphFilter:u,highlightedFlowIds:w,highlightedNodeIds:E,orchestraLabel:x?.flowId??null,follow:a,activeNodeId:g,onNodeClick:k,onPaneClick:ee,leading:l})})})]})]})}export{Hn 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{$n as d,Cr as f,E as p,F as m,I as h,Qn as g,R as _,tr as v,x as y}from"./shortcut-keys-DTE1sjTC.js";import{C as b,E as x,S,b as C,d as w,m as T,w as E,x as D}from"./explorer-chrome-Dslh2yE8.js";import{a as O,b as k,c as ee,d as te,f as ne,i as A,l as re,n as ie,o as ae,p as oe,r as se,t as j,u as ce}from"./element-icons-C6t8Vlml.js";import{s as M}from"./collapsible-C0AThBZg.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./trace-detail-sheet-DKtr1-K1.js";import{t as he}from"./duration-tone-Bptur2gX.js";import{a as ge,c as _e,i as ve,l as ye,o as be,s as xe}from"./highlighted-json-BKf0PjBK.js";import{C as Se,_ as N,b as P,f as Ce,g as F,m as we,p as Te,v as I,w as Ee,x as De,y as L}from"./request-meta-BTBZ3Ulc.js";import{n as Oe}from"./dagre.esm-B1_XeuLP.js";import{At as ke,a as Ae,c as je,jt as Me,l as Ne,o as Pe}from"./index-Duxus_sG.js";import{a as Fe,c as R,i as Ie,n as Le,o as Re,r as ze,t as Be}from"./cache-glyph-CC1yFJ8A.js";import{t as Ve}from"./agent-disclosure-CiRvA3M9.js";var He=[[`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`}]],z=e(t(),1),B=[`flow`,`signal`,`store`,`clock`,`gate`,`vault`,`channel`,`ai`];function V(e,t,n){return{x:I.cx+t*Math.cos(e)-n.width/2,y:I.cy+t*Math.sin(e)-n.height/2}}function Ue(e){if(e<=0)return[];let t=2*Math.PI/e;return Array.from({length:e},(e,n)=>-Math.PI/2+n*t)}var We=2*Math.PI/B.length;function Ge(e,t,n=I.typeRing){if(t<=0)return[];if(t===1)return[e];let r=(L.type.width+10)/n,i=Math.min(r*(t-1),We*.7);return Array.from({length:t},(n,r)=>e-i/2+r/(t-1)*i)}function Ke(e,t){if(t<=0)return[];let n=I.typeRing,r=I.typeRing+I.typeRow;if(t===1)return[{angle:e,radius:n}];if(t===4)return Je(e,n,r);if(t<=3)return Ge(e,t,n).map(e=>({angle:e,radius:n}));let i=Math.ceil(t/2),a=t-i;return[...Ge(e,i,n).map(e=>({angle:e,radius:n})),...Ge(e,a,r).map(e=>({angle:e,radius:r}))]}function qe(e){return Math.abs(Math.cos(e))*L.type.height+Math.abs(Math.sin(e))*L.type.width}function Je(e,t,n){let r=(qe(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 Ye(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`),B.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`:case`decide`:t.add(`ai`);break;case`secret`:t.add(`vault`)}return B.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}`,ze(t),R(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:Ce.map(e=>({kind:e,label:Te[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=R(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 Ye(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:B.filter(t=>i.get(e)?.has(t)),live:0,errors:0})),s=B.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??R(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(ct(`orbit:elements`,I.elementRing)),s.push(ct(`orbit:types`,I.typeRing)),s.push(ct(`orbit:spokes`,I.spokeRing)),s.push({id:`law:oke`,type:`law`,position:{x:I.cx-L.law.width/2,y:I.cy-L.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:N.leaf,width:L.law.width,height:L.law.height,style:{width:L.law.width,height:L.law.height,overflow:`visible`}});let l=Ue(B.length);if(r.hubs.forEach((e,t)=>{let n=l[t]??0,r=L.hub;s.push({id:`element:${e.element}`,type:`element`,position:V(n,I.elementRing,r),data:{kind:`element`,label:j[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:N.leaf,width:r.width,height:r.height,style:{width:r.width,height:r.height}}),c.push(H(`element:${e.element}`,`law:oke`,e.element,1,!0))}),!i||i===`flow`){let t=L.type;r.hubs.forEach((n,r)=>{let i=l[r]??0,a=et(e,n.element),o=Ke(i,a.length);a.forEach((e,r)=>{let a=o[r]??{angle:i,radius:I.typeRing};s.push({id:e.id,type:`typeChip`,position:V(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:N.leaf,width:t.width,height:t.height,style:{width:t.width,height:t.height}}),c.push(H(e.id,`element:${n.element}`,n.element,1))})})}if(i&&i!==`flow`){let t=Ze(e,i),n=De.store,r=Ue(t.length);t.forEach((e,t)=>{let a=r[t]??0;s.push({id:e.id,type:i,position:V(a,I.spokeRing,n),data:{kind:i,label:e.label,refId:e.id,...e.badge===void 0?{}:{badge:e.badge,facet:e.badge}},draggable:!1,zIndex:N.leaf,width:n.width,height:n.height,style:{width:n.width,height:n.height}}),c.push(H(e.id,`element:${i}`,i,1))})}else{let t=L.unit,n=Ue(r.units.length);r.units.forEach((e,r)=>{let i=n[r]??0;s.push({id:`unit:${e.unit}`,type:`unitChip`,position:V(i,I.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:N.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=R(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 Ye(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(H(`unit:${t.unit}`,e,n,r))}for(let e of r)c.push(H(`unit:${t.unit}`,`element:${e}`,e,1))}}return{nodes:s,edges:c,units:r.units,hubs:r.hubs}}function ct(e,t){let n=t*2;return{id:e,type:`orbit`,position:{x:I.cx-t,y:I.cy-t},data:{kind:`law`,label:``,refId:e},selectable:!1,draggable:!1,zIndex:N.edge,width:n,height:n,style:{width:n,height:n}}}function lt(e,t){return t===`law:oke`?`trunk`:e.startsWith(`type:`)&&t.startsWith(`element:`)?`bind`:`spoke`}function ut(e){return e===`trunk`?.14:e===`bind`?.2:0}function H(e,t,n,r,i=!1){let a=i?`trunk`:lt(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:F.couple,strokeWidth:o,opacity:ut(a)},zIndex:N.edge}}function dt(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 ft(e,t){for(let n of[t,e]){let e=dt(n);if(e)return P[e].accent}return F.couple}function pt(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:${R(r)}`;n.add(a);for(let r of Ye(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 mt(e,t,n={}){let r=n.hoverNodeId??null,i=n.highlightedFlowIds??new Set,a=n.highlightedNodeIds??new Set,o=pt(n.manifest,i),s=o.nodeIds.size>0||a.size>0,c=r!=null,l=r==null?null:ht(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=lt(e.source,e.target),a=c||s?r?1:ut(i)*.35:ut(i);return{...e,animated:r,style:{...e.style,stroke:r?ft(e.source,e.target):F.couple,opacity:a,strokeWidth:r?2.25:e.style?.strokeWidth}}})}}function U(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 ht(e,t){let n=new Set([e]),r=e=>n.add(e);if(e.startsWith(`unit:`)){for(let n of U(t,e)){if(r(n),n.startsWith(`type:`)){for(let e of U(t,n))if(e.startsWith(`element:`)){r(e);for(let n of U(t,e))n===`law:oke`&&r(n)}}if(n.startsWith(`element:`))for(let e of U(t,n))e===`law:oke`&&r(e)}return n}if(e.startsWith(`type:`)){for(let n of U(t,e))r(n);let i=[...n].find(e=>e.startsWith(`element:`));if(i)for(let e of U(t,i))e===`law:oke`&&r(e);return n}if(e.startsWith(`element:`)||e===`law:oke`)for(let n of U(t,e))r(n);return n}var W=n(),gt={flow:j.flow.icon,signal:j.signal.icon,store:j.store.icon,clock:j.clock.icon,gate:j.gate.icon,vault:j.vault.icon,channel:j.channel.icon,ai:j.ai.icon},_t={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 G(e,t){return g(`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`,_t[t],e.dimmed&&`opacity-30 saturate-[0.35]`,e.highlighted&&`z-10`,e.focused&&`z-10`)}function K(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 q({data:e,kind:t,className:n,style:r,children:i,...a}){let o=Ne(),s=P[t];return(0,W.jsx)(je.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 vt({kind:e,size:t=`sm`}){let n=P[e];return(0,W.jsx)(`span`,{className:g(`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,W.jsx)(d,{icon:gt[e],size:t===`md`?17:15,strokeWidth:1.9})})}function J({text:e}){return(0,W.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 yt({type:e,kind:t}){let n=P[t];return(0,W.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,W.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 bt({live:e,errors:t}){return e<=0?null:(0,W.jsx)(`span`,{className:g(`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 xt({elements:e}){return e.length===0?null:(0,W.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1`,"aria-hidden":!0,children:e.map(e=>(0,W.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:P[e].accent},title:j[e].label},e))})}function St({data:e}){return(0,W.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,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.label}),e.badge?(0,W.jsx)(J,{text:e.badge}):null]})})}function Ct({data:e}){let t=e.kind in P?e.kind:`flow`;return(0,W.jsxs)(q,{data:e,kind:t,className:g(G(e,t),`justify-center gap-0 rounded-full px-2`),style:K(t,e),"data-slot":`type-chip`,"data-type":e.refId,children:[(0,W.jsx)(Y,{type:`source`}),(0,W.jsx)(Y,{type:`target`}),(0,W.jsx)(`div`,{className:`min-w-0 truncate text-center text-[10px] leading-none font-medium tracking-wide text-foreground`,children:e.label})]})}function wt({data:e}){return(0,W.jsxs)(q,{data:e,kind:`flow`,className:g(G(e,`flow`),`rounded-full px-2.5`),style:K(`flow`,e),"data-slot":`unit-chip`,"data-unit":e.refId,children:[(0,W.jsx)(Y,{type:`source`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-medium tracking-wide text-foreground uppercase`,children:e.label}),(0,W.jsx)(bt,{live:e.live??0,errors:e.errors??0})]}),(0,W.jsx)(xt,{elements:e.elements??[]})]}),e.badge?(0,W.jsx)(J,{text:e.badge}):null]})}function Tt({data:e}){let t=kt(e.refId)??`flow`,n=P[t];return(0,W.jsxs)(q,{data:e,kind:t,className:g(G(e,t),`flex-col justify-center gap-0.5 rounded-full px-1.5 text-center`),style:{...K(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,W.jsx)(Y,{type:`target`}),(0,W.jsx)(Y,{type:`source`}),(0,W.jsx)(`span`,{className:`text-[18px] font-semibold tracking-tight text-foreground`,title:j[t].label,children:e.label})]})}function Et(e){return e>=40?1.05:e>=12?1.55:2.2}function Dt({data:e}){let t=Ne(),n=e.live??0,r=e.errors??0,[i,a]=(0,z.useState)(0),o=(0,z.useRef)(n);(0,z.useEffect)(()=>{n>o.current&&a(e=>e+1),o.current=n},[n]);let s=n>0,c=Et(n),l=r>0?`var(--color-rose-400)`:`var(--foreground)`;return(0,W.jsxs)(`div`,{className:g(`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,W.jsx)(Y,{type:`target`}),!t&&s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,color:l}}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-ripple`,style:{animationDuration:`${c}s`,animationDelay:`${c/2}s`,color:l}})]}):null,i>0&&!t?(0,W.jsx)(`span`,{"aria-hidden":!0,className:`oke-law-hit`,style:{color:l}},i):null,(0,W.jsx)(je.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,W.jsx)(Ae,{className:`h-7 w-auto text-foreground`})})]})}function Ot(){return(0,W.jsx)(`div`,{className:`pointer-events-none h-full w-full rounded-full border border-dashed border-foreground/15`,"data-slot":`orbit`})}function kt(e){return e in P?e:null}function X({data:e,kind:t,slot:n}){return(0,W.jsxs)(q,{data:e,kind:t,className:G(e,t),style:K(t,e),"data-slot":n,"data-flow-id":t===`flow`?e.refId:void 0,"data-highlighted":e.highlighted?`true`:`false`,children:[(0,W.jsx)(yt,{type:`target`,kind:t}),(0,W.jsx)(Y,{type:`source`}),(0,W.jsx)(vt,{kind:t}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:e.label}),(0,W.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:(0,W.jsx)(J,{text:e.badge??e.plane??e.facet??t})})]}),t===`flow`||t===`signal`?(0,W.jsx)(yt,{type:`source`,kind:t}):null]})}function At({data:e}){return(0,W.jsx)(X,{data:e,kind:`flow`,slot:`flow-node`})}function jt({data:e}){return(0,W.jsx)(X,{data:e,kind:`store`,slot:`store-node`})}function Mt({data:e}){return(0,W.jsx)(X,{data:e,kind:`signal`,slot:`signal-node`})}function Nt({data:e}){return(0,W.jsx)(X,{data:e,kind:`ai`,slot:`ai-node`})}function Pt({data:e}){return(0,W.jsx)(X,{data:e,kind:`clock`,slot:`clock-node`})}function Ft({data:e}){return(0,W.jsx)(X,{data:e,kind:`gate`,slot:`gate-node`})}function It({data:e}){return(0,W.jsx)(X,{data:e,kind:`vault`,slot:`vault-node`})}function Lt({data:e}){return(0,W.jsx)(X,{data:e,kind:`channel`,slot:`channel-node`})}var Rt={unit:St,unitChip:wt,typeChip:Ct,element:Tt,law:Dt,orbit:Ot,flow:At,store:jt,signal:Mt,ai:Nt,clock:Pt,gate:Ft,vault:It,channel:Lt};function zt(e,t){let n=e.flows??{},r=new Set;if(t.kind===`unit`){for(let e of Object.keys(n))R(e)===t.unit&&r.add(e);let e=[];for(let t of r)for(let r of n[t]?.effects?.calls??[])Ee(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??[])Ee(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))Bt(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 Bt(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=Ee(e);return t?n===Se(t.server):n===`flow:${e}`})):!1}var Vt=[`!=`,`>=`,`<=`,`=`,`>`,`<`],Ht={clauses:[]},Ut=[`flow`,`unit`,`trigger`,`plane`,`tenant`,`principal`,`cache`,`replica`,`error`,`buildVersion`,`promptVersion`,`duration`];function Wt(e){if(!e||!e.trim())return Ht;let t=e.split(/\s+AND\s+/i).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t){let t=tn(e);t&&n.push(t)}return{clauses:n}}function Z(e,t){return{clauses:[...e.clauses.filter(e=>e.dimension!==t.dimension),t]}}function Gt(e,t){return{clauses:e.clauses.filter(e=>e.dimension!==t)}}function Kt(e,t){return e.dimension===t.dimension&&e.op===t.op&&e.value===t.value}function qt(e,t){return e.clauses.some(e=>Kt(e,t))}function Jt(e,t){return qt(e,t)?Gt(e,t.dimension):Z(e,t)}function Yt(e){let t=an(e.dimension,e.value);return`${e.dimension} ${e.op} ${t}`}function Xt(e,t){for(let n of t.clauses)if(!on(e,n))return!1;return!0}function Zt(e,t){return t.clauses.length===0?[...e]:e.filter(e=>Xt(e,t))}function Qt(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 $t(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 en(e){let t=new Set(Ut);for(let n of e)for(let e of Object.keys(n.dimensions))t.add(e);return[...t].sort()}function tn(e){let t=null,n=-1;for(let r of Vt){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=nn(r,i);return a===void 0?null:{dimension:r,op:t,value:a}}function nn(e,t){return e===`duration`||e===`duration_ms`?Qt(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 rn(e,t){return an(e,t)}function an(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 on(e,t){let n=$t(e,t.dimension);if(n==null)return t.op===`!=`;let r=t.value;if(t.op===`=`)return sn(n,r);if(t.op===`!=`)return!sn(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 sn(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 cn=new Set(Object.keys(j));function ln(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 cn.has(t)?{kind:`element`,element:t}:null}if(e.startsWith(`type:`)){let t=e.slice(5).split(`:`)[0];return t&&cn.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 un(e){switch(e.kind){case`flow`:return e.flowId;case`signal`:return`signal:${e.signal}`;case`unit`:return e.unit;case`element`:return j[e.element].label;case`resource`:return e.nodeId}}function dn(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 fn(e,t,n){if(t.kind===`flow`)return Xt(e,{clauses:[{dimension:`flow`,op:`=`,value:t.flowId}]});if(t.kind===`unit`)return(e.unit??R(e.flow))===t.unit;if(t.kind===`element`)return t.element===`flow`||Xe(e).includes(t.element);if(t.kind===`resource`)return pn(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 pn(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&&Bt(i,e.flow,t))}function mn(e,t,n){return t?e.filter(e=>fn(e,t,n)):[...e]}function hn(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 gn({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:_}=Pe(),[v,y]=(0,z.useState)(null),b=_===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:_,x=hn(n),S=n?.kind===`element`?n.element:null,C=x===null,w=(0,z.useMemo)(()=>st(e,t,S?{kind:`element`,element:S}:null),[e,t,S]),T=(0,z.useMemo)(()=>Re(!x||!e?e:zt(e,x)),[e,x]),E=(0,z.useMemo)(()=>mt(w.nodes,w.edges,{hoverNodeId:v,highlightedFlowIds:r,highlightedNodeIds:s,manifest:e}),[w.nodes,w.edges,v,r,s,e]),D=(0,z.useMemo)(()=>Ie(T.nodes,r,s,{activeNodeId:d,focusedNodeId:f}),[T.nodes,r,s,d,f]),O=(0,z.useMemo)(()=>Fe(T.edges,D),[T.edges,D]),k=C?E.nodes:D,ee=C?E.edges:O;return(0,z.useEffect)(()=>{g({duration:280,padding:.18})},[C,n,e,g]),(0,z.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,W.jsxs)(`div`,{className:`relative h-full w-full`,children:[n?(0,W.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,W.jsx)(`span`,{className:`text-foreground`,children:`Map`}),(0,W.jsx)(`span`,{"aria-hidden":!0,children:`/`}),(0,W.jsx)(`span`,{className:`truncate`,children:un(n)})]}):(0,W.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,W.jsxs)(W.Fragment,{children:[`Orchestra `,(0,W.jsx)(`span`,{className:`text-foreground normal-case`,children:p})]}):`Hover a unit — spokes light the elements it touches`}),(0,W.jsxs)(i,{nodes:k,edges:ee,nodeTypes:Rt,colorMode:b,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},minZoom:.15,maxZoom:1.6,defaultEdgeOptions:{type:`smoothstep`,zIndex:N.edge},zIndexMode:`manual`,onNodeClick:(e,t)=>m?.(t.id),onPaneClick:()=>h?.(),onNodeMouseEnter:(e,t)=>y(t.id),onNodeMouseLeave:()=>y(null),children:[(0,W.jsx)(u,{gap:24,size:1,color:`color-mix(in oklab, var(--foreground) 14%, transparent)`}),(0,W.jsx)(c,{showInteractive:!1}),(0,W.jsx)(o,{pannable:!0,zoomable:!0,ariaLabel:`Flow graph overview`,bgColor:`var(--card)`,maskColor:`color-mix(in oklab, var(--background) 55%, transparent)`,nodeColor:_n,nodeStrokeColor:vn,nodeStrokeWidth:12,nodeBorderRadius:10})]})]})}function _n(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 vn(e){return e.data.kind===`unit`?`color-mix(in oklab, var(--foreground) 32%, transparent)`:`transparent`}function yn(e){let{leading:t,...n}=e;return(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,"data-slot":`flow-graph`,children:[t?(0,W.jsxs)(`header`,{className:D,children:[t,(0,W.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})]}):null,(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,W.jsx)(l,{children:(0,W.jsx)(gn,{...n})})})]})}var bn=`orch-`;function xn(e){return e.startsWith(bn)}function Sn(e,t){return e&&t}function Cn(e,t=Math.random){let n=e.filter(e=>!xn(e.id)&&e.flow.length>0);return n.length===0?null:n[Math.floor(t()*n.length)]??null}function wn(e,t,n){let r=t-e.startedAt,i=e.flow.replaceAll(`.`,`-`);return{...e,id:`${bn}${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 Tn(e=Math.random){return 1800+Math.floor(e()*1600)}var En=1400;function Dn(e){let t=f(),[n,r]=(0,z.useState)(null),i=(0,z.useRef)(0),a=(0,z.useRef)(null),o=(0,z.useRef)(null),s=(0,z.useRef)(e.paused);return s.current=e.paused,(0,z.useEffect)(()=>{if(!Sn(!1,e.enabled))return;let n=()=>{a.current&&=(clearTimeout(a.current),null)},c=()=>{if(s.current||document.hidden)return;let e=Cn(t.getQueryData(be)??[]);if(!e)return;i.current+=1;let o=wn(e,Date.now(),i.current);t.setQueryData(be,e=>ye(e??[],o)),r({flowId:o.flow,runId:o.id}),n(),a.current=setTimeout(()=>{r(null),a.current=null},En)},l=e=>{o.current=setTimeout(()=>{c(),l(Tn())},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 On(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 kn=[{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`}],An=`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`,jn=`grid grid-cols-[minmax(0,1fr)_1.25rem_minmax(0,1fr)_1.25rem] items-center gap-x-1`;function Mn({query:e,runs:t,onChange:n}){let r=(0,z.useMemo)(()=>en(t),[t]),i=(0,z.useMemo)(()=>[...new Set([...Ut,...r])].sort(),[r]),[a,o]=(0,z.useState)(`trigger`),[s,c]=(0,z.useState)(`=`),[l,u]=(0,z.useState)(`signal`),[d,f]=(0,z.useState)(!1),m=()=>{let t=Wt(`${a} ${s} ${l}`).clauses[0];t&&(n(Z(e,t)),f(!1))};return(0,W.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,W.jsx)(`ul`,{"aria-label":`Active filters`,className:`flex flex-col gap-0.5`,children:e.clauses.map(t=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Nn,{clause:t,onRemove:()=>n(Gt(e,t.dimension))})},t.dimension))}):null,d?(0,W.jsxs)(`div`,{className:jn,"data-slot":`traces-advanced-composer`,children:[(0,W.jsx)(`select`,{"aria-label":`Filter dimension`,className:An,value:a,onChange:e=>o(e.target.value),children:i.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}),(0,W.jsx)(`select`,{"aria-label":`Filter operator`,className:g(An,`text-center text-foreground/70`),value:s,onChange:e=>c(e.target.value),children:[`=`,`!=`,`>`,`<`,`>=`,`<=`].map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}),(0,W.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`&&m()}}),(0,W.jsx)(`button`,{type:`button`,className:$,onClick:m,children:`Add`})]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[kn.map(t=>{let r=Wt(t.expr).clauses[0],i=r!==void 0&&qt(e,r);return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:r===void 0,onClick:()=>{r&&n(Jt(e,r))},className:g($,i?`font-medium text-foreground`:`text-foreground/70`),children:t.label},t.id)}),(0,W.jsx)(`button`,{type:`button`,"aria-expanded":d,className:g($,`ml-auto`,d&&`text-foreground`),onClick:()=>f(e=>!e),children:d?`Cancel`:`Add clause`}),e.clauses.length>0?(0,W.jsx)(`button`,{type:`button`,className:$,onClick:()=>n(Wt(``)),children:`Clear`}):null]})]})}function Nn({clause:e,onRemove:t}){let n=Yt(e);return(0,W.jsxs)(`div`,{className:jn,"data-slot":`traces-advanced-clause`,children:[(0,W.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground/80`,children:e.dimension}),(0,W.jsx)(`span`,{className:`text-center font-mono text-[11px] text-foreground/65`,"aria-hidden":!0,children:e.op}),(0,W.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground`,children:rn(e.dimension,e.value)}),(0,W.jsx)(`button`,{type:`button`,className:g($,`flex size-5 items-center justify-center text-foreground/55 hover:text-destructive`),"aria-label":`Remove ${n}`,onClick:t,children:(0,W.jsx)(d,{icon:v,className:`size-3`})})]})}var Pn={query:``,status:`all`,advanced:Ht};function Fn(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 In(e,t){return Zt(e.filter(e=>!(!Fn(e,t.query)||t.status===`errors`&&e.error===null)),t.advanced)}function Ln(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 Rn(e,t=Date.now()){let n=Ln(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 zn({run:e,selected:t,onSelect:n,copyText:r=async e=>{await navigator.clipboard.writeText(e)}}){let i=Rn(e),a=i.failed,o=de(e.trigger),s=e.cache,[c,l]=(0,z.useState)(null),u=async t=>{t.stopPropagation();try{await r(pe(e)),l(`Copied run id`)}catch{l(`Copy failed`)}};return(0,W.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:g(`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,W.jsx)(`span`,{"aria-hidden":!0,className:g(`absolute inset-y-0 left-0 w-0.5`,t&&!a&&`bg-sky-500`,a&&`bg-destructive`)}),(0,W.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,W.jsx)(`span`,{className:g(`ml-2.5 size-1.5 shrink-0 rounded-full`,a?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:o.label,"aria-hidden":!0,children:(0,W.jsx)(d,{icon:o.icon,className:`size-3.5`})}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.flow}),(0,W.jsx)(Be,{cache:s,dataSlot:`trace-row-cache`}),(0,W.jsx)(`span`,{className:g(`w-10 shrink-0 text-right tabular-nums font-medium`,he(e.durationMs)),children:ve(e.durationMs)}),(0,W.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,W.jsx)(`div`,{className:g(`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,W.jsxs)(m,{children:[(0,W.jsx)(_,{render:e=>(0,W.jsx)(y,{...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,W.jsx)(d,{icon:k,className:`size-3`})})}),(0,W.jsx)(h,{side:`top`,children:`Copy run ID`})]})}),c?(0,W.jsx)(`span`,{className:`sr-only`,role:`status`,children:c}):null]})}var Bn=[{value:`all`,label:`All`,icon:He},{value:`errors`,label:`Errors`,icon:M}];function Vn({runs:e,selectedRunId:t,onSelect:n,liveStatus:r,manifest:i,graphFilter:a,onGraphFilterChange:o,focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u,selectedRun:f}){let[p,v]=(0,z.useState)(Pn),[y,C]=(0,z.useState)(!1);(0,z.useEffect)(()=>{(a?.kind===`flow`||a?.kind===`unit`)&&v(e=>({...e,advanced:dn(e.advanced,a)}))},[a]);let T=(0,z.useMemo)(()=>mn(In(e,p),a,i),[e,p,a,i]),O=(0,z.useMemo)(()=>t?T.some(e=>e.id===t)?T:e:T,[T,e,t]),k=(0,z.useMemo)(()=>f===void 0?t?e.find(e=>e.id===t)??null:null:f,[f,e,t]),A=p.advanced.clauses.length>0,ie=e=>{v(t=>({...t,query:e}))},ae=e=>{v(t=>({...t,status:e}))},se=e=>{v(t=>({...t,advanced:e}))},M=(0,z.useRef)(null);return(0,z.useEffect)(()=>{if(!t||!M.current)return;let e=M.current.querySelector(`[data-run-id="${CSS.escape(t)}"]`);e instanceof HTMLElement&&e.scrollIntoView({block:`nearest`})},[t]),(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`traces-pane`,children:[(0,W.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,W.jsxs)(`div`,{className:g(x,`border-b-0`),children:[(0,W.jsx)(ee,{value:p.query,onChange:e=>ie(e.target.value),placeholder:`Search traces…`,"aria-label":`Search traces`,"data-slot":`traces-search`}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[e.length>0?(0,W.jsxs)(m,{children:[(0,W.jsx)(_,{render:e=>(0,W.jsxs)(`button`,{...e,type:`button`,"aria-expanded":y,"aria-controls":`traces-advanced-panel`,"aria-label":A?`Advanced filters, ${p.advanced.clauses.length} active`:`Advanced filters`,"data-slot":`traces-advanced-toggle`,onClick:t=>{e.onClick?.(t),C(e=>!e)},className:g(w,`relative`,(y||A)&&`text-foreground`),children:[(0,W.jsx)(d,{icon:Oe,className:`size-3`,"aria-hidden":!0}),A?(0,W.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:p.advanced.clauses.length}):null]})}),(0,W.jsx)(h,{side:`bottom`,children:`Advanced`})]}):null,e.length>0?(0,W.jsx)(`span`,{className:`mx-0.5 h-3 w-px bg-border/60`,"aria-hidden":!0}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-0.5 text-[10px] text-muted-foreground`,children:[(0,W.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,W.jsx)(`div`,{className:g(D,`border-t border-b-0`),"data-slot":`traces-filters`,children:(0,W.jsx)(`div`,{className:`flex shrink-0 items-stretch`,role:`group`,"aria-label":`Status filter`,children:Bn.map(({value:e,label:t,icon:n})=>{let r=p.status===e;return(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ae(e),className:g(b,`font-semibold tracking-[0.08em] uppercase`,r?e===`errors`?`text-destructive`:S:E),children:[(0,W.jsx)(d,{icon:n,className:`size-3`,"aria-hidden":!0}),t]},e)})})}):null,e.length>0&&a?(0,W.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,W.jsx)(`span`,{className:`truncate`,children:un(a)}),(0,W.jsx)(`span`,{"aria-hidden":!0,children:`×`})]}):null]}),e.length>0?(0,W.jsx)(Ve,{id:`traces-advanced-panel`,role:`region`,"aria-label":`Advanced filters`,open:y,className:`shrink-0`,children:(0,W.jsx)(Mn,{query:p.advanced,runs:e,onChange:se})}):null,(0,W.jsx)(`div`,{ref:M,className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:e.length===0?(0,W.jsx)(re,{className:`border-none`,children:(0,W.jsxs)(te,{children:[(0,W.jsx)(ne,{variant:`icon`,children:(0,W.jsx)(d,{icon:j.flow.icon})}),(0,W.jsx)(oe,{children:`No traces yet`}),(0,W.jsx)(ce,{children:`No runs for the flows on this graph yet. Trigger a flow to see live activity here.`})]})}):T.length===0?(0,W.jsx)(re,{className:`border-none`,children:(0,W.jsxs)(te,{children:[(0,W.jsx)(oe,{children:`No matching traces`}),(0,W.jsx)(ce,{children:`Nothing in this list matches the current search, status, or advanced filters.`})]})}):T.map(e=>(0,W.jsx)(zn,{run:e,selected:e.id===t,onSelect:e=>n(e===t?null:e)},e.id))}),(0,W.jsx)(me,{run:k,onClose:()=>n(null),focusEffectIndex:s,onFocusEffectChange:c,playbackKey:l,onReplayStart:u,navigationRuns:O,onSelectRun:e=>n(e)})]})}function Hn(){let e=_e(),t=xe(),n=ge(!0),{selectedRunId:r,selectedFlowId:i,follow:a,setSelectedRun:o,setSelectedFlow:s}=ke(),c=ie(),l=(0,W.jsx)(ae,{open:c.open,onToggle:c.toggle,noun:`traces`,controlsId:`overview-traces`,dataSlot:`overview-traces-toggle`}),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null);(0,z.useEffect)(()=>{p(null)},[r]);let[m,h]=(0,z.useState)(0),[g,_]=(0,z.useState)(null),v=(0,z.useRef)(null),y=(0,z.useMemo)(()=>new Set(Object.keys(e.data?.flows??{})),[e.data]),b=(0,z.useMemo)(()=>Le(t.data??[],y),[t.data,y]),x=Dn({enabled:!!e.data&&b.length>0,paused:r!=null||u!=null});(0,z.useEffect)(()=>{i&&d(e=>e?.kind===`flow`&&e.flowId===i?e:{kind:`flow`,flowId:i})},[i]);let S=(0,z.useCallback)(e=>{d(e),e?.kind===`flow`?s(e.flowId):s(null)},[s]),w=(0,z.useMemo)(()=>{let e=On(t.data??[],r);return e.size>0?e:i?new Set([i]):x?.flowId?new Set([x.flowId]):e},[t.data,r,i,x?.flowId]),E=(0,z.useMemo)(()=>{let t=new Set,n=e.data?.flows??{};for(let e of w){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},[w,e.data]),D=(0,z.useMemo)(()=>r?t.data?.find(e=>e.id===r)??null:null,[t.data,r]),k=(0,z.useCallback)(e=>{let t=ln(e);t&&S(u&&u.kind===t.kind&&JSON.stringify(u)===JSON.stringify(t)?null:t)},[S,u]),ee=(0,z.useCallback)(()=>{S(null)},[S]),te=(0,z.useCallback)(()=>{h(e=>e+1)},[]);return(0,z.useEffect)(()=>{if(m===0||!D)return;let n=fe(On(t.data??[],D.id),e.data??null);if(n.length===0)return;let r=le(D.durationMs),i=performance.now();return _(n[0]??null),v.current=setInterval(()=>{let e=Math.min(1,(performance.now()-i)/r);_(ue(n,e)),e>=1&&v.current&&(clearInterval(v.current),v.current=null,setTimeout(()=>_(null),400))},60),()=>{v.current&&=(clearInterval(v.current),null),_(null)}},[m,D,t.data,e.data]),(0,W.jsxs)(`div`,{className:T,"data-slot":`flows-page`,children:[(0,W.jsx)(`div`,{className:`flex justify-end px-3 py-1`,children:(0,W.jsx)(Me,{to:`/flows/decisions`,className:`text-sm underline`,children:`Decisions`})}),(0,W.jsxs)(O,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,W.jsx)(A,{panelRef:c.panelRef,collapsible:!0,collapsedSize:0,defaultSize:C.start.defaultSize,minSize:C.start.minSize,maxSize:`50%`,onResize:c.onResize,className:`min-h-0`,children:(0,W.jsx)(`div`,{id:`overview-traces`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`overview-traces`,children:(0,W.jsx)(Vn,{runs:b,selectedRunId:r,onSelect:o,liveStatus:n,manifest:e.data??null,graphFilter:u,onGraphFilterChange:S,focusEffectIndex:f,onFocusEffectChange:p,playbackKey:m,onReplayStart:te,selectedRun:D})})}),c.open?(0,W.jsx)(se,{withHandle:!0}):null,(0,W.jsx)(A,{defaultSize:C.end.defaultSize,minSize:C.end.minSize,className:`min-h-0`,children:(0,W.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:(0,W.jsx)(yn,{manifest:e.data??null,runs:b,graphFilter:u,highlightedFlowIds:w,highlightedNodeIds:E,orchestraLabel:x?.flowId??null,follow:a,activeNodeId:g,onNodeClick:k,onPaneClick:ee,leading:l})})})]})]})}export{Hn as FlowsPage};
|