okengine 0.19.9 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/AGENTS.md +1 -1
  2. package/package.json +2 -1
  3. package/site/content/docs/client/auth.mdx +1 -2
  4. package/site/content/docs/client/calling.mdx +125 -37
  5. package/site/content/docs/client/index.mdx +7 -7
  6. package/site/content/docs/client/react.mdx +5 -0
  7. package/site/content/docs/elements/channel/email.mdx +25 -36
  8. package/site/content/docs/elements/channel/index.mdx +88 -46
  9. package/site/content/docs/elements/channel/push.mdx +7 -9
  10. package/site/content/docs/elements/channel/sms.mdx +6 -4
  11. package/site/content/docs/elements/channel/whatsapp.mdx +11 -9
  12. package/site/content/docs/elements/clock/index.mdx +14 -25
  13. package/site/content/docs/elements/flow/http.mdx +42 -23
  14. package/site/content/docs/elements/flow/index.mdx +41 -30
  15. package/site/content/docs/elements/flow/routing.mdx +166 -122
  16. package/site/content/docs/elements/gate/rls.mdx +2 -2
  17. package/site/content/docs/elements/gate/tenancy.mdx +1 -1
  18. package/site/content/docs/elements/store/files.mdx +11 -5
  19. package/site/content/docs/elements/store/index.mdx +13 -6
  20. package/site/content/docs/elements/store/kv.mdx +8 -2
  21. package/site/content/docs/elements/store/search.mdx +5 -5
  22. package/site/content/docs/elements/store/sql.mdx +100 -39
  23. package/site/content/docs/elements/vault/index.mdx +14 -13
  24. package/site/content/docs/elements/vault/secrets.mdx +6 -3
  25. package/site/content/docs/index.mdx +1 -1
  26. package/site/content/docs/plugins/magic-link.mdx +4 -3
  27. package/site/content/docs/plugins/otp.mdx +4 -3
  28. package/site/content/docs/plugins/two-factor.mdx +4 -0
  29. package/site/content/docs/providers/index.mdx +1 -1
  30. package/site/content/docs/recipes/index.mdx +1 -1
  31. package/site/content/docs/recipes/rustfs.mdx +1 -1
  32. package/site/content/docs/reference/cli.mdx +7 -4
  33. package/site/content/docs/reference/configuration.mdx +8 -8
  34. package/site/content/docs/reference/errors.mdx +229 -55
  35. package/site/content/docs/reference/fx.mdx +22 -9
  36. package/site/content/docs/reference/i18n.mdx +4 -4
  37. package/site/content/docs/reference/plugins.mdx +4 -4
  38. package/site/content/docs/understand/the-architecture.mdx +2 -2
  39. package/site/content/docs/understand/try-it.mdx +759 -24
  40. package/src/cli/ai-setup/ai-setup.test.ts +40 -0
  41. package/src/cli/ai-setup/apply.ts +28 -46
  42. package/src/cli/build.test.ts +3 -3
  43. package/src/cli/build.ts +5 -5
  44. package/src/cli/db-auto-push.test.ts +11 -0
  45. package/src/cli/db-auto-push.ts +6 -2
  46. package/src/cli/db.test.ts +1 -1
  47. package/src/cli/db.ts +6 -6
  48. package/src/cli/dev-app-runner.ts +2 -1
  49. package/src/cli/dev-db-push.test.ts +6 -2
  50. package/src/cli/dev-schema-sync.ts +1 -1
  51. package/src/cli/dev.test.ts +10 -7
  52. package/src/cli/dev.ts +13 -11
  53. package/src/cli/ensure-drizzle-config.ts +4 -3
  54. package/src/cli/start.ts +2 -1
  55. package/src/client/create.ts +3 -3
  56. package/src/client/explain.test.ts +252 -0
  57. package/src/client/explain.ts +272 -0
  58. package/src/client/live.test.ts +44 -0
  59. package/src/client/notes-contract.test.ts +10 -0
  60. package/src/client/sse.ts +6 -2
  61. package/src/client/transport.test.ts +67 -0
  62. package/src/client/transport.ts +24 -40
  63. package/src/client/types.ts +17 -6
  64. package/src/client-react/browser.test.ts +23 -0
  65. package/src/client-react/live-resource.ts +6 -2
  66. package/src/client-react/use-live-query.ts +1 -1
  67. package/src/compiler/flow-path.test.ts +1 -0
  68. package/src/compiler/flow-path.ts +1 -1
  69. package/src/compiler/generate-adopt.test.ts +55 -1
  70. package/src/compiler/generate-adopt.ts +111 -21
  71. package/src/compiler/response.ts +17 -27
  72. package/src/config/index.ts +6 -4
  73. package/src/console/server/invoke-user-flow.test.ts +8 -2
  74. package/src/console/server/invoke-user-flow.ts +12 -18
  75. package/src/console/server/security.gate.test.ts +1 -1
  76. package/src/console/ui-next/dist/assets/{access-page-BoC83Ubl.js → access-page-tIbsiphz.js} +1 -1
  77. package/src/console/ui-next/dist/assets/{agent-disclosure-CKjAEOqA.js → agent-disclosure-CSKumwS2.js} +1 -1
  78. package/src/console/ui-next/dist/assets/{cache-glyph-Ceaq9pYh.js → cache-glyph-BCC-DxKT.js} +1 -1
  79. package/src/console/ui-next/dist/assets/{call-pii-button-C4lmY7ck.js → call-pii-button-jOmYISdc.js} +1 -1
  80. package/src/console/ui-next/dist/assets/{collapsible-82y257sL.js → collapsible-DC2xNaAb.js} +1 -1
  81. package/src/console/ui-next/dist/assets/{duration-tone-W63jaMZ8.js → duration-tone-CwoV56jn.js} +1 -1
  82. package/src/console/ui-next/dist/assets/{flows-page-KFTFj2rK.js → flows-page-gT1lsWQK.js} +1 -1
  83. package/src/console/ui-next/dist/assets/{highlighted-json-yE9zNTqC.js → highlighted-json-C2GZEJNI.js} +1 -1
  84. package/src/console/ui-next/dist/assets/{http-method-CwFeFroN.js → http-method-BdYjcIrD.js} +1 -1
  85. package/src/console/ui-next/dist/assets/{index-r7xXt_VV.js → index-Cul17AcV.js} +3 -3
  86. package/src/console/ui-next/dist/assets/{observability-page-BDiliMiC.js → observability-page-oY9vdYBk.js} +1 -1
  87. package/src/console/ui-next/dist/assets/{replica-lag-DYDzWUFT.js → replica-lag-C4QdAF7J.js} +1 -1
  88. package/src/console/ui-next/dist/assets/{request-meta-CzrOfgiz.js → request-meta-C43DHyld.js} +1 -1
  89. package/src/console/ui-next/dist/assets/{store-page-CZC2cwaw.js → store-page-CL0D9dOq.js} +1 -1
  90. package/src/console/ui-next/dist/assets/{trace-detail-sheet-DgeeejW7.js → trace-detail-sheet-Dcpo4Us_.js} +1 -1
  91. package/src/console/ui-next/dist/assets/{tree-expand-toggle-CzGIyOPY.js → tree-expand-toggle-CKJTuv43.js} +1 -1
  92. package/src/console/ui-next/dist/assets/{units-page-DBiDCLIB.js → units-page-1PlT19ft.js} +1 -1
  93. package/src/console/ui-next/dist/assets/{vault-page-CcHsthPe.js → vault-page-BwZ9YjTW.js} +1 -1
  94. package/src/console/ui-next/dist/index.html +1 -1
  95. package/src/docker/docker.test.ts +3 -3
  96. package/src/docker/images-config.test.ts +4 -4
  97. package/src/docker/stack-id.test.ts +1 -1
  98. package/src/drivers/clock-postgres.test.ts +10 -2
  99. package/src/drivers/clock-postgres.ts +18 -2
  100. package/src/drivers/vault-driver-removal.test.ts +2 -2
  101. package/src/elements/channel/declare.ts +66 -3
  102. package/src/elements/channel/runtime.ts +9 -11
  103. package/src/elements/channel.test.ts +42 -0
  104. package/src/elements/channel.ts +4 -2
  105. package/src/elements/clock/reconcile.ts +45 -24
  106. package/src/elements/clock.test.ts +33 -0
  107. package/src/elements/store/emit-drizzle.ts +285 -65
  108. package/src/elements/store/files-errors.test.ts +149 -0
  109. package/src/elements/store/files-errors.ts +189 -0
  110. package/src/elements/store/kv-errors.test.ts +98 -0
  111. package/src/elements/store/kv-errors.ts +139 -0
  112. package/src/elements/store/load-plugin-tables.ts +1 -1
  113. package/src/elements/store/prepare-row.test.ts +57 -4
  114. package/src/elements/store/resource.ts +11 -7
  115. package/src/elements/store/runtime.ts +18 -13
  116. package/src/elements/store/schema-decl.test.ts +178 -0
  117. package/src/elements/store/sql-errors.test.ts +197 -0
  118. package/src/elements/store/sql-errors.ts +294 -0
  119. package/src/elements/store/sql-session.test.ts +52 -0
  120. package/src/elements/store/sql-session.ts +50 -2
  121. package/src/elements/store/store-errors.ts +47 -0
  122. package/src/elements/store/table.ts +8 -6
  123. package/src/http.ts +9 -1
  124. package/src/i18n/catalogs/ar.ts +18 -0
  125. package/src/i18n/catalogs/en.ts +18 -0
  126. package/src/index.ts +9 -1
  127. package/src/kernel/adopt-barrel-fresh.test.ts +1 -1
  128. package/src/kernel/app.ts +40 -34
  129. package/src/kernel/auto-registry.test.ts +26 -1
  130. package/src/kernel/boot.ts +2 -2
  131. package/src/kernel/boundary-contract.ts +6 -1
  132. package/src/kernel/builtin-errors.test.ts +117 -0
  133. package/src/kernel/builtin-errors.ts +129 -0
  134. package/src/kernel/call.test.ts +182 -0
  135. package/src/kernel/errors-vault.ts +16 -0
  136. package/src/kernel/errors.registry.test.ts +7 -0
  137. package/src/kernel/errors.ts +97 -24
  138. package/src/kernel/fail-helpers.ts +34 -0
  139. package/src/kernel/flow-units.ts +3 -3
  140. package/src/kernel/fx.test.ts +8 -0
  141. package/src/kernel/fx.ts +24 -8
  142. package/src/kernel/index.ts +12 -1
  143. package/src/kernel/mutation-id.ts +8 -0
  144. package/src/kernel/plugin.ts +4 -3
  145. package/src/kernel/project-out.test.ts +176 -0
  146. package/src/kernel/project-out.ts +91 -0
  147. package/src/kernel/realtime-bind.ts +2 -3
  148. package/src/kernel/router/linear.ts +12 -6
  149. package/src/kernel/router.test.ts +13 -0
  150. package/src/plugins/magic-link.ts +25 -24
  151. package/src/plugins/otp.ts +35 -24
  152. package/src/plugins/two-factor.ts +15 -0
  153. package/src/runs/duckdb.test.ts +2 -2
  154. package/src/runtime/dev-request-log.ts +29 -11
  155. package/src/term.test.ts +76 -0
  156. package/src/term.ts +166 -3
@@ -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,f as r}from"./xyflow-yApv7D4e.js";import{$ as i,A as a,B as o,Bn as s,Bt as c,Ct as l,D as u,Dr as d,E as f,Er as p,Et as m,Gn as h,Gr as g,H as _,Ht as v,In as y,Jn as b,Jt as ee,Kn as x,Kr as S,Kt as C,M as w,Mn as T,N as E,O as D,On as O,Or as k,Ot as A,P as j,Q as M,Qt as N,S as P,St as F,Tt as I,U as L,Un as R,Ur as z,Ut as te,V as ne,Vr as re,Wn as B,Wr as ie,Wt as V,Xt as ae,Yi as H,Yt as oe,Zn as se,Zt as U,_n as W,bn as G,br as K,cr as ce,dn as q,dt as le,ft as ue,g as de,gn as fe,ht as pe,in as me,j as he,jn as ge,k as _e,lt as ve,mn as ye,mr as be,mt as xe,nn as Se,pi as Ce,pr as we,pt as Te,qn as Ee,qt as De,sr as Oe,st as ke,un as Ae,v as je,wr as Me,xr as Ne,yr as Pe,yt as Fe,z as J}from"./shortcut-keys-3ILd8oGn.js";import{i as Ie}from"./call-pii-button-C4lmY7ck.js";import{m as Le,s as Re}from"./element-icons-BI8cJgdh.js";import{t as ze}from"./UserIcon-DaE2PB5_.js";import{t as Be}from"./dagre.esm-B1_XeuLP.js";import{_ as Ve,b as He,f as Ue,g as We,h as Ge,m as Ke,p as qe,x as Je,y as Ye}from"./dropdown-menu-4h2LOVXM.js";import{bt as Xe,it as Ze}from"./index-r7xXt_VV.js";var Qe=[[`path`,{d:`M8 7H16.75C18.8567 7 19.91 7 20.6667 7.50559C20.9943 7.72447 21.2755 8.00572 21.4944 8.33329C22 9.08996 22 10.1433 22 12.25C22 15.7612 22 17.5167 21.1573 18.7779C20.7926 19.3238 20.3238 19.7926 19.7779 20.1573C18.5167 21 16.7612 21 13.25 21H12C7.28595 21 4.92893 21 3.46447 19.5355C2 18.0711 2 15.714 2 11V7.94427C2 6.1278 2 5.21956 2.38032 4.53806C2.65142 4.05227 3.05227 3.65142 3.53806 3.38032C4.21956 3 5.1278 3 6.94427 3C8.10802 3 8.6899 3 9.19926 3.19101C10.3622 3.62712 10.8418 4.68358 11.3666 5.73313L12 7`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}]],$e=[[`path`,{d:`M18 19C18 19 13.5811 14 12 14C10.4188 14 6 19 6 19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 5.00004C18 5.00004 13.5811 9.99999 12 10C10.4188 10 6 5 6 5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],et=[[`path`,{d:`M18 14C18 14 13.5811 19 12 19C10.4188 19 6 14 6 14`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 9.99996C18 9.99996 13.5811 5.00001 12 5C10.4188 4.99999 6 10 6 10`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]];function tt(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=A(),a=Fe()!=null,o=se(()=>new le({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new M,floatingId:i,syncOnly:!1,nested:a})).current;return h(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=T(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var Y=e(t(),1);function nt(e){let[t,n]=Y.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var X=n();function Z(e){return e.kind===`index`||e.kind===`function`||e.kind===`trigger`||e.kind===`extension`||e.kind===`policy`?e.kind:null}function rt(e){return Z(e)!==null}function it(e){return e.kind===`table`&&typeof e.rls==`boolean`}function at(e,t,n){return typeof e.rlsPolicyCount==`number`?e.rlsPolicyCount:Object.keys(t?.stores?.[n]?.tables?.[e.name]?.policies??{}).length}function ot(e){let t=Z(e);return t===`index`?`Indexes`:t===`function`?`Functions`:t===`trigger`?`Triggers`:t===`extension`?`Extensions`:t===`policy`?`RLS Policies`:e.name}function st(e){let t=[],n=[];for(let r of e)rt(r)?n.push(r):t.push(r);return{tables:t,catalog:n}}function ct(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var lt=[`console.store.query`];function ut(e,t,n){if(!e||!n||!t)return;let r=t[1];if(ft(r)&&r.ref===n.ref&&(r.child??``)===(n.child??``)&&(r.tenant??``)===(n.tenant??``))return e}function dt(e,t){return H({queryKey:[...lt,e],enabled:t&&e!==null,placeholderData:(t,n)=>ut(t,n?.queryKey,e),queryFn:async()=>{if(!e)throw Error(`Missing store query input`);let t=await Ce(e);if(t.error)throw Error(re(t.error));if(!t.data)throw Error(`Empty store query`);return t.data}})}function ft(e){return typeof e==`object`&&!!e&&`ref`in e&&typeof e.ref==`string`}function pt(e){let t=Y.useRef(!0);t.current&&(t.current=!1,e())}var mt=Y.createContext(void 0),ht=Y.createContext(void 0),gt=Y.createContext(void 0);function Q(){let e=Y.useContext(mt);if(e===void 0)throw Error(B(60));return e}function _t(){let e=Y.useContext(ht);if(e===void 0)throw Error(B(101));return e}function vt(){let e=Y.useContext(gt);if(e===void 0)throw Error(B(61));return e}function yt(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var bt=(e,t)=>Object.is(e,t);function xt(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function St(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!yt(e,t,(e,t)=>xt(e,t,n)):e!==t}function Ct(e,t,n){return e?e.some(e=>e!==void 0&&xt(t,e,n)):!1}function wt(e,t,n){return e?e.findIndex(e=>e!==void 0&&xt(e,t,n)):-1}function Tt(e,t){if(t!==bt)return n=>Ct(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Et(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Tt(t,n)):wt(e,t,n);return i===-1?null:i}function Dt(e,t,n,r,i,a){return Ct(r,t,i)?a!=null&&e>a&&Ct(r,n[a],i)?a:e:e===a?Et(n,r,i,!0):a}function Ot(e,t,n){return e.filter(e=>!xt(t,e,n))}function kt(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function At(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function jt(e){return At(e?.[0])}function Mt(e){return jt(e)?e.flatMap(e=>e.items):e}function Nt(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(jt(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Pt(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return kt(e)}function Ft(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?kt(e.value):kt(e)}function It(e,t,n){function r(){return Pt(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Mt(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Lt(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,X.jsx)(Y.Fragment,{children:It(r,t,n)},i)),e),[])}var Rt={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ft(t,r)!==``},hasNullItemLabel:(e,t)=>t?Nt(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>xt(t,e,n)):xt(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function zt(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function Bt(e,t){return Math.max(0,e-t)}function Vt(e,t){if(t<=0)return 0;let n=zt(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function Ht(e){let{id:t,value:n,defaultValue:r=null,onValueChange:o,open:s,defaultOpen:c=!1,onOpenChange:l,name:d,form:f,autoComplete:p,disabled:g=!1,readOnly:_=!1,required:y=!1,modal:S=!0,actionsRef:C,inputRef:T,onOpenChangeComplete:O,items:k,multiple:A=!1,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N=bt,highlightItemOnHover:P=!0,children:F}=e,{clearErrors:I}=w(),{setDirty:L,setTouched:R,setFocused:z,validityData:ne,setFilled:re,name:B,disabled:ie,validation:V,validationMode:ae}=E(),H=a({id:t}),W=ie||g,G=B??d,[K,ce]=_e({controlled:n,default:A?r??x:r,name:`Select`,state:`value`}),[q,le]=_e({controlled:s,default:c,name:`Select`,state:`open`}),de=Y.useRef([]),fe=Y.useRef([]),pe=Y.useRef(null),he=Y.useRef(null),ge=Y.useRef(0),ye=Y.useRef(null),be=Y.useRef([]),Se=Y.useRef(!1),Ce=Y.useRef(null),we=Y.useRef(null),Te=Y.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),Oe=Y.useRef(!1),Ae=Y.useRef(K),{mounted:je,setMounted:Me,transitionStatus:Ne}=ve(q),{openMethod:Pe,triggerProps:Fe}=Ve(q),J=se(()=>new ue({id:H,labelId:void 0,modal:S,multiple:A,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,value:K,open:q,mounted:je,transitionStatus:Ne,items:k,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ee,triggerProps:Ee,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:b,setOpen:b,handleScrollArrowVisibility:b,onOpenChangeComplete:b,listRef:de,popupRef:pe,scrollHandlerRef:he,scrollArrowsMountedCountRef:ge,valueRef:ye,valuesRef:be,labelsRef:fe,typingRef:Se,selectionRef:Te,firstItemTextRef:Ce,selectedItemTextRef:we,alignItemWithTriggerActiveRef:Oe,initialValueRef:Ae},Rt)).current,Ie=J.useState(`activeIndex`),Le=J.useState(`selectedIndex`),Re=J.useState(`triggerElement`),ze=J.useState(`positionerElement`),Be=nt(Pe),Ue=Pe??Be,We=Y.useMemo(()=>A?``:Ft(K,M),[A,K,M]),Ge=Y.useMemo(()=>A&&Array.isArray(K)?K.map(e=>Ft(e,M)):Ft(K,M),[A,K,M]),Ke=ee(Re),qe=De(()=>Ge);D(Ke,H,K,qe,!W,d);let Xe=A?Array.isArray(K)&&K.length>0:K!=null&&We!==``;h(()=>{re(Xe)},[Xe,re]),h(function(){let e=Et(be.current,K,N,A);e===null&&(we.current=null),!q&&J.set(`selectedIndex`,e)},[A,q,K,N,J]),u(K,()=>{I(G),L(St(K,ne.initialValue,N)),V.change(K)});let Ze=De((e,t)=>{l?.(e,t),!t.isCanceled&&(le(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(R(!0),z(!1),ae===`onBlur`&&V.commit(K)))}),Qe=De(()=>{Me(!1),J.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),O?.(!1)});ke({enabled:!C,open:q,ref:pe,onComplete(){q||Qe()}}),Y.useImperativeHandle(C,()=>({unmount:Qe}),[Qe]);let $e=De((e,t)=>{o?.(e,t),!t.isCanceled&&ce(e)}),et=De(e=>{let t=Bt(e.scrollHeight,e.clientHeight),n=Vt(e.scrollTop,t),r=n>0,i=n<t;J.set(`scrollUpArrowVisible`,r),J.set(`scrollDownArrowVisible`,i)}),Z=tt({open:q,onOpenChange:Ze,elements:{reference:Re,floating:ze}}),rt=Je(Z,{enabled:!W,event:`mousedown`}),it=xe(Z),at=He(Z,{enabled:!W,listRef:de,activeIndex:Ie,selectedIndex:Le,disabledIndices:x,onNavigate(e){(e!==null||q)&&J.set(`activeIndex`,e)},focusItemOnHover:P}),ot=Ye(Z,{enabled:!W&&(q||!_&&!A),listRef:fe,activeIndex:Ie,selectedIndex:Le,disabledIndices:e=>ct(de.current[e]),onMatch(e){q?J.set(`activeIndex`,e):$e(be.current[e],U(me))},onTyping(e){Se.current=e}}),st=Y.useMemo(()=>m(ot.reference,at.reference,it.reference,rt.reference,Fe),[rt.reference,ot.reference,at.reference,it.reference,Fe]),lt=Y.useMemo(()=>m(i,ot.floating,at.floating,it.floating),[ot.floating,at.floating,it.floating]),ut=at.item??Ee;J.useContextCallback(`setValue`,$e),J.useContextCallback(`setOpen`,Ze),J.useContextCallback(`handleScrollArrowVisibility`,et),J.useContextCallback(`onOpenChangeComplete`,O),pt(()=>{J.update({popupProps:lt,triggerProps:st})}),J.useSyncedValues({id:H,modal:S,multiple:A,value:K,open:q,mounted:je,transitionStatus:Ne,popupProps:lt,triggerProps:st,items:k,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,openMethod:Ue});let dt=Y.useMemo(()=>({disabled:W,readOnly:_,required:y,multiple:A,highlightItemOnHover:P,itemProps:ut}),[W,_,y,A,P,ut]),ft=oe(T,V.inputRef),Q=A?void 0:G,_t=Y.useMemo(()=>!A||!Array.isArray(K)||!G?null:K.map(e=>{let t=Ft(e,M);return(0,X.jsx)(`input`,{type:`hidden`,form:f,name:G,value:t,disabled:W},t)}),[A,K,f,G,M,W]);return(0,X.jsxs)(mt.Provider,{value:J,children:[(0,X.jsx)(ht.Provider,{value:dt,children:(0,X.jsx)(gt.Provider,{value:Z,children:F})}),(0,X.jsx)(`input`,{...V.getValidationProps(W,{onFocus(){J.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||W||_)return;let t=e.currentTarget.value,n=U(me,e.nativeEvent);function r(){if(A)return;let e=t.toLowerCase(),r=be.current.findIndex(t=>Ft(t,M).toLowerCase()===e||Pt(t,j).toLowerCase()===e);r===-1&&(r=be.current.findIndex((t,n)=>{let r=fe.current[n];return r!=null&&r.toLowerCase()===e}));let i=be.current[r];i!=null&&$e(i,n)}J.set(`forceMount`,!0),queueMicrotask(r)}}),id:H&&Q==null?`${H}-hidden-input`:void 0,form:f,name:Q,autoComplete:p,value:We,disabled:W,required:y&&!(A&&Xe),readOnly:_,ref:ft,style:G?te:v,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),_t]})}function Ut(e,t){return e??t}var Wt=`data-popup-side`,Gt=400,Kt={...fe,...j,popupSide:e=>e?{[Wt]:e}:null,value:()=>null},qt=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:o=!1,nativeButton:s=!0,style:c,...l}=e,{setTouched:u,setFocused:d,validationMode:f,validation:p,state:h,disabled:g}=E(),{labelId:_}=he(),v=Q(),{readOnly:y,required:b,disabled:x}=_t(),S=g||x||o,C=v.useState(`open`),w=v.useState(`mounted`),T=v.useState(`value`),D=v.useState(`triggerProps`),k=v.useState(`positionerElement`),A=v.useState(`listElement`),j=v.useState(`popupSide`),M=v.useState(`id`),F=v.useState(`labelId`),L=v.useState(`hasSelectedValue`),z=w&&k?j:null,te=i??M,ne=Ut(_,F);a({id:i});let re=ee(k),B=Y.useRef(null),{getButtonProps:ie,buttonRef:ae}=P({disabled:S,native:s}),H=v.useStateSetter(`triggerElement`),oe=R(),se=R(),W=R();Y.useEffect(()=>{if(C)return W.start(Gt,()=>{v.context.selectionRef.current.allowUnselectedMouseUp=!0,v.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{W.clear()};v.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},se.clear()},[C,v,se,W]);let G=m(D,{id:te,role:`combobox`,"aria-expanded":C,"aria-haspopup":`listbox`,"aria-controls":C?A?.id??q(k)?.id:void 0,"aria-labelledby":ne,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:S?-1:0,onFocus(e){d(!0),C&&v.context.alignItemWithTriggerActiveRef.current&&v.context.setOpen(!1,U(me,e.nativeEvent)),oe.start(0,()=>{v.set(`forceMount`,!0)})},onBlur(e){O(k,e.relatedTarget)||(u(!0),d(!1),f===`onBlur`&&p.commit(T))},onMouseDown(e){if(C)return;let t=V(e.currentTarget);function n(e){if(!B.current)return;let t=e.target;O(B.current,t)||O(re.current,t)||Ue(e,B.current)||v.context.setOpen(!1,U(N,e))}se.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},l,ie),K=p.getValidationProps(S,G);K.role=`combobox`;let ce={...h,open:C,disabled:S,value:T,readOnly:y,popupSide:z,placeholder:!L};return I(`button`,e,{ref:[t,B,ae,H],state:ce,stateAttributesMapping:Kt,props:K})}),Jt={value:()=>null},Yt=Y.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=Q(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?Lt(l,u,d):It(l,u,d)),I(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:Jt})}),Xt=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o={open:Q().useState(`open`)};return I(`span`,e,{state:o,ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:W})}),Zt=Y.forwardRef(function(e,t){let n=Q(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,X.jsx)(F,{ref:t,...e}):null}),Qt=Y.createContext(void 0);function $t(){let e=Y.useContext(Qt);if(!e)throw Error(B(59));return e}function en(e,t){e&&Object.assign(e.style,t)}var tn={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},nn={position:`fixed`},rn=Y.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:s,align:c,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:g,disableAnchorTracking:v,alignItemWithTrigger:y=!0,collisionAvoidance:b=l,style:ee,...x}=e,S=Q(),C=vt(),w=S.useState(`open`),T=S.useState(`mounted`),E=S.useState(`modal`),D=S.useState(`value`),O=S.useState(`openMethod`),k=S.useState(`positionerElement`),A=S.useState(`triggerElement`),j=S.useState(`isItemEqualToValue`),M=S.useState(`transitionStatus`),N=Y.useRef(null),P=Y.useRef(null),[F,I]=Y.useState(y),L=T&&F&&O!==`touch`;!T&&F!==y&&I(y),Y.useImperativeHandle(S.context.alignItemWithTriggerActiveRef,()=>L),qe((L||E)&&w,O===`touch`,k,A);let R=_({anchor:n,floatingRootContext:C,positionMethod:a,mounted:T,side:s,sideOffset:u,align:c,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:g,disableAnchorTracking:v??L,collisionAvoidance:b,keepMounted:!0}),z=L?`none`:R.side,te=L?nn:R.positionerStyles,ne={open:w,side:z,align:R.align,anchorHidden:R.anchorHidden};h(()=>{S.set(`popupSide`,R.side)},[S,R.side]);let re=S.useStateSetter(`positionerElement`),B=o(e,ne,{styles:te,transitionStatus:M,props:x,refs:[t,re],hidden:!T,inert:!w}),ie=Y.useRef(0),V=De(e=>{if(S.context.valuesRef.current.length===0)return;let t=ie.current;ie.current=e.size;let n=U(me);if(t!==0&&!S.state.multiple&&D!==null&&wt(S.context.valuesRef.current,D,j)===-1){let e=S.context.initialValueRef.current,t=e!=null&&wt(S.context.valuesRef.current,e,j)!==-1?e:null;S.context.setValue(t,n),t===null&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null)}if(t!==0&&S.state.multiple&&Array.isArray(D)){let e=D.filter(e=>wt(S.context.valuesRef.current,e,j)!==-1);e.length!==D.length&&(S.context.setValue(e,n),e.length===0&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null))}if(w&&L){S.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};en(k,e),en(S.context.popupRef.current,e)}}),ae=Y.useMemo(()=>({...R,side:z,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:I,scrollUpArrowRef:N,scrollDownArrowRef:P}),[R,z,L,I]);return(0,X.jsx)(Ke,{elementsRef:S.context.listRef,labelsRef:S.context.labelsRef,onMapChange:V,children:(0,X.jsxs)(Qt.Provider,{value:ae,children:[T&&E&&(0,X.jsx)(de,{inert:J(!w),cutout:A}),B]})})}),an=`base-ui-disable-scrollbar`,on={className:an,getElement(e){return(0,X.jsx)(`style`,{nonce:e,href:an,precedence:`base-ui:low`,children:`.${an}{scrollbar-width:none}.${an}::-webkit-scrollbar{display:none}`})}},sn=Y.createContext(void 0),cn={disableStyleElements:!1};function ln(){return Y.useContext(sn)??cn}var un=`--transform-origin`,dn={...ye,...G},fn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,c=Q(),{multiple:l,readOnly:u,highlightItemOnHover:d}=_t(),f=vt(),{side:p,align:m,alignItemWithTriggerActive:g,isPositioned:_,setControlledAlignItemWithTrigger:v}=$t(),y=Ge(!0)!=null,b=L(),{nonce:ee,disableStyleElements:x}=ln(),S=c.useState(`id`),w=c.useState(`open`),T=c.useState(`openMethod`),E=c.useState(`mounted`),D=c.useState(`popupProps`),O=c.useState(`transitionStatus`),k=c.useState(`triggerElement`),A=c.useState(`positionerElement`),j=c.useState(`listElement`),M=Y.useRef(!1),N=Y.useRef(!1),P=Y.useRef({}),F=C(),R=De(e=>{if(!A||!c.context.popupRef.current||!N.current)return;let t=A.style.top===`0px`,n=A.style.bottom===`0px`;if(M.current||!g||!t&&!n){c.context.handleScrollArrowVisibility(e);return}let r=hn(A),i=gn(A.getBoundingClientRect().height,`y`,r),a=V(A),o=ge(A),s=o.getComputedStyle(A),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=pn(o.getComputedStyle(c.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=mn(e),h=null,_=e=>{A.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=zt(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(M.current=!0),c.context.handleScrollArrowVisibility(e);return}f-y>1?h=t?1/0:0:n&&p<m&&(h=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),h!=null){let t=zt(h,0,mn(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(M.current=!0),c.context.handleScrollArrowVisibility(e)});Y.useImperativeHandle(c.context.scrollHandlerRef,()=>R,[R]),ke({open:w,ref:c.context.popupRef,onComplete(){w&&c.context.onOpenChangeComplete(!0)}});let z={open:w,transitionStatus:O,side:p,align:m};h(()=>{A&&c.context.popupRef.current&&!Object.keys(P.current).length&&(P.current={top:A.style.top||`0`,left:A.style.left||`0`,right:A.style.right,height:A.style.height,bottom:A.style.bottom,minHeight:A.style.minHeight,maxHeight:A.style.maxHeight,marginTop:A.style.marginTop,marginBottom:A.style.marginBottom})},[c,A]),h(()=>{w||g||(N.current=!1,M.current=!1,en(A,P.current))},[w,g,A]),h(()=>{let e=c.context.popupRef.current;if(!w||!k||!A||!e||g&&!_||c.state.transitionStatus===`ending`)return;if(N.current=!0,e.style.removeProperty(un),!g){F.request(()=>c.context.handleScrollArrowVisibility(j||e));return}let t=yn(e);try{let t=c.context.selectedItemTextRef.current;t?.isConnected||(t=!c.select(`hasSelectedValue`)&&c.context.firstItemTextRef.current?.isConnected?c.context.firstItemTextRef.current:null);let n=c.context.valueRef.current,r=ge(A),i=r.getComputedStyle(A),a=r.getComputedStyle(e),o=V(k),l=hn(k),u=_n(k.getBoundingClientRect(),l),f=_n(A.getBoundingClientRect(),l),p=u.height,m=j||e,h=m.scrollHeight,g=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,ee=parseFloat(i.minHeight)||100,x=pn(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-u.bottom+p,T,E=b===`rtl`?u.right-f.width:u.left,D=0;if(t&&n){let e=_n(n.getBoundingClientRect(),l);T=_n(t.getBoundingClientRect(),l),E=f.left+(b===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-u.top+e.height/2;D=T.top-f.top+T.height/2-r}let O=w+D+y+g,N=Math.min(S,O),F=S-_-y,I=O-N,L=C-5;A.style.left=`${zt(E,5,L-f.width)}px`,A.style.height=`${N}px`,A.style.maxHeight=`none`,A.style.marginTop=`${_}px`,A.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=mn(m),z=I>=R-1;z&&(N=Math.min(S,f.height)-(I-R));let te=u.top<20||u.bottom>S-20||Math.ceil(N)+1<Math.min(h,ee),ne=(r.visualViewport?.scale??1)!==1&&s;if(te||ne){en(A,P.current),v(!1);return}let re=Math.max(ee,N);if(z){let e=Math.max(0,S-O);A.style.top=f.height>=F?`0`:`${e}px`,A.style.height=`${N}px`,m.scrollTop=mn(m)}else A.style.bottom=`0`,m.scrollTop=I;if(T){let t=f.top,n=f.height,r=T.top+T.height/2,i=zt(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(un,`50% ${i}%`)}(re===S||N>=x)&&(M.current=!0),c.context.handleScrollArrowVisibility(m),d&&c.state.selectedIndex===null&&c.state.activeIndex===null&&c.context.listRef.current[0]!=null&&c.set(`activeIndex`,0)}finally{t()}},[c,w,A,k,g,v,F,j,d,b,_]),Y.useEffect(()=>{if(!g||!A||!w)return;let e=ge(A);function t(e){c.context.setOpen(!1,U(Ae,e))}return ae(e,`resize`,t)},[c,g,A,w]);let te={...j?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":l||void 0,"aria-readonly":u||void 0,id:`${S}-list`},onKeyDown(e){y&&je.has(e.key)&&e.stopPropagation()},onScroll(e){j||R(e.currentTarget)},...g&&{style:j?{height:`100%`}:tn},className:!j&&g?on.className:void 0},re=I(`div`,e,{ref:[t,c.context.popupRef],state:z,stateAttributesMapping:dn,props:[D,te,ne(O),o]});return(0,X.jsxs)(Y.Fragment,{children:[!x&&on.getElement(ee),(0,X.jsx)(pe,{context:f,modal:!1,disabled:!E,openInteractionType:T,returnFocus:a,restoreFocus:!0,children:re})]})});function pn(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function mn(e){return Bt(e.scrollHeight,e.clientHeight)}function hn(e){return Te.getScale(e)}function gn(e,t,n){return e/n[t]}function _n(e,t){return c({x:gn(e.x,`x`,t),y:gn(e.y,`y`,t),width:gn(e.width,`x`,t),height:gn(e.height,`y`,t)})}var vn=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function yn(e){let{style:t}=e,n={};for(let[e,r]of vn)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of vn){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var bn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Q(),{multiple:s,readOnly:c}=_t(),{alignItemWithTriggerActive:l}=$t(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:tn},className:u&&d!==`touch`?on.className:void 0},p=o.useStateSetter(`listElement`);return I(`div`,e,{ref:[t,p],props:[f,a]})}),xn=Y.createContext(void 0);function Sn(){let e=Y.useContext(xn);if(!e)throw Error(B(57));return e}var Cn=Y.memo(Y.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=Y.useRef(null),d=We({guess:!0,label:o,textRef:u}),f=Q(),{itemProps:p,multiple:m,disabled:g,readOnly:_}=_t(),v=g||s,b=f.useState(`isActive`,d.index),ee=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=f.useState(`isItemEqualToValue`),w=d.index,T=Y.useRef(null);h(()=>{let e=f.context.valuesRef.current;return e[w]=a,()=>{delete e[w]}},[w,a,f]),h(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=Dt(w,a,f.context.valuesRef.current,e,C,t),r=n===w,w===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&xt(a,e,C),r&&(n=w)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[w,m,C,f,a]);let E=Y.useRef(`mouse`),D=Y.useRef(!1),{getButtonProps:O,buttonRef:k}=P({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),A={disabled:v,selected:x,highlighted:b};function j(e){if(g||_)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?Ot(n,a,C):[...n,a];f.context.setValue(r,U(Se,e))}else f.context.setValue(a,U(Se,e)),f.context.setOpen(!1,U(Se,e))}function M(){f.context.selectionRef.current.dragY=0}let N={role:`option`,"aria-selected":x,tabIndex:ee&&b?0:-1,onKeyDown(e){f.set(`activeIndex`,w),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=E.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&y(e.nativeEvent)&&(n!==void 0||b),i=t&&!r&&!D.current;D.current=!1,!(v||i)&&j(e.nativeEvent)},onPointerEnter(e){E.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){E.current=e.pointerType,D.current=!0,M()},onMouseUp(){if(M(),v||E.current===`touch`||D.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(D.current=!0,T.current?.click(),D.current=!1)}},F=I(`div`,e,{ref:[k,t,d.ref,T],state:A,props:[p,N,l,O]}),L=Y.useMemo(()=>({selected:x,index:w,textRef:u,selectedByFocus:S}),[x,w,u,S]);return(0,X.jsx)(xn.Provider,{value:L,children:F})})),wn=Y.forwardRef(function(e,t){let{selected:n}=Sn();return e.keepMounted||n?(0,X.jsx)(Tn,{...e,ref:t}):null}),Tn=Y.memo(Y.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Sn(),c=Y.useRef(null),{transitionStatus:l,setMounted:u}=ve(s),d=I(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:G});return ke({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||u(!1)}}),d})),En=Y.memo(Y.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Sn(),a=Q(),{render:o,className:s,style:c,...l}=e,u=Y.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]);return I(`div`,e,{ref:[u,t,r],props:l})})),Dn=Y.createContext(void 0),On=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Y.useState(),c=Y.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=I(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,X.jsx)(Dn.Provider,{value:c,children:l})}),kn=Ht;function An({className:e,...t}){return(0,X.jsx)(On,{"data-slot":`select-group`,className:p(`scroll-my-1 p-1`,e),...t})}function jn({className:e,...t}){return(0,X.jsx)(Yt,{"data-slot":`select-value`,className:p(`flex flex-1 text-left`,e),...t})}function Mn({className:e,size:t=`default`,flat:n=!1,children:r,...i}){return(0,X.jsxs)(qt,{"data-slot":`select-trigger`,"data-size":t,"data-flat":n?`true`:void 0,className:p(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n&&`rounded-none border-0 bg-transparent shadow-none hover:bg-transparent focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`,e),...i,children:[r,(0,X.jsx)(Xt,{render:(0,X.jsx)(d,{icon:et,className:`pointer-events-none size-4 text-muted-foreground`,strokeWidth:1.5})})]})}function Nn({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,X.jsx)(Zt,{children:(0,X.jsx)(rn,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,X.jsx)(fn,{"data-slot":`select-content`,"data-align-trigger":o,className:p(`cn-menu-target cn-menu-translucent relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...s,children:(0,X.jsx)(bn,{children:t})})})})}function Pn({className:e,children:t,...n}){return(0,X.jsxs)(Cn,{"data-slot":`select-item`,className:p(`relative flex w-full cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,X.jsx)(En,{className:`flex min-w-0 flex-1 items-center gap-2`,children:t}),(0,X.jsx)(wn,{render:(0,X.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 right-2 flex size-4 -translate-y-1/2 items-center justify-center`}),children:(0,X.jsx)(d,{icon:k,className:`pointer-events-none size-3.5`,strokeWidth:1.5})})]})}var Fn=new Set([`ALL`,`SELECT`,`INSERT`,`UPDATE`,`DELETE`]),In=new Set([`PERMISSIVE`,`RESTRICTIVE`]),Ln=new Set([`public`,`current_role`,`current_user`,`session_user`]),Rn=`oke_app`;`${[`CREATE SCHEMA IF NOT EXISTS oke`,`SET search_path TO public, oke`,`DO $oke_search_path$
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n,f as r}from"./xyflow-yApv7D4e.js";import{$ as i,A as a,B as o,Bn as s,Bt as c,Ct as l,D as u,Dr as d,E as f,Er as p,Et as m,Gn as h,Gr as g,H as _,Ht as v,In as y,Jn as b,Jt as ee,Kn as x,Kr as S,Kt as C,M as w,Mn as T,N as E,O as D,On as O,Or as k,Ot as A,P as j,Q as M,Qt as N,S as P,St as F,Tt as I,U as L,Un as R,Ur as z,Ut as te,V as ne,Vr as re,Wn as B,Wr as ie,Wt as V,Xt as ae,Yi as H,Yt as oe,Zn as se,Zt as U,_n as W,bn as G,br as K,cr as ce,dn as q,dt as le,ft as ue,g as de,gn as fe,ht as pe,in as me,j as he,jn as ge,k as _e,lt as ve,mn as ye,mr as be,mt as xe,nn as Se,pi as Ce,pr as we,pt as Te,qn as Ee,qt as De,sr as Oe,st as ke,un as Ae,v as je,wr as Me,xr as Ne,yr as Pe,yt as Fe,z as J}from"./shortcut-keys-3ILd8oGn.js";import{i as Ie}from"./call-pii-button-jOmYISdc.js";import{m as Le,s as Re}from"./element-icons-BI8cJgdh.js";import{t as ze}from"./UserIcon-DaE2PB5_.js";import{t as Be}from"./dagre.esm-B1_XeuLP.js";import{_ as Ve,b as He,f as Ue,g as We,h as Ge,m as Ke,p as qe,x as Je,y as Ye}from"./dropdown-menu-4h2LOVXM.js";import{bt as Xe,it as Ze}from"./index-Cul17AcV.js";var Qe=[[`path`,{d:`M8 7H16.75C18.8567 7 19.91 7 20.6667 7.50559C20.9943 7.72447 21.2755 8.00572 21.4944 8.33329C22 9.08996 22 10.1433 22 12.25C22 15.7612 22 17.5167 21.1573 18.7779C20.7926 19.3238 20.3238 19.7926 19.7779 20.1573C18.5167 21 16.7612 21 13.25 21H12C7.28595 21 4.92893 21 3.46447 19.5355C2 18.0711 2 15.714 2 11V7.94427C2 6.1278 2 5.21956 2.38032 4.53806C2.65142 4.05227 3.05227 3.65142 3.53806 3.38032C4.21956 3 5.1278 3 6.94427 3C8.10802 3 8.6899 3 9.19926 3.19101C10.3622 3.62712 10.8418 4.68358 11.3666 5.73313L12 7`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}]],$e=[[`path`,{d:`M18 19C18 19 13.5811 14 12 14C10.4188 14 6 19 6 19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 5.00004C18 5.00004 13.5811 9.99999 12 10C10.4188 10 6 5 6 5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],et=[[`path`,{d:`M18 14C18 14 13.5811 19 12 19C10.4188 19 6 14 6 14`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 9.99996C18 9.99996 13.5811 5.00001 12 5C10.4188 4.99999 6 10 6 10`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]];function tt(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=A(),a=Fe()!=null,o=se(()=>new le({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new M,floatingId:i,syncOnly:!1,nested:a})).current;return h(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=T(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var Y=e(t(),1);function nt(e){let[t,n]=Y.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var X=n();function Z(e){return e.kind===`index`||e.kind===`function`||e.kind===`trigger`||e.kind===`extension`||e.kind===`policy`?e.kind:null}function rt(e){return Z(e)!==null}function it(e){return e.kind===`table`&&typeof e.rls==`boolean`}function at(e,t,n){return typeof e.rlsPolicyCount==`number`?e.rlsPolicyCount:Object.keys(t?.stores?.[n]?.tables?.[e.name]?.policies??{}).length}function ot(e){let t=Z(e);return t===`index`?`Indexes`:t===`function`?`Functions`:t===`trigger`?`Triggers`:t===`extension`?`Extensions`:t===`policy`?`RLS Policies`:e.name}function st(e){let t=[],n=[];for(let r of e)rt(r)?n.push(r):t.push(r);return{tables:t,catalog:n}}function ct(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var lt=[`console.store.query`];function ut(e,t,n){if(!e||!n||!t)return;let r=t[1];if(ft(r)&&r.ref===n.ref&&(r.child??``)===(n.child??``)&&(r.tenant??``)===(n.tenant??``))return e}function dt(e,t){return H({queryKey:[...lt,e],enabled:t&&e!==null,placeholderData:(t,n)=>ut(t,n?.queryKey,e),queryFn:async()=>{if(!e)throw Error(`Missing store query input`);let t=await Ce(e);if(t.error)throw Error(re(t.error));if(!t.data)throw Error(`Empty store query`);return t.data}})}function ft(e){return typeof e==`object`&&!!e&&`ref`in e&&typeof e.ref==`string`}function pt(e){let t=Y.useRef(!0);t.current&&(t.current=!1,e())}var mt=Y.createContext(void 0),ht=Y.createContext(void 0),gt=Y.createContext(void 0);function Q(){let e=Y.useContext(mt);if(e===void 0)throw Error(B(60));return e}function _t(){let e=Y.useContext(ht);if(e===void 0)throw Error(B(101));return e}function vt(){let e=Y.useContext(gt);if(e===void 0)throw Error(B(61));return e}function yt(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var bt=(e,t)=>Object.is(e,t);function xt(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function St(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!yt(e,t,(e,t)=>xt(e,t,n)):e!==t}function Ct(e,t,n){return e?e.some(e=>e!==void 0&&xt(t,e,n)):!1}function wt(e,t,n){return e?e.findIndex(e=>e!==void 0&&xt(e,t,n)):-1}function Tt(e,t){if(t!==bt)return n=>Ct(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Et(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Tt(t,n)):wt(e,t,n);return i===-1?null:i}function Dt(e,t,n,r,i,a){return Ct(r,t,i)?a!=null&&e>a&&Ct(r,n[a],i)?a:e:e===a?Et(n,r,i,!0):a}function Ot(e,t,n){return e.filter(e=>!xt(t,e,n))}function kt(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function At(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function jt(e){return At(e?.[0])}function Mt(e){return jt(e)?e.flatMap(e=>e.items):e}function Nt(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(jt(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Pt(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return kt(e)}function Ft(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?kt(e.value):kt(e)}function It(e,t,n){function r(){return Pt(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Mt(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Lt(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,X.jsx)(Y.Fragment,{children:It(r,t,n)},i)),e),[])}var Rt={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ft(t,r)!==``},hasNullItemLabel:(e,t)=>t?Nt(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>xt(t,e,n)):xt(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function zt(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function Bt(e,t){return Math.max(0,e-t)}function Vt(e,t){if(t<=0)return 0;let n=zt(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function Ht(e){let{id:t,value:n,defaultValue:r=null,onValueChange:o,open:s,defaultOpen:c=!1,onOpenChange:l,name:d,form:f,autoComplete:p,disabled:g=!1,readOnly:_=!1,required:y=!1,modal:S=!0,actionsRef:C,inputRef:T,onOpenChangeComplete:O,items:k,multiple:A=!1,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N=bt,highlightItemOnHover:P=!0,children:F}=e,{clearErrors:I}=w(),{setDirty:L,setTouched:R,setFocused:z,validityData:ne,setFilled:re,name:B,disabled:ie,validation:V,validationMode:ae}=E(),H=a({id:t}),W=ie||g,G=B??d,[K,ce]=_e({controlled:n,default:A?r??x:r,name:`Select`,state:`value`}),[q,le]=_e({controlled:s,default:c,name:`Select`,state:`open`}),de=Y.useRef([]),fe=Y.useRef([]),pe=Y.useRef(null),he=Y.useRef(null),ge=Y.useRef(0),ye=Y.useRef(null),be=Y.useRef([]),Se=Y.useRef(!1),Ce=Y.useRef(null),we=Y.useRef(null),Te=Y.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),Oe=Y.useRef(!1),Ae=Y.useRef(K),{mounted:je,setMounted:Me,transitionStatus:Ne}=ve(q),{openMethod:Pe,triggerProps:Fe}=Ve(q),J=se(()=>new ue({id:H,labelId:void 0,modal:S,multiple:A,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,value:K,open:q,mounted:je,transitionStatus:Ne,items:k,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ee,triggerProps:Ee,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:b,setOpen:b,handleScrollArrowVisibility:b,onOpenChangeComplete:b,listRef:de,popupRef:pe,scrollHandlerRef:he,scrollArrowsMountedCountRef:ge,valueRef:ye,valuesRef:be,labelsRef:fe,typingRef:Se,selectionRef:Te,firstItemTextRef:Ce,selectedItemTextRef:we,alignItemWithTriggerActiveRef:Oe,initialValueRef:Ae},Rt)).current,Ie=J.useState(`activeIndex`),Le=J.useState(`selectedIndex`),Re=J.useState(`triggerElement`),ze=J.useState(`positionerElement`),Be=nt(Pe),Ue=Pe??Be,We=Y.useMemo(()=>A?``:Ft(K,M),[A,K,M]),Ge=Y.useMemo(()=>A&&Array.isArray(K)?K.map(e=>Ft(e,M)):Ft(K,M),[A,K,M]),Ke=ee(Re),qe=De(()=>Ge);D(Ke,H,K,qe,!W,d);let Xe=A?Array.isArray(K)&&K.length>0:K!=null&&We!==``;h(()=>{re(Xe)},[Xe,re]),h(function(){let e=Et(be.current,K,N,A);e===null&&(we.current=null),!q&&J.set(`selectedIndex`,e)},[A,q,K,N,J]),u(K,()=>{I(G),L(St(K,ne.initialValue,N)),V.change(K)});let Ze=De((e,t)=>{l?.(e,t),!t.isCanceled&&(le(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(R(!0),z(!1),ae===`onBlur`&&V.commit(K)))}),Qe=De(()=>{Me(!1),J.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),O?.(!1)});ke({enabled:!C,open:q,ref:pe,onComplete(){q||Qe()}}),Y.useImperativeHandle(C,()=>({unmount:Qe}),[Qe]);let $e=De((e,t)=>{o?.(e,t),!t.isCanceled&&ce(e)}),et=De(e=>{let t=Bt(e.scrollHeight,e.clientHeight),n=Vt(e.scrollTop,t),r=n>0,i=n<t;J.set(`scrollUpArrowVisible`,r),J.set(`scrollDownArrowVisible`,i)}),Z=tt({open:q,onOpenChange:Ze,elements:{reference:Re,floating:ze}}),rt=Je(Z,{enabled:!W,event:`mousedown`}),it=xe(Z),at=He(Z,{enabled:!W,listRef:de,activeIndex:Ie,selectedIndex:Le,disabledIndices:x,onNavigate(e){(e!==null||q)&&J.set(`activeIndex`,e)},focusItemOnHover:P}),ot=Ye(Z,{enabled:!W&&(q||!_&&!A),listRef:fe,activeIndex:Ie,selectedIndex:Le,disabledIndices:e=>ct(de.current[e]),onMatch(e){q?J.set(`activeIndex`,e):$e(be.current[e],U(me))},onTyping(e){Se.current=e}}),st=Y.useMemo(()=>m(ot.reference,at.reference,it.reference,rt.reference,Fe),[rt.reference,ot.reference,at.reference,it.reference,Fe]),lt=Y.useMemo(()=>m(i,ot.floating,at.floating,it.floating),[ot.floating,at.floating,it.floating]),ut=at.item??Ee;J.useContextCallback(`setValue`,$e),J.useContextCallback(`setOpen`,Ze),J.useContextCallback(`handleScrollArrowVisibility`,et),J.useContextCallback(`onOpenChangeComplete`,O),pt(()=>{J.update({popupProps:lt,triggerProps:st})}),J.useSyncedValues({id:H,modal:S,multiple:A,value:K,open:q,mounted:je,transitionStatus:Ne,popupProps:lt,triggerProps:st,items:k,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,openMethod:Ue});let dt=Y.useMemo(()=>({disabled:W,readOnly:_,required:y,multiple:A,highlightItemOnHover:P,itemProps:ut}),[W,_,y,A,P,ut]),ft=oe(T,V.inputRef),Q=A?void 0:G,_t=Y.useMemo(()=>!A||!Array.isArray(K)||!G?null:K.map(e=>{let t=Ft(e,M);return(0,X.jsx)(`input`,{type:`hidden`,form:f,name:G,value:t,disabled:W},t)}),[A,K,f,G,M,W]);return(0,X.jsxs)(mt.Provider,{value:J,children:[(0,X.jsx)(ht.Provider,{value:dt,children:(0,X.jsx)(gt.Provider,{value:Z,children:F})}),(0,X.jsx)(`input`,{...V.getValidationProps(W,{onFocus(){J.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||W||_)return;let t=e.currentTarget.value,n=U(me,e.nativeEvent);function r(){if(A)return;let e=t.toLowerCase(),r=be.current.findIndex(t=>Ft(t,M).toLowerCase()===e||Pt(t,j).toLowerCase()===e);r===-1&&(r=be.current.findIndex((t,n)=>{let r=fe.current[n];return r!=null&&r.toLowerCase()===e}));let i=be.current[r];i!=null&&$e(i,n)}J.set(`forceMount`,!0),queueMicrotask(r)}}),id:H&&Q==null?`${H}-hidden-input`:void 0,form:f,name:Q,autoComplete:p,value:We,disabled:W,required:y&&!(A&&Xe),readOnly:_,ref:ft,style:G?te:v,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),_t]})}function Ut(e,t){return e??t}var Wt=`data-popup-side`,Gt=400,Kt={...fe,...j,popupSide:e=>e?{[Wt]:e}:null,value:()=>null},qt=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:o=!1,nativeButton:s=!0,style:c,...l}=e,{setTouched:u,setFocused:d,validationMode:f,validation:p,state:h,disabled:g}=E(),{labelId:_}=he(),v=Q(),{readOnly:y,required:b,disabled:x}=_t(),S=g||x||o,C=v.useState(`open`),w=v.useState(`mounted`),T=v.useState(`value`),D=v.useState(`triggerProps`),k=v.useState(`positionerElement`),A=v.useState(`listElement`),j=v.useState(`popupSide`),M=v.useState(`id`),F=v.useState(`labelId`),L=v.useState(`hasSelectedValue`),z=w&&k?j:null,te=i??M,ne=Ut(_,F);a({id:i});let re=ee(k),B=Y.useRef(null),{getButtonProps:ie,buttonRef:ae}=P({disabled:S,native:s}),H=v.useStateSetter(`triggerElement`),oe=R(),se=R(),W=R();Y.useEffect(()=>{if(C)return W.start(Gt,()=>{v.context.selectionRef.current.allowUnselectedMouseUp=!0,v.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{W.clear()};v.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},se.clear()},[C,v,se,W]);let G=m(D,{id:te,role:`combobox`,"aria-expanded":C,"aria-haspopup":`listbox`,"aria-controls":C?A?.id??q(k)?.id:void 0,"aria-labelledby":ne,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:S?-1:0,onFocus(e){d(!0),C&&v.context.alignItemWithTriggerActiveRef.current&&v.context.setOpen(!1,U(me,e.nativeEvent)),oe.start(0,()=>{v.set(`forceMount`,!0)})},onBlur(e){O(k,e.relatedTarget)||(u(!0),d(!1),f===`onBlur`&&p.commit(T))},onMouseDown(e){if(C)return;let t=V(e.currentTarget);function n(e){if(!B.current)return;let t=e.target;O(B.current,t)||O(re.current,t)||Ue(e,B.current)||v.context.setOpen(!1,U(N,e))}se.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},l,ie),K=p.getValidationProps(S,G);K.role=`combobox`;let ce={...h,open:C,disabled:S,value:T,readOnly:y,popupSide:z,placeholder:!L};return I(`button`,e,{ref:[t,B,ae,H],state:ce,stateAttributesMapping:Kt,props:K})}),Jt={value:()=>null},Yt=Y.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=Q(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?Lt(l,u,d):It(l,u,d)),I(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:Jt})}),Xt=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o={open:Q().useState(`open`)};return I(`span`,e,{state:o,ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:W})}),Zt=Y.forwardRef(function(e,t){let n=Q(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,X.jsx)(F,{ref:t,...e}):null}),Qt=Y.createContext(void 0);function $t(){let e=Y.useContext(Qt);if(!e)throw Error(B(59));return e}function en(e,t){e&&Object.assign(e.style,t)}var tn={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},nn={position:`fixed`},rn=Y.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:s,align:c,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:g,disableAnchorTracking:v,alignItemWithTrigger:y=!0,collisionAvoidance:b=l,style:ee,...x}=e,S=Q(),C=vt(),w=S.useState(`open`),T=S.useState(`mounted`),E=S.useState(`modal`),D=S.useState(`value`),O=S.useState(`openMethod`),k=S.useState(`positionerElement`),A=S.useState(`triggerElement`),j=S.useState(`isItemEqualToValue`),M=S.useState(`transitionStatus`),N=Y.useRef(null),P=Y.useRef(null),[F,I]=Y.useState(y),L=T&&F&&O!==`touch`;!T&&F!==y&&I(y),Y.useImperativeHandle(S.context.alignItemWithTriggerActiveRef,()=>L),qe((L||E)&&w,O===`touch`,k,A);let R=_({anchor:n,floatingRootContext:C,positionMethod:a,mounted:T,side:s,sideOffset:u,align:c,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:g,disableAnchorTracking:v??L,collisionAvoidance:b,keepMounted:!0}),z=L?`none`:R.side,te=L?nn:R.positionerStyles,ne={open:w,side:z,align:R.align,anchorHidden:R.anchorHidden};h(()=>{S.set(`popupSide`,R.side)},[S,R.side]);let re=S.useStateSetter(`positionerElement`),B=o(e,ne,{styles:te,transitionStatus:M,props:x,refs:[t,re],hidden:!T,inert:!w}),ie=Y.useRef(0),V=De(e=>{if(S.context.valuesRef.current.length===0)return;let t=ie.current;ie.current=e.size;let n=U(me);if(t!==0&&!S.state.multiple&&D!==null&&wt(S.context.valuesRef.current,D,j)===-1){let e=S.context.initialValueRef.current,t=e!=null&&wt(S.context.valuesRef.current,e,j)!==-1?e:null;S.context.setValue(t,n),t===null&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null)}if(t!==0&&S.state.multiple&&Array.isArray(D)){let e=D.filter(e=>wt(S.context.valuesRef.current,e,j)!==-1);e.length!==D.length&&(S.context.setValue(e,n),e.length===0&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null))}if(w&&L){S.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};en(k,e),en(S.context.popupRef.current,e)}}),ae=Y.useMemo(()=>({...R,side:z,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:I,scrollUpArrowRef:N,scrollDownArrowRef:P}),[R,z,L,I]);return(0,X.jsx)(Ke,{elementsRef:S.context.listRef,labelsRef:S.context.labelsRef,onMapChange:V,children:(0,X.jsxs)(Qt.Provider,{value:ae,children:[T&&E&&(0,X.jsx)(de,{inert:J(!w),cutout:A}),B]})})}),an=`base-ui-disable-scrollbar`,on={className:an,getElement(e){return(0,X.jsx)(`style`,{nonce:e,href:an,precedence:`base-ui:low`,children:`.${an}{scrollbar-width:none}.${an}::-webkit-scrollbar{display:none}`})}},sn=Y.createContext(void 0),cn={disableStyleElements:!1};function ln(){return Y.useContext(sn)??cn}var un=`--transform-origin`,dn={...ye,...G},fn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,c=Q(),{multiple:l,readOnly:u,highlightItemOnHover:d}=_t(),f=vt(),{side:p,align:m,alignItemWithTriggerActive:g,isPositioned:_,setControlledAlignItemWithTrigger:v}=$t(),y=Ge(!0)!=null,b=L(),{nonce:ee,disableStyleElements:x}=ln(),S=c.useState(`id`),w=c.useState(`open`),T=c.useState(`openMethod`),E=c.useState(`mounted`),D=c.useState(`popupProps`),O=c.useState(`transitionStatus`),k=c.useState(`triggerElement`),A=c.useState(`positionerElement`),j=c.useState(`listElement`),M=Y.useRef(!1),N=Y.useRef(!1),P=Y.useRef({}),F=C(),R=De(e=>{if(!A||!c.context.popupRef.current||!N.current)return;let t=A.style.top===`0px`,n=A.style.bottom===`0px`;if(M.current||!g||!t&&!n){c.context.handleScrollArrowVisibility(e);return}let r=hn(A),i=gn(A.getBoundingClientRect().height,`y`,r),a=V(A),o=ge(A),s=o.getComputedStyle(A),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=pn(o.getComputedStyle(c.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=mn(e),h=null,_=e=>{A.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=zt(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(M.current=!0),c.context.handleScrollArrowVisibility(e);return}f-y>1?h=t?1/0:0:n&&p<m&&(h=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),h!=null){let t=zt(h,0,mn(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(M.current=!0),c.context.handleScrollArrowVisibility(e)});Y.useImperativeHandle(c.context.scrollHandlerRef,()=>R,[R]),ke({open:w,ref:c.context.popupRef,onComplete(){w&&c.context.onOpenChangeComplete(!0)}});let z={open:w,transitionStatus:O,side:p,align:m};h(()=>{A&&c.context.popupRef.current&&!Object.keys(P.current).length&&(P.current={top:A.style.top||`0`,left:A.style.left||`0`,right:A.style.right,height:A.style.height,bottom:A.style.bottom,minHeight:A.style.minHeight,maxHeight:A.style.maxHeight,marginTop:A.style.marginTop,marginBottom:A.style.marginBottom})},[c,A]),h(()=>{w||g||(N.current=!1,M.current=!1,en(A,P.current))},[w,g,A]),h(()=>{let e=c.context.popupRef.current;if(!w||!k||!A||!e||g&&!_||c.state.transitionStatus===`ending`)return;if(N.current=!0,e.style.removeProperty(un),!g){F.request(()=>c.context.handleScrollArrowVisibility(j||e));return}let t=yn(e);try{let t=c.context.selectedItemTextRef.current;t?.isConnected||(t=!c.select(`hasSelectedValue`)&&c.context.firstItemTextRef.current?.isConnected?c.context.firstItemTextRef.current:null);let n=c.context.valueRef.current,r=ge(A),i=r.getComputedStyle(A),a=r.getComputedStyle(e),o=V(k),l=hn(k),u=_n(k.getBoundingClientRect(),l),f=_n(A.getBoundingClientRect(),l),p=u.height,m=j||e,h=m.scrollHeight,g=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,ee=parseFloat(i.minHeight)||100,x=pn(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-u.bottom+p,T,E=b===`rtl`?u.right-f.width:u.left,D=0;if(t&&n){let e=_n(n.getBoundingClientRect(),l);T=_n(t.getBoundingClientRect(),l),E=f.left+(b===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-u.top+e.height/2;D=T.top-f.top+T.height/2-r}let O=w+D+y+g,N=Math.min(S,O),F=S-_-y,I=O-N,L=C-5;A.style.left=`${zt(E,5,L-f.width)}px`,A.style.height=`${N}px`,A.style.maxHeight=`none`,A.style.marginTop=`${_}px`,A.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=mn(m),z=I>=R-1;z&&(N=Math.min(S,f.height)-(I-R));let te=u.top<20||u.bottom>S-20||Math.ceil(N)+1<Math.min(h,ee),ne=(r.visualViewport?.scale??1)!==1&&s;if(te||ne){en(A,P.current),v(!1);return}let re=Math.max(ee,N);if(z){let e=Math.max(0,S-O);A.style.top=f.height>=F?`0`:`${e}px`,A.style.height=`${N}px`,m.scrollTop=mn(m)}else A.style.bottom=`0`,m.scrollTop=I;if(T){let t=f.top,n=f.height,r=T.top+T.height/2,i=zt(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(un,`50% ${i}%`)}(re===S||N>=x)&&(M.current=!0),c.context.handleScrollArrowVisibility(m),d&&c.state.selectedIndex===null&&c.state.activeIndex===null&&c.context.listRef.current[0]!=null&&c.set(`activeIndex`,0)}finally{t()}},[c,w,A,k,g,v,F,j,d,b,_]),Y.useEffect(()=>{if(!g||!A||!w)return;let e=ge(A);function t(e){c.context.setOpen(!1,U(Ae,e))}return ae(e,`resize`,t)},[c,g,A,w]);let te={...j?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":l||void 0,"aria-readonly":u||void 0,id:`${S}-list`},onKeyDown(e){y&&je.has(e.key)&&e.stopPropagation()},onScroll(e){j||R(e.currentTarget)},...g&&{style:j?{height:`100%`}:tn},className:!j&&g?on.className:void 0},re=I(`div`,e,{ref:[t,c.context.popupRef],state:z,stateAttributesMapping:dn,props:[D,te,ne(O),o]});return(0,X.jsxs)(Y.Fragment,{children:[!x&&on.getElement(ee),(0,X.jsx)(pe,{context:f,modal:!1,disabled:!E,openInteractionType:T,returnFocus:a,restoreFocus:!0,children:re})]})});function pn(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function mn(e){return Bt(e.scrollHeight,e.clientHeight)}function hn(e){return Te.getScale(e)}function gn(e,t,n){return e/n[t]}function _n(e,t){return c({x:gn(e.x,`x`,t),y:gn(e.y,`y`,t),width:gn(e.width,`x`,t),height:gn(e.height,`y`,t)})}var vn=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function yn(e){let{style:t}=e,n={};for(let[e,r]of vn)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of vn){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var bn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Q(),{multiple:s,readOnly:c}=_t(),{alignItemWithTriggerActive:l}=$t(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:tn},className:u&&d!==`touch`?on.className:void 0},p=o.useStateSetter(`listElement`);return I(`div`,e,{ref:[t,p],props:[f,a]})}),xn=Y.createContext(void 0);function Sn(){let e=Y.useContext(xn);if(!e)throw Error(B(57));return e}var Cn=Y.memo(Y.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=Y.useRef(null),d=We({guess:!0,label:o,textRef:u}),f=Q(),{itemProps:p,multiple:m,disabled:g,readOnly:_}=_t(),v=g||s,b=f.useState(`isActive`,d.index),ee=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=f.useState(`isItemEqualToValue`),w=d.index,T=Y.useRef(null);h(()=>{let e=f.context.valuesRef.current;return e[w]=a,()=>{delete e[w]}},[w,a,f]),h(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=Dt(w,a,f.context.valuesRef.current,e,C,t),r=n===w,w===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&xt(a,e,C),r&&(n=w)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[w,m,C,f,a]);let E=Y.useRef(`mouse`),D=Y.useRef(!1),{getButtonProps:O,buttonRef:k}=P({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),A={disabled:v,selected:x,highlighted:b};function j(e){if(g||_)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?Ot(n,a,C):[...n,a];f.context.setValue(r,U(Se,e))}else f.context.setValue(a,U(Se,e)),f.context.setOpen(!1,U(Se,e))}function M(){f.context.selectionRef.current.dragY=0}let N={role:`option`,"aria-selected":x,tabIndex:ee&&b?0:-1,onKeyDown(e){f.set(`activeIndex`,w),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=E.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&y(e.nativeEvent)&&(n!==void 0||b),i=t&&!r&&!D.current;D.current=!1,!(v||i)&&j(e.nativeEvent)},onPointerEnter(e){E.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){E.current=e.pointerType,D.current=!0,M()},onMouseUp(){if(M(),v||E.current===`touch`||D.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(D.current=!0,T.current?.click(),D.current=!1)}},F=I(`div`,e,{ref:[k,t,d.ref,T],state:A,props:[p,N,l,O]}),L=Y.useMemo(()=>({selected:x,index:w,textRef:u,selectedByFocus:S}),[x,w,u,S]);return(0,X.jsx)(xn.Provider,{value:L,children:F})})),wn=Y.forwardRef(function(e,t){let{selected:n}=Sn();return e.keepMounted||n?(0,X.jsx)(Tn,{...e,ref:t}):null}),Tn=Y.memo(Y.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Sn(),c=Y.useRef(null),{transitionStatus:l,setMounted:u}=ve(s),d=I(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:G});return ke({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||u(!1)}}),d})),En=Y.memo(Y.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Sn(),a=Q(),{render:o,className:s,style:c,...l}=e,u=Y.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]);return I(`div`,e,{ref:[u,t,r],props:l})})),Dn=Y.createContext(void 0),On=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Y.useState(),c=Y.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=I(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,X.jsx)(Dn.Provider,{value:c,children:l})}),kn=Ht;function An({className:e,...t}){return(0,X.jsx)(On,{"data-slot":`select-group`,className:p(`scroll-my-1 p-1`,e),...t})}function jn({className:e,...t}){return(0,X.jsx)(Yt,{"data-slot":`select-value`,className:p(`flex flex-1 text-left`,e),...t})}function Mn({className:e,size:t=`default`,flat:n=!1,children:r,...i}){return(0,X.jsxs)(qt,{"data-slot":`select-trigger`,"data-size":t,"data-flat":n?`true`:void 0,className:p(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n&&`rounded-none border-0 bg-transparent shadow-none hover:bg-transparent focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`,e),...i,children:[r,(0,X.jsx)(Xt,{render:(0,X.jsx)(d,{icon:et,className:`pointer-events-none size-4 text-muted-foreground`,strokeWidth:1.5})})]})}function Nn({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,X.jsx)(Zt,{children:(0,X.jsx)(rn,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,X.jsx)(fn,{"data-slot":`select-content`,"data-align-trigger":o,className:p(`cn-menu-target cn-menu-translucent relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...s,children:(0,X.jsx)(bn,{children:t})})})})}function Pn({className:e,children:t,...n}){return(0,X.jsxs)(Cn,{"data-slot":`select-item`,className:p(`relative flex w-full cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,X.jsx)(En,{className:`flex min-w-0 flex-1 items-center gap-2`,children:t}),(0,X.jsx)(wn,{render:(0,X.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 right-2 flex size-4 -translate-y-1/2 items-center justify-center`}),children:(0,X.jsx)(d,{icon:k,className:`pointer-events-none size-3.5`,strokeWidth:1.5})})]})}var Fn=new Set([`ALL`,`SELECT`,`INSERT`,`UPDATE`,`DELETE`]),In=new Set([`PERMISSIVE`,`RESTRICTIVE`]),Ln=new Set([`public`,`current_role`,`current_user`,`session_user`]),Rn=`oke_app`;`${[`CREATE SCHEMA IF NOT EXISTS oke`,`SET search_path TO public, oke`,`DO $oke_search_path$
2
2
  BEGIN
3
3
  EXECUTE 'ALTER ROLE CURRENT_USER SET search_path TO public, oke';
4
4
  EXCEPTION
@@ -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{Cr as r,Dr as i,E as a,Er as o,F as s,I as c,Or as l,R as u,Tr as d,_r as f,a as p,ar as m,br as h,cr as g,dr as _,er as v,fr as y,i as b,ir as x,kr as S,l as C,lr as w,mr as T,nr as E,o as D,or as O,pr as k,rr as A,s as j,tr as M,u as N,ur as P,vr as F,wr as I,x as L,xr as R,yr as ee}from"./shortcut-keys-3ILd8oGn.js";import{c as te,l as ne,n as re,o as ie,r as ae,t as oe}from"./call-pii-button-C4lmY7ck.js";import{a as z,n as se,r as ce,t as le}from"./http-method-CwFeFroN.js";import{a as ue,b as de,c as fe,g as pe,i as me,m as he,n as ge,o as _e,r as ve,s as ye,t as be}from"./element-icons-BI8cJgdh.js";import{a as xe,i as Se,n as Ce,o as we,r as Te,s as Ee,t as De}from"./collapsible-82y257sL.js";import{a as Oe,c as ke,f as Ae,i as je,s as Me,t as Ne,u as Pe}from"./highlighted-json-yE9zNTqC.js";import{a as Fe,c as Ie,d as Le,f as Re,l as ze,m as Be,o as Ve,p as B,s as He,t as Ue,u as We,w as Ge}from"./request-meta-CzrOfgiz.js";import{t as Ke}from"./UserIcon-DaE2PB5_.js";import{n as qe}from"./dagre.esm-B1_XeuLP.js";import{$ as V,G as Je,Q as H,X as U,Y as W,a as Ye,c as Xe,d as Ze,et as G,f as Qe,h as $e,i as et,n as tt,nt,o as rt,p as it,r as at,s as ot,t as st,u as ct,ut as lt,v as ut}from"./tree-expand-toggle-CzGIyOPY.js";import{d as dt,r as ft,t as pt}from"./dropdown-menu-4h2LOVXM.js";import{at as mt,gt as ht,yt as gt}from"./index-r7xXt_VV.js";import{t as _t}from"./explorer-empty-CJs5A-wm.js";import{c as K,n as vt,t as yt,u as bt}from"./detail-header-DVWNjWjg.js";import{c as xt,n as St,s as Ct,t as wt}from"./cache-glyph-Ceaq9pYh.js";var Tt=[[`path`,{d:`M16.4999 3.26621C17.3443 3.25421 20.1408 2.67328 20.7337 3.26621C21.3266 3.85913 20.7457 6.65559 20.7337 7.5M20.5059 3.49097L13.5021 10.4961`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M3.26636 16.5001C3.25436 17.3445 2.67343 20.141 3.26636 20.7339C3.85928 21.3268 6.65574 20.7459 7.50015 20.7339M10.502 13.4976L3.49824 20.5027`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],Et=[[`path`,{d:`M21 6.5C21 8.15685 19.6569 9.5 18 9.5C16.3431 9.5 15 8.15685 15 6.5C15 4.84315 16.3431 3.5 18 3.5C19.6569 3.5 21 4.84315 21 6.5Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M9 12C9 13.6569 7.65685 15 6 15C4.34315 15 3 13.6569 3 12C3 10.3431 4.34315 9 6 9C7.65685 9 9 10.3431 9 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M21 17.5C21 19.1569 19.6569 20.5 18 20.5C16.3431 20.5 15 19.1569 15 17.5C15 15.8431 16.3431 14.5 18 14.5C19.6569 14.5 21 15.8431 21 17.5Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M8.72852 10.7495L15.2285 7.75M8.72852 13.25L15.2285 16.2495`,stroke:`currentColor`,strokeWidth:`1.5`,key:`3`}]],Dt=[[`path`,{d:`M15.1312 2.5C14.1462 2.17555 13.0936 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 10.9548 21.8396 9.94704 21.5422 9`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12C7 9.23858 9.23858 7 12 7`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M19.5 4.5L12 12M19.5 4.5V2M19.5 4.5H22`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`2`}]],q=e(t(),1),J=n();function Ot(e,t){let n=ot(e.asGate);return n===`operator`?`Operator`:n===`public`?`Public`:e.asUserId?t.find(t=>t.id===e.asUserId)?.name??e.asUserId:e.asGate?`As · ${e.asGate}`:`As`}function Y(e){let t=ot(e.asGate);return t===`operator`||t===`public`||!!(e.asUserId||e.asGate)}function kt({manifest:e,identities:t,value:n,onChange:r}){let a=Je(!0),s=(0,q.useMemo)(()=>$e(ut(e),a.data??null),[e,a.data]),c=(0,q.useMemo)(()=>Xe(s),[s]),l=(0,q.useMemo)(()=>ct(t,s),[t,s]),u=s.gates.find(e=>e.kind===`public`)?.description??`Intentionally unauthenticated.`,d=ot(n.asGate),f=n.asGate!==null,[p,m]=(0,q.useState)(n.asUserId?`user`:`policy`),h=c.find(e=>e.id===n.asGate)??null,g=l.find(e=>e.id===n.asUserId&&e.gate===n.asGate)??null,_=c.length>0||l.length>0,v=e=>{if(e===`operator`){r({asGate:null,asUserId:null});return}if(e===`public`){r({asGate:`public`,asUserId:null});return}if(d===`as`)return;let t=h?.id??c[0]?.id??l[0]?.gate??null;if(t!==null){if(l[0]&&t===l[0].gate&&c.length===0){m(`user`),r({asGate:l[0].gate,asUserId:l[0].id});return}m(`policy`),r({asGate:t,asUserId:null})}};return(0,J.jsxs)(pt,{children:[(0,J.jsx)(dt,{render:e=>(0,J.jsxs)(L,{...e,type:`button`,variant:`ghost`,size:`sm`,className:o(`h-full max-w-44 min-w-0 rounded-none px-2 text-[11px]`,f&&`text-sky-800 dark:text-sky-300`),"aria-label":f?`Invoke as Gate ${n.asGate}`:`Invoke as Operator (bypass gates)`,"data-slot":`call-api-identity`,children:[(0,J.jsx)(i,{icon:be.gate.icon,"data-icon":`inline-start`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`truncate`,children:Ot(n,t)})]})}),(0,J.jsxs)(ft,{align:`end`,className:`w-80 overflow-hidden p-0`,children:[(0,J.jsx)(rt,{children:`Invoke as`}),(0,J.jsxs)(Ye,{label:`Invoke as`,children:[(0,J.jsx)(at,{mode:`operator`,title:`Operator`,caption:`Bypass`,selected:d===`operator`,onSelect:()=>v(`operator`)}),(0,J.jsx)(at,{mode:`public`,title:`Public`,caption:`Anonymous`,selected:d===`public`,onSelect:()=>v(`public`)}),(0,J.jsx)(at,{mode:`as`,title:`As`,caption:g?g.label:h?.label??`User / policy`,selected:d===`as`,disabled:!_,onSelect:()=>v(`as`)})]}),d===`operator`?(0,J.jsx)(et,{title:`Operator`,badge:`Default`,children:`Bypasses the flow's gate chain.`}):null,d===`public`?(0,J.jsxs)(et,{title:`Public`,children:[u,` Only `,(0,J.jsx)(`span`,{className:`font-mono`,children:`gate.public`}),` flows succeed.`]}):null,d===`as`?(0,J.jsx)(tt,{tab:p,onTabChange:m,policies:c,users:l,asGate:n.asGate,asUserId:g?.id??null,onSelectPolicy:e=>{m(`policy`),r({asGate:e.id,asUserId:null})},onSelectUser:e=>{m(`user`),r({asGate:e.gate,asUserId:e.id})},hint:g?(0,J.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[`Calls as `,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:g.label}),` `,`via `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.asGate}),`.`]}):h?(0,J.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[h.detail,` Sets scopes for`,` `,(0,J.jsx)(`span`,{className:`font-mono`,children:h.id}),`.`]}):null}):null]})]})}var At=new Set([`q`,`query`,`search`,`limit`,`offset`,`cursor`,`page`,`pageSize`,`perPage`,`per_page`,`page_size`,`order`,`orderBy`,`order_by`,`sort`,`sortBy`,`sort_by`,`direction`]);function jt(e,t=[]){let n=new Set,r=[];for(let i of t){n.add(i);let t=e.find(e=>e.name===i);r.push(t??Mt(i))}let i=[];for(let t of e)n.has(t.name)||(At.has(t.name)?r.push(t):i.push(t));return{parameters:r,fields:i}}function Mt(e){return{path:`/path/${e}`,name:e,type:`string`,required:!0}}function Nt(e,t={}){let n=t.pathParams??[],r=new Set(n);if(t.http!==!0)return{path:[],query:[],body:e};let i=e.filter(e=>!r.has(e.name));return se(t.method)?{path:n,query:[],body:i}:{path:n,query:i,body:[]}}function Pt(e,t){let n={};for(let r of t)Object.hasOwn(e,r.name)&&(n[r.name]=e[r.name]);return n}function X(e,t=``){if(!e)return[];if(e.type===`object`||e.properties){let n=e.properties??{},r=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(n).map(([e,n])=>Ft(e,`${t}/${e}`,n,r.has(e)))}return[Ft(`value`,t||`/`,e,!0)]}function Ft(e,t,n,r){let i=It(e,n),a=typeof n.description==`string`?n.description:void 0;if(Array.isArray(n.enum)){let o=Ut(n);return{path:t,name:e,type:`enum`,required:r,enumValues:n.enum.map(String),...a===void 0?{}:{description:a},...o===void 0?{}:{valueMeanings:o},...i}}let o=n.type;if(o===`object`||n.properties)return{path:t,name:e,type:`object`,required:r,...a===void 0?{}:{description:a},...i,children:X(n,t)};if(o===`array`)return{path:t,name:e,type:`array`,required:r,...a===void 0?{}:{description:a},...i,children:n.items?X(n.items,`${t}/0`):void 0};let s=o===`integer`||o===`number`||o===`boolean`||o===`string`?o:`unknown`,c=Ut(n);return{path:t,name:e,type:s,required:r,minimum:typeof n.minimum==`number`?n.minimum:void 0,maximum:typeof n.maximum==`number`?n.maximum:void 0,...a===void 0?{}:{description:a},...c===void 0?{}:{valueMeanings:c},...i}}function It(e,t){let n=Lt(e),r=Rt(t.references),i=t.primaryKey===!0||n.primaryKey===!0,a=r!==void 0||n.foreignKey===!0,o=!i&&(t.unique===!0||n.unique===!0);return{...t.pii===!0?{pii:!0}:{},...t.sensitive===!0?{sensitive:!0}:{},...i?{primaryKey:!0}:{},...a?{foreignKey:!0}:{},...o?{unique:!0}:{},...r===void 0?{}:{references:r}}}function Lt(e){return e===`id`?{primaryKey:!0}:/(?:Id|_id)$/.test(e)||/(?:Key|_key)$/.test(e)&&e!==`key`?{foreignKey:!0}:e===`identifier`||e===`key`?{unique:!0}:{}}function Rt(e){if(!e||typeof e!=`object`)return;let t=`table`in e&&typeof e.table==`string`?e.table:void 0;if(!t)return;let n=`column`in e&&typeof e.column==`string`?e.column:void 0;return n===void 0?{table:t}:{table:t,column:n}}var zt=12;function Bt(e){return e.enumValues&&e.enumValues.length>0?e.enumValues.join(` · `):e.minimum!==void 0&&e.maximum!==void 0?`${e.minimum}–${e.maximum}`:e.minimum===void 0?e.maximum===void 0?null:`≤ ${e.maximum}`:`≥ ${e.minimum}`}function Vt(e){return e.minimum!==void 0&&e.maximum!==void 0?`Must be from ${e.minimum} up to ${e.maximum}.`:e.minimum===void 0?e.maximum===void 0?null:`Must be at most ${e.maximum}.`:`Must be at least ${e.minimum}.`}function Ht(e){return e.filter(e=>e.minimum!==void 0||e.maximum!==void 0||(e.enumValues?.length??0)>0||(e.valueMeanings?.length??0)>0)}function Ut(e){let t=Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:null;if(t){let e=[];for(let n of t){if(!n||typeof n!=`object`)continue;let t=n;if(!(`const`in t))continue;let r=String(t.const),i=typeof t.title==`string`?t.title:typeof t.description==`string`?t.description:void 0;i&&e.push({value:r,label:i})}return e.length>0?e:void 0}}function Wt(e){if(e.type!==`integer`||e.minimum===void 0||e.maximum===void 0||!Number.isInteger(e.minimum)||!Number.isInteger(e.maximum))return null;let t=e.maximum-e.minimum;return t<0||t>zt?null:Array.from({length:t+1},(t,n)=>e.minimum+n)}function Gt(e){return e?Kt(e):{}}function Kt(e){if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];let t=e.type;if(t===`object`||!t&&e.properties){let t=e.properties??{},n=new Set(Array.isArray(e.required)?e.required:[]),r={};for(let[e,i]of Object.entries(t))(n.has(e)||`default`in i||Object.keys(t).length<=4)&&(r[e]=Kt(i));return r}if(t===`array`){let t=e.items;return t?[Kt(t)]:[]}return t===`integer`||t===`number`?typeof e.default==`number`?e.default:typeof e.minimum==`number`?e.minimum:1:t===`boolean`?!1:t===`string`?e.format===`email`?`user@example.com`:e.format===`uuid`?`00000000-0000-4000-8000-000000000001`:typeof e.default==`string`?e.default:e.minLength?`x`.repeat(Number(e.minLength)):``:null}function qt(e){return!e||typeof e==`string`?null:e}function Jt(e,t){if(!e.foreignKey||!t)return null;let n=Qt(t);if(n.length===0)return null;if(e.references?.table){let t=$t(n,e.references.table);return t?Xt(t,e.references.column??tn(t.table)??`id`):null}let r=Zt(e.name);if(!r)return null;let i=en(n,r.stem);return i?Xt(i,r.kind===`key`?nn(i.table,`key`)??tn(i.table)??`id`:tn(i.table)??`id`):null}function Yt(e,t){if(!t)return[];let n=new Set,r=[];for(let i of e){let e=i[t.column];if(e==null)continue;let a=String(e);if(n.has(a))continue;n.add(a);let o=t.labelColumn?i[t.labelColumn]:void 0,s=o!=null&&String(o)!==a?String(o):null;r.push({value:a,label:s?`${a} · ${s}`:a})}return r}function Xt(e,t){let n=rn(e.table,t);return{ref:e.ref,child:e.name,column:t,...n===void 0?{}:{labelColumn:n}}}function Zt(e){return e===`id`?null:e.endsWith(`Id`)?{stem:e.slice(0,-2),kind:`id`}:e.endsWith(`_id`)?{stem:e.slice(0,-3),kind:`id`}:e.endsWith(`Key`)?{stem:e.slice(0,-3),kind:`key`}:e.endsWith(`_key`)?{stem:e.slice(0,-4),kind:`key`}:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(e.stores??{}))r.facet===`sql`&&r.tables&&t.push({ref:`sql:${n}`,tables:r.tables});return t}function $t(e,t){let n=t.toLowerCase();for(let t of e)for(let[e,r]of Object.entries(t.tables))if(e.toLowerCase()===n)return{ref:t.ref,name:e,table:r};return null}function en(e,t){let n=sn(t),r=[t,n,on(t),on(n)].map(e=>e.toLowerCase());for(let t of e)for(let[e,n]of Object.entries(t.tables))if(r.includes(e.toLowerCase()))return{ref:t.ref,name:e,table:n};return null}function tn(e){for(let[t,n]of Object.entries(e.columns??{}))if(an(n)&&n.primaryKey===!0)return t;if(e.columns&&`id`in e.columns)return`id`}function nn(e,t){return e.columns&&t in e.columns?t:void 0}function rn(e,t){if(t!==`name`&&e.columns&&`name`in e.columns)return`name`}function an(e){return`type`in e||`primaryKey`in e||`references`in e}function on(e){return e.endsWith(`y`)&&!/[aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(?:s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}function sn(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function cn(e){let t=[];for(let n of e.split(`/`))n.startsWith(`:`)&&n.length>1&&t.push(n.slice(1));return t}function ln(e){return`:${e}`}var un={"attachments:id":`attachments/tsk_eng_12/spec.pdf`,"tasks:id":`tsk_eng_12`,"comments:id":`cmt_1`,"projects:id":`proj_api`,"spaces:id":`space_eng`,"tags:id":`tag_bug`,"tags:tagId":`tag_feature`,"goals:id":`goal_harbor`,"documents:id":`doc_prd_api`,"members:id":`mem_aria`,"forms:id":`form_customer`,"drafts:id":`ENG-12`,"views:id":`view_web_board`,"inbox:id":`inb_1`};function dn(e,t){let n=e.split(`/`).filter(Boolean),r=`:${t}`,i=n.indexOf(r),a=i>0?n[i-1]:void 0;return(a?un[`${a}:${t}`]:void 0)??un[`:${t}`]}function fn(e,t){let n={};if(!e)return n;for(let r of t){let t=dn(e,r);t&&(n[r]=t)}return n}function pn(e,t){let n=e?.flows?.[t],r=n?.trigger?.cron,i=n?.trigger?.every;if(!r&&!i)return{kind:`unmatched`};let a=e?.clocks??{},o=new Set;for(let[e,n]of Object.entries(a)){if(t===e||t.endsWith(`.${e}`)){o.add(e);continue}if(r&&n.cron===r){o.add(e);continue}i&&n.every===i&&o.add(e)}if(o.size!==1)return{kind:`unmatched`};let s=[...o][0],c=a[s];return{kind:`matched`,clockName:s,timezone:c.timezone??null,description:c.description??null,cron:c.cron??null,every:c.every??null}}function mn(e){let t=e.handlerMs!=null&&Number.isFinite(e.handlerMs)?e.handlerMs:null;return t===null?e.rttMs!==null&&Number.isFinite(e.rttMs)?{primaryMs:e.rttMs,primaryKind:`rtt`,rttMs:e.rttMs}:null:{primaryMs:t,primaryKind:`handler`,rttMs:e.rttMs}}function hn(e){let t=new Set;if(!e?.stores)return t;for(let n of Object.values(e.stores)){for(let e of Object.values(n.tables??{}))for(let[n,r]of Object.entries(e.columns??{}))r?.pii&&ae(t,n);for(let[e,r]of Object.entries(n.classifications??{}))if(r&&typeof r==`object`&&!Array.isArray(r)&&`pii`in r&&r.pii){let n=e.includes(`.`)?e.slice(e.lastIndexOf(`.`)+1):e;ae(t,n)}}return t}function gn(e,t,n=re){if(t.size===0||e==null)return e;if(Array.isArray(e))return e.map(e=>gn(e,t,n));if(typeof e==`object`){let r={};for(let[i,a]of Object.entries(e))r[i]=t.has(i)?n:gn(a,t,n);return r}return e}function _n(e){return e.failure==null?e.response!==void 0&&e.response!==null?JSON.stringify(e.response,null,2):JSON.stringify({status:e.status??200,failure:null,response:null},null,2):JSON.stringify({status:e.status??null,failure:e.failure,response:e.response??null},null,2)}function vn(e,t,n){return t&&e.masked===!1?_n({...e,response:gn(e.response,n),failure:e.failure===void 0?void 0:{...e.failure,data:gn(e.failure.data,n)},masked:!0}):_n(e)}function yn(e){let t=e.flow.effects;return!t||(t.writes?.length??0)===0&&(t.emits?.length??0)===0&&(t.sends?.length??0)===0&&(t.asks?.length??0)===0&&(t.embeds?.length??0)===0&&(t.fetches?.length??0)===0}function bn(e,t){return!t&&yn(e)}function xn(e,t){if(!e)return{ok:!0,errors:[],value:t};let n=[];return Sn(e,t,``,n),{ok:n.length===0,errors:n,value:t}}function Sn(e,t,n,r){let i=e.type;if(i===`object`||e.properties){if(typeof t!=`object`||!t||Array.isArray(t)){r.push({path:n||`/`,message:`must be object`});return}let i=t,a=e.properties??{},o=Array.isArray(e.required)?e.required:[];for(let e of o)(i[e]===void 0||i[e]===null||i[e]===``)&&r.push({path:`${n}/${e}`,message:`required`});for(let[e,t]of Object.entries(a))i[e]!==void 0&&Sn(t,i[e],`${n}/${e}`,r);return}if(Array.isArray(e.enum)){e.enum.map(String).includes(String(t))||r.push({path:n||`/`,message:`invalid enum`});return}i===`string`&&typeof t!=`string`?r.push({path:n||`/`,message:`must be string`}):i===`integer`?typeof t!=`number`||!Number.isInteger(t)?r.push({path:n||`/`,message:`must be integer`}):Cn(e,t,n,r):i===`number`?typeof t!=`number`||Number.isNaN(t)?r.push({path:n||`/`,message:`must be number`}):Cn(e,t,n,r):i===`boolean`&&typeof t!=`boolean`&&r.push({path:n||`/`,message:`must be boolean`})}function Cn(e,t,n,r){let i=typeof e.minimum==`number`?e.minimum:void 0,a=typeof e.maximum==`number`?e.maximum:void 0;i!==void 0&&t<i&&r.push({path:n||`/`,message:`must be ≥ ${i}`}),a!==void 0&&t>a&&r.push({path:n||`/`,message:`must be ≤ ${a}`})}function wn(e){return JSON.stringify(e,null,2)}function Tn({row:e,manifest:t}){let n=B(e.flow.trigger);return n===`cron`||n===`every`?(0,J.jsx)(En,{row:e,manifest:t}):(0,J.jsx)(Dn,{row:e,kind:n,manifest:t})}function En({row:e,manifest:t}){let n=(0,q.useMemo)(()=>pn(t,e.id),[t,e.id]),r=Ze(),a=Qe(),o=it(),[s,c]=(0,q.useState)({asGate:null,asUserId:null}),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null);(0,q.useEffect)(()=>{r.reset(),o.reset(),f(null),u(null)},[e.id]);let p=n.kind===`matched`;async function m(){if(u(performance.now()),p){f(`clock`);try{await r.mutateAsync({name:n.clockName})}catch{}return}if(Y(s)){f(`invoke`);try{await o.mutateAsync({flowId:e.id,body:{},...s.asUserId?{asUserId:s.asUserId}:{},...s.asGate?{asGate:s.asGate}:{}})}catch{}}}let h=p?r.isPending:o.isPending,g=p?r.isError:o.isError||o.isSuccess&&o.data?.failure!=null,_=p?r.isSuccess:o.isSuccess&&!o.data?.failure,v=l!==null&&(_||g)?performance.now()-l:null,y=(0,q.useMemo)(()=>p&&r.data?JSON.stringify(r.data,null,2):!p&&o.data?_n(o.data):null,[p,r.data,o.data]),b=p?`Run now`:`Run handler`,x=p?`Run now`:`Run handler once`;return(0,J.jsx)(jn,{title:b,dataMode:p?`clock`:`invoke-fallback`,actions:(0,J.jsxs)(J.Fragment,{children:[p?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kt,{manifest:t,identities:a.data??[],value:s,onChange:c}),(0,J.jsx)(In,{})]}),(0,J.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:h||!p&&!Y(s),onClick:()=>void m(),className:Fn,children:h?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:mt,className:`animate-spin`,"data-icon":`inline-start`}),`Running…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:te,"data-icon":`inline-start`}),x]})})]}),children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[p?(0,J.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,"data-slot":`clock-path-copy`,children:[`Fires Manifest clock`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:n.clockName}),` `,`via`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/clock/run-now`}),` `,`(lease-gated — the real scheduler path).`,n.timezone?(0,J.jsxs)(J.Fragment,{children:[` `,`Timezone · `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.timezone}),`.`]}):null]}):(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-snug text-foreground/90`,"data-slot":`invoke-fallback-copy`,role:`note`,children:[`No unique Manifest clock matches this flow's schedule.`,` `,(0,J.jsx)(`strong`,{className:`font-medium`,children:`Run handler once`}),` uses`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),` `,`with empty input — it does `,(0,J.jsx)(`em`,{children:`not`}),` exercise the Clock lease / scheduler path.`]}),(0,J.jsx)(On,{failed:!!g,success:!!_,elapsed:v,handlerMs:p?null:o.data?.durationMs,statusCode:p?r.data?.ran?200:409:o.data?.status,errorMessage:p?r.isError?r.error.message:null:o.isError?o.error.message:null,responseJson:y,emptyHint:p?`Run now to fire the real clock tick.`:`Run handler once to invoke with empty input.`,pathUsed:d,cache:p?void 0:o.data?.cache})]})})}function Dn({row:e,kind:t,manifest:n}){let r=Qe(),l=it(),d=qt(e.flow.in),f=(0,q.useMemo)(()=>X(d),[d]),p=(0,q.useMemo)(()=>t===`http`&&e.path?cn(e.path):[],[t,e.path]),m=(0,q.useMemo)(()=>Nt(f,{http:t===`http`,method:e.method,pathParams:p}),[f,t,e.method,p]),h=t!==`http`||se(e.method),[g,_]=(0,q.useState)({asGate:null,asUserId:null}),[v,y]=(0,q.useState)(!0),[b,x]=(0,q.useState)(()=>fn(e.path,p)),S=(0,q.useMemo)(()=>Gt(d)??{},[d]),C=(0,q.useMemo)(()=>Pt(S,m.query),[S,m.query]),w=(0,q.useMemo)(()=>Pt(S,m.body),[S,m.body]),[T,E]=(0,q.useState)(C),[D,O]=(0,q.useState)(w),[k,A]=(0,q.useState)(`fields`),[j,M]=(0,q.useState)(()=>wn(w)),[N,P]=(0,q.useState)(null),[F,I]=(0,q.useState)([]),[R,ee]=(0,q.useState)(null),[ne,re]=(0,q.useState)(null);(0,q.useEffect)(()=>{E(C),O(w),M(wn(w)),P(null),A(`fields`),x(fn(e.path,p)),I([]),re(null),ee(null),l.reset()},[e.id]);function ie(e){try{let t=JSON.parse(e);return typeof t!=`object`||!t||Array.isArray(t)?(P(`Body must be a JSON object.`),!1):(O(t),P(null),!0)}catch(e){return P(e instanceof Error?e.message:`Invalid JSON.`),!1}}function ae(e){if(e!==k){if(e===`raw`){M(wn(D)),P(null),A(`raw`);return}ie(j)&&A(`fields`)}}async function z(t=!v){let n=h?D:{};if(h&&k===`raw`){if(!ie(j))return;try{n=JSON.parse(j)}catch{return}}let r={...T,...n},i=xn(d,{...b,...r});if(!i.ok){I(i.errors);return}if(I([]),Y(g)){ee(performance.now());try{await l.mutateAsync({flowId:e.id,body:r,...g.asUserId?{asUserId:g.asUserId}:{},...g.asGate?{asGate:g.asGate}:{},...p.length>0?{pathParams:b}:{},...t?{revealPii:!0}:{}})}catch{}}}function ce(){E(C),O(w),M(wn(w)),P(null),x(fn(e.path,p)),I([])}(0,q.useEffect)(()=>{R===null||l.isPending||(l.isSuccess||l.isError)&&re(performance.now()-R)},[l.isSuccess,l.isError,l.isPending,R]);let le=(0,q.useMemo)(()=>l.data?vn(l.data,v,hn(n)):null,[l.data,v,n]),ue=l.data?.failure!=null,de=l.data?.status,fe=t===`http`?`Call API`:t===`signal`?`Run handler`:`Invoke`,pe=fe;return(0,J.jsx)(jn,{title:fe,dataTrigger:t,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kt,{manifest:n,identities:r.data??[],value:g,onChange:_}),(0,J.jsx)(oe,{piiMasked:v,disabled:l.isPending,onToggle:()=>{let t=!v;y(t),l.data&&!l.isPending&&bn(e,t)&&z(!0)}}),h?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(In,{}),(0,J.jsx)(Mn,{view:k,onChange:ae})]}):null,(0,J.jsx)(In,{}),(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsxs)(L,{...e,type:`button`,variant:`ghost`,"data-slot":`call-api-reset`,disabled:l.isPending,onClick:ce,className:Pn,children:[(0,J.jsx)(i,{icon:Ae,"data-icon":`inline-start`}),`Reset`]})}),(0,J.jsx)(c,{side:`bottom`,className:`text-[11px]`,children:h?`Reset body to the schema example`:`Reset to schema examples`})]}),(0,J.jsx)(In,{}),(0,J.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:l.isPending||!Y(g),onClick:()=>void z(),className:Fn,children:l.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:mt,className:`animate-spin`,"data-icon":`inline-start`}),`Calling…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:te,"data-icon":`inline-start`}),pe]})})]}),children:(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`min-h-0 min-w-0 shrink overflow-y-auto`,children:[t===`http`?(0,J.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:[`Operator session · invoke-as`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`console:flows:invoke-as`})]}):null,t===`signal`?(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-snug text-foreground/90`,"data-slot":`signal-honest-copy`,role:`note`,children:[(0,J.jsx)(`strong`,{className:`font-medium`,children:`Run handler directly`}),` — invokes the flow with your payload via`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),`. It does `,(0,J.jsx)(`em`,{children:`not`}),` publish on the signal bus, so it does not test delivery physics (once / broadcast / live, retries, dead-letter).`]}):null,t===`internal`?(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-border/60 bg-muted/20 px-3 py-2 text-[11px] leading-snug text-muted-foreground`,"data-slot":`call-only-bypass-copy`,role:`note`,children:[`This flow has no external trigger. Invoking here bypasses its normal caller (`,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`fx.call`}),` /`,` `,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`effects.calls`}),`). The body still matches `,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`flow.in`}),`.`]}):null,t===`cdc`?(0,J.jsx)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:`Direct handler invoke — not a Store CDC event.`}):null,p.length>0?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Path params`,"data-slot":`call-api-path`,children:[(0,J.jsx)(Rn,{title:`Path params`,hint:e.path??void 0}),p.map(e=>(0,J.jsx)(K,{label:e,className:`[&>span]:px-3`,children:(0,J.jsx)(a,{id:`path-${e}`,flat:!0,className:o(vt,`px-3 font-mono`),placeholder:ln(e),value:b[e]??``,onChange:t=>x(n=>({...n,[e]:t.target.value}))})},e))]}):null,m.query.length>0?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Query params`,"data-slot":`call-api-query`,children:[(0,J.jsx)(Rn,{title:`Query params`,hint:`seeded from schema`}),(0,J.jsx)(bt,{children:m.query.map(e=>(0,J.jsx)(zn,{field:e,idPrefix:`query`,value:T[e.name],onChange:t=>E(n=>({...n,[e.name]:t})),error:F.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,h?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Body`,"data-slot":`call-api-body`,children:[(0,J.jsx)(Rn,{title:`Body`,hint:k===`raw`?`raw JSON`:`seeded from schema`}),k===`raw`?(0,J.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,J.jsx)(`textarea`,{"data-slot":`call-api-body-raw`,"aria-label":`Raw JSON body`,spellCheck:!1,value:j,onChange:e=>{M(e.target.value),N&&P(null)},className:o(`min-h-40 w-full resize-y rounded-none border-0 bg-transparent px-3 py-2 font-mono text-xs leading-relaxed text-foreground outline-none`,`placeholder:text-muted-foreground focus-visible:bg-muted/20`,N&&`text-destructive`)}),N?(0,J.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-xs text-destructive`,"data-slot":`call-api-raw-error`,children:N}):null]}):m.body.length===0?(0,J.jsx)(`p`,{className:`border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No body fields (empty object).`}):(0,J.jsx)(bt,{children:m.body.map(e=>(0,J.jsx)(zn,{field:e,value:D[e.name],onChange:t=>O(n=>({...n,[e.name]:t})),error:F.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,F.length>0?(0,J.jsx)(`p`,{role:`alert`,className:`px-3 py-2 text-xs text-destructive`,"data-slot":`call-api-validation`,children:`Fix contract errors before sending.`}):null]}),(0,J.jsx)(On,{failed:!!ue,success:!!l.data&&!ue,elapsed:ne,handlerMs:l.data?.durationMs,statusCode:de,errorMessage:l.isError?l.error.message:null,responseJson:le,emptyHint:`Call to see a real host response.`,pathUsed:null,cache:l.data?.cache})]})})}function On({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,errorMessage:s,responseJson:c,emptyHint:l,pathUsed:u,cache:d}){let[f,m]=(0,q.useState)(!1),h=(0,J.jsx)(An,{failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:u,cache:d});return(0,J.jsxs)(`section`,{className:`flex min-h-56 min-w-0 flex-1 flex-col overflow-hidden`,"aria-label":`Response`,"data-slot":`call-api-response-block`,children:[(0,J.jsxs)(`div`,{className:F,children:[(0,J.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,J.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,c?(0,J.jsx)(ye,{label:`Expand response`,className:`flex self-stretch`,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":`Expand response`,"data-slot":`call-api-response-expand`,className:g,onClick:()=>m(!0),children:(0,J.jsx)(i,{icon:Tt,className:`size-3.5`,"aria-hidden":!0})})}):null]})]}),s?(0,J.jsx)(`p`,{role:`alert`,className:`px-2 py-2 text-sm text-destructive`,"data-slot":`call-api-error`,children:s}):null,c?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-slot":`call-api-response-frame`,children:[(0,J.jsx)(`div`,{className:o(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0,"data-slot":`call-api-response-rail`}),(0,J.jsx)(Ne,{json:c,dataSlot:`call-api-response`,className:`flex min-h-0 flex-1 overflow-auto`})]}):(0,J.jsx)(`p`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:l}),c?(0,J.jsx)(b,{open:f,onOpenChange:m,children:(0,J.jsxs)(D,{side:`right`,showCloseButton:!1,className:`gap-0 p-0 data-[side=right]:w-[min(48rem,calc(100vw-2rem))] data-[side=right]:sm:max-w-[min(48rem,calc(100vw-2rem))]`,"data-slot":`call-api-response-dialog`,children:[(0,J.jsxs)(C,{className:o(F,`flex-row gap-0 border-border/60 p-0`),children:[(0,J.jsx)(N,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,J.jsx)(j,{className:`sr-only`,children:`Full Call API response JSON`}),(0,J.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,(0,J.jsx)(kn,{json:c}),(0,J.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,J.jsxs)(p,{"aria-label":`Close`,className:g,"data-slot":`call-api-response-close`,children:[(0,J.jsx)(i,{icon:S,className:`size-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,J.jsx)(`div`,{className:o(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,J.jsx)(Ne,{json:c,dataSlot:`call-api-response-expanded`,className:`flex min-h-0 flex-1 overflow-auto`})]})})]})}):null]})}function kn({json:e}){let[t,n]=(0,q.useState)(!1);return(0,J.jsx)(ye,{label:t?`Copied`:`Copy response`,className:`flex self-stretch`,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":t?`Copied`:`Copy response`,"data-slot":`call-api-response-copy`,className:g,onClick:()=>{navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)})},children:(0,J.jsx)(i,{icon:t?l:de,className:`size-3.5`,"aria-hidden":!0})})})}function An({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:d,cache:f}){let p=t||e,m=p?mn({handlerMs:r,rttMs:n}):null;return(0,J.jsxs)(J.Fragment,{children:[d?(0,J.jsxs)(`span`,{className:`flex h-full items-center px-2 font-mono text-[10px] text-muted-foreground`,"data-slot":`call-api-path-used`,"data-path":d,children:[`via `,d===`clock`?`clock.run-now`:`flows.invoke`]}):null,p?(0,J.jsxs)(`span`,{className:o(`inline-flex h-full items-center gap-1 px-2 font-mono text-[10px] font-semibold`,e?`text-destructive`:`text-emerald-700 dark:text-emerald-400`),"data-slot":`call-api-status`,"data-failed":e?`true`:`false`,children:[(0,J.jsx)(i,{icon:e?Ee:l,className:`size-3`,"aria-hidden":!0}),a??(e?`error`:`ok`)]}):null,p?(0,J.jsx)(`span`,{className:`flex h-full items-center px-2`,children:(0,J.jsx)(wt,{cache:f??`none`,dataSlot:`call-api-cache`})}):null,m?(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsx)(`span`,{...e,className:`flex h-full items-center px-2 font-mono text-[10px] tabular-nums text-muted-foreground`,"data-slot":`call-api-duration`,"data-kind":m.primaryKind,children:je(m.primaryMs)})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:m.primaryKind===`handler`?`Handler time — same clock as Traces.`:`Browser round-trip. Handler time is on the Traces row.`})]}):null,m?.primaryKind===`handler`&&m.rttMs!==null?(0,J.jsxs)(`span`,{className:`flex h-full items-center px-2 font-mono text-[10px] tabular-nums text-muted-foreground/70`,"data-slot":`call-api-rtt`,title:`Browser round-trip`,children:[je(m.rttMs),` rtt`]}):null]})}function jn({title:e,actions:t,children:n,dataTrigger:a,dataMode:s}){return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`call-api-panel`,"data-trigger":a,"data-mode":s,children:[(0,J.jsxs)(`div`,{className:o(r,`min-w-0`),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 px-2`,children:[(0,J.jsx)(i,{icon:te,className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`h3`,{className:o(I,`text-foreground`),children:e})]}),(0,J.jsx)(`div`,{className:`ml-auto flex h-full min-w-0 items-stretch`,children:t})]}),(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:n})]})}function Mn({view:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`flex h-full shrink-0 items-stretch`,role:`group`,"aria-label":`Body view`,"data-slot":`call-api-body-view-toggle`,children:[(0,J.jsx)(Nn,{active:e===`fields`,label:`Fields`,icon:Ge,onClick:()=>t(`fields`)}),(0,J.jsx)(Nn,{active:e===`raw`,label:`Raw`,icon:xe,onClick:()=>t(`raw`)})]})}function Nn({active:e,label:t,icon:n,onClick:r}){return(0,J.jsxs)(`button`,{type:`button`,className:o(h,`font-semibold tracking-[0.08em] uppercase`,e?ee:R),"aria-pressed":e,"aria-label":t,onClick:r,children:[(0,J.jsx)(i,{icon:n,className:`size-3`}),(0,J.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}var Pn=`h-full rounded-none border-0 bg-transparent px-2 text-[10px] font-semibold tracking-[0.08em] uppercase shadow-none hover:bg-muted/50`,Fn=`h-full rounded-none border-0 px-3 text-[10px] font-semibold tracking-[0.14em] uppercase shadow-none`;function In(){return(0,J.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})}var Ln=`h-7 w-full justify-between rounded-none border-0 bg-transparent px-2 shadow-none focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`;function Rn({title:e,hint:t}){return(0,J.jsxs)(`div`,{className:F,children:[(0,J.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:e}),t?(0,J.jsx)(`span`,{className:`ml-auto flex items-center px-2 text-[10px] text-muted-foreground`,children:t}):null]})}function zn({field:e,value:t,onChange:n,error:r,wide:i=!1,manifest:s,idPrefix:c=`body`}){let l=`${c}-${e.name}`,u=Bn(e,s),d=[e.required?null:`optional`,u.lookup?`fk · ${u.lookup.child}.${u.lookup.column}`:e.type,u.lookup?null:Bt(e)].filter(Boolean).join(` · `),f=r?(0,J.jsx)(`p`,{className:`px-3 pb-2 text-xs text-destructive`,children:r.message}):null,p=o(i&&`col-span-full border-r-0`);if(u.lookup){let r=t==null||t===``?``:String(t),i=Vn(u.options,r);return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:r||null,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,disabled:u.isLoading,children:(0,J.jsx)(G,{placeholder:u.isLoading?`Loading…`:`Select…`})}),(0,J.jsx)(U,{children:i.map(e=>(0,J.jsx)(H,{value:e.value,children:e.label},e.value))})]}),f]})}if(e.type===`enum`&&e.enumValues)return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:String(t??``),onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{})}),(0,J.jsx)(U,{children:e.enumValues.map(e=>(0,J.jsx)(H,{value:e,children:e},e))})]}),f]});if(e.type===`boolean`)return(0,J.jsx)(K,{label:e.name,hint:d,dense:!0,className:p,children:(0,J.jsxs)(W,{value:t===!0?`true`:`false`,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e)===`true`)},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{})}),(0,J.jsxs)(U,{children:[(0,J.jsx)(H,{value:`true`,children:`true`}),(0,J.jsx)(H,{value:`false`,children:`false`})]})]})});if(e.type===`integer`||e.type===`number`){let r=Wt(e);if(r){let i=typeof t==`number`?String(t):``;return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:i||null,onValueChange:e=>{e==null||Array.isArray(e)||n(Number(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{placeholder:`Select…`})}),(0,J.jsx)(U,{children:r.map(t=>{let n=e.valueMeanings?.find(e=>e.value===String(t));return(0,J.jsx)(H,{value:String(t),children:n?`${t} · ${n.label}`:t},t)})})]}),f]})}return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsx)(a,{id:l,type:`number`,flat:!0,className:o(vt,`h-7 px-2 font-mono`),min:e.minimum,max:e.maximum,step:e.type===`integer`?1:void 0,value:typeof t==`number`?t:``,onChange:t=>{if(t.target.value===``){n(void 0);return}n(Hn(Number(t.target.value),e.minimum,e.maximum))}}),f]})}return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsx)(a,{id:l,flat:!0,className:o(vt,`h-7 px-2 font-mono`),value:typeof t==`string`?t:t==null?``:String(t),onChange:e=>n(e.target.value)}),f]})}function Bn(e,t){let n=(0,q.useMemo)(()=>Jt(e,t),[e,t]),r=nt(n?{ref:n.ref,child:n.child,limit:200}:null,n!==null);return{lookup:n,options:(0,q.useMemo)(()=>Yt(r.data?.rows??[],n),[r.data?.rows,n]),isLoading:r.isFetching}}function Vn(e,t){return!t||e.some(e=>e.value===t)?e:[{value:t,label:t},...e]}function Hn(e,t,n){let r=e;return t!==void 0&&r<t&&(r=t),n!==void 0&&r>n&&(r=n),r}function Z({title:e,meta:t,ruled:n=!0}){return(0,J.jsxs)(`div`,{className:o(`flex items-baseline justify-between gap-2`,n&&`border-b border-border/60 pb-1.5`),children:[(0,J.jsx)(`h3`,{className:I,children:e}),t?(0,J.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t}):null]})}function Un({method:e,className:t}){return(0,J.jsx)(Se,{variant:`outline`,className:o(`h-5 px-1.5 font-mono text-[10px] uppercase`,le(e),t),"data-slot":`http-method-badge`,children:e})}var Wn=[`once`,`broadcast`,`live`],Gn={once:{delivery:`once`,icon:Dt,label:`once`,title:`once — one consumer claims; retries + DLQ`,wellClass:`border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-400`,badgeClass:`border-amber-500/35 bg-amber-500/15 text-amber-800 dark:text-amber-400`},broadcast:{delivery:`broadcast`,icon:Et,label:`broadcast`,title:`broadcast — every subscriber gets a copy`,wellClass:`border-sky-500/35 bg-sky-500/10 text-sky-700 dark:text-sky-400`,badgeClass:`border-sky-500/35 bg-sky-500/15 text-sky-700 dark:text-sky-400`},live:{delivery:`live`,icon:ne,label:`live`,title:`live — retained feed; late subscribers replay history`,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,badgeClass:`border-emerald-500/35 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`}};function Kn({delivery:e,className:t}){let n=Gn[e];return(0,J.jsx)(Se,{variant:`outline`,title:n.title,className:o(`h-5 px-1.5 font-mono text-[10px]`,n.badgeClass,t),"data-slot":`signal-delivery-badge`,"data-delivery":e,children:n.label})}function qn({effects:e}){let t=Jn(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`effects-summary`,"aria-label":`Effects`,children:[(0,J.jsx)(Z,{title:`Effects`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=He(e.kind),n=Ie(e.kind,e.ref),r=e.kind===`call`?Fe(e.ref):null;return(0,J.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px]`,style:{borderColor:`${t}55`,color:t},title:r??`${Ve[e.kind]} ${e.ref}`,children:[(0,J.jsx)(i,{icon:n,className:`size-3`}),r?(0,J.jsx)(`span`,{className:`text-foreground/90`,children:r}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:Ve[e.kind]}),(0,J.jsx)(`span`,{className:`text-foreground/90`,children:e.ref})]})]},`${e.kind}:${e.ref}`)})})]})}function Jn(e){if(!e)return[];let t=[],n=(e,n)=>{for(let r of n??[]){let n=typeof r==`string`?r:r.ref??String(r);t.push({kind:e,ref:n})}};return n(`read`,e.reads),n(`write`,e.writes),n(`emit`,e.emits),n(`send`,e.sends),n(`ask`,e.asks),n(`embed`,e.embeds),n(`secret`,e.secrets),n(`call`,e.calls),n(`fetch`,e.fetches),t}function Yn({errors:e}){let t=Xn(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`errors-section`,"aria-label":`Flow errors`,children:[(0,J.jsx)(Z,{title:`Flow errors`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=(e.schema?X(e.schema):[]).map(e=>e.name).join(`, `);return(0,J.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md border border-destructive/25 bg-destructive/[0.04] px-1.5 py-0.5 font-mono text-[10px] text-destructive`,title:t?`{ code, data: { ${t} } }`:`Typed error — { code, data }`,"data-slot":`error-code`,"data-code":e.code,children:[(0,J.jsx)(i,{icon:Ee,className:`size-3`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-foreground/90`,children:e.code}),t?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t}):null]},e.code)})})]})}function Xn(e){return e?Array.isArray(e)?e.map(e=>({code:e,schema:null})):Object.entries(e).map(([e,t])=>({code:e,schema:qt(t)})):[]}var Zn=36e5;function Qn(e,t,n,r=Zn){let i=St(e,new Set([t])),a=n-r,o=i.filter(e=>e.startedAt>=a);if(o.length===0)return{kind:`empty`};let s=o.filter(e=>e.error!=null&&e.error.length>0).length,c=o[0];return{kind:`summary`,calls:o.length,errors:s,errorRate:s/o.length,lastStartedAt:c.startedAt,latestRunId:c.id,windowMs:r}}function $n({flowId:e,runs:t,nowMs:n=Date.now(),windowMs:r=Zn,children:i}){let a=Qn(t??[],e,n,r);return(0,J.jsxs)(`div`,{className:o(F,`px-2`),"data-slot":`flow-activity-strip`,"data-kind":a.kind,"aria-label":`Recent activity`,children:[(0,J.jsx)(`span`,{className:o(I,`flex items-center`),children:`Activity`}),(0,J.jsx)(er,{summary:a,nowMs:n}),i?(0,J.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:i}):null]})}function er({summary:e,nowMs:t}){if(e.kind===`empty`)return(0,J.jsx)(`p`,{className:`flex items-center text-[11px] text-muted-foreground`,"data-slot":`flow-activity-empty`,children:`No recent runs in the Console buffer.`});let n=Math.round(e.errorRate*100),r=tr(e.lastStartedAt,t);return(0,J.jsxs)(`p`,{className:`flex min-w-0 items-center gap-x-2 text-[11px] text-foreground/85`,children:[(0,J.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-calls`,children:[e.calls,` call`,e.calls===1?``:`s`]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,J.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-errors`,children:[n,`% errors`]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"data-slot":`flow-activity-ago`,children:r}),(0,J.jsx)(gt,{to:`/overview`,search:{run:e.latestRunId},className:o(h,R),"data-slot":`flow-activity-open-run`,children:`Open latest`})]})}function tr(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.max(1,Math.round(n/1e3))}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function nr(e){switch(e){case`string`:return`border-teal-500/35 bg-teal-500/10 text-teal-800 dark:text-teal-300`;case`integer`:return`border-blue-500/35 bg-blue-500/10 text-blue-800 dark:text-blue-300`;case`number`:return`border-amber-500/35 bg-amber-500/10 text-amber-800 dark:text-amber-300`;case`boolean`:return`border-violet-500/35 bg-violet-500/10 text-violet-800 dark:text-violet-300`;case`enum`:return`border-indigo-500/35 bg-indigo-500/10 text-indigo-800 dark:text-indigo-300`;case`array`:return`border-cyan-500/35 bg-cyan-500/10 text-cyan-800 dark:text-cyan-300`;case`object`:return`border-zinc-500/35 bg-zinc-500/10 text-zinc-700 dark:text-zinc-300`;default:return`border-border/70 bg-muted/40 text-muted-foreground`}}function rr({fields:e,emptyLabel:t=`No schema fields declared.`,layout:n=`list`}){return e.length===0?(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-slot":`schema-fields-empty`,children:t}):n===`grid`?(0,J.jsx)(`div`,{"data-slot":`schema-fields`,"data-layout":`grid`,children:(0,J.jsx)(bt,{columns:3,children:e.map(e=>(0,J.jsx)(ir,{field:e,depth:0,cell:!0},e.path))})}):(0,J.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`schema-fields`,children:e.map(e=>(0,J.jsx)(ir,{field:e,depth:0},e.path))})}function ir({field:e,depth:t,cell:n=!1}){let r=e.type===`enum`&&e.enumValues,i=Bt(e);return(0,J.jsxs)(n?`div`:`li`,{className:n?`min-w-0 border-b border-border/50`:void 0,children:[(0,J.jsxs)(`div`,{className:n?`flex items-center gap-1.5 px-2 py-1.5`:`flex items-center gap-2 py-1`,style:n?void 0:{paddingLeft:t*14},"data-slot":`schema-field-row`,children:[(0,J.jsx)(`span`,{className:`shrink-0`,"data-slot":`schema-field-keys`,title:ar(e),children:(0,J.jsx)(ie,{primaryKey:e.primaryKey,foreignKey:e.foreignKey,unique:e.unique,empty:`none`})}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),e.required?null:(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-border/60 bg-muted/30 px-1 py-px text-[9px] font-medium tracking-wide text-muted-foreground uppercase`,"data-slot":`schema-field-optional`,children:`optional`}),e.pii?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-amber-500/40 bg-amber-500/10 px-1 py-px text-[9px] font-medium tracking-wide text-amber-800 uppercase dark:text-amber-300`,"data-slot":`schema-field-pii`,children:`pii`}):null,e.sensitive?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-rose-500/40 bg-rose-500/10 px-1 py-px text-[9px] font-medium tracking-wide text-rose-700 uppercase dark:text-rose-300`,"data-slot":`schema-field-sensitive`,children:`sensitive`}):null,i&&!r?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-blue-500/35 bg-blue-500/10 px-1 py-px font-mono text-[9px] font-medium tracking-wide text-blue-800 dark:text-blue-300`,"data-slot":`schema-field-constraint`,title:`Allowed range ${i}`,children:i}):null,(0,J.jsx)(`span`,{className:o(`ml-auto shrink-0 rounded border px-1.5 py-px font-mono text-[9px] font-medium tracking-wide`,nr(e.type)),"data-slot":`schema-field-type`,title:r?e.enumValues?.join(` | `):e.type,children:e.type})]}),e.children?.map(e=>(0,J.jsx)(ir,{field:e,depth:t+1,cell:n},e.path))]})}function ar(e){let t=[];if(e.primaryKey&&t.push(`Primary key`),e.foreignKey){let n=e.references?[e.references.table,e.references.column].filter(Boolean).join(`.`):null;t.push(n?`Foreign key → ${n}`:`Foreign key`)}return e.unique&&t.push(`Unique`),t.length>0?t.join(` · `):`None`}function or({fields:e}){let t=Ht(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`validation-section`,"aria-label":`Validation`,children:[(0,J.jsx)(Z,{title:`Validation`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,J.jsx)(sr,{field:e},e.path))})]})}function sr({field:e}){let t=Vt(e),n=e.valueMeanings?.length?e.valueMeanings:e.enumValues?.map(e=>({value:e,label:e}));return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5`,"data-slot":`validation-field`,"data-field":e.name,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,J.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),t?(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}):null]}),n&&n.length>0?(0,J.jsx)(`ul`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 sm:grid-cols-3 lg:grid-cols-5`,children:n.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,"data-slot":`validation-option`,children:[(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.value}),(0,J.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.label})]},e.value))}):null]})}function cr({row:e,manifest:t,runs:n,leading:r}){let a=B(e.flow.trigger),s=Be(e.flow.trigger),c=Ue(t,e.id,a===`http`?`http`:a===`internal`?`internal`:a),l=qt(e.flow.in),u=qt(e.flow.out),d=We(e.flow.gates??[],t),f=a===`signal`&&e.flow.trigger?.signal?t?.signals?.[e.flow.trigger.signal]:void 0,p=a===`cron`||a===`every`?pn(t,e.id):null,m=a===`internal`?Ct(t,e.id):[],g=a===`http`?`Request`:`Input`,_=a===`http`?`Response`:`Output`,v=a!==`cron`&&a!==`every`,y=X(l),b=X(u),x=jt(y,a===`http`&&e.path?cn(e.path):[]);return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`flow-contract-panel`,"data-trigger":a,children:[(0,J.jsx)(yt,{dataSlot:`endpoint-header`,leading:r,icon:(0,J.jsx)(`span`,{"data-slot":`trigger-kind-icon`,"data-kind":a,children:(0,J.jsx)(i,{icon:s.icon,className:`size-4`})}),wellClassName:s.wellClass,title:(0,J.jsx)(`span`,{className:`font-mono`,children:e.id}),badge:(0,J.jsx)(`span`,{className:`font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,"data-slot":`trigger-kind-badge`,children:s.label}),subtitle:a===`http`&&c.method&&c.path?(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`http-endpoint-line`,children:[(0,J.jsx)(Un,{method:c.method}),(0,J.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:c.path})]}):a===`signal`&&f?(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`signal-endpoint-line`,children:[(0,J.jsx)(Kn,{delivery:f.delivery}),(0,J.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:e.flow.trigger?.signal})]}):(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] leading-none text-muted-foreground`,"data-slot":`trigger-headline`,children:c.headline}),actions:(0,J.jsxs)(gt,{to:`/overview`,search:{flow:e.id},"data-slot":`open-in-graph`,className:o(h,`text-sky-700 dark:text-sky-400`),children:[(0,J.jsx)(i,{icon:be.flow.icon,className:`size-3.5`,"aria-hidden":!0}),`Open in graph`]})}),(0,J.jsxs)($n,{flowId:e.id,runs:n,children:[e.flow.plane?(0,J.jsx)(lr,{plane:e.flow.plane}):null,e.flow.durable?(0,J.jsx)(ur,{icon:Pe,label:`durable`,title:`Durable — long-running, retryable steps`}):null,e.flow.live?(0,J.jsx)(ur,{icon:pe,label:`live`,title:typeof e.flow.live==`string`?`Live — SSE for ${e.flow.live}`:`Live — SSE signal feed`}):null]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(qn,{effects:e.flow.effects}),(0,J.jsx)(ze,{gates:d}),(0,J.jsx)(Yn,{errors:e.flow.errors}),a===`signal`&&f&&(f.retries!==void 0||f.deadLetter)?(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`signal-delivery`,children:[f.retries===void 0?null:`retries ${f.retries}`,f.deadLetter?`dead-letter`:null].filter(e=>e!==null).join(` · `)}):null,(a===`cron`||a===`every`)&&p?.kind===`matched`?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`clock-join`,children:[`Clock · `,(0,J.jsx)(`span`,{className:`font-mono`,children:p.clockName}),p.timezone?` · ${p.timezone}`:``]}):null,a===`internal`?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`call-only-note`,children:[`No external trigger — reachable via `,(0,J.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` /`,` `,(0,J.jsx)(`code`,{className:`font-mono`,children:`fx.call`}),`.`]}):null,a===`internal`?(0,J.jsxs)(`section`,{className:`flex flex-col gap-1.5`,"aria-label":`Callers`,"data-slot":`callers-list`,children:[(0,J.jsx)(Z,{title:`Called by`,meta:String(m.length)}),m.length===0?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No Manifest caller declares `,(0,J.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` for this flow.`]}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:m.map(e=>(0,J.jsx)(`li`,{className:`font-mono text-xs text-foreground/90`,children:e},e))})]}):null,v&&x.parameters.length>0?(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Parameters`,"data-slot":`parameters`,children:[(0,J.jsx)(Z,{title:`Parameters`,meta:String(x.parameters.length)}),(0,J.jsx)(rr,{fields:x.parameters,layout:`grid`})]}):null,(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[v&&(x.fields.length>0||x.parameters.length===0)?(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":g,"data-slot":`request`,children:[(0,J.jsx)(Z,{title:g,meta:String(x.fields.length)}),(0,J.jsx)(rr,{fields:x.fields,emptyLabel:typeof e.flow.in==`string`?`Schema not expanded in Manifest.`:a===`signal`?`No flow input schema — signal payload shape lives on the signal when declared.`:`No input schema declared.`})]}):null,(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":_,children:[(0,J.jsx)(Z,{title:_,meta:String(b.length)}),(0,J.jsx)(rr,{fields:b,emptyLabel:typeof e.flow.out==`string`?`Schema not expanded in Manifest.`:`No output schema declared.`})]})]}),v?(0,J.jsx)(or,{fields:y}):null]})})]})}function lr({plane:e}){let t=e===`operator`,n=t?he:Ke,r=t?`operator`:`user`;return(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:t=>(0,J.jsxs)(`span`,{...t,className:o(h,`cursor-help`),"data-slot":`plane-badge`,"data-plane":e,children:[(0,J.jsx)(i,{icon:n,className:`size-3`,"aria-hidden":!0}),r]})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:t?`Operator plane — runs under a Console operator identity, not an application user.`:`User plane — runs under an application user identity (invoke-as).`})]})}function ur({icon:e,label:t,title:n}){return(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:n=>(0,J.jsxs)(`span`,{...n,className:o(h,R,`cursor-help`),children:[(0,J.jsx)(i,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:n})]})}function dr(e){let t=new Map(Le.map(e=>[e,[]]));for(let n of e){let e=new Map;for(let t of n.flows){let n=B(t.flow.trigger),r=e.get(n)??[];r.push(t),e.set(n,r)}for(let[r,i]of e)t.get(r)?.push({unit:n.unit,flows:i})}return Le.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{id:e,label:Re[e].label,groups:n}]})}function fr(e){return`band:${e}`}function pr(e,t){return`unit:${e}:${t}`}function mr(e,t,n=!1){let r=t[e];return r===void 0?n:r}function hr(e){let t=[];for(let n of e){t.push(fr(n.id));for(let e of n.groups)t.push(pr(n.id,e.unit))}return t}function gr(e,t){for(let n of e)for(let e of n.groups)if(e.flows.some(e=>e.id===t))return[fr(n.id),pr(n.id,e.unit)];return[]}function _r(e,t){let n=z(e.method)-z(t.method);return n===0?e.id.localeCompare(t.id):n}function vr(e){let t=e?.flows;if(!t)return[];let n=new Map;for(let[r,i]of Object.entries(t)){let t=xt(r),a=r.includes(`.`)?r.slice(r.indexOf(`.`)+1):r,o=i.trigger?.http,s=i.trigger?.signal??null,c={id:r,unit:t,action:a,flow:i,method:o?.method??null,path:o?.path??null,signal:s,delivery:s?e.signals?.[s]?.delivery??null:null},l=n.get(t)??[];l.push(c),n.set(t,l)}return[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({unit:e,flows:t.sort(_r)}))}function yr(e,t){let n=t.trim().toLowerCase();return n?e.map(e=>{let t=e.unit.toLowerCase().includes(n)?e.flows:e.flows.filter(e=>e.id.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||(e.method?.toLowerCase().includes(n)??!1)||(e.path?.toLowerCase().includes(n)??!1)||(e.signal?.toLowerCase().includes(n)??!1)||(e.delivery?.toLowerCase().includes(n)??!1));return t.length>0?{unit:e.unit,flows:t}:null}).filter(e=>e!==null):e}function br(e){return(e.triggerKinds?.length??0)+(e.planes?.length??0)+(e.deliveries?.length??0)+ +!!e.durableOnly+ +!!e.liveOnly}function xr(e,t){let n=t.triggerKinds?.length?new Set(t.triggerKinds):null,r=t.planes?.length?new Set(t.planes):null,i=t.deliveries?.length?new Set(t.deliveries):null,a=t.durableOnly===!0,o=t.liveOnly===!0;return!n&&!r&&!i&&!a&&!o?e:e.map(e=>{let t=e.flows.filter(e=>!(n&&!n.has(B(e.flow.trigger))||r&&!r.has(e.flow.plane??`user`)||i&&(e.delivery===null||!i.has(e.delivery))||a&&!e.flow.durable||o&&!e.flow.live));return t.length>0?{unit:e.unit,flows:t}:null}).filter(e=>e!==null)}var Sr={user:{icon:Ke,label:`user`},operator:{icon:he,label:`operator`}},Cr=[`user`,`operator`];function wr({groups:e,selectedFlowId:t,onSelect:n}){let[a,l]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)({}),[h,_]=(0,q.useState)({}),v=(0,q.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)t.add(B(e.flow.trigger));return Le.filter(e=>t.has(e))},[e]),y=(0,q.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)e.flow.plane&&t.add(e.flow.plane);return Cr.filter(e=>t.has(e))},[e]),{hasDurable:b,hasLive:x,availableDeliveries:S}=(0,q.useMemo)(()=>{let t=!1,n=!1,r=new Set;for(let i of e)for(let e of i.flows)e.flow.durable&&(t=!0),e.flow.live&&(n=!0),e.delivery&&r.add(e.delivery);return{hasDurable:t,hasLive:n,availableDeliveries:Wn.filter(e=>r.has(e))}},[e]),C=br(p),w=(0,q.useMemo)(()=>dr(xr(yr(e,a),p)),[e,a,p]),T=(0,q.useMemo)(()=>hr(w),[w]),E=a.trim().length>0,D=T.length>0&&T.every(e=>mr(e,h,E));(0,q.useEffect)(()=>{if(!t)return;let e=gr(w,t);e.length!==0&&_(t=>{let n=!1,r={...t};for(let t of e)r[t]!==!0&&(r[t]=!0,n=!0);return n?r:t})},[t,w]);let O=(e,t)=>{_(n=>n[e]===t?n:{...n,[e]:t})},k=()=>{let e=!D;_(t=>{let n={...t};for(let t of T)n[t]=e;return n})},A=e=>m(t=>({...t,triggerKinds:Tr(t.triggerKinds??[],e)})),j=e=>m(t=>({...t,planes:Tr(t.planes??[],e)})),M=e=>m(t=>({...t,[e]:!t[e]})),N=e=>m(t=>({...t,deliveries:Tr(t.deliveries??[],e)}));return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`units-tree`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,J.jsxs)(`div`,{className:o(r,`border-b-0`),children:[(0,J.jsx)(fe,{value:a,onChange:e=>l(e.target.value),placeholder:`Search flows…`,"aria-label":`Search flows`,"data-slot":`units-search`}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsxs)(`button`,{...e,type:`button`,"aria-expanded":d,"aria-controls":`units-advanced-panel`,"aria-label":C>0?`Advanced filters, ${C} active`:`Advanced filters`,"data-slot":`units-advanced-toggle`,onClick:t=>{e.onClick?.(t),f(e=>!e)},className:o(g,`relative`,(d||C>0)&&`text-foreground`),children:[(0,J.jsx)(i,{icon:qe,className:`size-3`,"aria-hidden":!0}),C>0?(0,J.jsx)(`span`,{"data-slot":`units-advanced-count`,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:C}):null]})}),(0,J.jsx)(c,{side:`bottom`,children:`Advanced`})]}),(0,J.jsx)(st,{allOpen:D,disabled:T.length===0,onToggle:k,dataSlot:`units-tree-expand-toggle`})]})]}),d?(0,J.jsxs)(`div`,{id:`units-advanced-panel`,"data-slot":`units-advanced-panel`,className:`flex flex-col gap-2 border-t border-border/60 bg-muted/20 p-2`,children:[(0,J.jsx)(Q,{label:`Trigger`,groupLabel:`Trigger kind filter`,children:v.map(e=>{let t=Re[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.triggerKinds?.includes(e)??!1,onToggle:()=>A(e),dataFacet:`kind:${e}`},e)})}),S.length>0?(0,J.jsx)(Q,{label:`Delivery`,groupLabel:`Signal delivery filter`,children:S.map(e=>{let t=Gn[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.deliveries?.includes(e)??!1,onToggle:()=>N(e),dataFacet:`delivery:${e}`},e)})}):null,y.length>0?(0,J.jsx)(Q,{label:`Plane`,groupLabel:`Plane filter`,children:y.map(e=>{let t=Sr[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.planes?.includes(e)??!1,onToggle:()=>j(e),dataFacet:`plane:${e}`},e)})}):null,b||x?(0,J.jsxs)(Q,{label:`Flags`,groupLabel:`Flow flags filter`,children:[b?(0,J.jsx)($,{icon:Pe,label:`durable`,pressed:p.durableOnly??!1,onToggle:()=>M(`durableOnly`),dataFacet:`flag:durable`}):null,x?(0,J.jsx)($,{icon:pe,label:`live`,pressed:p.liveOnly??!1,onToggle:()=>M(`liveOnly`),dataFacet:`flag:live`}):null]}):null,C>0?(0,J.jsx)(`button`,{type:`button`,"data-slot":`units-advanced-clear`,onClick:()=>m({}),className:`self-end px-2 py-1 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,children:`Clear all`}):null]}):null]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:w.length===0?(0,J.jsx)(`p`,{className:P,children:`No flows match.`}):(0,J.jsx)(`div`,{className:`flex flex-col`,children:w.map(e=>{let r=fr(e.id);return(0,J.jsx)(Er,{band:e,open:mr(r,h,E),onOpenChange:e=>O(r,e),groupOpen:t=>mr(pr(e.id,t),h,E),onGroupOpenChange:(t,n)=>O(pr(e.id,t),n),selectedFlowId:t,onSelect:n},e.id)})})})]})}function Q({label:e,groupLabel:t,children:n}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[9px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:e}),(0,J.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-stretch`,role:`group`,"aria-label":t,children:n})]})}function $({icon:e,label:t,pressed:n,onToggle:r,dataFacet:a}){return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`units-facet-chip`,"data-facet":a,"aria-pressed":n,onClick:r,className:o(`inline-flex items-center gap-1 px-2 text-[10px] font-medium transition-colors hover:bg-muted/50`,n?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[(0,J.jsx)(i,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}function Tr(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Er({band:e,open:t,onOpenChange:n,groupOpen:r,onGroupOpenChange:a,selectedFlowId:s,onSelect:c}){let l=Re[e.id],u=e.groups.reduce((e,t)=>e+t.flows.length,0),f=e.groups.map(e=>e.unit),p=f.length>0&&f.every(e=>r(e)),h=()=>{let e=!p;for(let t of f)a(t,e);e&&n(!0)};return(0,J.jsx)(`section`,{"data-slot":`units-trigger-band`,"data-band":e.id,"aria-label":e.label,className:M,children:(0,J.jsxs)(De,{open:t,onOpenChange:n,children:[(0,J.jsx)(Te,{nativeButton:!1,className:E,"data-slot":`units-trigger-band-toggle`,render:n=>(0,J.jsxs)(`div`,{...n,children:[(0,J.jsx)(i,{icon:we,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,J.jsx)(i,{icon:l.icon,className:o(w,d(l.wellClass)),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:o(A,`flex-1`),children:e.label}),(0,J.jsx)(`span`,{className:m,children:u}),(0,J.jsx)(`span`,{className:v,children:(0,J.jsx)(st,{allOpen:p,disabled:f.length===0,onToggle:h,collapseLabel:`Collapse all in ${e.label}`,expandLabel:`Expand all in ${e.label}`,dataSlot:`units-band-expand-toggle`,disclose:!0,bare:!0})})]})}),(0,J.jsx)(Ce,{children:(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.groups.map(t=>(0,J.jsx)(Dr,{group:t,open:r(t.unit),onOpenChange:e=>a(t.unit,e),selectedFlowId:s,onSelect:c},`${e.id}:${t.unit}`))})})]})})}function Dr({group:e,open:t,onOpenChange:n,selectedFlowId:r,onSelect:a}){return(0,J.jsx)(`li`,{"data-slot":`unit-group`,"data-unit":e.unit,children:(0,J.jsxs)(De,{open:t,onOpenChange:n,children:[(0,J.jsxs)(Te,{className:o(O,`pl-4`),children:[(0,J.jsx)(i,{icon:we,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,J.jsx)(i,{icon:lt,className:o(w,`text-muted-foreground`),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.unit}),(0,J.jsx)(`span`,{className:m,children:e.flows.length})]}),(0,J.jsx)(Ce,{children:(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.flows.map(e=>(0,J.jsx)(Or,{flow:e,selected:r===e.id,onSelect:a},e.id))})})]})})}function Or({flow:e,selected:t,onSelect:n}){let r=Be(e.flow.trigger),a=e.delivery?Gn[e.delivery]:null,l=a?.icon??(e.method?ce(e.method):r.icon),f=d(a?.wellClass??(e.method?le(e.method):r.wellClass)),p=a?e.signal?`${a.title} · ${e.signal}`:a.title:r.detail?`${r.label} · ${r.detail}`:r.label;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`unit-flow-item`,"data-flow-id":e.id,"data-delivery":e.delivery??void 0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:o(T,`group/flow pl-8`,t&&`bg-muted/70 text-foreground`),children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:o(k,t?y:`bg-transparent`)}),(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsx)(`span`,{...e,className:o(w,f),"aria-hidden":!0,children:(0,J.jsx)(i,{icon:l,className:`size-3.5`})})}),(0,J.jsx)(c,{side:`right`,className:`text-[11px]`,children:p})]}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.action}),e.method?(0,J.jsx)(Un,{method:e.method,className:`ml-auto h-3.5 px-1 text-[8px] leading-none`}):null]})})}function kr(){let e=ke(),t=Me();Oe(!0);let{selectedFlowId:n,setSelectedFlow:r}=ht(),i=ge(),a=(0,q.useMemo)(()=>vr(e.data??null),[e.data]),o=(0,J.jsx)(_e,{open:i.open,onToggle:i.toggle,noun:`flows`,controlsId:`flows-tree`,dataSlot:`flows-tree-toggle`}),s=n??a[0]?.flows[0]?.id??null,c=(0,q.useMemo)(()=>{if(!s)return null;for(let e of a){let t=e.flows.find(e=>e.id===s);if(t)return t}return null},[a,s]);return(0,J.jsx)(`div`,{className:_,"data-slot":`units-page`,children:(0,J.jsxs)(ue,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,J.jsx)(me,{panelRef:i.panelRef,collapsible:!0,collapsedSize:0,defaultSize:f.start.defaultSize,minSize:f.start.minSize,onResize:i.onResize,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(`div`,{id:`flows-tree`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`flows-tree`,children:(0,J.jsx)(wr,{groups:a,selectedFlowId:s,onSelect:e=>{r(e)}})})}),i.open?(0,J.jsx)(ve,{withHandle:!0}):null,(0,J.jsx)(me,{defaultSize:f.end.defaultSize,minSize:f.end.minSize,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:c?(0,J.jsxs)(ue,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-slot":`units-inspector`,children:[(0,J.jsx)(me,{defaultSize:`56%`,minSize:`28%`,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(cr,{row:c,manifest:e.data??null,runs:t.data,leading:o})}),(0,J.jsx)(ve,{withHandle:!0}),(0,J.jsx)(me,{defaultSize:`44%`,minSize:`220px`,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(Tn,{row:c,manifest:e.data??null})})]}):(0,J.jsx)(_t,{icon:be.flow.icon,title:e.isLoading?`Loading Manifest…`:`Select a flow`,description:e.isLoading?`Reading the derived Manifest.`:`Pick a flow from the tree to inspect its contract.`,leading:o})})})]})})}export{kr as UnitsPage};
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{Cr as r,Dr as i,E as a,Er as o,F as s,I as c,Or as l,R as u,Tr as d,_r as f,a as p,ar as m,br as h,cr as g,dr as _,er as v,fr as y,i as b,ir as x,kr as S,l as C,lr as w,mr as T,nr as E,o as D,or as O,pr as k,rr as A,s as j,tr as M,u as N,ur as P,vr as F,wr as I,x as L,xr as R,yr as ee}from"./shortcut-keys-3ILd8oGn.js";import{c as te,l as ne,n as re,o as ie,r as ae,t as oe}from"./call-pii-button-jOmYISdc.js";import{a as z,n as se,r as ce,t as le}from"./http-method-BdYjcIrD.js";import{a as ue,b as de,c as fe,g as pe,i as me,m as he,n as ge,o as _e,r as ve,s as ye,t as be}from"./element-icons-BI8cJgdh.js";import{a as xe,i as Se,n as Ce,o as we,r as Te,s as Ee,t as De}from"./collapsible-DC2xNaAb.js";import{a as Oe,c as ke,f as Ae,i as je,s as Me,t as Ne,u as Pe}from"./highlighted-json-C2GZEJNI.js";import{a as Fe,c as Ie,d as Le,f as Re,l as ze,m as Be,o as Ve,p as B,s as He,t as Ue,u as We,w as Ge}from"./request-meta-C43DHyld.js";import{t as Ke}from"./UserIcon-DaE2PB5_.js";import{n as qe}from"./dagre.esm-B1_XeuLP.js";import{$ as V,G as Je,Q as H,X as U,Y as W,a as Ye,c as Xe,d as Ze,et as G,f as Qe,h as $e,i as et,n as tt,nt,o as rt,p as it,r as at,s as ot,t as st,u as ct,ut as lt,v as ut}from"./tree-expand-toggle-CKJTuv43.js";import{d as dt,r as ft,t as pt}from"./dropdown-menu-4h2LOVXM.js";import{at as mt,gt as ht,yt as gt}from"./index-Cul17AcV.js";import{t as _t}from"./explorer-empty-CJs5A-wm.js";import{c as K,n as vt,t as yt,u as bt}from"./detail-header-DVWNjWjg.js";import{c as xt,n as St,s as Ct,t as wt}from"./cache-glyph-BCC-DxKT.js";var Tt=[[`path`,{d:`M16.4999 3.26621C17.3443 3.25421 20.1408 2.67328 20.7337 3.26621C21.3266 3.85913 20.7457 6.65559 20.7337 7.5M20.5059 3.49097L13.5021 10.4961`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M3.26636 16.5001C3.25436 17.3445 2.67343 20.141 3.26636 20.7339C3.85928 21.3268 6.65574 20.7459 7.50015 20.7339M10.502 13.4976L3.49824 20.5027`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],Et=[[`path`,{d:`M21 6.5C21 8.15685 19.6569 9.5 18 9.5C16.3431 9.5 15 8.15685 15 6.5C15 4.84315 16.3431 3.5 18 3.5C19.6569 3.5 21 4.84315 21 6.5Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M9 12C9 13.6569 7.65685 15 6 15C4.34315 15 3 13.6569 3 12C3 10.3431 4.34315 9 6 9C7.65685 9 9 10.3431 9 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M21 17.5C21 19.1569 19.6569 20.5 18 20.5C16.3431 20.5 15 19.1569 15 17.5C15 15.8431 16.3431 14.5 18 14.5C19.6569 14.5 21 15.8431 21 17.5Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M8.72852 10.7495L15.2285 7.75M8.72852 13.25L15.2285 16.2495`,stroke:`currentColor`,strokeWidth:`1.5`,key:`3`}]],Dt=[[`path`,{d:`M15.1312 2.5C14.1462 2.17555 13.0936 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 10.9548 21.8396 9.94704 21.5422 9`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12C7 9.23858 9.23858 7 12 7`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M19.5 4.5L12 12M19.5 4.5V2M19.5 4.5H22`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`2`}]],q=e(t(),1),J=n();function Ot(e,t){let n=ot(e.asGate);return n===`operator`?`Operator`:n===`public`?`Public`:e.asUserId?t.find(t=>t.id===e.asUserId)?.name??e.asUserId:e.asGate?`As · ${e.asGate}`:`As`}function Y(e){let t=ot(e.asGate);return t===`operator`||t===`public`||!!(e.asUserId||e.asGate)}function kt({manifest:e,identities:t,value:n,onChange:r}){let a=Je(!0),s=(0,q.useMemo)(()=>$e(ut(e),a.data??null),[e,a.data]),c=(0,q.useMemo)(()=>Xe(s),[s]),l=(0,q.useMemo)(()=>ct(t,s),[t,s]),u=s.gates.find(e=>e.kind===`public`)?.description??`Intentionally unauthenticated.`,d=ot(n.asGate),f=n.asGate!==null,[p,m]=(0,q.useState)(n.asUserId?`user`:`policy`),h=c.find(e=>e.id===n.asGate)??null,g=l.find(e=>e.id===n.asUserId&&e.gate===n.asGate)??null,_=c.length>0||l.length>0,v=e=>{if(e===`operator`){r({asGate:null,asUserId:null});return}if(e===`public`){r({asGate:`public`,asUserId:null});return}if(d===`as`)return;let t=h?.id??c[0]?.id??l[0]?.gate??null;if(t!==null){if(l[0]&&t===l[0].gate&&c.length===0){m(`user`),r({asGate:l[0].gate,asUserId:l[0].id});return}m(`policy`),r({asGate:t,asUserId:null})}};return(0,J.jsxs)(pt,{children:[(0,J.jsx)(dt,{render:e=>(0,J.jsxs)(L,{...e,type:`button`,variant:`ghost`,size:`sm`,className:o(`h-full max-w-44 min-w-0 rounded-none px-2 text-[11px]`,f&&`text-sky-800 dark:text-sky-300`),"aria-label":f?`Invoke as Gate ${n.asGate}`:`Invoke as Operator (bypass gates)`,"data-slot":`call-api-identity`,children:[(0,J.jsx)(i,{icon:be.gate.icon,"data-icon":`inline-start`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`truncate`,children:Ot(n,t)})]})}),(0,J.jsxs)(ft,{align:`end`,className:`w-80 overflow-hidden p-0`,children:[(0,J.jsx)(rt,{children:`Invoke as`}),(0,J.jsxs)(Ye,{label:`Invoke as`,children:[(0,J.jsx)(at,{mode:`operator`,title:`Operator`,caption:`Bypass`,selected:d===`operator`,onSelect:()=>v(`operator`)}),(0,J.jsx)(at,{mode:`public`,title:`Public`,caption:`Anonymous`,selected:d===`public`,onSelect:()=>v(`public`)}),(0,J.jsx)(at,{mode:`as`,title:`As`,caption:g?g.label:h?.label??`User / policy`,selected:d===`as`,disabled:!_,onSelect:()=>v(`as`)})]}),d===`operator`?(0,J.jsx)(et,{title:`Operator`,badge:`Default`,children:`Bypasses the flow's gate chain.`}):null,d===`public`?(0,J.jsxs)(et,{title:`Public`,children:[u,` Only `,(0,J.jsx)(`span`,{className:`font-mono`,children:`gate.public`}),` flows succeed.`]}):null,d===`as`?(0,J.jsx)(tt,{tab:p,onTabChange:m,policies:c,users:l,asGate:n.asGate,asUserId:g?.id??null,onSelectPolicy:e=>{m(`policy`),r({asGate:e.id,asUserId:null})},onSelectUser:e=>{m(`user`),r({asGate:e.gate,asUserId:e.id})},hint:g?(0,J.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[`Calls as `,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:g.label}),` `,`via `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.asGate}),`.`]}):h?(0,J.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[h.detail,` Sets scopes for`,` `,(0,J.jsx)(`span`,{className:`font-mono`,children:h.id}),`.`]}):null}):null]})]})}var At=new Set([`q`,`query`,`search`,`limit`,`offset`,`cursor`,`page`,`pageSize`,`perPage`,`per_page`,`page_size`,`order`,`orderBy`,`order_by`,`sort`,`sortBy`,`sort_by`,`direction`]);function jt(e,t=[]){let n=new Set,r=[];for(let i of t){n.add(i);let t=e.find(e=>e.name===i);r.push(t??Mt(i))}let i=[];for(let t of e)n.has(t.name)||(At.has(t.name)?r.push(t):i.push(t));return{parameters:r,fields:i}}function Mt(e){return{path:`/path/${e}`,name:e,type:`string`,required:!0}}function Nt(e,t={}){let n=t.pathParams??[],r=new Set(n);if(t.http!==!0)return{path:[],query:[],body:e};let i=e.filter(e=>!r.has(e.name));return se(t.method)?{path:n,query:[],body:i}:{path:n,query:i,body:[]}}function Pt(e,t){let n={};for(let r of t)Object.hasOwn(e,r.name)&&(n[r.name]=e[r.name]);return n}function X(e,t=``){if(!e)return[];if(e.type===`object`||e.properties){let n=e.properties??{},r=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(n).map(([e,n])=>Ft(e,`${t}/${e}`,n,r.has(e)))}return[Ft(`value`,t||`/`,e,!0)]}function Ft(e,t,n,r){let i=It(e,n),a=typeof n.description==`string`?n.description:void 0;if(Array.isArray(n.enum)){let o=Ut(n);return{path:t,name:e,type:`enum`,required:r,enumValues:n.enum.map(String),...a===void 0?{}:{description:a},...o===void 0?{}:{valueMeanings:o},...i}}let o=n.type;if(o===`object`||n.properties)return{path:t,name:e,type:`object`,required:r,...a===void 0?{}:{description:a},...i,children:X(n,t)};if(o===`array`)return{path:t,name:e,type:`array`,required:r,...a===void 0?{}:{description:a},...i,children:n.items?X(n.items,`${t}/0`):void 0};let s=o===`integer`||o===`number`||o===`boolean`||o===`string`?o:`unknown`,c=Ut(n);return{path:t,name:e,type:s,required:r,minimum:typeof n.minimum==`number`?n.minimum:void 0,maximum:typeof n.maximum==`number`?n.maximum:void 0,...a===void 0?{}:{description:a},...c===void 0?{}:{valueMeanings:c},...i}}function It(e,t){let n=Lt(e),r=Rt(t.references),i=t.primaryKey===!0||n.primaryKey===!0,a=r!==void 0||n.foreignKey===!0,o=!i&&(t.unique===!0||n.unique===!0);return{...t.pii===!0?{pii:!0}:{},...t.sensitive===!0?{sensitive:!0}:{},...i?{primaryKey:!0}:{},...a?{foreignKey:!0}:{},...o?{unique:!0}:{},...r===void 0?{}:{references:r}}}function Lt(e){return e===`id`?{primaryKey:!0}:/(?:Id|_id)$/.test(e)||/(?:Key|_key)$/.test(e)&&e!==`key`?{foreignKey:!0}:e===`identifier`||e===`key`?{unique:!0}:{}}function Rt(e){if(!e||typeof e!=`object`)return;let t=`table`in e&&typeof e.table==`string`?e.table:void 0;if(!t)return;let n=`column`in e&&typeof e.column==`string`?e.column:void 0;return n===void 0?{table:t}:{table:t,column:n}}var zt=12;function Bt(e){return e.enumValues&&e.enumValues.length>0?e.enumValues.join(` · `):e.minimum!==void 0&&e.maximum!==void 0?`${e.minimum}–${e.maximum}`:e.minimum===void 0?e.maximum===void 0?null:`≤ ${e.maximum}`:`≥ ${e.minimum}`}function Vt(e){return e.minimum!==void 0&&e.maximum!==void 0?`Must be from ${e.minimum} up to ${e.maximum}.`:e.minimum===void 0?e.maximum===void 0?null:`Must be at most ${e.maximum}.`:`Must be at least ${e.minimum}.`}function Ht(e){return e.filter(e=>e.minimum!==void 0||e.maximum!==void 0||(e.enumValues?.length??0)>0||(e.valueMeanings?.length??0)>0)}function Ut(e){let t=Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:null;if(t){let e=[];for(let n of t){if(!n||typeof n!=`object`)continue;let t=n;if(!(`const`in t))continue;let r=String(t.const),i=typeof t.title==`string`?t.title:typeof t.description==`string`?t.description:void 0;i&&e.push({value:r,label:i})}return e.length>0?e:void 0}}function Wt(e){if(e.type!==`integer`||e.minimum===void 0||e.maximum===void 0||!Number.isInteger(e.minimum)||!Number.isInteger(e.maximum))return null;let t=e.maximum-e.minimum;return t<0||t>zt?null:Array.from({length:t+1},(t,n)=>e.minimum+n)}function Gt(e){return e?Kt(e):{}}function Kt(e){if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];let t=e.type;if(t===`object`||!t&&e.properties){let t=e.properties??{},n=new Set(Array.isArray(e.required)?e.required:[]),r={};for(let[e,i]of Object.entries(t))(n.has(e)||`default`in i||Object.keys(t).length<=4)&&(r[e]=Kt(i));return r}if(t===`array`){let t=e.items;return t?[Kt(t)]:[]}return t===`integer`||t===`number`?typeof e.default==`number`?e.default:typeof e.minimum==`number`?e.minimum:1:t===`boolean`?!1:t===`string`?e.format===`email`?`user@example.com`:e.format===`uuid`?`00000000-0000-4000-8000-000000000001`:typeof e.default==`string`?e.default:e.minLength?`x`.repeat(Number(e.minLength)):``:null}function qt(e){return!e||typeof e==`string`?null:e}function Jt(e,t){if(!e.foreignKey||!t)return null;let n=Qt(t);if(n.length===0)return null;if(e.references?.table){let t=$t(n,e.references.table);return t?Xt(t,e.references.column??tn(t.table)??`id`):null}let r=Zt(e.name);if(!r)return null;let i=en(n,r.stem);return i?Xt(i,r.kind===`key`?nn(i.table,`key`)??tn(i.table)??`id`:tn(i.table)??`id`):null}function Yt(e,t){if(!t)return[];let n=new Set,r=[];for(let i of e){let e=i[t.column];if(e==null)continue;let a=String(e);if(n.has(a))continue;n.add(a);let o=t.labelColumn?i[t.labelColumn]:void 0,s=o!=null&&String(o)!==a?String(o):null;r.push({value:a,label:s?`${a} · ${s}`:a})}return r}function Xt(e,t){let n=rn(e.table,t);return{ref:e.ref,child:e.name,column:t,...n===void 0?{}:{labelColumn:n}}}function Zt(e){return e===`id`?null:e.endsWith(`Id`)?{stem:e.slice(0,-2),kind:`id`}:e.endsWith(`_id`)?{stem:e.slice(0,-3),kind:`id`}:e.endsWith(`Key`)?{stem:e.slice(0,-3),kind:`key`}:e.endsWith(`_key`)?{stem:e.slice(0,-4),kind:`key`}:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(e.stores??{}))r.facet===`sql`&&r.tables&&t.push({ref:`sql:${n}`,tables:r.tables});return t}function $t(e,t){let n=t.toLowerCase();for(let t of e)for(let[e,r]of Object.entries(t.tables))if(e.toLowerCase()===n)return{ref:t.ref,name:e,table:r};return null}function en(e,t){let n=sn(t),r=[t,n,on(t),on(n)].map(e=>e.toLowerCase());for(let t of e)for(let[e,n]of Object.entries(t.tables))if(r.includes(e.toLowerCase()))return{ref:t.ref,name:e,table:n};return null}function tn(e){for(let[t,n]of Object.entries(e.columns??{}))if(an(n)&&n.primaryKey===!0)return t;if(e.columns&&`id`in e.columns)return`id`}function nn(e,t){return e.columns&&t in e.columns?t:void 0}function rn(e,t){if(t!==`name`&&e.columns&&`name`in e.columns)return`name`}function an(e){return`type`in e||`primaryKey`in e||`references`in e}function on(e){return e.endsWith(`y`)&&!/[aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(?:s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}function sn(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function cn(e){let t=[];for(let n of e.split(`/`))n.startsWith(`:`)&&n.length>1&&t.push(n.slice(1));return t}function ln(e){return`:${e}`}var un={"attachments:id":`attachments/tsk_eng_12/spec.pdf`,"tasks:id":`tsk_eng_12`,"comments:id":`cmt_1`,"projects:id":`proj_api`,"spaces:id":`space_eng`,"tags:id":`tag_bug`,"tags:tagId":`tag_feature`,"goals:id":`goal_harbor`,"documents:id":`doc_prd_api`,"members:id":`mem_aria`,"forms:id":`form_customer`,"drafts:id":`ENG-12`,"views:id":`view_web_board`,"inbox:id":`inb_1`};function dn(e,t){let n=e.split(`/`).filter(Boolean),r=`:${t}`,i=n.indexOf(r),a=i>0?n[i-1]:void 0;return(a?un[`${a}:${t}`]:void 0)??un[`:${t}`]}function fn(e,t){let n={};if(!e)return n;for(let r of t){let t=dn(e,r);t&&(n[r]=t)}return n}function pn(e,t){let n=e?.flows?.[t],r=n?.trigger?.cron,i=n?.trigger?.every;if(!r&&!i)return{kind:`unmatched`};let a=e?.clocks??{},o=new Set;for(let[e,n]of Object.entries(a)){if(t===e||t.endsWith(`.${e}`)){o.add(e);continue}if(r&&n.cron===r){o.add(e);continue}i&&n.every===i&&o.add(e)}if(o.size!==1)return{kind:`unmatched`};let s=[...o][0],c=a[s];return{kind:`matched`,clockName:s,timezone:c.timezone??null,description:c.description??null,cron:c.cron??null,every:c.every??null}}function mn(e){let t=e.handlerMs!=null&&Number.isFinite(e.handlerMs)?e.handlerMs:null;return t===null?e.rttMs!==null&&Number.isFinite(e.rttMs)?{primaryMs:e.rttMs,primaryKind:`rtt`,rttMs:e.rttMs}:null:{primaryMs:t,primaryKind:`handler`,rttMs:e.rttMs}}function hn(e){let t=new Set;if(!e?.stores)return t;for(let n of Object.values(e.stores)){for(let e of Object.values(n.tables??{}))for(let[n,r]of Object.entries(e.columns??{}))r?.pii&&ae(t,n);for(let[e,r]of Object.entries(n.classifications??{}))if(r&&typeof r==`object`&&!Array.isArray(r)&&`pii`in r&&r.pii){let n=e.includes(`.`)?e.slice(e.lastIndexOf(`.`)+1):e;ae(t,n)}}return t}function gn(e,t,n=re){if(t.size===0||e==null)return e;if(Array.isArray(e))return e.map(e=>gn(e,t,n));if(typeof e==`object`){let r={};for(let[i,a]of Object.entries(e))r[i]=t.has(i)?n:gn(a,t,n);return r}return e}function _n(e){return e.failure==null?e.response!==void 0&&e.response!==null?JSON.stringify(e.response,null,2):JSON.stringify({status:e.status??200,failure:null,response:null},null,2):JSON.stringify({status:e.status??null,failure:e.failure,response:e.response??null},null,2)}function vn(e,t,n){return t&&e.masked===!1?_n({...e,response:gn(e.response,n),failure:e.failure===void 0?void 0:{...e.failure,data:gn(e.failure.data,n)},masked:!0}):_n(e)}function yn(e){let t=e.flow.effects;return!t||(t.writes?.length??0)===0&&(t.emits?.length??0)===0&&(t.sends?.length??0)===0&&(t.asks?.length??0)===0&&(t.embeds?.length??0)===0&&(t.fetches?.length??0)===0}function bn(e,t){return!t&&yn(e)}function xn(e,t){if(!e)return{ok:!0,errors:[],value:t};let n=[];return Sn(e,t,``,n),{ok:n.length===0,errors:n,value:t}}function Sn(e,t,n,r){let i=e.type;if(i===`object`||e.properties){if(typeof t!=`object`||!t||Array.isArray(t)){r.push({path:n||`/`,message:`must be object`});return}let i=t,a=e.properties??{},o=Array.isArray(e.required)?e.required:[];for(let e of o)(i[e]===void 0||i[e]===null||i[e]===``)&&r.push({path:`${n}/${e}`,message:`required`});for(let[e,t]of Object.entries(a))i[e]!==void 0&&Sn(t,i[e],`${n}/${e}`,r);return}if(Array.isArray(e.enum)){e.enum.map(String).includes(String(t))||r.push({path:n||`/`,message:`invalid enum`});return}i===`string`&&typeof t!=`string`?r.push({path:n||`/`,message:`must be string`}):i===`integer`?typeof t!=`number`||!Number.isInteger(t)?r.push({path:n||`/`,message:`must be integer`}):Cn(e,t,n,r):i===`number`?typeof t!=`number`||Number.isNaN(t)?r.push({path:n||`/`,message:`must be number`}):Cn(e,t,n,r):i===`boolean`&&typeof t!=`boolean`&&r.push({path:n||`/`,message:`must be boolean`})}function Cn(e,t,n,r){let i=typeof e.minimum==`number`?e.minimum:void 0,a=typeof e.maximum==`number`?e.maximum:void 0;i!==void 0&&t<i&&r.push({path:n||`/`,message:`must be ≥ ${i}`}),a!==void 0&&t>a&&r.push({path:n||`/`,message:`must be ≤ ${a}`})}function wn(e){return JSON.stringify(e,null,2)}function Tn({row:e,manifest:t}){let n=B(e.flow.trigger);return n===`cron`||n===`every`?(0,J.jsx)(En,{row:e,manifest:t}):(0,J.jsx)(Dn,{row:e,kind:n,manifest:t})}function En({row:e,manifest:t}){let n=(0,q.useMemo)(()=>pn(t,e.id),[t,e.id]),r=Ze(),a=Qe(),o=it(),[s,c]=(0,q.useState)({asGate:null,asUserId:null}),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null);(0,q.useEffect)(()=>{r.reset(),o.reset(),f(null),u(null)},[e.id]);let p=n.kind===`matched`;async function m(){if(u(performance.now()),p){f(`clock`);try{await r.mutateAsync({name:n.clockName})}catch{}return}if(Y(s)){f(`invoke`);try{await o.mutateAsync({flowId:e.id,body:{},...s.asUserId?{asUserId:s.asUserId}:{},...s.asGate?{asGate:s.asGate}:{}})}catch{}}}let h=p?r.isPending:o.isPending,g=p?r.isError:o.isError||o.isSuccess&&o.data?.failure!=null,_=p?r.isSuccess:o.isSuccess&&!o.data?.failure,v=l!==null&&(_||g)?performance.now()-l:null,y=(0,q.useMemo)(()=>p&&r.data?JSON.stringify(r.data,null,2):!p&&o.data?_n(o.data):null,[p,r.data,o.data]),b=p?`Run now`:`Run handler`,x=p?`Run now`:`Run handler once`;return(0,J.jsx)(jn,{title:b,dataMode:p?`clock`:`invoke-fallback`,actions:(0,J.jsxs)(J.Fragment,{children:[p?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kt,{manifest:t,identities:a.data??[],value:s,onChange:c}),(0,J.jsx)(In,{})]}),(0,J.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:h||!p&&!Y(s),onClick:()=>void m(),className:Fn,children:h?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:mt,className:`animate-spin`,"data-icon":`inline-start`}),`Running…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:te,"data-icon":`inline-start`}),x]})})]}),children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[p?(0,J.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,"data-slot":`clock-path-copy`,children:[`Fires Manifest clock`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:n.clockName}),` `,`via`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/clock/run-now`}),` `,`(lease-gated — the real scheduler path).`,n.timezone?(0,J.jsxs)(J.Fragment,{children:[` `,`Timezone · `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.timezone}),`.`]}):null]}):(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-snug text-foreground/90`,"data-slot":`invoke-fallback-copy`,role:`note`,children:[`No unique Manifest clock matches this flow's schedule.`,` `,(0,J.jsx)(`strong`,{className:`font-medium`,children:`Run handler once`}),` uses`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),` `,`with empty input — it does `,(0,J.jsx)(`em`,{children:`not`}),` exercise the Clock lease / scheduler path.`]}),(0,J.jsx)(On,{failed:!!g,success:!!_,elapsed:v,handlerMs:p?null:o.data?.durationMs,statusCode:p?r.data?.ran?200:409:o.data?.status,errorMessage:p?r.isError?r.error.message:null:o.isError?o.error.message:null,responseJson:y,emptyHint:p?`Run now to fire the real clock tick.`:`Run handler once to invoke with empty input.`,pathUsed:d,cache:p?void 0:o.data?.cache})]})})}function Dn({row:e,kind:t,manifest:n}){let r=Qe(),l=it(),d=qt(e.flow.in),f=(0,q.useMemo)(()=>X(d),[d]),p=(0,q.useMemo)(()=>t===`http`&&e.path?cn(e.path):[],[t,e.path]),m=(0,q.useMemo)(()=>Nt(f,{http:t===`http`,method:e.method,pathParams:p}),[f,t,e.method,p]),h=t!==`http`||se(e.method),[g,_]=(0,q.useState)({asGate:null,asUserId:null}),[v,y]=(0,q.useState)(!0),[b,x]=(0,q.useState)(()=>fn(e.path,p)),S=(0,q.useMemo)(()=>Gt(d)??{},[d]),C=(0,q.useMemo)(()=>Pt(S,m.query),[S,m.query]),w=(0,q.useMemo)(()=>Pt(S,m.body),[S,m.body]),[T,E]=(0,q.useState)(C),[D,O]=(0,q.useState)(w),[k,A]=(0,q.useState)(`fields`),[j,M]=(0,q.useState)(()=>wn(w)),[N,P]=(0,q.useState)(null),[F,I]=(0,q.useState)([]),[R,ee]=(0,q.useState)(null),[ne,re]=(0,q.useState)(null);(0,q.useEffect)(()=>{E(C),O(w),M(wn(w)),P(null),A(`fields`),x(fn(e.path,p)),I([]),re(null),ee(null),l.reset()},[e.id]);function ie(e){try{let t=JSON.parse(e);return typeof t!=`object`||!t||Array.isArray(t)?(P(`Body must be a JSON object.`),!1):(O(t),P(null),!0)}catch(e){return P(e instanceof Error?e.message:`Invalid JSON.`),!1}}function ae(e){if(e!==k){if(e===`raw`){M(wn(D)),P(null),A(`raw`);return}ie(j)&&A(`fields`)}}async function z(t=!v){let n=h?D:{};if(h&&k===`raw`){if(!ie(j))return;try{n=JSON.parse(j)}catch{return}}let r={...T,...n},i=xn(d,{...b,...r});if(!i.ok){I(i.errors);return}if(I([]),Y(g)){ee(performance.now());try{await l.mutateAsync({flowId:e.id,body:r,...g.asUserId?{asUserId:g.asUserId}:{},...g.asGate?{asGate:g.asGate}:{},...p.length>0?{pathParams:b}:{},...t?{revealPii:!0}:{}})}catch{}}}function ce(){E(C),O(w),M(wn(w)),P(null),x(fn(e.path,p)),I([])}(0,q.useEffect)(()=>{R===null||l.isPending||(l.isSuccess||l.isError)&&re(performance.now()-R)},[l.isSuccess,l.isError,l.isPending,R]);let le=(0,q.useMemo)(()=>l.data?vn(l.data,v,hn(n)):null,[l.data,v,n]),ue=l.data?.failure!=null,de=l.data?.status,fe=t===`http`?`Call API`:t===`signal`?`Run handler`:`Invoke`,pe=fe;return(0,J.jsx)(jn,{title:fe,dataTrigger:t,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kt,{manifest:n,identities:r.data??[],value:g,onChange:_}),(0,J.jsx)(oe,{piiMasked:v,disabled:l.isPending,onToggle:()=>{let t=!v;y(t),l.data&&!l.isPending&&bn(e,t)&&z(!0)}}),h?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(In,{}),(0,J.jsx)(Mn,{view:k,onChange:ae})]}):null,(0,J.jsx)(In,{}),(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsxs)(L,{...e,type:`button`,variant:`ghost`,"data-slot":`call-api-reset`,disabled:l.isPending,onClick:ce,className:Pn,children:[(0,J.jsx)(i,{icon:Ae,"data-icon":`inline-start`}),`Reset`]})}),(0,J.jsx)(c,{side:`bottom`,className:`text-[11px]`,children:h?`Reset body to the schema example`:`Reset to schema examples`})]}),(0,J.jsx)(In,{}),(0,J.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:l.isPending||!Y(g),onClick:()=>void z(),className:Fn,children:l.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:mt,className:`animate-spin`,"data-icon":`inline-start`}),`Calling…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:te,"data-icon":`inline-start`}),pe]})})]}),children:(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`min-h-0 min-w-0 shrink overflow-y-auto`,children:[t===`http`?(0,J.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:[`Operator session · invoke-as`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`console:flows:invoke-as`})]}):null,t===`signal`?(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-snug text-foreground/90`,"data-slot":`signal-honest-copy`,role:`note`,children:[(0,J.jsx)(`strong`,{className:`font-medium`,children:`Run handler directly`}),` — invokes the flow with your payload via`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),`. It does `,(0,J.jsx)(`em`,{children:`not`}),` publish on the signal bus, so it does not test delivery physics (once / broadcast / live, retries, dead-letter).`]}):null,t===`internal`?(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-border/60 bg-muted/20 px-3 py-2 text-[11px] leading-snug text-muted-foreground`,"data-slot":`call-only-bypass-copy`,role:`note`,children:[`This flow has no external trigger. Invoking here bypasses its normal caller (`,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`fx.call`}),` /`,` `,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`effects.calls`}),`). The body still matches `,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`flow.in`}),`.`]}):null,t===`cdc`?(0,J.jsx)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:`Direct handler invoke — not a Store CDC event.`}):null,p.length>0?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Path params`,"data-slot":`call-api-path`,children:[(0,J.jsx)(Rn,{title:`Path params`,hint:e.path??void 0}),p.map(e=>(0,J.jsx)(K,{label:e,className:`[&>span]:px-3`,children:(0,J.jsx)(a,{id:`path-${e}`,flat:!0,className:o(vt,`px-3 font-mono`),placeholder:ln(e),value:b[e]??``,onChange:t=>x(n=>({...n,[e]:t.target.value}))})},e))]}):null,m.query.length>0?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Query params`,"data-slot":`call-api-query`,children:[(0,J.jsx)(Rn,{title:`Query params`,hint:`seeded from schema`}),(0,J.jsx)(bt,{children:m.query.map(e=>(0,J.jsx)(zn,{field:e,idPrefix:`query`,value:T[e.name],onChange:t=>E(n=>({...n,[e.name]:t})),error:F.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,h?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Body`,"data-slot":`call-api-body`,children:[(0,J.jsx)(Rn,{title:`Body`,hint:k===`raw`?`raw JSON`:`seeded from schema`}),k===`raw`?(0,J.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,J.jsx)(`textarea`,{"data-slot":`call-api-body-raw`,"aria-label":`Raw JSON body`,spellCheck:!1,value:j,onChange:e=>{M(e.target.value),N&&P(null)},className:o(`min-h-40 w-full resize-y rounded-none border-0 bg-transparent px-3 py-2 font-mono text-xs leading-relaxed text-foreground outline-none`,`placeholder:text-muted-foreground focus-visible:bg-muted/20`,N&&`text-destructive`)}),N?(0,J.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-xs text-destructive`,"data-slot":`call-api-raw-error`,children:N}):null]}):m.body.length===0?(0,J.jsx)(`p`,{className:`border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No body fields (empty object).`}):(0,J.jsx)(bt,{children:m.body.map(e=>(0,J.jsx)(zn,{field:e,value:D[e.name],onChange:t=>O(n=>({...n,[e.name]:t})),error:F.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,F.length>0?(0,J.jsx)(`p`,{role:`alert`,className:`px-3 py-2 text-xs text-destructive`,"data-slot":`call-api-validation`,children:`Fix contract errors before sending.`}):null]}),(0,J.jsx)(On,{failed:!!ue,success:!!l.data&&!ue,elapsed:ne,handlerMs:l.data?.durationMs,statusCode:de,errorMessage:l.isError?l.error.message:null,responseJson:le,emptyHint:`Call to see a real host response.`,pathUsed:null,cache:l.data?.cache})]})})}function On({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,errorMessage:s,responseJson:c,emptyHint:l,pathUsed:u,cache:d}){let[f,m]=(0,q.useState)(!1),h=(0,J.jsx)(An,{failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:u,cache:d});return(0,J.jsxs)(`section`,{className:`flex min-h-56 min-w-0 flex-1 flex-col overflow-hidden`,"aria-label":`Response`,"data-slot":`call-api-response-block`,children:[(0,J.jsxs)(`div`,{className:F,children:[(0,J.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,J.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,c?(0,J.jsx)(ye,{label:`Expand response`,className:`flex self-stretch`,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":`Expand response`,"data-slot":`call-api-response-expand`,className:g,onClick:()=>m(!0),children:(0,J.jsx)(i,{icon:Tt,className:`size-3.5`,"aria-hidden":!0})})}):null]})]}),s?(0,J.jsx)(`p`,{role:`alert`,className:`px-2 py-2 text-sm text-destructive`,"data-slot":`call-api-error`,children:s}):null,c?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-slot":`call-api-response-frame`,children:[(0,J.jsx)(`div`,{className:o(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0,"data-slot":`call-api-response-rail`}),(0,J.jsx)(Ne,{json:c,dataSlot:`call-api-response`,className:`flex min-h-0 flex-1 overflow-auto`})]}):(0,J.jsx)(`p`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:l}),c?(0,J.jsx)(b,{open:f,onOpenChange:m,children:(0,J.jsxs)(D,{side:`right`,showCloseButton:!1,className:`gap-0 p-0 data-[side=right]:w-[min(48rem,calc(100vw-2rem))] data-[side=right]:sm:max-w-[min(48rem,calc(100vw-2rem))]`,"data-slot":`call-api-response-dialog`,children:[(0,J.jsxs)(C,{className:o(F,`flex-row gap-0 border-border/60 p-0`),children:[(0,J.jsx)(N,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,J.jsx)(j,{className:`sr-only`,children:`Full Call API response JSON`}),(0,J.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,(0,J.jsx)(kn,{json:c}),(0,J.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,J.jsxs)(p,{"aria-label":`Close`,className:g,"data-slot":`call-api-response-close`,children:[(0,J.jsx)(i,{icon:S,className:`size-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,J.jsx)(`div`,{className:o(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,J.jsx)(Ne,{json:c,dataSlot:`call-api-response-expanded`,className:`flex min-h-0 flex-1 overflow-auto`})]})})]})}):null]})}function kn({json:e}){let[t,n]=(0,q.useState)(!1);return(0,J.jsx)(ye,{label:t?`Copied`:`Copy response`,className:`flex self-stretch`,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":t?`Copied`:`Copy response`,"data-slot":`call-api-response-copy`,className:g,onClick:()=>{navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)})},children:(0,J.jsx)(i,{icon:t?l:de,className:`size-3.5`,"aria-hidden":!0})})})}function An({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:d,cache:f}){let p=t||e,m=p?mn({handlerMs:r,rttMs:n}):null;return(0,J.jsxs)(J.Fragment,{children:[d?(0,J.jsxs)(`span`,{className:`flex h-full items-center px-2 font-mono text-[10px] text-muted-foreground`,"data-slot":`call-api-path-used`,"data-path":d,children:[`via `,d===`clock`?`clock.run-now`:`flows.invoke`]}):null,p?(0,J.jsxs)(`span`,{className:o(`inline-flex h-full items-center gap-1 px-2 font-mono text-[10px] font-semibold`,e?`text-destructive`:`text-emerald-700 dark:text-emerald-400`),"data-slot":`call-api-status`,"data-failed":e?`true`:`false`,children:[(0,J.jsx)(i,{icon:e?Ee:l,className:`size-3`,"aria-hidden":!0}),a??(e?`error`:`ok`)]}):null,p?(0,J.jsx)(`span`,{className:`flex h-full items-center px-2`,children:(0,J.jsx)(wt,{cache:f??`none`,dataSlot:`call-api-cache`})}):null,m?(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsx)(`span`,{...e,className:`flex h-full items-center px-2 font-mono text-[10px] tabular-nums text-muted-foreground`,"data-slot":`call-api-duration`,"data-kind":m.primaryKind,children:je(m.primaryMs)})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:m.primaryKind===`handler`?`Handler time — same clock as Traces.`:`Browser round-trip. Handler time is on the Traces row.`})]}):null,m?.primaryKind===`handler`&&m.rttMs!==null?(0,J.jsxs)(`span`,{className:`flex h-full items-center px-2 font-mono text-[10px] tabular-nums text-muted-foreground/70`,"data-slot":`call-api-rtt`,title:`Browser round-trip`,children:[je(m.rttMs),` rtt`]}):null]})}function jn({title:e,actions:t,children:n,dataTrigger:a,dataMode:s}){return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`call-api-panel`,"data-trigger":a,"data-mode":s,children:[(0,J.jsxs)(`div`,{className:o(r,`min-w-0`),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 px-2`,children:[(0,J.jsx)(i,{icon:te,className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`h3`,{className:o(I,`text-foreground`),children:e})]}),(0,J.jsx)(`div`,{className:`ml-auto flex h-full min-w-0 items-stretch`,children:t})]}),(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:n})]})}function Mn({view:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`flex h-full shrink-0 items-stretch`,role:`group`,"aria-label":`Body view`,"data-slot":`call-api-body-view-toggle`,children:[(0,J.jsx)(Nn,{active:e===`fields`,label:`Fields`,icon:Ge,onClick:()=>t(`fields`)}),(0,J.jsx)(Nn,{active:e===`raw`,label:`Raw`,icon:xe,onClick:()=>t(`raw`)})]})}function Nn({active:e,label:t,icon:n,onClick:r}){return(0,J.jsxs)(`button`,{type:`button`,className:o(h,`font-semibold tracking-[0.08em] uppercase`,e?ee:R),"aria-pressed":e,"aria-label":t,onClick:r,children:[(0,J.jsx)(i,{icon:n,className:`size-3`}),(0,J.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}var Pn=`h-full rounded-none border-0 bg-transparent px-2 text-[10px] font-semibold tracking-[0.08em] uppercase shadow-none hover:bg-muted/50`,Fn=`h-full rounded-none border-0 px-3 text-[10px] font-semibold tracking-[0.14em] uppercase shadow-none`;function In(){return(0,J.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})}var Ln=`h-7 w-full justify-between rounded-none border-0 bg-transparent px-2 shadow-none focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`;function Rn({title:e,hint:t}){return(0,J.jsxs)(`div`,{className:F,children:[(0,J.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:e}),t?(0,J.jsx)(`span`,{className:`ml-auto flex items-center px-2 text-[10px] text-muted-foreground`,children:t}):null]})}function zn({field:e,value:t,onChange:n,error:r,wide:i=!1,manifest:s,idPrefix:c=`body`}){let l=`${c}-${e.name}`,u=Bn(e,s),d=[e.required?null:`optional`,u.lookup?`fk · ${u.lookup.child}.${u.lookup.column}`:e.type,u.lookup?null:Bt(e)].filter(Boolean).join(` · `),f=r?(0,J.jsx)(`p`,{className:`px-3 pb-2 text-xs text-destructive`,children:r.message}):null,p=o(i&&`col-span-full border-r-0`);if(u.lookup){let r=t==null||t===``?``:String(t),i=Vn(u.options,r);return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:r||null,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,disabled:u.isLoading,children:(0,J.jsx)(G,{placeholder:u.isLoading?`Loading…`:`Select…`})}),(0,J.jsx)(U,{children:i.map(e=>(0,J.jsx)(H,{value:e.value,children:e.label},e.value))})]}),f]})}if(e.type===`enum`&&e.enumValues)return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:String(t??``),onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{})}),(0,J.jsx)(U,{children:e.enumValues.map(e=>(0,J.jsx)(H,{value:e,children:e},e))})]}),f]});if(e.type===`boolean`)return(0,J.jsx)(K,{label:e.name,hint:d,dense:!0,className:p,children:(0,J.jsxs)(W,{value:t===!0?`true`:`false`,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e)===`true`)},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{})}),(0,J.jsxs)(U,{children:[(0,J.jsx)(H,{value:`true`,children:`true`}),(0,J.jsx)(H,{value:`false`,children:`false`})]})]})});if(e.type===`integer`||e.type===`number`){let r=Wt(e);if(r){let i=typeof t==`number`?String(t):``;return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:i||null,onValueChange:e=>{e==null||Array.isArray(e)||n(Number(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{placeholder:`Select…`})}),(0,J.jsx)(U,{children:r.map(t=>{let n=e.valueMeanings?.find(e=>e.value===String(t));return(0,J.jsx)(H,{value:String(t),children:n?`${t} · ${n.label}`:t},t)})})]}),f]})}return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsx)(a,{id:l,type:`number`,flat:!0,className:o(vt,`h-7 px-2 font-mono`),min:e.minimum,max:e.maximum,step:e.type===`integer`?1:void 0,value:typeof t==`number`?t:``,onChange:t=>{if(t.target.value===``){n(void 0);return}n(Hn(Number(t.target.value),e.minimum,e.maximum))}}),f]})}return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsx)(a,{id:l,flat:!0,className:o(vt,`h-7 px-2 font-mono`),value:typeof t==`string`?t:t==null?``:String(t),onChange:e=>n(e.target.value)}),f]})}function Bn(e,t){let n=(0,q.useMemo)(()=>Jt(e,t),[e,t]),r=nt(n?{ref:n.ref,child:n.child,limit:200}:null,n!==null);return{lookup:n,options:(0,q.useMemo)(()=>Yt(r.data?.rows??[],n),[r.data?.rows,n]),isLoading:r.isFetching}}function Vn(e,t){return!t||e.some(e=>e.value===t)?e:[{value:t,label:t},...e]}function Hn(e,t,n){let r=e;return t!==void 0&&r<t&&(r=t),n!==void 0&&r>n&&(r=n),r}function Z({title:e,meta:t,ruled:n=!0}){return(0,J.jsxs)(`div`,{className:o(`flex items-baseline justify-between gap-2`,n&&`border-b border-border/60 pb-1.5`),children:[(0,J.jsx)(`h3`,{className:I,children:e}),t?(0,J.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t}):null]})}function Un({method:e,className:t}){return(0,J.jsx)(Se,{variant:`outline`,className:o(`h-5 px-1.5 font-mono text-[10px] uppercase`,le(e),t),"data-slot":`http-method-badge`,children:e})}var Wn=[`once`,`broadcast`,`live`],Gn={once:{delivery:`once`,icon:Dt,label:`once`,title:`once — one consumer claims; retries + DLQ`,wellClass:`border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-400`,badgeClass:`border-amber-500/35 bg-amber-500/15 text-amber-800 dark:text-amber-400`},broadcast:{delivery:`broadcast`,icon:Et,label:`broadcast`,title:`broadcast — every subscriber gets a copy`,wellClass:`border-sky-500/35 bg-sky-500/10 text-sky-700 dark:text-sky-400`,badgeClass:`border-sky-500/35 bg-sky-500/15 text-sky-700 dark:text-sky-400`},live:{delivery:`live`,icon:ne,label:`live`,title:`live — retained feed; late subscribers replay history`,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,badgeClass:`border-emerald-500/35 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`}};function Kn({delivery:e,className:t}){let n=Gn[e];return(0,J.jsx)(Se,{variant:`outline`,title:n.title,className:o(`h-5 px-1.5 font-mono text-[10px]`,n.badgeClass,t),"data-slot":`signal-delivery-badge`,"data-delivery":e,children:n.label})}function qn({effects:e}){let t=Jn(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`effects-summary`,"aria-label":`Effects`,children:[(0,J.jsx)(Z,{title:`Effects`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=He(e.kind),n=Ie(e.kind,e.ref),r=e.kind===`call`?Fe(e.ref):null;return(0,J.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px]`,style:{borderColor:`${t}55`,color:t},title:r??`${Ve[e.kind]} ${e.ref}`,children:[(0,J.jsx)(i,{icon:n,className:`size-3`}),r?(0,J.jsx)(`span`,{className:`text-foreground/90`,children:r}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:Ve[e.kind]}),(0,J.jsx)(`span`,{className:`text-foreground/90`,children:e.ref})]})]},`${e.kind}:${e.ref}`)})})]})}function Jn(e){if(!e)return[];let t=[],n=(e,n)=>{for(let r of n??[]){let n=typeof r==`string`?r:r.ref??String(r);t.push({kind:e,ref:n})}};return n(`read`,e.reads),n(`write`,e.writes),n(`emit`,e.emits),n(`send`,e.sends),n(`ask`,e.asks),n(`embed`,e.embeds),n(`secret`,e.secrets),n(`call`,e.calls),n(`fetch`,e.fetches),t}function Yn({errors:e}){let t=Xn(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`errors-section`,"aria-label":`Flow errors`,children:[(0,J.jsx)(Z,{title:`Flow errors`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=(e.schema?X(e.schema):[]).map(e=>e.name).join(`, `);return(0,J.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md border border-destructive/25 bg-destructive/[0.04] px-1.5 py-0.5 font-mono text-[10px] text-destructive`,title:t?`{ code, data: { ${t} } }`:`Typed error — { code, data }`,"data-slot":`error-code`,"data-code":e.code,children:[(0,J.jsx)(i,{icon:Ee,className:`size-3`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-foreground/90`,children:e.code}),t?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t}):null]},e.code)})})]})}function Xn(e){return e?Array.isArray(e)?e.map(e=>({code:e,schema:null})):Object.entries(e).map(([e,t])=>({code:e,schema:qt(t)})):[]}var Zn=36e5;function Qn(e,t,n,r=Zn){let i=St(e,new Set([t])),a=n-r,o=i.filter(e=>e.startedAt>=a);if(o.length===0)return{kind:`empty`};let s=o.filter(e=>e.error!=null&&e.error.length>0).length,c=o[0];return{kind:`summary`,calls:o.length,errors:s,errorRate:s/o.length,lastStartedAt:c.startedAt,latestRunId:c.id,windowMs:r}}function $n({flowId:e,runs:t,nowMs:n=Date.now(),windowMs:r=Zn,children:i}){let a=Qn(t??[],e,n,r);return(0,J.jsxs)(`div`,{className:o(F,`px-2`),"data-slot":`flow-activity-strip`,"data-kind":a.kind,"aria-label":`Recent activity`,children:[(0,J.jsx)(`span`,{className:o(I,`flex items-center`),children:`Activity`}),(0,J.jsx)(er,{summary:a,nowMs:n}),i?(0,J.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:i}):null]})}function er({summary:e,nowMs:t}){if(e.kind===`empty`)return(0,J.jsx)(`p`,{className:`flex items-center text-[11px] text-muted-foreground`,"data-slot":`flow-activity-empty`,children:`No recent runs in the Console buffer.`});let n=Math.round(e.errorRate*100),r=tr(e.lastStartedAt,t);return(0,J.jsxs)(`p`,{className:`flex min-w-0 items-center gap-x-2 text-[11px] text-foreground/85`,children:[(0,J.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-calls`,children:[e.calls,` call`,e.calls===1?``:`s`]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,J.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-errors`,children:[n,`% errors`]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"data-slot":`flow-activity-ago`,children:r}),(0,J.jsx)(gt,{to:`/overview`,search:{run:e.latestRunId},className:o(h,R),"data-slot":`flow-activity-open-run`,children:`Open latest`})]})}function tr(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.max(1,Math.round(n/1e3))}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function nr(e){switch(e){case`string`:return`border-teal-500/35 bg-teal-500/10 text-teal-800 dark:text-teal-300`;case`integer`:return`border-blue-500/35 bg-blue-500/10 text-blue-800 dark:text-blue-300`;case`number`:return`border-amber-500/35 bg-amber-500/10 text-amber-800 dark:text-amber-300`;case`boolean`:return`border-violet-500/35 bg-violet-500/10 text-violet-800 dark:text-violet-300`;case`enum`:return`border-indigo-500/35 bg-indigo-500/10 text-indigo-800 dark:text-indigo-300`;case`array`:return`border-cyan-500/35 bg-cyan-500/10 text-cyan-800 dark:text-cyan-300`;case`object`:return`border-zinc-500/35 bg-zinc-500/10 text-zinc-700 dark:text-zinc-300`;default:return`border-border/70 bg-muted/40 text-muted-foreground`}}function rr({fields:e,emptyLabel:t=`No schema fields declared.`,layout:n=`list`}){return e.length===0?(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-slot":`schema-fields-empty`,children:t}):n===`grid`?(0,J.jsx)(`div`,{"data-slot":`schema-fields`,"data-layout":`grid`,children:(0,J.jsx)(bt,{columns:3,children:e.map(e=>(0,J.jsx)(ir,{field:e,depth:0,cell:!0},e.path))})}):(0,J.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`schema-fields`,children:e.map(e=>(0,J.jsx)(ir,{field:e,depth:0},e.path))})}function ir({field:e,depth:t,cell:n=!1}){let r=e.type===`enum`&&e.enumValues,i=Bt(e);return(0,J.jsxs)(n?`div`:`li`,{className:n?`min-w-0 border-b border-border/50`:void 0,children:[(0,J.jsxs)(`div`,{className:n?`flex items-center gap-1.5 px-2 py-1.5`:`flex items-center gap-2 py-1`,style:n?void 0:{paddingLeft:t*14},"data-slot":`schema-field-row`,children:[(0,J.jsx)(`span`,{className:`shrink-0`,"data-slot":`schema-field-keys`,title:ar(e),children:(0,J.jsx)(ie,{primaryKey:e.primaryKey,foreignKey:e.foreignKey,unique:e.unique,empty:`none`})}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),e.required?null:(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-border/60 bg-muted/30 px-1 py-px text-[9px] font-medium tracking-wide text-muted-foreground uppercase`,"data-slot":`schema-field-optional`,children:`optional`}),e.pii?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-amber-500/40 bg-amber-500/10 px-1 py-px text-[9px] font-medium tracking-wide text-amber-800 uppercase dark:text-amber-300`,"data-slot":`schema-field-pii`,children:`pii`}):null,e.sensitive?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-rose-500/40 bg-rose-500/10 px-1 py-px text-[9px] font-medium tracking-wide text-rose-700 uppercase dark:text-rose-300`,"data-slot":`schema-field-sensitive`,children:`sensitive`}):null,i&&!r?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-blue-500/35 bg-blue-500/10 px-1 py-px font-mono text-[9px] font-medium tracking-wide text-blue-800 dark:text-blue-300`,"data-slot":`schema-field-constraint`,title:`Allowed range ${i}`,children:i}):null,(0,J.jsx)(`span`,{className:o(`ml-auto shrink-0 rounded border px-1.5 py-px font-mono text-[9px] font-medium tracking-wide`,nr(e.type)),"data-slot":`schema-field-type`,title:r?e.enumValues?.join(` | `):e.type,children:e.type})]}),e.children?.map(e=>(0,J.jsx)(ir,{field:e,depth:t+1,cell:n},e.path))]})}function ar(e){let t=[];if(e.primaryKey&&t.push(`Primary key`),e.foreignKey){let n=e.references?[e.references.table,e.references.column].filter(Boolean).join(`.`):null;t.push(n?`Foreign key → ${n}`:`Foreign key`)}return e.unique&&t.push(`Unique`),t.length>0?t.join(` · `):`None`}function or({fields:e}){let t=Ht(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`validation-section`,"aria-label":`Validation`,children:[(0,J.jsx)(Z,{title:`Validation`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,J.jsx)(sr,{field:e},e.path))})]})}function sr({field:e}){let t=Vt(e),n=e.valueMeanings?.length?e.valueMeanings:e.enumValues?.map(e=>({value:e,label:e}));return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5`,"data-slot":`validation-field`,"data-field":e.name,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,J.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),t?(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}):null]}),n&&n.length>0?(0,J.jsx)(`ul`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 sm:grid-cols-3 lg:grid-cols-5`,children:n.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,"data-slot":`validation-option`,children:[(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.value}),(0,J.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.label})]},e.value))}):null]})}function cr({row:e,manifest:t,runs:n,leading:r}){let a=B(e.flow.trigger),s=Be(e.flow.trigger),c=Ue(t,e.id,a===`http`?`http`:a===`internal`?`internal`:a),l=qt(e.flow.in),u=qt(e.flow.out),d=We(e.flow.gates??[],t),f=a===`signal`&&e.flow.trigger?.signal?t?.signals?.[e.flow.trigger.signal]:void 0,p=a===`cron`||a===`every`?pn(t,e.id):null,m=a===`internal`?Ct(t,e.id):[],g=a===`http`?`Request`:`Input`,_=a===`http`?`Response`:`Output`,v=a!==`cron`&&a!==`every`,y=X(l),b=X(u),x=jt(y,a===`http`&&e.path?cn(e.path):[]);return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`flow-contract-panel`,"data-trigger":a,children:[(0,J.jsx)(yt,{dataSlot:`endpoint-header`,leading:r,icon:(0,J.jsx)(`span`,{"data-slot":`trigger-kind-icon`,"data-kind":a,children:(0,J.jsx)(i,{icon:s.icon,className:`size-4`})}),wellClassName:s.wellClass,title:(0,J.jsx)(`span`,{className:`font-mono`,children:e.id}),badge:(0,J.jsx)(`span`,{className:`font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,"data-slot":`trigger-kind-badge`,children:s.label}),subtitle:a===`http`&&c.method&&c.path?(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`http-endpoint-line`,children:[(0,J.jsx)(Un,{method:c.method}),(0,J.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:c.path})]}):a===`signal`&&f?(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`signal-endpoint-line`,children:[(0,J.jsx)(Kn,{delivery:f.delivery}),(0,J.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:e.flow.trigger?.signal})]}):(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] leading-none text-muted-foreground`,"data-slot":`trigger-headline`,children:c.headline}),actions:(0,J.jsxs)(gt,{to:`/overview`,search:{flow:e.id},"data-slot":`open-in-graph`,className:o(h,`text-sky-700 dark:text-sky-400`),children:[(0,J.jsx)(i,{icon:be.flow.icon,className:`size-3.5`,"aria-hidden":!0}),`Open in graph`]})}),(0,J.jsxs)($n,{flowId:e.id,runs:n,children:[e.flow.plane?(0,J.jsx)(lr,{plane:e.flow.plane}):null,e.flow.durable?(0,J.jsx)(ur,{icon:Pe,label:`durable`,title:`Durable — long-running, retryable steps`}):null,e.flow.live?(0,J.jsx)(ur,{icon:pe,label:`live`,title:typeof e.flow.live==`string`?`Live — SSE for ${e.flow.live}`:`Live — SSE signal feed`}):null]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(qn,{effects:e.flow.effects}),(0,J.jsx)(ze,{gates:d}),(0,J.jsx)(Yn,{errors:e.flow.errors}),a===`signal`&&f&&(f.retries!==void 0||f.deadLetter)?(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`signal-delivery`,children:[f.retries===void 0?null:`retries ${f.retries}`,f.deadLetter?`dead-letter`:null].filter(e=>e!==null).join(` · `)}):null,(a===`cron`||a===`every`)&&p?.kind===`matched`?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`clock-join`,children:[`Clock · `,(0,J.jsx)(`span`,{className:`font-mono`,children:p.clockName}),p.timezone?` · ${p.timezone}`:``]}):null,a===`internal`?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`call-only-note`,children:[`No external trigger — reachable via `,(0,J.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` /`,` `,(0,J.jsx)(`code`,{className:`font-mono`,children:`fx.call`}),`.`]}):null,a===`internal`?(0,J.jsxs)(`section`,{className:`flex flex-col gap-1.5`,"aria-label":`Callers`,"data-slot":`callers-list`,children:[(0,J.jsx)(Z,{title:`Called by`,meta:String(m.length)}),m.length===0?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No Manifest caller declares `,(0,J.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` for this flow.`]}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:m.map(e=>(0,J.jsx)(`li`,{className:`font-mono text-xs text-foreground/90`,children:e},e))})]}):null,v&&x.parameters.length>0?(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Parameters`,"data-slot":`parameters`,children:[(0,J.jsx)(Z,{title:`Parameters`,meta:String(x.parameters.length)}),(0,J.jsx)(rr,{fields:x.parameters,layout:`grid`})]}):null,(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[v&&(x.fields.length>0||x.parameters.length===0)?(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":g,"data-slot":`request`,children:[(0,J.jsx)(Z,{title:g,meta:String(x.fields.length)}),(0,J.jsx)(rr,{fields:x.fields,emptyLabel:typeof e.flow.in==`string`?`Schema not expanded in Manifest.`:a===`signal`?`No flow input schema — signal payload shape lives on the signal when declared.`:`No input schema declared.`})]}):null,(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":_,children:[(0,J.jsx)(Z,{title:_,meta:String(b.length)}),(0,J.jsx)(rr,{fields:b,emptyLabel:typeof e.flow.out==`string`?`Schema not expanded in Manifest.`:`No output schema declared.`})]})]}),v?(0,J.jsx)(or,{fields:y}):null]})})]})}function lr({plane:e}){let t=e===`operator`,n=t?he:Ke,r=t?`operator`:`user`;return(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:t=>(0,J.jsxs)(`span`,{...t,className:o(h,`cursor-help`),"data-slot":`plane-badge`,"data-plane":e,children:[(0,J.jsx)(i,{icon:n,className:`size-3`,"aria-hidden":!0}),r]})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:t?`Operator plane — runs under a Console operator identity, not an application user.`:`User plane — runs under an application user identity (invoke-as).`})]})}function ur({icon:e,label:t,title:n}){return(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:n=>(0,J.jsxs)(`span`,{...n,className:o(h,R,`cursor-help`),children:[(0,J.jsx)(i,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:n})]})}function dr(e){let t=new Map(Le.map(e=>[e,[]]));for(let n of e){let e=new Map;for(let t of n.flows){let n=B(t.flow.trigger),r=e.get(n)??[];r.push(t),e.set(n,r)}for(let[r,i]of e)t.get(r)?.push({unit:n.unit,flows:i})}return Le.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{id:e,label:Re[e].label,groups:n}]})}function fr(e){return`band:${e}`}function pr(e,t){return`unit:${e}:${t}`}function mr(e,t,n=!1){let r=t[e];return r===void 0?n:r}function hr(e){let t=[];for(let n of e){t.push(fr(n.id));for(let e of n.groups)t.push(pr(n.id,e.unit))}return t}function gr(e,t){for(let n of e)for(let e of n.groups)if(e.flows.some(e=>e.id===t))return[fr(n.id),pr(n.id,e.unit)];return[]}function _r(e,t){let n=z(e.method)-z(t.method);return n===0?e.id.localeCompare(t.id):n}function vr(e){let t=e?.flows;if(!t)return[];let n=new Map;for(let[r,i]of Object.entries(t)){let t=xt(r),a=r.includes(`.`)?r.slice(r.indexOf(`.`)+1):r,o=i.trigger?.http,s=i.trigger?.signal??null,c={id:r,unit:t,action:a,flow:i,method:o?.method??null,path:o?.path??null,signal:s,delivery:s?e.signals?.[s]?.delivery??null:null},l=n.get(t)??[];l.push(c),n.set(t,l)}return[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({unit:e,flows:t.sort(_r)}))}function yr(e,t){let n=t.trim().toLowerCase();return n?e.map(e=>{let t=e.unit.toLowerCase().includes(n)?e.flows:e.flows.filter(e=>e.id.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||(e.method?.toLowerCase().includes(n)??!1)||(e.path?.toLowerCase().includes(n)??!1)||(e.signal?.toLowerCase().includes(n)??!1)||(e.delivery?.toLowerCase().includes(n)??!1));return t.length>0?{unit:e.unit,flows:t}:null}).filter(e=>e!==null):e}function br(e){return(e.triggerKinds?.length??0)+(e.planes?.length??0)+(e.deliveries?.length??0)+ +!!e.durableOnly+ +!!e.liveOnly}function xr(e,t){let n=t.triggerKinds?.length?new Set(t.triggerKinds):null,r=t.planes?.length?new Set(t.planes):null,i=t.deliveries?.length?new Set(t.deliveries):null,a=t.durableOnly===!0,o=t.liveOnly===!0;return!n&&!r&&!i&&!a&&!o?e:e.map(e=>{let t=e.flows.filter(e=>!(n&&!n.has(B(e.flow.trigger))||r&&!r.has(e.flow.plane??`user`)||i&&(e.delivery===null||!i.has(e.delivery))||a&&!e.flow.durable||o&&!e.flow.live));return t.length>0?{unit:e.unit,flows:t}:null}).filter(e=>e!==null)}var Sr={user:{icon:Ke,label:`user`},operator:{icon:he,label:`operator`}},Cr=[`user`,`operator`];function wr({groups:e,selectedFlowId:t,onSelect:n}){let[a,l]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)({}),[h,_]=(0,q.useState)({}),v=(0,q.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)t.add(B(e.flow.trigger));return Le.filter(e=>t.has(e))},[e]),y=(0,q.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)e.flow.plane&&t.add(e.flow.plane);return Cr.filter(e=>t.has(e))},[e]),{hasDurable:b,hasLive:x,availableDeliveries:S}=(0,q.useMemo)(()=>{let t=!1,n=!1,r=new Set;for(let i of e)for(let e of i.flows)e.flow.durable&&(t=!0),e.flow.live&&(n=!0),e.delivery&&r.add(e.delivery);return{hasDurable:t,hasLive:n,availableDeliveries:Wn.filter(e=>r.has(e))}},[e]),C=br(p),w=(0,q.useMemo)(()=>dr(xr(yr(e,a),p)),[e,a,p]),T=(0,q.useMemo)(()=>hr(w),[w]),E=a.trim().length>0,D=T.length>0&&T.every(e=>mr(e,h,E));(0,q.useEffect)(()=>{if(!t)return;let e=gr(w,t);e.length!==0&&_(t=>{let n=!1,r={...t};for(let t of e)r[t]!==!0&&(r[t]=!0,n=!0);return n?r:t})},[t,w]);let O=(e,t)=>{_(n=>n[e]===t?n:{...n,[e]:t})},k=()=>{let e=!D;_(t=>{let n={...t};for(let t of T)n[t]=e;return n})},A=e=>m(t=>({...t,triggerKinds:Tr(t.triggerKinds??[],e)})),j=e=>m(t=>({...t,planes:Tr(t.planes??[],e)})),M=e=>m(t=>({...t,[e]:!t[e]})),N=e=>m(t=>({...t,deliveries:Tr(t.deliveries??[],e)}));return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`units-tree`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,J.jsxs)(`div`,{className:o(r,`border-b-0`),children:[(0,J.jsx)(fe,{value:a,onChange:e=>l(e.target.value),placeholder:`Search flows…`,"aria-label":`Search flows`,"data-slot":`units-search`}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsxs)(`button`,{...e,type:`button`,"aria-expanded":d,"aria-controls":`units-advanced-panel`,"aria-label":C>0?`Advanced filters, ${C} active`:`Advanced filters`,"data-slot":`units-advanced-toggle`,onClick:t=>{e.onClick?.(t),f(e=>!e)},className:o(g,`relative`,(d||C>0)&&`text-foreground`),children:[(0,J.jsx)(i,{icon:qe,className:`size-3`,"aria-hidden":!0}),C>0?(0,J.jsx)(`span`,{"data-slot":`units-advanced-count`,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:C}):null]})}),(0,J.jsx)(c,{side:`bottom`,children:`Advanced`})]}),(0,J.jsx)(st,{allOpen:D,disabled:T.length===0,onToggle:k,dataSlot:`units-tree-expand-toggle`})]})]}),d?(0,J.jsxs)(`div`,{id:`units-advanced-panel`,"data-slot":`units-advanced-panel`,className:`flex flex-col gap-2 border-t border-border/60 bg-muted/20 p-2`,children:[(0,J.jsx)(Q,{label:`Trigger`,groupLabel:`Trigger kind filter`,children:v.map(e=>{let t=Re[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.triggerKinds?.includes(e)??!1,onToggle:()=>A(e),dataFacet:`kind:${e}`},e)})}),S.length>0?(0,J.jsx)(Q,{label:`Delivery`,groupLabel:`Signal delivery filter`,children:S.map(e=>{let t=Gn[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.deliveries?.includes(e)??!1,onToggle:()=>N(e),dataFacet:`delivery:${e}`},e)})}):null,y.length>0?(0,J.jsx)(Q,{label:`Plane`,groupLabel:`Plane filter`,children:y.map(e=>{let t=Sr[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.planes?.includes(e)??!1,onToggle:()=>j(e),dataFacet:`plane:${e}`},e)})}):null,b||x?(0,J.jsxs)(Q,{label:`Flags`,groupLabel:`Flow flags filter`,children:[b?(0,J.jsx)($,{icon:Pe,label:`durable`,pressed:p.durableOnly??!1,onToggle:()=>M(`durableOnly`),dataFacet:`flag:durable`}):null,x?(0,J.jsx)($,{icon:pe,label:`live`,pressed:p.liveOnly??!1,onToggle:()=>M(`liveOnly`),dataFacet:`flag:live`}):null]}):null,C>0?(0,J.jsx)(`button`,{type:`button`,"data-slot":`units-advanced-clear`,onClick:()=>m({}),className:`self-end px-2 py-1 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,children:`Clear all`}):null]}):null]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:w.length===0?(0,J.jsx)(`p`,{className:P,children:`No flows match.`}):(0,J.jsx)(`div`,{className:`flex flex-col`,children:w.map(e=>{let r=fr(e.id);return(0,J.jsx)(Er,{band:e,open:mr(r,h,E),onOpenChange:e=>O(r,e),groupOpen:t=>mr(pr(e.id,t),h,E),onGroupOpenChange:(t,n)=>O(pr(e.id,t),n),selectedFlowId:t,onSelect:n},e.id)})})})]})}function Q({label:e,groupLabel:t,children:n}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[9px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:e}),(0,J.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-stretch`,role:`group`,"aria-label":t,children:n})]})}function $({icon:e,label:t,pressed:n,onToggle:r,dataFacet:a}){return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`units-facet-chip`,"data-facet":a,"aria-pressed":n,onClick:r,className:o(`inline-flex items-center gap-1 px-2 text-[10px] font-medium transition-colors hover:bg-muted/50`,n?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[(0,J.jsx)(i,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}function Tr(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Er({band:e,open:t,onOpenChange:n,groupOpen:r,onGroupOpenChange:a,selectedFlowId:s,onSelect:c}){let l=Re[e.id],u=e.groups.reduce((e,t)=>e+t.flows.length,0),f=e.groups.map(e=>e.unit),p=f.length>0&&f.every(e=>r(e)),h=()=>{let e=!p;for(let t of f)a(t,e);e&&n(!0)};return(0,J.jsx)(`section`,{"data-slot":`units-trigger-band`,"data-band":e.id,"aria-label":e.label,className:M,children:(0,J.jsxs)(De,{open:t,onOpenChange:n,children:[(0,J.jsx)(Te,{nativeButton:!1,className:E,"data-slot":`units-trigger-band-toggle`,render:n=>(0,J.jsxs)(`div`,{...n,children:[(0,J.jsx)(i,{icon:we,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,J.jsx)(i,{icon:l.icon,className:o(w,d(l.wellClass)),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:o(A,`flex-1`),children:e.label}),(0,J.jsx)(`span`,{className:m,children:u}),(0,J.jsx)(`span`,{className:v,children:(0,J.jsx)(st,{allOpen:p,disabled:f.length===0,onToggle:h,collapseLabel:`Collapse all in ${e.label}`,expandLabel:`Expand all in ${e.label}`,dataSlot:`units-band-expand-toggle`,disclose:!0,bare:!0})})]})}),(0,J.jsx)(Ce,{children:(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.groups.map(t=>(0,J.jsx)(Dr,{group:t,open:r(t.unit),onOpenChange:e=>a(t.unit,e),selectedFlowId:s,onSelect:c},`${e.id}:${t.unit}`))})})]})})}function Dr({group:e,open:t,onOpenChange:n,selectedFlowId:r,onSelect:a}){return(0,J.jsx)(`li`,{"data-slot":`unit-group`,"data-unit":e.unit,children:(0,J.jsxs)(De,{open:t,onOpenChange:n,children:[(0,J.jsxs)(Te,{className:o(O,`pl-4`),children:[(0,J.jsx)(i,{icon:we,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,J.jsx)(i,{icon:lt,className:o(w,`text-muted-foreground`),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.unit}),(0,J.jsx)(`span`,{className:m,children:e.flows.length})]}),(0,J.jsx)(Ce,{children:(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.flows.map(e=>(0,J.jsx)(Or,{flow:e,selected:r===e.id,onSelect:a},e.id))})})]})})}function Or({flow:e,selected:t,onSelect:n}){let r=Be(e.flow.trigger),a=e.delivery?Gn[e.delivery]:null,l=a?.icon??(e.method?ce(e.method):r.icon),f=d(a?.wellClass??(e.method?le(e.method):r.wellClass)),p=a?e.signal?`${a.title} · ${e.signal}`:a.title:r.detail?`${r.label} · ${r.detail}`:r.label;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`unit-flow-item`,"data-flow-id":e.id,"data-delivery":e.delivery??void 0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:o(T,`group/flow pl-8`,t&&`bg-muted/70 text-foreground`),children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:o(k,t?y:`bg-transparent`)}),(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsx)(`span`,{...e,className:o(w,f),"aria-hidden":!0,children:(0,J.jsx)(i,{icon:l,className:`size-3.5`})})}),(0,J.jsx)(c,{side:`right`,className:`text-[11px]`,children:p})]}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.action}),e.method?(0,J.jsx)(Un,{method:e.method,className:`ml-auto h-3.5 px-1 text-[8px] leading-none`}):null]})})}function kr(){let e=ke(),t=Me();Oe(!0);let{selectedFlowId:n,setSelectedFlow:r}=ht(),i=ge(),a=(0,q.useMemo)(()=>vr(e.data??null),[e.data]),o=(0,J.jsx)(_e,{open:i.open,onToggle:i.toggle,noun:`flows`,controlsId:`flows-tree`,dataSlot:`flows-tree-toggle`}),s=n??a[0]?.flows[0]?.id??null,c=(0,q.useMemo)(()=>{if(!s)return null;for(let e of a){let t=e.flows.find(e=>e.id===s);if(t)return t}return null},[a,s]);return(0,J.jsx)(`div`,{className:_,"data-slot":`units-page`,children:(0,J.jsxs)(ue,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,J.jsx)(me,{panelRef:i.panelRef,collapsible:!0,collapsedSize:0,defaultSize:f.start.defaultSize,minSize:f.start.minSize,onResize:i.onResize,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(`div`,{id:`flows-tree`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`flows-tree`,children:(0,J.jsx)(wr,{groups:a,selectedFlowId:s,onSelect:e=>{r(e)}})})}),i.open?(0,J.jsx)(ve,{withHandle:!0}):null,(0,J.jsx)(me,{defaultSize:f.end.defaultSize,minSize:f.end.minSize,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:c?(0,J.jsxs)(ue,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-slot":`units-inspector`,children:[(0,J.jsx)(me,{defaultSize:`56%`,minSize:`28%`,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(cr,{row:c,manifest:e.data??null,runs:t.data,leading:o})}),(0,J.jsx)(ve,{withHandle:!0}),(0,J.jsx)(me,{defaultSize:`44%`,minSize:`220px`,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(Tn,{row:c,manifest:e.data??null})})]}):(0,J.jsx)(_t,{icon:be.flow.icon,title:e.isLoading?`Loading Manifest…`:`Select a flow`,description:e.isLoading?`Reading the derived Manifest.`:`Pick a flow from the tree to inspect its contract.`,leading:o})})})]})})}export{kr as UnitsPage};