okengine 0.23.1 → 0.23.2
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/package.json +1 -1
- package/site/content/docs/ai/mcp.mdx +3 -3
- package/site/content/docs/elements/signal/broadcast.mdx +4 -2
- package/site/content/docs/reference/configuration.mdx +16 -0
- package/site/content/docs/reference/errors.mdx +31 -19
- package/src/compiler/aot.test.ts +3 -2
- package/src/compiler/aot.ts +45 -1
- package/src/compiler/dynamic.ts +1 -1
- package/src/compiler/http-parse.test.ts +101 -0
- package/src/compiler/http-parse.ts +188 -9
- package/src/compiler/interpret.ts +25 -2
- package/src/console/ui-next/dist/assets/{access-page-C_N4qvai.js → access-page-zBMhZnFm.js} +1 -1
- package/src/console/ui-next/dist/assets/{agent-disclosure-Cq1TxniW.js → agent-disclosure-CBj9f7Ju.js} +1 -1
- package/src/console/ui-next/dist/assets/{cache-glyph-BaI4uxZz.js → cache-glyph-D3MY49h3.js} +1 -1
- package/src/console/ui-next/dist/assets/{call-pii-button-DNyK7IIY.js → call-pii-button-L9JxdBhp.js} +1 -1
- package/src/console/ui-next/dist/assets/{collapsible-CRhBJMZR.js → collapsible-BvFaX-Zt.js} +1 -1
- package/src/console/ui-next/dist/assets/{decisions-page-D9twj8Xy.js → decisions-page-DgB76m-X.js} +1 -1
- package/src/console/ui-next/dist/assets/{duration-tone-CsHWlVPU.js → duration-tone-l1DSJ2Vz.js} +1 -1
- package/src/console/ui-next/dist/assets/{flows-page-ZaTJAhR9.js → flows-page-Bb9t1lu6.js} +1 -1
- package/src/console/ui-next/dist/assets/{highlighted-json-DQ-EMAfz.js → highlighted-json-DMvsi3Ti.js} +1 -1
- package/src/console/ui-next/dist/assets/{http-method-Cn_Fl79s.js → http-method-BwhJBTcQ.js} +1 -1
- package/src/console/ui-next/dist/assets/{index-CmRFeWdT.js → index-RhV2jT_7.js} +3 -3
- package/src/console/ui-next/dist/assets/{observability-page-Cn6R_dXz.js → observability-page-BRfUILBq.js} +1 -1
- package/src/console/ui-next/dist/assets/{replica-lag-Bx6EZhSe.js → replica-lag-BsceAzIG.js} +1 -1
- package/src/console/ui-next/dist/assets/{request-meta-DmdiUrfh.js → request-meta-C6lTyCXp.js} +1 -1
- package/src/console/ui-next/dist/assets/{store-page-8P6vGXnn.js → store-page-YmE806bJ.js} +1 -1
- package/src/console/ui-next/dist/assets/{trace-detail-sheet-BfGvpFSv.js → trace-detail-sheet-Di4irS49.js} +1 -1
- package/src/console/ui-next/dist/assets/{tree-expand-toggle-CWdUHbc0.js → tree-expand-toggle-DYeL6Rye.js} +1 -1
- package/src/console/ui-next/dist/assets/{units-page-CZOFZzay.js → units-page-07agasRA.js} +1 -1
- package/src/console/ui-next/dist/assets/{vault-page-ki_ishmX.js → vault-page-CHBck4n_.js} +1 -1
- package/src/console/ui-next/dist/index.html +1 -1
- package/src/console/ui-next/seed-parked-approval.ts +5 -1
- package/src/drivers/journal-postgres.test.ts +84 -1
- package/src/drivers/journal-postgres.ts +282 -32
- package/src/drivers/postgres.test.ts +60 -0
- package/src/drivers/postgres.ts +79 -5
- package/src/drivers/signal-compete.test.ts +6 -2
- package/src/drivers/signal-postgres.test.ts +170 -0
- package/src/drivers/signal-postgres.ts +449 -196
- package/src/drivers/signal-redis.test.ts +224 -0
- package/src/drivers/signal-redis.ts +835 -150
- package/src/elements/ai/approval.test.ts +15 -3
- package/src/elements/ai/approval.ts +15 -9
- package/src/elements/channel/runtime.ts +31 -4
- package/src/elements/channel/sql-ledger.test.ts +404 -0
- package/src/elements/channel/sql-ledger.ts +177 -33
- package/src/elements/clock/chaos-child.ts +12 -2
- package/src/elements/clock/durable.ts +11 -0
- package/src/elements/store/cache-bus.test.ts +121 -0
- package/src/elements/store/cache-bus.ts +278 -0
- package/src/elements/store/cache.test.ts +59 -0
- package/src/elements/store/cache.ts +157 -12
- package/src/elements/store/runtime.ts +44 -2
- package/src/elements/store/sql-errors.test.ts +131 -0
- package/src/elements/store/sql-errors.ts +39 -16
- package/src/elements/store/sql-nested-tx.test.ts +344 -0
- package/src/elements/store/sql-session.ts +183 -3
- package/src/kernel/app.ts +176 -28
- package/src/kernel/auto-registry.test.ts +5 -1
- package/src/kernel/boot-bind/signal.ts +13 -2
- package/src/kernel/boot-bind/store.ts +16 -1
- package/src/kernel/boot.test.ts +2 -2
- package/src/kernel/boot.ts +41 -11
- package/src/kernel/boundary-contract.ts +7 -0
- package/src/kernel/builtin-errors.ts +2 -0
- package/src/kernel/call.test.ts +1 -0
- package/src/kernel/fx-sql-handle.ts +7 -1
- package/src/kernel/horizontal-child.ts +54 -1
- package/src/kernel/horizontal.integration.test.ts +131 -7
- package/src/kernel/idempotency.test.ts +5 -6
- package/src/kernel/journal-boot.test.ts +83 -6
- package/src/kernel/journal.test.ts +44 -0
- package/src/kernel/journal.ts +171 -26
- package/src/mcp/authorization.ts +5 -11
- package/src/mcp/confirmation.ts +203 -38
- package/src/mcp/docs-server.ts +7 -2
- package/src/mcp/index.ts +4 -0
- package/src/mcp/mcp.test.ts +321 -33
- package/src/mcp/server.ts +8 -3
- package/src/mcp/session.ts +7 -0
- package/src/mcp/tools.ts +68 -19
- package/src/runtime/bun.ts +5 -0
- package/src/runtime/types.ts +5 -0
|
@@ -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{$n as r,Cr as i,E as a,F as o,I as s,Qn as c,R as l,c as u,i as d,l as f,o as p,rr as m,s as h,tr as g,u as _,x as v}from"./shortcut-keys-DTE1sjTC.js";import{C as y,D as b,E as x,F as S,I as C,L as w,M as ee,N as T,O as E,P as D,T as O,W as k,_ as A,a as j,b as M,c as N,d as P,f as F,g as I,i as L,m as R,o as z,p as te,u as B,w as V,x as H}from"./explorer-chrome-Dslh2yE8.js";import{i as ne,t as re}from"./http-method-
|
|
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{$n as r,Cr as i,E as a,F as o,I as s,Qn as c,R as l,c as u,i as d,l as f,o as p,rr as m,s as h,tr as g,u as _,x as v}from"./shortcut-keys-DTE1sjTC.js";import{C as y,D as b,E as x,F as S,I as C,L as w,M as ee,N as T,O as E,P as D,T as O,W as k,_ as A,a as j,b as M,c as N,d as P,f as F,g as I,i as L,m as R,o as z,p as te,u as B,w as V,x as H}from"./explorer-chrome-Dslh2yE8.js";import{i as ne,t as re}from"./http-method-BwhJBTcQ.js";import{a as ie,c as ae,h as oe,i as se,n as ce,o as le,r as ue,s as U,t as de}from"./element-icons-C6t8Vlml.js";import{t as fe}from"./UserIcon-DaE2PB5_.js";import{n as pe,t as W}from"./copy-inline-button-BTjPVjRT.js";import{Mt as G,bt as me,ht as he}from"./index-RhV2jT_7.js";import{t as ge}from"./explorer-empty-CIVg7Jgb.js";import{a as K,c as _e,l as q,n as J,o as ve,r as ye,s as be,t as xe}from"./detail-header-Dk5LipF6.js";import{t as Se}from"./confirm-sheet-DZfuJXP4.js";var Ce=[[`path`,{d:`M5 21H19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12.125 12.75H12M12.25 12.75C12.25 12.8881 12.1381 13 12 13C11.8619 13 11.75 12.8881 11.75 12.75C11.75 12.6119 11.8619 12.5 12 12.5C12.1381 12.5 12.25 12.6119 12.25 12.75Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M14.9152 7.61089L13.8078 5.38179C13.019 3.79393 12.6246 3 12 3C11.3754 3 10.981 3.79393 10.1922 5.38179L9.08483 7.61089C8.58107 8.62494 8.32919 9.13197 7.87976 9.24608C7.8485 9.25401 7.81689 9.26043 7.78503 9.26533C7.32682 9.3357 6.89919 8.96678 6.04393 8.22895C4.0124 6.47635 2.99663 5.60004 2.38034 5.94899C2.34045 5.97157 2.30213 5.99686 2.26565 6.02467C1.70197 6.45439 2.09541 7.74136 2.88229 10.3153L4.04783 14.1279C4.47098 15.5121 4.68255 16.2042 5.21787 16.6021C5.75318 17 6.47261 17 7.91147 17L16.0886 16.9999C17.5274 16.9999 18.2468 16.9999 18.7821 16.602C19.3175 16.2041 19.529 15.512 19.9522 14.1279L21.1177 10.3153C21.9046 7.74137 22.298 6.4544 21.7344 6.02468C21.6979 5.99687 21.6595 5.97158 21.6197 5.94899C21.0034 5.60006 19.9876 6.47636 17.9561 8.22896C17.1008 8.96679 16.6732 9.3357 16.215 9.26533C16.1831 9.26043 16.1515 9.25401 16.1202 9.24607C15.6708 9.13197 15.4189 8.62494 14.9152 7.61089Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],Y=e(t(),1);function we(e,t){if(e==null)return`never`;let n=e-t;if(Math.abs(n)<6e4)return`just now`;let r=Ee(Math.abs(n));return n<0?`${r} ago`:`in ${r}`}function Te(e,t){return e==null?`never`:e<=t?`expired`:we(e,t)}function Ee(e){if(e<36e5)return`${Math.floor(e/6e4)}m`;if(e<864e5)return`${Math.floor(e/36e5)}h`;let t=Math.floor(e/864e5);return t<100?`${t}d`:`${Math.floor(t/30)}mo`}var X=864e5;function De(e){let t=/^(\d+)(ms|s|m|h|d)$/.exec(e.trim());if(!t)return 0;let n=Number(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;case`d`:return n*X;default:return 0}}function Oe(e,t,n=``){if(e===`never`)return null;if(e===`30d`)return t+30*X;if(e===`90d`)return t+90*X;let r=De(n);return r>0?t+r:null}var Z=36e5;function ke(e,t){if(e==null)return{choice:`never`,custom:``};let n=e-t;return n<=0?{choice:`never`,custom:``}:Math.abs(n-30*X)<Z?{choice:`30d`,custom:``}:Math.abs(n-90*X)<Z?{choice:`90d`,custom:``}:{choice:`custom`,custom:Me(n)}}var Ae=7*X;function je(e,t){if(e==null||e<=t)return{choice:`90d`,custom:``};let n=e-t;return Math.abs(n-30*X)<=Ae?{choice:`30d`,custom:``}:Math.abs(n-90*X)<=Ae?{choice:`90d`,custom:``}:{choice:`custom`,custom:Me(n)}}function Me(e){return e<=0?``:e>=X&&e%X===0?`${e/X}d`:e>=Z&&e%Z===0?`${e/Z}h`:e>=6e4&&e%6e4==0?`${e/6e4}m`:e>=X?`${Math.max(1,Math.round(e/X))}d`:e>=Z?`${Math.max(1,Math.round(e/Z))}h`:`${Math.max(1,Math.round(e/6e4))}m`}var Ne=[`s`,`m`,`h`,`d`,`ms`],Pe={s:`Seconds`,m:`Minutes`,h:`Hours`,d:`Days`,ms:`Milliseconds`};function Fe(e,t,n){let r=e.trim(),i=t.trim();if(r.length===0&&i.length===0)return null;if(r.length===0||i.length===0||!/^\d+$/.test(r)||!/^\d+$/.test(i))return;let a=Number(r),o=Number(i);if(a<=0||o<=0)return;let s=`${o}${n}`;if(!(De(s)<=0))return{max:a,per:s}}function Ie(e){let t=/^(\d+)(ms|s|m|h|d)$/.exec(e.trim());return t?{count:t[1],unit:t[2]}:{count:``,unit:`m`}}function Le(e){let t=ze(e);return t.length===0?null:Be(t)?`ip`:Ve(t)?`host`:null}function Re(e){let t=new Set,n=[];for(let r of e.split(/[\s,]+/)){let e=ze(r);e.length===0||t.has(e)||Le(e)!=null&&(t.add(e),n.push(e))}return n}function ze(e){let t=e.trim().toLowerCase();if(t=t.replace(/^https?:\/\//,``),t.startsWith(`[`)&&t.includes(`]`)){let e=t.indexOf(`]`),n=t.slice(1,e),r=t.slice(e+1);t=r.startsWith(`:`)||r.startsWith(`/`)?n:`${n}${r}`}let n=t.indexOf(`/`);return n>=0&&(t=t.slice(0,n)),t.endsWith(`.`)&&(t=t.slice(0,-1)),t}function Be(e){return/^\d{1,3}(?:\.\d{1,3}){3}$/.test(e)?e.split(`.`).every(e=>Number(e)<=255):!e.includes(`:`)||!/^[0-9a-f:]+$/.test(e)||e.split(`::`).length>2?!1:e.split(`:`).filter(e=>e.length>0).length>=1}function Ve(e){if(e===`localhost`)return!0;if(e.length>253||e.includes(`:`))return!1;let t=e.split(`.`);return t.length<2?!1:t.every((e,n)=>!(e.length===0||e.length>63||!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(e)||n===t.length-1&&!/^[a-z]{2,63}$/.test(e)))}function He(e){let t=[],n=new Map;for(let r of e){let e=r.indexOf(`:`),i=e<=0?r:r.slice(0,e),a=e<=0?r:r.slice(e+1),o=n.get(i);if(o){o.push({scope:r,action:a});continue}t.push(i),n.set(i,[{scope:r,action:a}])}return t.map(e=>({group:e,items:n.get(e)??[]}))}var Q=n(),Ue=`GET /secure
|
|
2
2
|
Authorization: Bearer <secret>`,We=`{ "ok": true }`;function Ge({keyRow:e,blast:t,now:n,leading:i,onEdit:a,onRefresh:o,onRevoke:s,onRotate:l,rotatePending:u}){let d=e.revokedAt!==null,f=e.expiresAt!==null&&e.expiresAt<=n,p=t?.lastUsedAt??e.lastUsedAt,m=t?.callVolume??0,h=Te(e.expiresAt,n),g=we(p,n),_=e.rateLimit?`${e.rateLimit.max} / ${e.rateLimit.per}`:`none`,y=(0,Y.useMemo)(()=>He(e.scopes),[e.scopes]),x=e.creatorScopes.length,S=x>0&&e.scopes.length<x;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-y-auto`,"data-slot":`access-detail`,"aria-label":`Access key detail`,"aria-live":`polite`,children:[(0,Q.jsx)(xe,{dataSlot:`access-detail-header`,leading:i,icon:(0,Q.jsx)(r,{icon:oe,className:`size-4`}),title:e.name,badge:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,children:[(0,Q.jsx)(r,{icon:e.plane===`operator`?Ce:fe,className:`size-3`,"aria-hidden":!0}),e.plane]}),d?(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-destructive`,children:`revoked`}):null,f&&!d?(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-amber-700 dark:text-amber-400`,children:`expired`}):null,e.unused90d&&!d&&!f?(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-amber-700 dark:text-amber-400`,children:`unused`}):null]}),subtitle:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-foreground/80`,children:e.id}),(0,Q.jsx)(W,{value:e.id,label:`Copy ${e.id}`})]}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(U,{label:`Rename or re-attenuate scopes`,className:`flex self-stretch`,children:(0,Q.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`h-full rounded-none`,disabled:d,onClick:a,children:`Edit`})}),(0,Q.jsx)(U,{label:`Reset expiry from now. The secret stays the same.`,className:`flex self-stretch`,children:(0,Q.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`h-full rounded-none`,"data-slot":`access-refresh`,disabled:d,onClick:o,children:`Refresh`})}),(0,Q.jsx)(U,{label:`Mint a new secret. The current secret stops working after residual TTL.`,className:`flex self-stretch`,children:(0,Q.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`h-full rounded-none`,disabled:u||d,onClick:l,children:`Rotate`})}),(0,Q.jsx)(U,{label:`Irreversible. Residual sessions may continue for the access TTL.`,className:`flex self-stretch`,children:(0,Q.jsx)(v,{type:`button`,variant:`destructive`,size:`sm`,className:`h-full rounded-none`,disabled:d,onClick:s,children:`Revoke`})})]})}),(0,Q.jsx)(Ke,{revoked:d,expired:f,unused:e.unused90d,residual:t?.residualAccessNote}),(0,Q.jsxs)(`div`,{className:H,"data-slot":`access-briefing`,role:`group`,"aria-label":`Usage`,children:[(0,Q.jsx)(Xe,{label:`calls`,value:String(m)}),(0,Q.jsx)(Xe,{label:`used`,value:g,hint:p?new Date(p).toISOString():`No recorded call`,warn:p==null&&!d}),(0,Q.jsx)(Xe,{label:`expires`,value:h,hint:e.expiresAt?new Date(e.expiresAt).toISOString():`No expiry`,warn:f&&!d}),(0,Q.jsx)(Xe,{label:`rate`,value:_})]}),(0,Q.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Scopes`,children:[(0,Q.jsx)($,{title:`Scopes`,meta:S?`${e.scopes.length} of ${x}`:String(e.scopes.length),children:e.scopes.length>0?(0,Q.jsx)(W,{value:e.scopes.join(`
|
|
3
3
|
`),label:`Copy scopes`}):null}),y.length===0?(0,Q.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted-foreground`,children:`No scopes granted.`}):(0,Q.jsx)(`ul`,{"data-slot":`access-scopes`,children:y.map(e=>(0,Q.jsxs)(`li`,{className:A,"aria-label":e.group,children:[(0,Q.jsx)(`span`,{className:c(b,`w-[5.5rem] shrink-0`),children:e.group}),(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-2`,children:e.items.map(e=>(0,Q.jsx)(`span`,{title:e.scope,className:`font-mono text-[11px] text-foreground`,children:e.action},e.scope))}),(0,Q.jsx)(Ze,{value:e.items.map(e=>e.scope).join(`
|
|
4
4
|
`),label:`Copy ${e.group} scopes`})]},e.group))})]}),(0,Q.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Key`,children:[(0,Q.jsx)($,{title:`Key`}),(0,Q.jsxs)(`dl`,{"data-slot":`access-key-facts`,children:[(0,Q.jsx)(Qe,{label:`Issuer`,value:e.creatorId,copy:e.creatorId,copyLabel:`Copy ${e.creatorId}`}),(0,Q.jsx)(Qe,{label:`Created`,value:we(e.createdAt,n),hint:new Date(e.createdAt).toISOString()}),(0,Q.jsx)(Qe,{label:`Expires`,value:h,hint:e.expiresAt?new Date(e.expiresAt).toISOString():void 0,warn:f&&!d}),(0,Q.jsx)(Qe,{label:`Rate`,value:_})]})]}),(0,Q.jsx)(qe,{entries:e.ipAllowlist}),(0,Q.jsx)(Je,{sourceAddresses:t?.sourceAddresses??[],residual:t?.residualAccessNote,lastUsed:p,now:n}),(0,Q.jsx)(Ye,{scopes:e.scopes})]})}function Ke({revoked:e,expired:t,unused:n,residual:r}){return e?(0,Q.jsx)(`section`,{className:c(H,`border-destructive/25 bg-destructive/5`),"aria-label":`Revoked`,role:`status`,children:(0,Q.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-destructive`,children:[`Revoked`,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,r??`This secret no longer authenticates.`]})]})}):t?(0,Q.jsx)(`section`,{className:c(H,`border-amber-500/25 bg-amber-500/5`),"aria-label":`Expired`,role:`status`,children:(0,Q.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-amber-900 dark:text-amber-300`,children:[`Expired`,r?(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,r]}):null]})}):n?(0,Q.jsx)(`section`,{className:c(H,`border-amber-500/25 bg-amber-500/5`),"aria-label":`Unused`,role:`status`,children:(0,Q.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-amber-900 dark:text-amber-300`,children:[`No calls in 90 days`,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:` · rotate or revoke`})]})}):null}function qe({entries:e}){return(0,Q.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Allow`,children:[(0,Q.jsx)($,{title:`Allow`,meta:e.length>0?String(e.length):`any`}),e.length===0?(0,Q.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted-foreground`,children:`Any origin.`}):(0,Q.jsx)(`ul`,{"data-slot":`access-allow`,children:e.map(e=>{let t=Le(e);return(0,Q.jsxs)(`li`,{className:A,children:[(0,Q.jsx)(`span`,{className:c(b,`w-[5.5rem] shrink-0`),children:t===`ip`?`IP`:t===`host`?`Host`:`—`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px]`,children:e}),(0,Q.jsx)(Ze,{value:e,label:`Copy ${e}`})]},e)})})]})}function Je({sourceAddresses:e,residual:t,lastUsed:n,now:r}){return(0,Q.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Usage`,children:[(0,Q.jsx)($,{title:`Usage`,meta:n?we(n,r):`never`}),e.length===0?(0,Q.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted-foreground`,children:`No observed source IPs.`}):(0,Q.jsx)(`ul`,{"data-slot":`access-sources`,children:e.map(e=>(0,Q.jsxs)(`li`,{className:A,children:[(0,Q.jsx)(`span`,{className:c(b,`w-[5.5rem] shrink-0`),children:`IP`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px]`,children:e}),(0,Q.jsx)(Ze,{value:e,label:`Copy ${e}`})]},e))}),t?(0,Q.jsx)(`p`,{className:`border-t border-border/60 px-2 py-1.5 text-[11px] text-muted-foreground`,children:t}):null]})}function Ye({scopes:e}){return(0,Q.jsxs)(`section`,{"data-slot":`access-call-example`,children:[(0,Q.jsx)($,{title:`Request`,children:(0,Q.jsx)(W,{value:Ue,label:`Copy request`})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 border-b border-border/60`,children:[(0,Q.jsx)(`div`,{className:c(`w-1 shrink-0 self-stretch`,ne(`GET`)),"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:c(`shrink-0 font-mono text-[10px] font-semibold tracking-[0.08em] uppercase`,E(re(`GET`))),children:`GET`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground select-all`,children:`/secure`})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 border-t border-border/60 px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`w-[7.5rem] shrink-0 truncate font-mono text-[11px] font-medium text-sky-600 dark:text-sky-400`,children:`Authorization`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground`,children:`Bearer <secret>`})]})]})]}),(0,Q.jsx)($,{title:`Response`,children:(0,Q.jsx)(W,{value:We,label:`Copy response`})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 border-b border-border/60`,children:[(0,Q.jsx)(`div`,{className:`w-1 shrink-0 self-stretch bg-emerald-500`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 px-2.5 py-2 font-mono text-[11px] text-foreground/80 select-all`,children:We})]}),(0,Q.jsxs)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted-foreground`,children:[`Seed the Bearer secret from create / rotate. The key is the issuer; gates see`,` `,e.join(`, `)||`its scopes`,`.`]})]})}function $({title:e,meta:t,children:n}){return(0,Q.jsxs)(`header`,{className:c(H,`items-center gap-2 px-2`),children:[(0,Q.jsx)(`h3`,{className:c(b,`shrink-0 leading-none`),children:e}),t?(0,Q.jsx)(`span`,{className:c(N,!n&&`ml-auto`),children:t}):null,n?(0,Q.jsx)(`div`,{className:`ml-auto flex items-center`,children:n}):null]})}function Xe({label:e,value:t,hint:n,warn:r=!1}){return(0,Q.jsxs)(`span`,{title:n,className:c(y,V,`gap-1.5`),children:[(0,Q.jsx)(`span`,{className:`tracking-[0.08em] uppercase`,children:e}),(0,Q.jsx)(`span`,{className:c(`font-mono tabular-nums text-foreground`,r&&`text-amber-800 dark:text-amber-400`),children:t})]})}function Ze({value:e,label:t}){return(0,Q.jsx)(`div`,{className:`opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,children:(0,Q.jsx)(W,{value:e,label:t})})}function Qe({label:e,value:t,hint:n,copy:r,copyLabel:i,warn:a=!1}){return(0,Q.jsxs)(`div`,{className:A,children:[(0,Q.jsx)(`dt`,{className:c(b,`w-[5.5rem] shrink-0`),children:e}),(0,Q.jsx)(`dd`,{className:c(`min-w-0 flex-1 truncate font-mono text-[11px]`,a&&`text-amber-800 dark:text-amber-400`),title:n,children:t}),r?(0,Q.jsx)(Ze,{value:r,label:i??`Copy ${e}`}):null]})}var $e=[`console.access.list`];function et(){return m({queryKey:$e,queryFn:async()=>{let e=await D();if(e.error||!e.data)throw Error(e.error?.message??`Empty access list`);return e.data}})}function tt({rows:e,selectedKey:t,query:n,loading:r=!1,onSelect:i}){let a=e.filter(e=>e.plane===`user`),o=e.filter(e=>e.plane===`operator`);return(0,Q.jsxs)(`div`,{id:`access-list`,"data-slot":`access-list`,className:`min-h-0 flex-1 overflow-y-auto`,children:[r&&e.length===0?(0,Q.jsx)(`p`,{className:te,children:`Loading…`}):null,!r&&e.length===0&&n.trim().length>0?(0,Q.jsx)(`p`,{className:te,children:`No keys match.`}):null,(0,Q.jsx)(nt,{label:`User`,icon:fe,rows:a,selectedKey:t,onSelect:i}),(0,Q.jsx)(nt,{label:`Operator`,icon:Ce,rows:o,selectedKey:t,onSelect:i})]})}function nt(e){return(0,Q.jsxs)(`section`,{className:L,"aria-label":e.label,children:[(0,Q.jsxs)(`div`,{className:j,children:[(0,Q.jsx)(r,{icon:e.icon,className:c(F,`text-muted-foreground`),"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:c(z,`flex-1`),children:e.label}),(0,Q.jsx)(`span`,{className:N,children:e.rows.length})]}),e.rows.map(t=>{let n=t.id===e.selectedKey,i=t.revokedAt!==null;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`access-key-row`,className:c(A,n&&`bg-muted/70 text-foreground`),onClick:()=>e.onSelect(t.id),children:[(0,Q.jsx)(`span`,{className:c(I,n&&`bg-sky-500`)}),(0,Q.jsx)(r,{icon:oe,className:c(F,`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:c(`min-w-0 truncate`,i&&`text-muted-foreground line-through`),children:t.name}),i?(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`revoked`}):t.unused90d?(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-amber-700 dark:text-amber-400`,children:`unused`}):(0,Q.jsx)(`span`,{className:c(`ml-auto tabular-nums text-[10px] text-muted-foreground`),children:t.scopes.length})]},t.id)})]})}function rt({entries:e,rateMax:t,rateCount:n,rateUnit:i,onEntries:u,onRateMax:d,onRateCount:f,onRateUnit:p}){let[m,h]=(0,Y.useState)(``),_=Re(m),v=m.trim().length>0&&_.length===0,x=()=>{if(_.length===0)return;let t=new Set(e),n=[...e];for(let e of _)t.has(e)||(t.add(e),n.push(e));u(n),h(``)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`border-b border-border/50`,"data-slot":`access-allow-field`,children:[(0,Q.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,Q.jsx)(`p`,{className:`flex h-8 w-[5.5rem] shrink-0 items-center px-4 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Allow`}),(0,Q.jsx)(a,{value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())},placeholder:`203.0.113.4 or ci.example.com`,autoComplete:`off`,"aria-label":`Add allow entry`,"aria-invalid":v,flat:!0,className:c(J,`min-w-0 flex-1 font-mono`)}),e.length>0?(0,Q.jsx)(`span`,{className:c(N,`flex h-8 items-center pr-2`),children:e.length}):null,(0,Q.jsx)(`button`,{type:`button`,className:c(P,`h-8`),"aria-label":`Add allow entry`,disabled:_.length===0,onClick:x,children:(0,Q.jsx)(r,{icon:pe,className:`size-3.5`,"aria-hidden":!0})})]}),v?(0,Q.jsx)(`p`,{className:`border-t border-border/50 px-4 py-2 text-[11px] text-destructive`,children:`Need an IP or host — 203.0.113.4, ::1, localhost, or ci.example.com.`}):e.length===0?(0,Q.jsx)(`p`,{className:`border-t border-border/50 px-4 py-2 text-[11px] text-muted-foreground`,children:`Any client. Add an IP or host.`}):(0,Q.jsx)(`div`,{role:`list`,"aria-label":`Allow list`,children:e.map(t=>{let n=Le(t);return(0,Q.jsxs)(`div`,{role:`listitem`,"data-slot":`access-allow-entry`,"data-kind":n??`invalid`,className:c(A,`last:border-b-0`),children:[(0,Q.jsx)(`span`,{className:c(b,`w-[5.5rem] shrink-0 px-1.5`,n==null&&`text-destructive`),children:n===`ip`?`IP`:n===`host`?`Host`:`Bad`}),(0,Q.jsx)(`span`,{className:c(`min-w-0 truncate font-mono text-[11px]`,n==null&&`text-destructive`),children:t}),(0,Q.jsx)(`button`,{type:`button`,className:c(B,`ml-auto opacity-0 group-hover:opacity-100 focus-visible:opacity-100`),"aria-label":`Remove ${t}`,onClick:()=>u(e.filter(e=>e!==t)),children:(0,Q.jsx)(r,{icon:g,className:`size-3`,"aria-hidden":!0})})]},t)})})]}),(0,Q.jsxs)(`div`,{className:`flex items-stretch border-b border-border/50`,"data-slot":`access-rate-field`,children:[(0,Q.jsx)(`p`,{className:`flex h-8 w-[5.5rem] shrink-0 items-center px-4 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Rate`}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-stretch border-r border-border/50`,children:[(0,Q.jsx)(`span`,{className:`flex h-8 shrink-0 items-center pl-1 text-[10px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Max`}),(0,Q.jsx)(a,{value:t,onChange:e=>d(e.target.value),placeholder:`none`,inputMode:`numeric`,autoComplete:`off`,"aria-label":`Rate max`,flat:!0,className:c(J,`min-w-0 flex-1 px-2 font-mono tabular-nums`)})]}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-stretch`,children:[(0,Q.jsx)(`span`,{className:`flex h-8 shrink-0 items-center pl-2 text-[10px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Every`}),(0,Q.jsx)(a,{value:n,onChange:e=>f(e.target.value),placeholder:`1`,inputMode:`numeric`,autoComplete:`off`,"aria-label":`Rate window`,flat:!0,className:c(J,`min-w-0 flex-1 px-2 font-mono tabular-nums`)})]}),(0,Q.jsx)(`div`,{className:`flex h-8 shrink-0 items-stretch`,role:`group`,"aria-label":`Rate unit`,children:Ne.map(e=>(0,Q.jsxs)(o,{children:[(0,Q.jsx)(l,{render:t=>(0,Q.jsx)(`button`,{...t,type:`button`,"aria-pressed":i===e,"aria-label":Pe[e],onClick:n=>{t.onClick?.(n),p(e)},className:c(y,`h-8 px-1.5 font-mono font-semibold`,i===e?O:V),children:e})}),(0,Q.jsx)(s,{side:`bottom`,className:`text-[11px]`,children:Pe[e]})]},e))})]})]})}function it({expires:e,customExpires:t,onExpires:n,onCustomExpires:r}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ve,{label:`Expires`,children:[(0,Q.jsx)(K,{active:e===`never`,onClick:()=>n(`never`),children:`never`}),(0,Q.jsx)(K,{active:e===`30d`,onClick:()=>n(`30d`),children:`30d`}),(0,Q.jsx)(K,{active:e===`90d`,onClick:()=>n(`90d`),children:`90d`}),(0,Q.jsx)(K,{active:e===`custom`,onClick:()=>n(`custom`),children:`custom`})]}),e===`custom`?(0,Q.jsx)(_e,{label:`Duration`,hint:`7d · 12h · 30m`,children:(0,Q.jsx)(a,{value:t,onChange:e=>r(e.target.value),placeholder:`7d`,autoComplete:`off`,"aria-label":`Custom expiry duration`,flat:!0,className:c(J,`font-mono`)})}):null]})}function at({value:e,placeholder:t,label:n,onChange:i}){return(0,Q.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,Q.jsx)(r,{icon:he,className:`pointer-events-none absolute top-1/2 left-3 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,Q.jsx)(a,{value:e,onChange:e=>i(e.target.value),placeholder:t,"aria-label":n,autoComplete:`off`,flat:!0,className:c(ye)})]})}function ot({scopes:e,selected:t,empty:n,onChange:r}){let[i,a]=(0,Y.useState)(``),o=new Set(t),s=(0,Y.useMemo)(()=>st(e,i),[e,i]),l=(0,Y.useMemo)(()=>He(s),[s]),u=e.join(`\0`);return(0,Y.useEffect)(()=>{a(``)},[u]),(0,Q.jsxs)(`div`,{className:`border-b border-border/50`,"data-slot":`access-scope-field`,children:[(0,Q.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,Q.jsx)(`p`,{className:`flex h-8 w-[5.5rem] shrink-0 items-center px-4 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Scopes`}),e.length>0?(0,Q.jsx)(at,{value:i,placeholder:`Search scopes`,label:`Search scopes`,onChange:a}):null]}),e.length===0?(0,Q.jsx)(`p`,{className:`border-t border-border/50 px-4 py-3 text-[11px] text-muted-foreground`,children:n}):s.length===0?(0,Q.jsx)(`p`,{className:`border-t border-border/50 px-4 py-3 text-[11px] text-muted-foreground`,children:`No scopes match.`}):(0,Q.jsx)(`div`,{className:`max-h-56 overflow-y-auto`,role:`group`,"aria-label":`Scopes`,children:l.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-stretch border-t border-border/50`,role:`group`,"aria-label":e.group,children:[(0,Q.jsx)(`p`,{className:`flex w-[5.5rem] shrink-0 items-center px-4 font-mono text-[10px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:e.group}),(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-stretch`,children:e.items.map(e=>{let n=o.has(e.scope);return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":n,"aria-label":e.scope,"data-slot":`access-scope-chip`,title:e.scope,onClick:()=>{r(n?t.filter(t=>t!==e.scope):[...t,e.scope])},className:c(`inline-flex h-8 min-w-0 items-center px-2 font-mono text-[10px] font-semibold outline-none select-none`,`focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-inset`,n?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e.action},e.scope)})})]},e.group))})]})}function st(e,t){let n=t.trim().toLowerCase();return n.length===0?e:e.filter(e=>e.toLowerCase().includes(n))}function ct({open:e,users:t,userScopes:n,operatorScopes:r,pending:i,error:o,onOpenChange:s,onSubmit:l}){let[m,g]=(0,Y.useState)(`user`),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)([]),[w,ee]=(0,Y.useState)(`never`),[T,E]=(0,Y.useState)(``),[D,O]=(0,Y.useState)([]),[k,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(`m`),[L,R]=(0,Y.useState)(``),z=t.find(e=>e.id===b)??null,te=(0,Y.useMemo)(()=>{let e=L.trim().toLowerCase(),n=e.length===0?t:t.filter(t=>t.name.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||t.email.toLowerCase().includes(e));return z&&!n.some(e=>e.id===z.id)?[z,...n]:n},[t,L,z]),B=(0,Y.useMemo)(()=>m===`operator`?r:z==null?[]:z.scopes.length>0?z.scopes:n,[m,n,r,z]);(0,Y.useEffect)(()=>{e||(g(`user`),y(``),x(``),C([]),ee(`never`),E(``),O([]),j(``),N(``),F(`m`),R(``))},[e]),(0,Y.useEffect)(()=>{C(e=>{let t=e.filter(e=>B.includes(e));if(t.length>0)return t;let n=B[0];return n?[n]:[]})},[B]);let V=De(T),H=Fe(k,M,P),ne=v.trim().length>0&&S.length>0&&!i&&H!==void 0&&(m===`operator`||b.length>0)&&(w!==`custom`||V>0);return(0,Q.jsx)(d,{open:e,modal:!1,disablePointerDismissal:!0,onOpenChange:s,children:(0,Q.jsxs)(p,{side:`right`,showOverlay:!1,className:`gap-0 p-0 data-[side=right]:sm:max-w-md`,"data-slot":`access-create-sheet`,children:[(0,Q.jsxs)(f,{className:`gap-1 border-b border-border/50`,children:[(0,Q.jsx)(_,{className:`text-sm`,children:`Create API key`}),(0,Q.jsx)(h,{className:`text-[11px]`,children:m===`user`?`User-plane keys require an issuer. The key cannot exceed that user's grants.`:`Operator keys inherit the actor ceiling. Absence is impossible — only grantable scopes appear.`})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Q.jsxs)(`div`,{className:`flex items-stretch border-b border-border/50`,"data-slot":`access-name-field`,children:[(0,Q.jsx)(`p`,{className:`flex h-8 w-[5.5rem] shrink-0 items-center px-4 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Name`}),(0,Q.jsx)(a,{value:v,onChange:e=>y(e.target.value),placeholder:`CI deploy`,autoComplete:`off`,"aria-label":`Key name`,flat:!0,className:c(J,`min-w-0 flex-1`)})]}),(0,Q.jsxs)(ve,{label:`Plane`,children:[(0,Q.jsx)(K,{active:m===`user`,icon:fe,onClick:()=>{g(`user`)},children:`user`}),(0,Q.jsx)(K,{active:m===`operator`,icon:Ce,onClick:()=>{g(`operator`),x(``),R(``)},children:`operator`})]}),(0,Q.jsx)(it,{expires:w,customExpires:T,onExpires:ee,onCustomExpires:E}),(0,Q.jsx)(rt,{entries:D,rateMax:k,rateCount:M,rateUnit:P,onEntries:O,onRateMax:j,onRateCount:N,onRateUnit:F}),m===`user`?(0,Q.jsxs)(`div`,{className:`border-b border-border/50`,"data-slot":`access-issuer-field`,children:[(0,Q.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,Q.jsx)(`p`,{className:`flex h-8 w-[5.5rem] shrink-0 items-center px-4 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Issuer`}),t.length>0?(0,Q.jsx)(at,{value:L,placeholder:`Search users`,label:`Search users`,onChange:R}):null]}),t.length===0?(0,Q.jsx)(`p`,{className:`border-t border-border/50 px-4 py-3 text-[11px] text-muted-foreground`,children:`No users on this plane.`}):te.length===0?(0,Q.jsx)(`p`,{className:`border-t border-border/50 px-4 py-3 text-[11px] text-muted-foreground`,children:`No users match.`}):(0,Q.jsx)(`div`,{className:`max-h-56 overflow-y-auto`,children:te.map(e=>{let t=e.id===b;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`access-creator-user`,"aria-pressed":t,className:c(A,t&&`bg-muted/70 text-foreground`),onClick:()=>x(e.id),children:[(0,Q.jsx)(`span`,{className:c(I,t&&`bg-sky-500`)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] text-muted-foreground`,children:e.id})]},e.id)})})]}):null,(0,Q.jsx)(ot,{scopes:B,selected:S,empty:m===`user`&&b.length===0?`Select an issuer to see grantable scopes.`:m===`user`?`This user has no grants.`:`No grantable scopes on this plane.`,onChange:C}),o?(0,Q.jsx)(be,{slot:`access-create-error`,children:o}):null]}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(q,{split:!0,onClick:()=>s(!1),disabled:i,children:`Cancel`}),(0,Q.jsx)(q,{variant:`default`,disabled:!ne,"data-slot":`access-create-submit`,onClick:()=>{if(H===void 0)return;let e=Oe(w,Date.now(),T);l({plane:m,name:v.trim(),scopes:S,...m===`user`?{creatorUserId:b}:{},...e==null?{}:{expiresAt:e},...H==null?{}:{rateLimit:H},...D.length>0?{ipAllowlist:D}:{}})},children:i?`Creating…`:`Create`})]})]})})}function lt({open:e,keyRow:t,users:n,operators:i,operatorScopes:o,pending:s,error:l,now:m=Date.now(),onOpenChange:g,onSubmit:v}){let y=ke(t.expiresAt,m),[b,x]=(0,Y.useState)(t.name),[S,C]=(0,Y.useState)(t.scopes),[w,ee]=(0,Y.useState)(y.choice),[T,E]=(0,Y.useState)(y.custom),[D,O]=(0,Y.useState)(t.ipAllowlist),k=Ie(t.rateLimit?.per??``),[A,j]=(0,Y.useState)(t.rateLimit?String(t.rateLimit.max):``),[M,N]=(0,Y.useState)(k.count),[P,F]=(0,Y.useState)(k.unit);(0,Y.useEffect)(()=>{if(!e)return;let n=ke(t.expiresAt,m);x(t.name),C(t.scopes),ee(n.choice),E(n.custom),O(t.ipAllowlist);let r=Ie(t.rateLimit?.per??``);j(t.rateLimit?String(t.rateLimit.max):``),N(r.count),F(r.unit)},[e,t.id]);let I=t.creatorId??``,L=(0,Y.useMemo)(()=>I.length===0?null:n.find(e=>e.id===I)??i.find(e=>e.id===I)??null,[I,i,n]),R=L?L.name.trim()||L.email.trim()||L.id:I||`Unknown`,z=(0,Y.useMemo)(()=>{let e=t.creatorScopes??[];return e.length>0?e:t.plane===`operator`?L&&L.scopes.length>0?L.scopes:o:L?.scopes??[]},[L,t.creatorScopes,t.plane,o]),te=Array.from(new Set([...z,...t.scopes])),B=De(T),V=Fe(A,M,P),H=b.trim().length>0&&S.length>0&&!s&&V!==void 0&&(w!==`custom`||B>0);return(0,Q.jsx)(d,{open:e,modal:!1,disablePointerDismissal:!0,onOpenChange:g,children:(0,Q.jsxs)(p,{side:`right`,showOverlay:!1,className:`gap-0 p-0 data-[side=right]:sm:max-w-md`,"data-slot":`access-edit-sheet`,children:[(0,Q.jsxs)(f,{className:`gap-1 border-b border-border/50`,children:[(0,Q.jsx)(_,{className:`text-sm`,children:`Edit key`}),(0,Q.jsx)(h,{className:`text-[11px]`,children:`Change name, expiry, allow, rate, and scopes. Issuer stays frozen.`})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Q.jsxs)(`div`,{className:`flex items-stretch border-b border-border/50`,"data-slot":`access-name-field`,children:[(0,Q.jsx)(`p`,{className:`flex h-8 w-[5.5rem] shrink-0 items-center px-4 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Name`}),(0,Q.jsx)(a,{value:b,onChange:e=>x(e.target.value),placeholder:`CI deploy`,autoComplete:`off`,"aria-label":`Key name`,flat:!0,className:c(J,`min-w-0 flex-1`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-stretch border-b border-border/50`,"data-slot":`access-issuer-field`,children:[(0,Q.jsx)(`p`,{className:`flex h-8 w-[5.5rem] shrink-0 items-center px-4 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Issuer`}),(0,Q.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1.5 px-4 text-[12px] text-muted-foreground`,"aria-label":`Issuer ${R}`,children:[(0,Q.jsx)(r,{icon:t.plane===`operator`?Ce:fe,className:`size-3 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:R})]}),I.length>0&&I!==R?(0,Q.jsx)(`span`,{className:`flex h-8 shrink-0 items-center pr-4 font-mono text-[10px] text-muted-foreground`,children:I}):null]}),(0,Q.jsx)(it,{expires:w,customExpires:T,onExpires:ee,onCustomExpires:E}),(0,Q.jsx)(rt,{entries:D,rateMax:A,rateCount:M,rateUnit:P,onEntries:O,onRateMax:j,onRateCount:N,onRateUnit:F}),(0,Q.jsx)(ot,{scopes:te,selected:S,empty:t.plane===`user`&&L==null?`Issuer is gone. Only scopes already on this key remain.`:t.plane===`user`?`This issuer has no grants.`:`No grantable scopes on this plane.`,onChange:C}),l?(0,Q.jsx)(be,{slot:`access-edit-error`,children:l}):null]}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(q,{split:!0,onClick:()=>g(!1),disabled:s,children:`Cancel`}),(0,Q.jsx)(q,{variant:`default`,disabled:!H,"data-slot":`access-edit-submit`,onClick:()=>{V!==void 0&&v({name:b.trim(),scopes:S,expiresAt:Oe(w,Date.now(),T),rateLimit:V,ipAllowlist:D})},children:s?`Saving…`:`Save`})]})]})})}function ut({open:e,keyRow:t,pending:n,error:r,now:i=Date.now(),onOpenChange:a,onSubmit:o}){let s=je(t.expiresAt,i),[c,l]=(0,Y.useState)(s.choice),[m,g]=(0,Y.useState)(s.custom);(0,Y.useEffect)(()=>{if(!e)return;let n=je(t.expiresAt,i);l(n.choice),g(n.custom)},[e,t.id]);let v=De(m);return(0,Q.jsx)(d,{open:e,modal:!1,disablePointerDismissal:!0,onOpenChange:a,children:(0,Q.jsxs)(p,{side:`right`,showOverlay:!1,className:`gap-0 p-0 data-[side=right]:sm:max-w-md`,"data-slot":`access-refresh-sheet`,children:[(0,Q.jsxs)(f,{className:`gap-1 border-b border-border/50`,children:[(0,Q.jsx)(_,{className:`text-sm`,children:`Refresh expiry`}),(0,Q.jsx)(h,{className:`text-[11px]`,children:`Reset the deadline from now. The secret does not change.`})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Q.jsx)(it,{expires:c,customExpires:m,onExpires:l,onCustomExpires:g}),r?(0,Q.jsx)(be,{slot:`access-refresh-error`,children:r}):null]}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(q,{split:!0,onClick:()=>a(!1),disabled:n,children:`Cancel`}),(0,Q.jsx)(q,{variant:`default`,disabled:!(!n&&(c!==`custom`||v>0)),"data-slot":`access-refresh-submit`,onClick:()=>{o(Oe(c,Date.now(),m))},children:n?`Refreshing…`:`Refresh`})]})]})})}function dt({secret:e,title:t=`New API key`,onDismiss:n}){let[r,i]=(0,Y.useState)(!1);return(0,Q.jsx)(d,{open:e!==null,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(p,{side:`right`,showOverlay:!1,className:`gap-0 p-0 data-[side=right]:sm:max-w-md`,"data-slot":`access-secret-sheet`,children:[(0,Q.jsxs)(f,{className:`gap-1 border-b border-border/50`,children:[(0,Q.jsx)(_,{className:`text-sm`,children:t}),(0,Q.jsx)(h,{className:`text-[11px]`,children:`Shown once. Store it offline. This Console process does not keep it for you.`})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Q.jsx)(`p`,{className:`border-b border-border/50 px-4 py-3 font-mono text-[11px] break-all`,children:e}),(0,Q.jsx)(`p`,{className:`px-4 py-3 text-[11px] text-muted-foreground`,role:`status`,children:`Copying puts the secret on the clipboard. Anyone with this device can read it until you clear it.`})]}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(q,{split:!0,disabled:!e,onClick:()=>{e&&(navigator.clipboard?.writeText(e),i(!0))},children:r?`Copied`:`Copy (clipboard warning)`}),(0,Q.jsx)(q,{variant:`destructive`,onClick:()=>{i(!1),n()},children:`I have stored this key`})]})]})})}function ft(){let e=et(),t=i(),{query:n,selectedKey:a,action:o,setQuery:s,setSelectedKey:c,setAction:l}=me(),u=ce(),[d]=(0,Y.useState)(()=>Date.now()),[f,p]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(`New API key`),_=(0,Y.useMemo)(()=>{let t=e.data?.userPlane.keys??[],n=e.data?.operatorPlane.keys??[];return[...t,...n]},[e.data]),v=(0,Y.useMemo)(()=>{let e=n.trim().toLowerCase();return e?_.filter(t=>t.name.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||t.scopes.some(t=>t.toLowerCase().includes(e))):_},[_,n]),y=v.find(e=>e.id===a)??_.find(e=>e.id===a),b=m({queryKey:[`console.access.blast`,y?.id],queryFn:async()=>{if(!y)throw Error(`no key`);let e=await T(y.id);if(e.error||!e.data)throw Error(e.error?.message??`blast failed`);return e.data},enabled:y!==void 0});(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(t instanceof HTMLElement){let e=t.tagName;if(e===`INPUT`||e===`TEXTAREA`||t.isContentEditable)return}e.preventDefault(),document.querySelector(`[data-slot='access-search-input']`)?.focus()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let E=()=>{t.invalidateQueries({queryKey:$e})},D=G({mutationFn:ee,onSuccess:e=>{if(e.error||!e.data)throw Error(e.error?k(e.error):`create failed`);g(`New API key`),p(e.data.secret),c(e.data.key.id),l(null),E()}}),O=G({mutationFn:e=>C({keyId:y.id,confirmation:e.confirmation,reason:e.reason}),onSuccess:e=>{if(e.error||!e.data)throw Error(e.error?k(e.error):`rotate failed`);g(`Rotated API key`),p(e.data.secret),l(null),E()}}),A=G({mutationFn:e=>S({keyId:y.id,confirmation:e.confirmation,reason:e.reason}),onSuccess:e=>{if(e.error||!e.data)throw Error(e.error?k(e.error):`revoke failed`);l(null),E()}}),j=G({mutationFn:w,onSuccess:e=>{if(e.error||!e.data)throw Error(e.error?k(e.error):`update failed`);l(null),E()}}),N=G({mutationFn:e=>w({keyId:y.id,expiresAt:e}),onSuccess:e=>{if(e.error||!e.data)throw Error(e.error?k(e.error):`refresh failed`);l(null),E()}}),F=(0,Q.jsx)(le,{open:u.open,onToggle:u.toggle,noun:`keys`,controlsId:`access-list`,dataSlot:`access-list-toggle`});return(0,Q.jsxs)(`div`,{className:R,"data-slot":`access-page`,children:[(0,Q.jsxs)(ie,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,Q.jsx)(se,{panelRef:u.panelRef,collapsible:!0,collapsedSize:0,defaultSize:M.start.defaultSize,minSize:M.start.minSize,onResize:u.onResize,className:`min-h-0 overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:x,children:[(0,Q.jsx)(ae,{"data-slot":`access-search-input`,placeholder:`Search keys`,"aria-label":`Search keys`,value:n,onChange:e=>s(e.target.value)}),(0,Q.jsx)(U,{label:`Create key`,className:`flex self-stretch`,children:(0,Q.jsx)(`button`,{type:`button`,className:P,"data-slot":`access-create`,"aria-label":`Create key`,onClick:()=>l(`create`),children:(0,Q.jsx)(r,{icon:pe,className:`size-3.5`})})})]}),(0,Q.jsx)(tt,{rows:v,selectedKey:a,query:n,loading:e.isLoading,onSelect:c})]})}),u.open?(0,Q.jsx)(ue,{withHandle:!0}):null,(0,Q.jsx)(se,{defaultSize:M.end.defaultSize,minSize:M.end.minSize,className:`min-h-0 overflow-hidden`,children:y?(0,Q.jsx)(Ge,{keyRow:y,blast:b.data,now:d,leading:F,onEdit:()=>l(`edit`),onRefresh:()=>l(`refresh`),onRevoke:()=>l(`revoke`),onRotate:()=>l(`rotate`),rotatePending:O.isPending}):(0,Q.jsx)(ge,{icon:de.gate.icon,iconClassName:`border-border/70`,title:e.isLoading?`Loading keys…`:_.length>0?`Select a key`:`No keys yet`,leading:F,description:e.isLoading?`Reading planes and grantable scopes.`:_.length>0&&n.trim().length>0?(0,Q.jsxs)(Q.Fragment,{children:[`Nothing matches `,(0,Q.jsx)(`span`,{className:`font-mono`,children:n}),`.`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`underline underline-offset-2 hover:text-foreground`,onClick:()=>s(``),children:`Clear search`})]}):`Create one to mint a secret once.`})})]}),(0,Q.jsx)(ct,{open:o===`create`,users:e.data?.userPlane.users??[],userScopes:e.data?.userPlane.grantableScopes??[],operatorScopes:e.data?.operatorPlane.grantableScopes??[],pending:D.isPending,error:D.error instanceof Error?D.error.message:null,onOpenChange:e=>{e||l(null)},onSubmit:e=>D.mutate(e)}),y?(0,Q.jsx)(lt,{open:o===`edit`,keyRow:y,users:e.data?.userPlane.users??[],operators:e.data?.operatorPlane.operators??[],operatorScopes:e.data?.operatorPlane.grantableScopes??[],pending:j.isPending,error:j.error instanceof Error?j.error.message:null,onOpenChange:e=>{e||l(null)},onSubmit:e=>j.mutate({keyId:y.id,...e})}):null,y?(0,Q.jsx)(ut,{open:o===`refresh`,keyRow:y,pending:N.isPending,error:N.error instanceof Error?N.error.message:null,onOpenChange:e=>{e||l(null)},onSubmit:e=>N.mutate(e)}):null,y?(0,Q.jsx)(Se,{open:o===`revoke`,onOpenChange:e=>{e||l(null)},phrase:`REVOKE`,title:`Revoke ${y.name}`,description:`Irreversible. Residual sessions may continue for the access TTL.`,pending:A.isPending,error:A.error instanceof Error?A.error.message:null,confirmLabel:`Revoke key`,slot:`access-revoke-sheet`,onConfirm:e=>A.mutate({confirmation:`REVOKE`,reason:e.reason})}):null,y?(0,Q.jsx)(Se,{open:o===`rotate`,onOpenChange:e=>{e||l(null)},phrase:`ROTATE`,title:`Rotate ${y.name}`,description:`Mints a new secret once. The current secret stops after residual TTL.`,pending:O.isPending,error:O.error instanceof Error?O.error.message:null,confirmLabel:`Rotate key`,confirmVariant:`ghost`,slot:`access-rotate-sheet`,onConfirm:e=>O.mutate({confirmation:`ROTATE`,reason:e.reason})}):null,(0,Q.jsx)(dt,{secret:f,title:h,onDismiss:()=>p(null)})]})}export{ft as AccessPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e}from"./xyflow-yApv7D4e.js";import{Qn as t}from"./shortcut-keys-DTE1sjTC.js";import{c as n,l as r,st as i}from"./index-
|
|
1
|
+
import{A as e}from"./xyflow-yApv7D4e.js";import{Qn as t}from"./shortcut-keys-DTE1sjTC.js";import{c as n,l as r,st as i}from"./index-RhV2jT_7.js";var a=e();function o({open:e,openHeight:o=`auto`,className:s,style:c,transition:l,...u}){let d=r()??!1;return(0,a.jsx)(n.div,{...u,"aria-hidden":!e,inert:!e||void 0,initial:!1,animate:d?{opacity:+!!e}:{opacity:+!!e,clipPath:e?`inset(0 0 0% 0)`:`inset(0 0 100% 0)`,y:e?0:-4},transition:l??{duration:d?0:e?.22:.14,ease:i},className:t(`overflow-hidden`,s),style:{...c,height:e?o:0,pointerEvents:e?void 0:`none`,transformOrigin:`top`}})}export{o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,f as t}from"./xyflow-yApv7D4e.js";import{$n as n,F as r,I as i,Qn as a,R as o}from"./shortcut-keys-DTE1sjTC.js";import{C as s,S as c,_ as l,g as u,n as d,w as f,x as p}from"./request-meta-
|
|
1
|
+
import{A as e,f as t}from"./xyflow-yApv7D4e.js";import{$n as n,F as r,I as i,Qn as a,R as o}from"./shortcut-keys-DTE1sjTC.js";import{C as s,S as c,_ as l,g as u,n as d,w as f,x as p}from"./request-meta-C6lTyCXp.js";import{t as m}from"./dagre.esm-B1_XeuLP.js";function h(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function g(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function _(e){let t=e?.flows??{},n=new Map;for(let e of Object.keys(t)){let r=t[e]?.effects?.calls??[];for(let t of r){let r=n.get(t)??[];r.push(e),n.set(t,r)}}for(let[e,t]of n)t.sort((e,t)=>e.localeCompare(t)),n.set(e,t);return n}function v(e,t){return _(e).get(t)??[]}function y(e){return e.startsWith(`sql:`)?{id:e,kind:`store`,label:e.slice(4),facet:`sql`}:e.startsWith(`kv:`)?{id:e,kind:`store`,label:e.slice(3),facet:`kv`}:e.startsWith(`files:`)?{id:e,kind:`store`,label:e.slice(6),facet:`files`}:e.startsWith(`index:`)?{id:e,kind:`store`,label:e.slice(6),facet:`index`}:e.startsWith(`signal:`)?{id:e,kind:`signal`,label:e.slice(7)}:e.startsWith(`ai:`)?{id:e,kind:`ai`,label:e.slice(3)}:e.startsWith(`vault:`)?{id:e,kind:`vault`,label:e.slice(6)}:e.startsWith(`channel:`)?{id:e,kind:`channel`,label:e.slice(8)}:e.startsWith(`gate:`)?{id:e,kind:`gate`,label:e.slice(5)}:e.startsWith(`clock:`)?{id:e,kind:`clock`,label:e.slice(6)}:null}function b(e,n,r,i,a=!1){let o=u[i];return{id:e,source:n,target:r,type:`smoothstep`,animated:a,data:{kind:i},style:{stroke:o,strokeWidth:i===`calls`?2.5:2.25},pathOptions:{borderRadius:28},zIndex:l.edge,markerEnd:{type:t.ArrowClosed,width:14,height:14,color:o}}}function x(e){let t=e?.flows??{},n=new Set(Object.keys(t)),r=[],i=new Map;for(let e of[...n].sort()){let t=h(e),n=i.get(t)??[];n.push(e),i.set(t,n)}let a=new Map,o=new Map;for(let e of n){let n=t[e];if(!n)continue;if(n.trigger?.signal){let t=`signal:${n.trigger.signal}`,i=y(t);i&&a.set(t,i),r.push(b(`e:${t}->flow:${e}`,t,`flow:${e}`,`trigger`))}if(n.trigger?.cron||n.trigger?.every){let t=`clock:${e}`,i=n.trigger.cron??n.trigger.every??e;a.set(t,{id:t,kind:`clock`,label:i,facet:n.trigger.cron?`cron`:`every`}),r.push(b(`e:${t}->flow:${e}`,t,`flow:${e}`,`trigger`))}for(let t of n.gates??[]){let n=`gate:${t}`;a.set(n,{id:n,kind:`gate`,label:t}),o.set(n,(o.get(n)??0)+1),r.push(b(`e:flow:${e}-gates->${n}`,`flow:${e}`,n,`gates`))}let i=n.effects;if(i){for(let t of i.reads??[]){let n=y(t);n&&(a.set(t,n),o.set(t,(o.get(t)??0)+1),r.push(b(`e:flow:${e}-reads->${t}`,`flow:${e}`,t,`reads`)))}for(let t of i.writes??[]){let n=y(t);n&&(a.set(t,n),o.set(t,(o.get(t)??0)+1),r.push(b(`e:flow:${e}-writes->${t}`,`flow:${e}`,t,`writes`)))}for(let t of i.emits??[]){let n=`signal:${t}`,i=y(n);i&&(a.set(n,i),o.set(n,(o.get(n)??0)+1),r.push(b(`e:flow:${e}->${n}`,`flow:${e}`,n,`emits`)))}for(let t of i.asks??[]){let n=`ai:${t}`,i=y(n);i&&(a.set(n,i),o.set(n,(o.get(n)??0)+1),r.push(b(`e:flow:${e}->${n}`,`flow:${e}`,n,`asks`)))}for(let t of i.sends??[]){let n=`channel:${t}`,i=y(n);i&&(a.set(n,i),o.set(n,(o.get(n)??0)+1),r.push(b(`e:flow:${e}->${n}`,`flow:${e}`,n,`sends`)))}for(let t of i.secrets??[]){let n=`vault:${t}`,i=y(n);i&&(a.set(n,i),o.set(n,(o.get(n)??0)+1),r.push(b(`e:flow:${e}->${n}`,`flow:${e}`,n,`secrets`)))}for(let t of i.calls??[]){let n=f(t);if(n){let t=s(n.server);a.set(t,{id:t,kind:`ai`,label:n.server}),o.set(t,(o.get(t)??0)+1),r.push(b(`e:flow:${e}->${t}`,`flow:${e}`,t,`calls`,!0));continue}r.push(b(`e:flow:${e}->flow:${t}`,`flow:${e}`,`flow:${t}`,`calls`,!0))}}}return{nodes:S(i,t,a,o),edges:r,flowIds:n}}function S(e,t,n,r){let i=new m.graphlib.Graph({compound:!0});i.setGraph({rankdir:`LR`,align:`UL`,nodesep:16,ranksep:88,edgesep:12,marginx:8,marginy:8}),i.setDefaultEdgeLabel(()=>({}));for(let[t,n]of[...e.entries()].sort()){i.setNode(`unit:${t}`,{});for(let e of n)i.setNode(`flow:${e}`,{...p.flow}),i.setParent(`flow:${e}`,`unit:${t}`)}for(let e of n.values())i.setNode(e.id,{...p[e.kind]});let a=new Set;for(let n of e.values())for(let e of n){let n=t[e];if(!n)continue;let r=(e,t)=>{let n=`${e}->${t}`;a.has(n)||i.hasNode(e)&&i.hasNode(t)&&(a.add(n),i.setEdge(e,t))};n.trigger?.signal&&r(`signal:${n.trigger.signal}`,`flow:${e}`),(n.trigger?.cron||n.trigger?.every)&&r(`clock:${e}`,`flow:${e}`);for(let t of n.gates??[])r(`flow:${e}`,`gate:${t}`);let o=n.effects;if(o){for(let t of o.reads??[])r(`flow:${e}`,t);for(let t of o.writes??[])r(`flow:${e}`,t);for(let t of o.emits??[])r(`flow:${e}`,`signal:${t}`);for(let t of o.asks??[])r(`flow:${e}`,`ai:${t}`);for(let t of o.sends??[])r(`flow:${e}`,`channel:${t}`);for(let t of o.secrets??[])r(`flow:${e}`,`vault:${t}`);for(let t of o.calls??[]){let n=f(t);n?r(`flow:${e}`,s(n.server)):r(`flow:${e}`,`flow:${t}`)}}}m.layout(i);let o=[],{headerH:u,padX:d,padBottom:h}=c;for(let[n,r]of[...e.entries()].sort()){let e=`unit:${n}`,a=i.node(e);if(!a)continue;let s=a.x??0,c=a.y??0,f=r.length*p.flow.height+Math.max(0,r.length-1)*10,m=p.flow.width+d*2,_=u+f+h,v=s-m/2,y=c-_/2;o.push({id:e,type:`unit`,position:{x:v,y},data:{kind:`unit`,label:n,refId:e,badge:String(r.length)},selectable:!1,draggable:!1,zIndex:l.unit,width:m,height:_,style:{width:m,height:_}}),r.forEach((r,i)=>{let a=t[r];a&&o.push({id:`flow:${r}`,type:`flow`,position:{x:d,y:u+i*(p.flow.height+10)},parentId:e,extent:`parent`,zIndex:l.leaf,data:{kind:`flow`,label:g(r),refId:r,unit:n,plane:a.plane??`user`,badge:a.plane??`user`},draggable:!1,width:p.flow.width,height:p.flow.height,style:{width:p.flow.width,height:p.flow.height}})})}let _=[...n.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.label.localeCompare(t.label));for(let e of _){let t=i.node(e.id),n=p[e.kind],a=r.get(e.id)??0;o.push({id:e.id,type:e.kind,position:{x:(t?.x??0)-n.width/2,y:(t?.y??0)-n.height/2},data:{kind:e.kind,label:e.label,refId:e.id,...e.facet===void 0?{}:{facet:e.facet},badge:e.facet??(a>0?String(a):e.kind)},draggable:!1,zIndex:l.leaf,width:n.width,height:n.height,style:{width:n.width,height:n.height}})}return o}function C(e,t,n,r={}){let i=t.size>0||n.size>0;return e.map(e=>{if(e.data.kind===`unit`||e.data.kind===`law`)return e;let a=e.data.kind===`flow`?t.has(e.data.refId):n.has(e.id);return{...e,data:{...e.data,highlighted:a,dimmed:i&&!a,active:r.activeNodeId!=null&&e.id===r.activeNodeId,focused:r.focusedNodeId!=null&&e.id===r.focusedNodeId}}})}function w(e,t){let n=new Map(t.map(e=>[e.id,e]));return t.some(e=>e.data.highlighted===!0)?e.map(e=>{let t=n.get(e.source),r=n.get(e.target),i=t?.data.highlighted===!0&&r?.data.highlighted===!0,a=u[e.data?.kind??`reads`];return{...e,animated:i?!0:e.animated,style:{...e.style,stroke:a,opacity:i?1:.32,strokeWidth:i?2.75:1.75},markerEnd:e.markerEnd&&typeof e.markerEnd==`object`?{...e.markerEnd,color:a}:e.markerEnd}}):e.map(e=>({...e,style:{...e.style,opacity:1}}))}var T=100;function E(e,t){return e.filter(e=>t.has(e.flow)).sort((e,t)=>t.startedAt-e.startedAt).slice(0,T)}var D=e();function O({cache:e,dataSlot:t}){let s=d(e);return(0,D.jsxs)(r,{children:[(0,D.jsx)(o,{render:r=>(0,D.jsx)(`span`,{...r,className:a(`flex w-4 shrink-0 items-center justify-center`,s.className),"data-slot":t,"data-cache":e,"aria-label":s.label,children:(0,D.jsx)(n,{icon:s.icon,className:`size-3`,"aria-hidden":!0})})}),(0,D.jsx)(i,{side:`top`,children:s.label})]})}export{w as a,h as c,C as i,E as n,x as o,g as r,v as s,O as t};
|
package/src/console/ui-next/dist/assets/{call-pii-button-DNyK7IIY.js → call-pii-button-L9JxdBhp.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-RhV2jT_7.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-RhV2jT_7.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-D9twj8Xy.js → decisions-page-DgB76m-X.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-RhV2jT_7.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.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`:``]}),(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-CsHWlVPU.js → duration-tone-l1DSJ2Vz.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-CmRFeWdT.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-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(`
|
|
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-CRhBJMZR.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./trace-detail-sheet-BfGvpFSv.js";import{t as he}from"./duration-tone-CsHWlVPU.js";import{a as ge,c as _e,i as ve,l as ye,o as be,s as xe}from"./highlighted-json-DQ-EMAfz.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-DmdiUrfh.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-CmRFeWdT.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-BaI4uxZz.js";import{t as Ve}from"./agent-disclosure-Cq1TxniW.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-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};
|