@puddle-code/cli 0.5.7 → 0.5.9

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 (68) hide show
  1. package/CHANGELOG.md +6 -16
  2. package/dist/host-control.mjs +3 -1
  3. package/dist/index.js +8 -4
  4. package/dist/public/assets/App-1ly-pQYt.js +15 -0
  5. package/dist/public/assets/{CompilationCommandForm-BkQcFUoa.js → CompilationCommandForm--aglvHpg.js} +1 -1
  6. package/dist/public/assets/Dashboard-CLdNA8WP.js +1 -0
  7. package/dist/public/assets/DraftRecovery-Da7OryXQ.js +1 -0
  8. package/dist/public/assets/{EditorTabClose-fs9t84tp.js → EditorTabClose-CQ73_M1i.js} +1 -1
  9. package/dist/public/assets/{FileCloseScope-BS5YFuzv.js → FileCloseScope-B527gWqW.js} +1 -1
  10. package/dist/public/assets/{FileEditorSettingsMenu-DUpeKKAz.js → FileEditorSettingsMenu-X23c7860.js} +1 -1
  11. package/dist/public/assets/{HuddlePane-CFYGRv0M.js → HuddlePane-BLBAcqwy.js} +1 -1
  12. package/dist/public/assets/{LazyTerminal-DRIHw2iz.js → LazyTerminal-Cu5V6ejk.js} +2 -2
  13. package/dist/public/assets/{NotebookWidget-O9o5XL61.js → NotebookWidget-CXmf3IRw.js} +1 -1
  14. package/dist/public/assets/{PaneEditorBody-gYNeVTlY.js → PaneEditorBody-DdnVw9lV.js} +19 -19
  15. package/dist/public/assets/{PdfViewer-BC-g7S60.js → PdfViewer-CSMNKPo1.js} +1 -1
  16. package/dist/public/assets/{ReadOnlyDiff-DVzIKTvw.js → ReadOnlyDiff-BwUPy5CW.js} +1 -1
  17. package/dist/public/assets/{Ripple-B_d76mLT.js → Ripple-D1mXgP5b.js} +1 -1
  18. package/dist/public/assets/{SettingsDialog-BgmpTW4O.js → SettingsDialog-Dxyi7dhn.js} +1 -1
  19. package/dist/public/assets/{Terminal-_I1S2ZXt.js → Terminal-J5WMTjuY.js} +3 -3
  20. package/dist/public/assets/Workspace-DQDh6TQ7.js +20 -0
  21. package/dist/public/assets/{api-BLc59FAZ.js → api-DhfvolrJ.js} +1 -1
  22. package/dist/public/assets/{auth-tYM1depE.js → auth-BPXeEntX.js} +1 -1
  23. package/dist/public/assets/{colour-picker-cDlTcc8M.js → colour-picker-Dwq4M4eT.js} +1 -1
  24. package/dist/public/assets/{content-state-BO1TLd_9.js → content-state-PQEVgsS8.js} +1 -1
  25. package/dist/public/assets/{context-C632GWyy.js → context-CvPVX4oN.js} +1 -1
  26. package/dist/public/assets/context-menu-CaNn4t1W.js +1 -0
  27. package/dist/public/assets/{drafts-wug-3Dad.js → drafts-CqDYmkTF.js} +1 -1
  28. package/dist/public/assets/{editor-context-CR20pm26.js → editor-context-Bijx3uIG.js} +1 -1
  29. package/dist/public/assets/{editor-links-DFaQQsK-.js → editor-links-Djdkea3i.js} +1 -1
  30. package/dist/public/assets/{editor-sync-CVFWKRes.js → editor-sync-C6zSf7t5.js} +1 -1
  31. package/dist/public/assets/{errors-CV02t999.js → errors-SnGDjajv.js} +1 -1
  32. package/dist/public/assets/{expanding-content-CQQYN3yg.js → expanding-content-CKYjs3iT.js} +1 -1
  33. package/dist/public/assets/{file-editor-settings-DXGv9vrt.js → file-editor-settings-XayiLMfU.js} +1 -1
  34. package/dist/public/assets/{file-links-JFyQw_0a.js → file-links-CEjYCLBn.js} +1 -1
  35. package/dist/public/assets/{forward-link-Kt311XAU.js → forward-link-BT0QTRVB.js} +1 -1
  36. package/dist/public/assets/{hotkeys-ChnvTHTH.js → hotkeys-B417biB9.js} +1 -1
  37. package/dist/public/assets/{index-Cif1X6lX.css → index-CbJEmhvZ.css} +1 -1
  38. package/dist/public/assets/{index-Dp1Lhq2t.js → index-DTGZfxsX.js} +3 -3
  39. package/dist/public/assets/{local-store-3IuC2qMo.js → local-store-DKFKEHML.js} +1 -1
  40. package/dist/public/assets/{notification-delivery-DWIF1cHd.js → notification-delivery-yJcsFWYx.js} +1 -1
  41. package/dist/public/assets/{preferences-sJF-HcJf.js → preferences-BP2Incj1.js} +1 -1
  42. package/dist/public/assets/{profile-icons-CFPzzic1.js → profile-icons-BmQVYS_o.js} +1 -1
  43. package/dist/public/assets/{profile-store-BDrSK8Qs.js → profile-store-BnferXV3.js} +1 -1
  44. package/dist/public/assets/{project-actions-DsWg9uGZ.js → project-actions-DX_j3cML.js} +1 -1
  45. package/dist/public/assets/{project-drag-B0ojbuY7.js → project-drag-DZbLfoWj.js} +1 -1
  46. package/dist/public/assets/{protocol-support-C2shbX3-.js → protocol-support-DIWnYJkt.js} +1 -1
  47. package/dist/public/assets/{queries-essOjrjZ.js → queries-C9DYtGQW.js} +1 -1
  48. package/dist/public/assets/{render-rich-content-DlSv3j1S.js → render-rich-content-Br9yR6jZ.js} +1 -1
  49. package/dist/public/assets/{scroll-restoration-Bt7-rGXy.js → scroll-restoration-C-VTTLs8.js} +1 -1
  50. package/dist/public/assets/{selection-actions-Bis7oo_z.js → selection-actions-DX3EnNRv.js} +1 -1
  51. package/dist/public/assets/{session-display-Bxz8xi3w.js → session-display-DHxCigRa.js} +1 -1
  52. package/dist/public/assets/session-order-BK0vJanT.js +1 -0
  53. package/dist/public/assets/{state-BoqmEoqv.js → state-BegCSQn_.js} +1 -1
  54. package/dist/public/assets/use-arrangement-ready-CMe547fb.js +1 -0
  55. package/dist/public/assets/{use-desktop-state-CS5BxWes.js → use-desktop-state-xeH1nq63.js} +2 -2
  56. package/dist/public/assets/{view-state-store-gvFpSJG_.js → view-state-store-Cr1BaTzj.js} +1 -1
  57. package/dist/public/assets/{window-context-Euxqnh6S.js → window-context-DddmcmmO.js} +2 -2
  58. package/dist/public/assets/{ws-Du8jZ4aQ.js → ws-fD2y3o7n.js} +1 -1
  59. package/dist/public/index.html +5 -5
  60. package/dist/pudl.js +3 -1
  61. package/package.json +1 -1
  62. package/dist/public/assets/App-CYkXXLs2.js +0 -25
  63. package/dist/public/assets/Dashboard-03re-W2v.js +0 -1
  64. package/dist/public/assets/DraftRecovery-tIdw_B9k.js +0 -1
  65. package/dist/public/assets/Workspace-DjRRDhFc.js +0 -20
  66. package/dist/public/assets/dist-CaMNiZN8.js +0 -1
  67. package/dist/public/assets/session-order-DsJCcSqx.js +0 -1
  68. package/dist/public/assets/use-arrangement-ready-CovEzBp-.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{C as r}from"./protocol-support-C2shbX3-.js";import{At as i,Bt as a,Ct as o,Dt as s,Et as c,Ft as l,Gn as u,Ht as d,It as f,Lt as p,Mt as m,Nt as h,Ot as g,Pt as _,Qt as v,Rt as y,St as b,Tt as x,Ut as S,Vt as C,Wt as w,Zt as T,_n as ee,_t as E,an as D,at as O,bt as k,cn as te,ct as A,dn as j,dt as M,en as N,ft as P,gt as F,hn as I,ht as ne,in as re,it as ie,jt as ae,kt as oe,ln as se,lt as ce,mn as le,mt as ue,n as de,on as fe,ot as pe,pn as me,pt as he,r as ge,sn as _e,st as ve,un as ye,vn as be,vt as xe,wt as Se,xt as Ce,yt as we,zt as Te}from"./local-store-3IuC2qMo.js";import{r as Ee}from"./auth-tYM1depE.js";import{n as L}from"./api-BLc59FAZ.js";import{Ft as De,J as Oe,Nt as ke,Rt as Ae,Tt as je,U as Me,b as R,bt as Ne,dt as Pe,et as Fe,ft as Ie,gt as Le,ht as Re,jt as ze,lt as Be,mt as Ve,ot as He,pt as Ue,s as We,st as z,ut as Ge,vt as Ke,y as qe}from"./queries-essOjrjZ.js";import{J as Je,m as Ye,n as Xe,q as Ze}from"./editor-context-CR20pm26.js";import{c as Qe,r as $e,t as et}from"./square-terminal-CrlDquCd.js";import{t as tt}from"./utils-B6KiDbIe.js";import{a as nt,i as B,r as V,s as H,t as U}from"./dialog-DfdBRe6G.js";import{n as W}from"./dist-DMpqv5CF.js";import{t as rt}from"./x-CbfJFzGo.js";import{a as it,d as at,r as ot,u as st}from"./dist-CNoWjXWo.js";import{a as ct,i as lt,n as ut,r as dt,s as ft,t as pt}from"./select-DHaYbZVV.js";import{i as mt,n as ht,t as gt}from"./tooltip-CtT-5xHL.js";import{t as _t}from"./button-BNH9tKwf.js";import{n as G,r as vt}from"./chevron-right-6pjfw_yV.js";import{n as yt,o as K,r as bt,t as xt}from"./colour-picker-cDlTcc8M.js";import{t as q}from"./createLucideIcon-DyMAgLa3.js";import{n as St}from"./profile-icons-CFPzzic1.js";import{n as Ct,t as wt}from"./shield-check-CY69Ons-.js";import{a as Tt,n as Et,r as Dt,t as Ot}from"./switch-DZ2lisDt.js";import{t as kt}from"./code-DRWf9a5s.js";import{a as At,g as jt,p as Mt,s as Nt,t as Pt}from"./ReadOnlyDiff-DVzIKTvw.js";import{S as Ft,_ as It,a as Lt,b as Rt,c as zt,d as Bt,f as Vt,g as Ht,h as Ut,i as Wt,m as Gt,n as Kt,o as qt,p as Jt,r as Yt,t as Xt,u as Zt,v as Qt,x as $t,y as en}from"./state-BoqmEoqv.js";import{n as tn,t as nn}from"./disclosure-oYVpfMYO.js";import{t as rn}from"./rotate-ccw-CNjR2LSi.js";import{t as an}from"./save-BT7q_AMN.js";import{t as on}from"./settings-2-CInoy48z.js";import{i as sn,t as cn}from"./profile-store-BDrSK8Qs.js";import{t as ln}from"./control-tray-jUtkASPS.js";import{n as un,r as dn,t as fn}from"./popover-CNEMQBFf.js";import{r as pn}from"./view-state-store-gvFpSJG_.js";import{r as mn}from"./buffer-logic-D9FvoilV.js";import{a as hn,m as gn,p as _n,s as vn,t as yn,u as bn}from"./buffer-store-OTFEYxTw.js";import{t as xn}from"./zoom-intent-vemBFIak.js";function Sn(e,t){let n=new TextEncoder,r=n.encode(e).length;if(r>128*1024)throw Error(`Prompt exceeds its byte limit`);return e.replace(/\{\{\s*input((?:\.[a-zA-Z0-9_-]+)*)\s*\}\}/g,(e,i)=>{let a=t;for(let e of i.split(`.`).filter(Boolean)){if(!a||typeof a!=`object`||!Object.hasOwn(a,e))throw Error(`Missing prompt input field: `+i);a=a[e]}let o=typeof a==`string`?a:JSON.stringify(a);if(o===void 0)throw Error(`Missing prompt input value`);if(r+=n.encode(o).length-n.encode(e).length,r>128*1024)throw Error(`Prompt exceeds its byte limit`);return o})}function Cn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function wn(e,t,n){let r=e.slice(0);return r[t]=n,r}var Tn=class extends Ae{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,je.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!De(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Cn(e,n).forEach(e=>{e.destroy()}),Cn(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=ke(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Ne(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=wn(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&je.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},J=e(t(),1);function En({queries:e,...t},n){let r=Ke(n),i=Le(),a=Re(),o=J.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Be(e);let t=r.getQueryCache().get(e.queryHash);Ie(e,a,t)}),Ve(a);let[s]=J.useState(()=>new Tn(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;J.useSyncExternalStore(J.useCallback(e=>d?s.subscribe(je.batchCalls(e)):ze,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),J.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Pe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Pe(n,e)?Ge(n,new Ne(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Ue({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var Dn=q(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),On=q(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),kn=q(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),An=q(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),jn=q(`calendar-check`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`m9 16 2 2 4-4`,key:`19s6y9`}]]),Mn=q(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),Nn=q(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Pn=q(`calendar-range`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M17 14h-6`,key:`bkmgh3`}],[`path`,{d:`M13 18H7`,key:`bb0bb7`}],[`path`,{d:`M7 14h.01`,key:`1qa3f1`}],[`path`,{d:`M17 18h.01`,key:`1bdyru`}]]),Fn=q(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),In=q(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ln=q(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),Rn=q(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),zn=q(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Bn=q(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Vn=q(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),Hn=q(`file-input`,[[`path`,{d:`M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-1`,key:`1q9hii`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 15h10`,key:`jfw4w8`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Un=q(`file-output`,[[`path`,{d:`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`,key:`wfxp4w`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 11-3 3`,key:`1dgrs4`}],[`path`,{d:`m5 17-3-3h10`,key:`1mvvaf`}]]),Wn=q(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Gn=q(`focus`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),Kn=q(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),qn=q(`folder-output`,[[`path`,{d:`M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5`,key:`1yk7aj`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m5 10-3 3 3 3`,key:`1r8ie0`}]]),Jn=q(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),Yn=q(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),Xn=q(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Zn=q(`hard-drive`,[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]),Qn=q(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),$n=q(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),er=q(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),tr=q(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),nr=q(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),rr=q(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),ir=q(`merge`,[[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}],[`path`,{d:`M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22`,key:`1hyw0i`}],[`path`,{d:`m20 22-5-5`,key:`1m27yz`}]]),ar=q(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),or=q(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),sr=q(`package-open`,[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]),cr=q(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),lr=q(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),ur=q(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),dr=q(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),fr=q(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),pr=q(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),mr=q(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),hr=q(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),gr=q(`scan`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),_r=q(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),vr=q(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),yr=q(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),br=q(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),xr=q(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),Sr=q(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),Cr=q(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),wr=q(`webhook`,[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]),Tr=q(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Y=n();function X({icon:e,label:t,title:n,className:r,...i}){return(0,Y.jsxs)(gt,{children:[(0,Y.jsx)(mt,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":t,className:tt(ot,r),...i,children:(0,Y.jsx)(e,{className:`size-4`})})}),(0,Y.jsx)(ht,{side:`bottom`,children:n??t})]})}var Z=`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`;function Er({title:e,label:t=e,onClose:n,children:r}){return(0,Y.jsxs)(`aside`,{"aria-label":t,"data-state":`open`,className:`${at} ${st} absolute right-3 top-[var(--huddle-toolbar-bottom,4rem)] bottom-16 z-20 flex w-80 max-w-[calc(100%-1.5rem)] flex-col overflow-hidden text-sm`,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.stopPropagation(),n())},children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-4 py-2`,children:[(0,Y.jsx)(`h2`,{className:`min-w-0 truncate`,children:e}),(0,Y.jsx)(X,{label:`Close ${t.toLowerCase()}`,icon:rt,onClick:n})]}),(0,Y.jsx)(`div`,{className:`no-scrollbar min-h-0 overflow-y-auto overscroll-contain px-3 pb-3`,children:r})]})}function Q({id:e,label:t,value:n,onValueChange:r,options:i,placeholder:a,disabled:o}){return(0,Y.jsxs)(pt,{value:i.some(e=>e.value===n)?`value:${n}`:``,onValueChange:e=>r(e.slice(6)),disabled:o,children:[(0,Y.jsx)(lt,{"data-value":n,id:e,"aria-label":t,className:`min-w-0`,children:(0,Y.jsx)(ct,{placeholder:a})}),(0,Y.jsx)(ut,{children:i.map(e=>(0,Y.jsx)(dt,{"data-value":e.value,value:`value:${e.value}`,disabled:e.disabled,children:e.label},e.value))})]})}function Dr(e,t){let n=new Set(e.map(e=>e.id));if(!n.has(t))return t;for(let e=2;;e++)if(!n.has(`${t}-${e}`))return`${t}-${e}`}function Or(e,t,n,r){let i=te.parse({id:Dr(e.nodes,n),source:t,...r?{appearance:r}:{}});return{...e,nodes:[...e.nodes,i]}}function kr(e,t){let{triggerAdmission:n,...r}=e.execution,i={...n};return delete i[t],{...e,nodes:e.nodes.filter(e=>e.id!==t),edges:e.edges.filter(e=>e.from.node!==t&&e.to.node!==t),execution:{...r,...Object.keys(i).length?{triggerAdmission:i}:{}}}}function Ar(e,t,n){let r=e.components[t.node]?.outputs[t.port],i=e.components[n.node]?.inputs[n.port];if(!e.definition.nodes.some(e=>e.id===t.node)||!r)return`The output no longer exists.`;if(!e.definition.nodes.some(e=>e.id===n.node)||!i)return`The input no longer exists.`;if(e.definition.edges.some(e=>e.from.node===t.node&&e.from.port===t.port&&e.to.node===n.node&&e.to.port===n.port))return`This connection already exists.`;if(A(r.schema,i.schema)===`incompatible`)return`These ports have incompatible types.`}function jr(e,t,n){let r=Ar(e,t,n);if(r)throw Error(r);return{...e.definition,edges:[...e.definition.edges,{id:Dr(e.definition.edges,`connection`),from:t,to:n}]}}function Mr(e,t=[]){return!e||t.length>16?[]:e.type===`boolean`&&t.length?[t]:Object.entries(e.properties??{}).flatMap(([e,n])=>Mr(n,[...t,e]))}function Nr({edge:e,schema:t,edit:n}){let r=(0,J.useId)(),i=Mr(t),[a,o]=(0,J.useState)(null),s=t=>n(n=>({...n,edges:n.edges.map(n=>{if(n.id!==e.id)return n;let{feedback:r,...i}=n;return t?{...i,feedback:t}:i})}));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 text-xs`,children:[(0,Y.jsxs)(`label`,{htmlFor:`${r}-enabled`,className:`flex cursor-pointer items-center gap-2`,children:[(0,Y.jsx)(Ot,{id:`${r}-enabled`,checked:!!e.feedback,disabled:!e.feedback&&!i.length,onCheckedChange:e=>s(e?{maxRounds:5,while:{path:i[0],equals:!1}}:void 0)}),`Bounded feedback`]}),e.feedback&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{htmlFor:`${r}-condition`,children:`Continue while`}),(0,Y.jsx)(Q,{id:`${r}-condition`,value:JSON.stringify(e.feedback.while.path),onValueChange:t=>s({...e.feedback,while:{...e.feedback.while,path:JSON.parse(t)}}),options:[...i.some(t=>JSON.stringify(t)===JSON.stringify(e.feedback.while.path))?[]:[{value:JSON.stringify(e.feedback.while.path),label:`${e.feedback.while.path.join(`.`)} · unavailable`}],...i.map(e=>({value:JSON.stringify(e),label:e.join(`.`)}))]}),(0,Y.jsx)(Q,{label:`Feedback condition value`,value:String(e.feedback.while.equals),onValueChange:t=>s({...e.feedback,while:{...e.feedback.while,equals:t===`true`}}),options:[{value:`false`,label:`False`},{value:`true`,label:`True`}]}),(0,Y.jsx)(K,{htmlFor:`${r}-rounds`,children:`Maximum rounds`}),(0,Y.jsx)(G,{id:`${r}-rounds`,type:`number`,min:1,max:1e3,value:a??String(e.feedback.maxRounds),onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:()=>{let t=Number(a);a!==null&&Number.isInteger(t)&&t>=1&&t<=1e3&&s({...e.feedback,maxRounds:t}),o(null)}})]})]})}var $=`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`;function Pr({graph:e,edit:t}){let n=(0,J.useId)(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),s=t=>e.definition.nodes.flatMap(n=>Object.keys(e.components[n.id]?.[t]??{}).map(e=>({node:n.id,port:e}))),c=s(`outputs`),l=s(`inputs`),u=c.find(e=>JSON.stringify(e)===r),d=l.find(e=>JSON.stringify(e)===a);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-label":`Edit connections`,children:[(0,Y.jsx)(K,{htmlFor:`${n}-output`,children:`Output`}),(0,Y.jsx)(Q,{id:`${n}-output`,value:u?r:``,onValueChange:i,placeholder:`Choose output`,options:c.map(e=>({value:JSON.stringify(e),label:`${e.node}.${e.port}`}))}),(0,Y.jsx)(K,{htmlFor:`${n}-input`,children:`Input`}),(0,Y.jsx)(Q,{id:`${n}-input`,value:d?a:``,onValueChange:o,placeholder:`Choose input`,options:l.map(e=>({value:JSON.stringify(e),label:`${e.node}.${e.port}`}))}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!u||!d,onClick:()=>{u&&d&&t(t=>jr({...e,definition:t},u,d))},children:`Connect`}),e.definition.edges.map(n=>(0,Y.jsxs)(`div`,{className:`${Z} flex flex-col gap-2 text-xs`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[n.from.node,`.`,n.from.port,` → `,n.to.node,`.`,n.to.port]}),(0,Y.jsx)(Nr,{edge:n,schema:e.components[n.from.node]?.outputs[n.from.port]?.schema,edit:t}),(0,Y.jsx)(`button`,{type:`button`,className:$,"aria-label":`Disconnect ${n.id}`,onClick:()=>t(e=>({...e,edges:e.edges.filter(e=>e.id!==n.id)})),children:`Disconnect`})]},n.id))]})}function Fr({value:e,fallback:t,disabled:n,rename:r}){let i=(0,J.useId)(),[a,o]=(0,J.useState)(null);return(0,Y.jsxs)(`form`,{className:`${Z} flex flex-col gap-2`,onSubmit:t=>{t.preventDefault(),n||(r(a??e),o(null))},children:[(0,Y.jsx)(K,{htmlFor:i,children:`Node name`}),(0,Y.jsx)(G,{id:i,value:a??e,placeholder:t,maxLength:200,disabled:n,onChange:e=>o(e.target.value)}),(0,Y.jsx)(`button`,{type:`submit`,className:$,disabled:n||a===null,children:`Rename node`}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Renaming requires a host supporting node labels.`})]})}var Ir=e=>({x:e.reduce((e,t)=>e+t.x,0)/e.length,y:e.reduce((e,t)=>e+t.y,0)/e.length}),Lr=e=>e.length<2?1:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y);function Rr(e,t,n){let r=(0,J.useRef)(new Map),i=(0,J.useRef)(!1),a=(0,J.useRef)(!1),o=(0,J.useRef)({x:0,y:0}),s=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let n=e.current,i=xn(n.ownerDocument.defaultView);s.current=i;let a=e=>{e.preventDefault();let a=i.wheel(e);if(a===`ignore`||r.current.size>1)return;let o=e.deltaMode===1?16:e.deltaMode===2?n.clientHeight:1;if(a===`zoom`){let r=n.getBoundingClientRect(),i={x:e.clientX-r.left,y:e.clientY-r.top};t.current?.gesture(Math.exp(-e.deltaY*o*.005),i,i)}else t.current?.gesture(1,{x:0,y:0},{x:-(e.shiftKey&&!e.deltaX?e.deltaY:e.deltaX)*o,y:e.shiftKey&&!e.deltaX?0:-e.deltaY*o})};return n.addEventListener(`wheel`,a,{passive:!1}),()=>{n.removeEventListener(`wheel`,a),i.dispose(),s.current=null}},[e,t]);let c=t=>{let n=e.current.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},l=e=>{r.current.delete(e.pointerId),a.current&&e.stopPropagation(),r.current.size||(i.current=!1,e.currentTarget.style.cursor=``)};return{onPointerDownCapture(e){if(![0,1].includes(e.button))return;r.current.size||(a.current=!1),r.current.set(e.pointerId,c(e));let t=!e.target.closest(`button, [data-huddle-node]`);r.current.size>=2&&(a.current||(o.current=Ir([...r.current.values()])),a.current=!0,n()),(t||a.current||e.button===1)&&(e.preventDefault(),e.stopPropagation(),i.current=!0,e.currentTarget.style.cursor=`grabbing`,e.currentTarget.setPointerCapture(e.pointerId),t&&e.currentTarget.focus({preventScroll:!0}))},onPointerMoveCapture(e){if(!r.current.has(e.pointerId))return;let n=[...r.current.values()];if(r.current.set(e.pointerId,c(e)),!i.current)return;e.preventDefault(),e.stopPropagation();let l=[...r.current.values()];a.current?(s.current?.suppressPan(),l.length>=2&&t.current?.gesture(Lr(l)/Math.max(1,Lr(n)),o.current,o.current)):!e.metaKey&&!e.ctrlKey&&!s.current?.panBlocked()&&t.current?.gesture(1,Ir(n),Ir(l))},onPointerUpCapture:l,onPointerCancelCapture:l,onLostPointerCaptureCapture:l,onClickCapture(e){a.current&&(e.preventDefault(),e.stopPropagation())},onKeyDown(e){if(e.target!==e.currentTarget)return;let n={ArrowLeft:[64,0],ArrowRight:[-64,0],ArrowUp:[0,64],ArrowDown:[0,-64]}[e.key];n&&(e.preventDefault(),t.current?.gesture(1,{x:0,y:0},{x:n[0],y:n[1]}))}}}function zr({locked:e,canUndo:t,canRedo:n,undo:r,redo:i,selected:a,fit:o,zoom:s,setZoom:c}){return(0,Y.jsx)(`div`,{className:`absolute bottom-3 left-3 z-10 max-w-[calc(100%-1.5rem)]`,children:(0,Y.jsxs)(ln,{label:`Graph navigation`,variant:`island`,className:`max-w-full flex-wrap`,children:[(0,Y.jsx)(X,{label:`Undo move`,icon:Jt,onClick:r,disabled:e||!t}),(0,Y.jsx)(X,{label:`Redo move`,icon:pr,onClick:i,disabled:e||!n}),(0,Y.jsx)(X,{label:`Fit graph`,icon:gr,onClick:()=>o(!1)}),(0,Y.jsx)(X,{label:`Fit selected`,icon:Gn,disabled:!a,onClick:()=>o(!0)}),(0,Y.jsx)(X,{label:`Zoom out`,icon:Ut,onClick:()=>c(Math.max(.001,s/1.25))}),(0,Y.jsxs)(`button`,{type:`button`,className:`px-2 text-xs tabular-nums`,"aria-label":`Reset zoom`,onClick:()=>c(1),children:[Math.round(s*100),`%`]}),(0,Y.jsx)(X,{label:`Zoom in`,icon:tn,onClick:()=>c(Math.min(2,s*1.25))})]})})}function Br(e){return{x:e%3*320,y:Math.floor(e/3)*220}}function Vr(e,t,n){let r=e=>Math.min(1e6,Math.max(-1e6,Math.round(e)));return{x:r(e.x+t),y:r(e.y+n)}}function Hr(e,t){return!!t&&e.x<=t.right&&e.right>=t.x&&e.y<=t.bottom&&e.bottom>=t.y}function Ur(e,t,n){return{...e,right:e.x+240,bottom:e.y+90+24*Math.max(t,n)}}function Wr(e,t){return{x:Math.min(e.x,t.x-80,t.x),right:Math.max(e.x,e.x+80,t.x),y:Math.min(e.y,t.y),bottom:Math.max(e.y,t.y)}}function Gr(e,t){return!e.clientWidth||!e.clientHeight?null:{x:(e.scrollLeft-200)/t,y:(e.scrollTop-200)/t,right:(e.scrollLeft+e.clientWidth+200)/t,bottom:(e.scrollTop+e.clientHeight+200)/t}}function Kr(e,t){return`M ${e.x} ${e.y} C ${e.x+80} ${e.y}, ${t.x-80} ${t.y}, ${t.x} ${t.y}`}function qr({edges:e,width:t,height:n,socket:r,selected:i,select:a,locked:o,disconnect:s,wire:c,visible:l,focused:u}){let d=c.pending&&r(c.pending.from,`outputs`);return(0,Y.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 text-fg-muted`,width:t,height:n,children:[e.map(e=>{let t=r(e.from,`outputs`),n=r(e.to,`inputs`);if(!t||!n||e.id!==i&&e.id!==u&&!Hr(Wr(t,n),l))return null;let d=Kr(t,n);return(0,Y.jsxs)(`g`,{"data-huddle-edge":e.id,children:[(0,Y.jsx)(`path`,{d,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,"aria-hidden":!0,className:i===e.id?`text-accent`:void 0,strokeDasharray:e.feedback?`5 4`:void 0}),(0,Y.jsx)(`path`,{d,fill:`none`,stroke:`transparent`,strokeWidth:14,vectorEffect:`non-scaling-stroke`,className:`pointer-events-auto cursor-pointer hover:stroke-accent/30 focus-visible:stroke-accent/30 focus-visible:outline-none`,role:`button`,tabIndex:0,"aria-pressed":i===e.id,"aria-label":`Connection ${e.from.node}.${e.from.port} to ${e.to.node}.${e.to.port}`,onPointerDown:e=>e.stopPropagation(),onClick:()=>{c.pending&&c.cancel(),a(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id)),(t.key===`Delete`||t.key===`Backspace`)&&!o&&(t.preventDefault(),s(e.id))},children:(0,Y.jsx)(`title`,{children:`Select connection; Delete disconnects`})})]},e.id)}),d&&c.pending?.point&&(0,Y.jsx)(`path`,{d:Kr(d,c.pending.point),fill:`none`,stroke:`currentColor`,"aria-hidden":!0,strokeWidth:1.5,strokeDasharray:`5 4`,className:`text-accent`})]})}var Jr=[{name:`play`,Icon:Je},{name:`clock`,Icon:zn},{name:`calendar-days`,Icon:Nn},{name:`calendar-clock`,Icon:Mn},{name:`calendar-range`,Icon:Pn},{name:`folder-tree`,Icon:$t},{name:`git-branch`,Icon:Rt},{name:`activity`,Icon:Dn},{name:`message-square`,Icon:ar},{name:`check-check`,Icon:Fn},{name:`rotate-ccw`,Icon:rn},{name:`plus`,Icon:tn},{name:`file-output`,Icon:Un},{name:`code`,Icon:kt},{name:`type`,Icon:Sr},{name:`git-fork`,Icon:Xn},{name:`merge`,Icon:ir},{name:`combine`,Icon:jt},{name:`radio`,Icon:fr},{name:`braces`,Icon:kn},{name:`file-code`,Icon:Ft},{name:`workflow`,Icon:Tr},{name:`network`,Icon:or},{name:`route`,Icon:hr},{name:`split`,Icon:vr},{name:`filter`,Icon:Jn},{name:`repeat`,Icon:mr},{name:`shuffle`,Icon:_r},{name:`list-checks`,Icon:nr},{name:`check`,Icon:ft},{name:`square`,Icon:Ze},{name:`pause`,Icon:ur},{name:`timer`,Icon:xr},{name:`hourglass`,Icon:$n},{name:`calendar-check`,Icon:jn},{name:`clipboard-check`,Icon:Ln},{name:`clipboard-list`,Icon:Rn},{name:`database`,Icon:Bn},{name:`table`,Icon:yr},{name:`layers`,Icon:tr},{name:`boxes`,Icon:On},{name:`package`,Icon:cr},{name:`package-open`,Icon:sr},{name:`file-input`,Icon:Hn},{name:`file-json`,Icon:Vn},{name:`file-text`,Icon:Wn},{name:`folder-input`,Icon:Kn},{name:`folder-output`,Icon:qn},{name:`hard-drive`,Icon:Zn},{name:`terminal`,Icon:br},{name:`square-terminal`,Icon:et},{name:`webhook`,Icon:wr},{name:`plug`,Icon:dr},{name:`cable`,Icon:An},{name:`link`,Icon:Qt},{name:`unlink`,Icon:Cr},{name:`send`,Icon:Gt},{name:`inbox`,Icon:er},{name:`bell`,Icon:Ct},{name:`mail`,Icon:rr},{name:`shield-check`,Icon:wt},{name:`lock`,Icon:Ht},{name:`settings2`,Icon:on}],Yr={...St,...Object.fromEntries(Jr.map(({name:e,Icon:t})=>[e,t]))};function Xr({value:e,onSelect:t}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,"aria-label":`Node icons`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Default node icon`,className:ot,onClick:()=>t(null),children:(0,Y.jsx)(Bt,{className:`size-4`})}),Jr.map(({name:n,Icon:r})=>(0,Y.jsx)(`button`,{type:`button`,title:n,"aria-label":n,"aria-pressed":e===n,className:ot,onClick:()=>t(n),children:(0,Y.jsx)(r,{className:`size-4`})},n))]})}function Zr({title:e,label:t,icon:n,selected:r,canRename:i,locked:a,rename:o,changeIcon:s,onKeyDown:c}){let[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(!1),p=(0,J.useRef)(!1),m=(0,J.useRef)(null),h=(0,J.useRef)(!1),g=(0,J.useRef)(null),_=l!==null;(0,J.useLayoutEffect)(()=>{if(_){let e=m.current?.querySelector(`input`);e?.focus({preventScroll:!0}),e?.select()}else h.current&&g.current?.focus({preventScroll:!0});h.current=_},[_]);let v=()=>{p.current&&(p.current=!1,l!==null&&l.trim()!==e&&o(l),u(null))},y=n&&Yr[n]||Bt;return(0,Y.jsxs)(`div`,{ref:m,className:`mb-1 flex h-8 items-center gap-2`,"data-node-identity":!0,children:[(0,Y.jsxs)(fn,{open:d,onOpenChange:f,children:[(0,Y.jsx)(dn,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Change icon for ${e}`,disabled:a,className:`flex size-7 shrink-0 cursor-grab items-center justify-center rounded-md hover:bg-explorer-hover disabled:opacity-50`,children:(0,Y.jsx)(y,{className:`size-4`})})}),(0,Y.jsx)(un,{className:`w-80`,onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsx)(Xr,{value:n,onSelect:e=>{s(e),f(!1)}})})]}),_?(0,Y.jsx)(G,{"aria-label":`Node name`,"data-node-control":!0,maxLength:200,className:`h-8 min-w-0 flex-1`,value:l,onChange:e=>u(e.target.value),onBlur:v,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),v()),e.key===`Escape`&&(e.preventDefault(),p.current=!1,u(null))}}):(0,Y.jsx)(`button`,{ref:g,type:`button`,"data-node-name":!0,"aria-label":t,"aria-pressed":r,title:`Rename node`,onKeyDown:c,className:`flex h-8 min-w-0 flex-1 cursor-grab touch-none items-center rounded-md text-left text-sm transition-colors hover:bg-explorer-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>{if(!i){W.warning(`Node renaming requires a supporting host and an editable layout.`);return}p.current=!0,u(e)},children:(0,Y.jsx)(`span`,{className:`truncate`,children:e})})]})}function Qr({node:e,title:t,rename:n,changeIcon:r,canRename:i,contract:a,position:o,shown:s,selected:c,locked:l,version:u,drag:d,wire:f,onSelect:p,move:m,undo:h,redo:g,onDelete:_}){let v=Object.keys(a?.inputs??{}),y=Object.keys(a?.outputs??{}),b=e.appearance??a?.appearance,x=!!b?.colour,S=`flex h-6 max-w-full items-center gap-2 rounded-sm text-xs hover:bg-explorer-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;return(0,Y.jsxs)(`div`,{"data-huddle-node":e.id,className:tt(`island-outline absolute w-60 touch-none select-none rounded-xl p-3`,!l&&(d.preview?.id===e.id?`cursor-grabbing`:`cursor-grab`),c?`bg-elevated text-accent`:`bg-surface text-fg`,yt(b?.colour)),style:{left:s.x,top:s.y,...bt(b?.colour),...x?{backgroundColor:`color-mix(in srgb, currentColor ${c?14:7}%, var(--bg-surface))`,outlineColor:`color-mix(in srgb, currentColor 35%, var(--border))`}:{}},...d.handlers(e.id,o),onClickCapture:e=>{d.suppressClick()&&(e.preventDefault(),e.stopPropagation())},onClick:t=>{t.currentTarget.contains(t.target)&&!t.target.closest(`button, input`)&&p(e.id)},children:[(0,Y.jsx)(Zr,{title:t,label:[t,...v,...y,...!v.length&&!y.length?[a?.category??`Unresolved component`]:[]].join(` `),icon:b?.icon,selected:c,canRename:i,locked:l,rename:n,changeIcon:r,onKeyDown:t=>{if(t.key===`Escape`){d.cancel();return}if((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()===`z`){t.preventDefault(),t.shiftKey?g():h();return}if(t.key===`Delete`||t.key===`Backspace`){t.preventDefault(),_(e.id);return}let n={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[t.key];if(!n||l)return;t.preventDefault(),p(e.id);let r=t.shiftKey?50:10;m(e.id,Vr(o,n[0]*r,n[1]*r),u)}}),(0,Y.jsxs)(`div`,{className:tt(`flex justify-between gap-3`,x?`text-current`:`text-fg-muted`),children:[(0,Y.jsx)(`div`,{className:`min-w-0`,children:v.map(t=>{let n={node:e.id,port:t},r=f.problem(n);return(0,Y.jsxs)(`button`,{type:`button`,"data-huddle-socket":!0,"aria-label":`Input ${e.id}.${t}`,title:r??`Input ${e.id}.${t}${a?.inputs[t]?.scope===`execution`?` · retained for this execution`:``}`,"aria-description":a?.inputs[t]?.scope===`execution`?`Retained for this execution, including feedback rounds`:void 0,...f.input(n),className:tt(S,f.pending&&!r&&`text-accent`,f.pending&&r&&`opacity-50`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-current`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t})]},t)})}),(0,Y.jsx)(`div`,{className:`min-w-0`,children:y.map(t=>(0,Y.jsxs)(`button`,{type:`button`,"data-huddle-socket":!0,"aria-label":`Output ${e.id}.${t}`,...f.output({node:e.id,port:t}),className:tt(S,`ml-auto touch-none justify-end disabled:opacity-50`),children:[(0,Y.jsx)(`span`,{className:`truncate`,children:t}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-current`})]},t))})]}),!v.length&&!y.length&&(0,Y.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a?.category??`Unresolved component`})]})}function $r({graph:e,version:t,locked:n,canvas:r,connect:i}){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(``),l=(0,J.useRef)(null),u=(0,J.useRef)(!1),d=!n&&a?.version===t?a:null,f=()=>{o(null),l.current=null},p=t=>{if(!d){f();return}let n=Ar(e,d.from,t);if(n){o({...d,point:void 0}),c(n);return}if(!i(d.from,t,d.version)){f(),c(`Connection was not added. Choose the output again.`);return}c(`Connected ${d.from.node}.${d.from.port} to ${t.node}.${t.port}.`),f()},m=e=>{let t=r.current;if(!t)return;let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)*t.offsetWidth/n.width,y:(e.clientY-n.top)*t.offsetHeight/n.height}};return{pending:d,message:a&&!d?`Connection cancelled because the graph changed.`:s,cancel:()=>{f(),u.current=!0,c(`Connection cancelled.`)},input(e){return{"data-huddle-input-node":e.node,"data-huddle-input-port":e.port,"aria-disabled":n,onClick(){n||p(e)}}},output(e){return{"aria-pressed":d?.from.node===e.node&&d.from.port===e.port,disabled:n,onClick(n){if(u.current&&n.detail!==0){u.current=!1;return}o({from:e,version:t}),c(`Choose an input for ${e.node}.${e.port}. Escape cancels.`)},onPointerDown(r){n||r.button!==0||!r.isPrimary||(r.stopPropagation(),u.current=!1,r.currentTarget.setPointerCapture(r.pointerId),l.current={id:r.pointerId,x:r.clientX,y:r.clientY,moved:!1},o({from:e,version:t}),c(`Choose an input for ${e.node}.${e.port}. Escape cancels.`))},onPointerMove(e){let t=l.current;if(!(!t||t.id!==e.pointerId)){if(!d){f(),u.current=!0;return}!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<4||(t.moved=!0,o({...d,point:m(e)}))}},onPointerUp(e){let t=l.current;if(!(!t||t.id!==e.pointerId)){if(l.current=null,t.moved){u.current=!0;let t=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-huddle-input-node]`);t&&r.current?.contains(t)?p({node:t.dataset.huddleInputNode,port:t.dataset.huddleInputPort}):(f(),c(`Connection cancelled. Drop on an input socket.`))}e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}},onPointerCancel(){f(),u.current=!0,c(`Connection cancelled.`)},onLostPointerCapture(){l.current&&(f(),u.current=!0)}}},problem(t){return d?Ar(e,d.from,t):void 0}}}function ei({viewport:e,zoom:t,version:n,locked:r,move:i,select:a}){let o=(0,J.useRef)(!1),s=(0,J.useRef)(null),[c,l]=(0,J.useState)(null),u=(t,n)=>Vr(t.origin,(n.clientX-t.x+(e.current?.scrollLeft??0)-t.scrollX)/t.zoom,(n.clientY-t.y+(e.current?.scrollTop??0)-t.scrollY)/t.zoom),d=()=>{s.current=null,l(null)};return{preview:c,cancel:d,suppressClick:()=>{let e=o.current;return o.current=!1,e},handlers:(c,f)=>({onPointerDown(i){if(i.button!==0||!i.isPrimary||r||!i.currentTarget.contains(i.target)||i.target.closest(`[data-huddle-socket], [data-node-control]`))return;i.stopPropagation(),o.current=!1,(i.currentTarget.querySelector(`[data-node-name]`)??i.currentTarget).focus({preventScroll:!0});let l=i.target.closest(`button`)??i.currentTarget;l.setPointerCapture(i.pointerId),s.current={captured:l,id:c,origin:f,pointer:i.pointerId,x:i.clientX,y:i.clientY,scrollX:e.current?.scrollLeft??0,scrollY:e.current?.scrollTop??0,zoom:t,version:n,moved:!1},i.target.closest(`[data-node-identity]`)||a(c)},onPointerMove(e){let t=s.current;if(!(!t||t.pointer!==e.pointerId)){if(r||n!==t.version){d();return}!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<4||(t.moved=!0,o.current=!0,l({id:c,position:u(t,e)}))}},onPointerUp(e){let t=s.current;!t||t.pointer!==e.pointerId||(t.moved&&!r&&i(c,u(t,e),t.version),d(),t.captured.hasPointerCapture(e.pointerId)&&t.captured.releasePointerCapture(e.pointerId))},onPointerCancel:d,onLostPointerCapture:d})}}function ti(e,t,n,r,i){let a=n??{x:t.left,y:t.top,zoom:1},o={left:e.scrollLeft,top:e.scrollTop},s=``,c=()=>[e.clientWidth,e.clientHeight,e.scrollWidth,e.scrollHeight].join(`:`),l=()=>e.clientWidth>0&&e.clientHeight>0,u=()=>{l()&&(s=c(),e.scrollLeft=(a.x-t.left)*a.zoom,e.scrollTop=(a.y-t.top)*a.zoom,o={left:e.scrollLeft,top:e.scrollTop})},d=()=>{if(l()){if(s!==c()){u();return}e.scrollLeft===o.left&&e.scrollTop===o.top||(a={zoom:a.zoom,x:e.scrollLeft/a.zoom+t.left,y:e.scrollTop/a.zoom+t.top},o={left:e.scrollLeft,top:e.scrollTop},r(a))}},f=e=>{a=e,r(a),i(a.zoom),u()};u(),e.addEventListener(`scroll`,d,{passive:!0});let p=new ResizeObserver(u);return p.observe(e),{geometry:e=>{t=e,u()},zoom:e=>{Number.isFinite(e)&&(d(),f({...a,zoom:Math.min(2,Math.max(.001,e))}))},gesture:(e,t,n)=>{if(!Number.isFinite(e)||e<=0)return;d();let r=Math.min(2,Math.max(.001,a.zoom*e));f({zoom:r,x:a.x+t.x/a.zoom-n.x/r,y:a.y+t.y/a.zoom-n.y/r})},fit:t=>{if(!l())return;let n=Math.min(2,Math.max(.001,Math.min((e.clientWidth-64)/Math.max(1,t.right-t.x),(e.clientHeight-64)/Math.max(1,t.bottom-t.y))));f({zoom:n,x:t.x-(e.clientWidth/n-(t.right-t.x))/2,y:t.y-(e.clientHeight/n-(t.bottom-t.y))/2})},dispose:()=>{d(),p.disconnect(),e.removeEventListener(`scroll`,d)}}}function ni(e,t,{left:n,top:r,width:i,height:a}){let[o,s]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{let n=e.current,r,i=()=>{r=void 0;let e=Gr(n,t);s(t=>t?.x===e?.x&&t?.y===e?.y&&t?.right===e?.right&&t?.bottom===e?.bottom?t:e)},a=()=>{r===void 0&&(r=requestAnimationFrame(i))};i(),n.addEventListener(`scroll`,a,{passive:!0});let o=new ResizeObserver(a);return o.observe(n),()=>{n.removeEventListener(`scroll`,a),o.disconnect(),r!==void 0&&cancelAnimationFrame(r)}},[e,t,n,r,i,a]),o}function ri(){let[e,t]=(0,J.useState)({}),n=(e,n)=>{let r=n instanceof Element&&e.contains(n)?n:null,i=r?.closest(`[data-huddle-node]`)?.getAttribute(`data-huddle-node`)??void 0,a=r?.closest(`[data-huddle-edge]`)?.getAttribute(`data-huddle-edge`)??void 0;t(e=>e.node===i&&e.edge===a?e:{node:i,edge:a})};return{focused:e,handlers:{onFocusCapture:e=>n(e.currentTarget,e.target),onBlurCapture:e=>n(e.currentTarget,e.relatedTarget)}}}function ii({document:e,selected:t,onSelect:n,rename:r,changeIcon:i,canRename:a,move:o,version:s,locked:c,undo:l,redo:u,canUndo:d,canRedo:f,onDelete:p,connect:m,graphVersion:h,graphLocked:g,disconnect:_,camera:v,rememberCamera:y,selectedEdge:b,setSelectedEdge:x}){let[S]=(0,J.useState)(v),[C,w]=(0,J.useState)(v?.zoom??1),T=(0,J.useRef)(null),ee=(0,J.useRef)(null),E=ri(),D=$r({graph:e,version:h,locked:g,canvas:ee,connect:m}),O=(0,J.useRef)(null),k=ei({viewport:O,zoom:C,version:s,locked:c,move:o,select:n}),te=Rr(O,T,()=>{k.cancel(),D.pending&&D.cancel()}),A=e.definition.nodes.map((t,n)=>{let r=e.components[t.id];return{node:t,contract:r,position:e.layout?.nodes[t.id]??Br(n),inputs:Object.keys(r?.inputs??{}),outputs:Object.keys(r?.outputs??{})}}),j=1600/C,M={x:Math.min(0,...A.map(({position:e})=>e.x))-32,y:Math.min(0,...A.map(({position:e})=>e.y))-32},N=M.x-j,P=M.y-j,F=Math.max(640,...A.map(({position:e})=>e.x-N+272+j)),I=Math.max(400,...A.map(({position:e,inputs:t,outputs:n})=>e.y-P+j+90+Math.max(t.length,n.length)*24)),[ne]=(0,J.useState)({left:N,top:P,width:F,height:I});(0,J.useLayoutEffect)(()=>{let e=ti(O.current,ne,S??{x:ne.left+1600,y:ne.top+1600,zoom:1},y,w);return T.current=e,()=>{e.dispose(),T.current=null}},[S,ne,y]),(0,J.useLayoutEffect)(()=>{T.current?.geometry({left:N,top:P,width:F,height:I})},[N,P,F,I,C]);let re=ni(O,C,{left:N,top:P,width:F,height:I}),ie=new Map(A.map(e=>[e.node.id,e])),ae=(e,t)=>k.preview?.id===e?k.preview.position:t;return(0,Y.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,onKeyDown:e=>{e.key===`Escape`&&D.cancel()},children:[(0,Y.jsx)(zr,{locked:c,canUndo:d,canRedo:f,undo:l,redo:u,selected:t,fit:e=>{let n=O.current,r=A.filter(n=>!e||n.node.id===t);if(!n||!r.length)return;let i=Math.min(...r.map(e=>e.position.x)),a=Math.min(...r.map(e=>e.position.y)),o=Math.max(...r.map(e=>e.position.x+240)),s=Math.max(...r.map(e=>e.position.y+90+24*Math.max(e.inputs.length,e.outputs.length)));T.current?.fit({x:i,y:a,right:o,bottom:s})},zoom:C,setZoom:e=>T.current?.zoom(e)}),(b||D.message||D.pending)&&(0,Y.jsxs)(`div`,{className:`island-outline absolute left-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center gap-2 rounded-[var(--ui-surface-radius)] bg-tray px-3 py-2 text-xs text-fg-muted`,children:[e.definition.edges.some(e=>e.id===b)&&(0,Y.jsx)(`button`,{type:`button`,disabled:g,className:`rounded px-2 hover:bg-elevated disabled:opacity-50`,onClick:()=>{_(b),x(null)},children:`Disconnect selected`}),(0,Y.jsx)(`span`,{role:`status`,children:D.message}),D.pending&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded px-2 hover:bg-elevated`,onClick:D.cancel,children:`Cancel connection`})]}),(0,Y.jsx)(`div`,{ref:O,className:`no-scrollbar min-h-0 flex-1 cursor-grab overflow-hidden touch-none overscroll-none [overflow-anchor:none]`,"aria-label":`Huddle graph`,"aria-description":`Only nearby nodes and connections are drawn. Use Node list to browse all nodes, then Fit selected to reveal one.`,tabIndex:0,...te,children:(0,Y.jsx)(`div`,{style:{width:F*C,height:I*C},children:(0,Y.jsxs)(`div`,{ref:ee,...E.handlers,className:`relative origin-top-left`,style:{width:F,height:I,transform:`scale(${C})`},children:[(0,Y.jsx)(qr,{edges:e.definition.edges,width:F,height:I,wire:D,visible:re,focused:E.focused.edge,selected:b,select:x,locked:g,disconnect:e=>{_(e),x(null)},socket:(e,t)=>{let n=ie.get(e.node);if(!n)return;let r=ae(e.node,n.position);return{x:r.x-N+(t===`outputs`?225:15),y:r.y-P+60+Math.max(0,n[t].indexOf(e.port))*24}}}),A.map(({node:d,contract:f,position:m,inputs:h,outputs:g})=>{let _=ae(d.id,m),v={x:_.x-N,y:_.y-P};return d.id!==t&&d.id!==E.focused.node&&d.id!==k.preview?.id&&d.id!==D.pending?.from.node&&!Hr(Ur(v,h.length,g.length),re)?null:(0,Y.jsx)(Qr,{node:d,contract:f,position:m,locked:c,version:s,drag:k,wire:D,onSelect:n,move:o,undo:l,redo:u,onDelete:p,title:e.layout?.labels?.[d.id]??f?.title??d.id,rename:e=>r(d.id,e),changeIcon:e=>i(d.id,e),canRename:a,selected:t===d.id,shown:v},d.id)})]})})})]})}function ai(e,t){if(e instanceof u){let n=e.issues[0];if(!n)return t;if(n.path.includes(`colour`))return`Choose a preset node colour or a six-digit hex colour.`;let r=n.path.map(String).join(`.`);return`${r?`${r}: `:``}${n.message}`}return e instanceof Error?e.message:t}function oi(e,t,n){let r=Nt(e,t,null,void 0,{focused:n,live:!0}),i=yn(e,t);return(0,J.useEffect)(()=>(bn(i),()=>vn(i)),[i]),{path:t,buffer:r,text:(0,J.useSyncExternalStore)((0,J.useCallback)(e=>_n(i,e),[i]),()=>r.model?.getValue()??``),locked:r.status!==`ready`||Ye(r.conflict)}}function si(e,t){let n=[...new Set(t?.nodes.flatMap(e=>e.source.kind===`local`?[e.source.manifest]:[])??[])];return En({queries:n.map(t=>{let n=`.puddle/huddle/${e.huddle_id}/${t.replace(/^\.\//,``)}`;return{queryKey:[`wt-file`,e.id,n],queryFn:({signal:t})=>L(`GET`,`/api/worktrees/${e.id}/file?path=${encodeURIComponent(n)}`,void 0,t),retry:!1}}),combine:e=>{let t={};for(let[r,i]of e.entries()){let e=i.data;if(i.isPending||(t[n[r]]=void 0),e?.content&&!e.binary&&e.size<=me.fileBytes)try{t[n[r]]=ye.parse(JSON.parse(e.content))}catch{}}return t}})}function ci(e,t,n){let r=N(e.huddle_id),{buffer:i,text:a,locked:o}=oi(e.id,r,n),s=(0,J.useMemo)(()=>{try{let t=fe.parse(JSON.parse(a));if(t.id!==e.huddle_id)throw Error(`The definition id must match this huddle directory.`);return{definition:t}}catch(e){return{error:e instanceof Error?e.message:`Invalid huddle definition`}}},[a,e.huddle_id]),c=si(e,s.definition);return{path:r,buffer:i,graph:(0,J.useMemo)(()=>{let e=s.definition;if(!e)return;let n=Object.fromEntries(e.nodes.flatMap(e=>{let n=t?.definition.nodes.find(t=>t.id===e.id),r=e.source.kind===`builtin`?he.get(`${e.source.component}@${e.source.version}`):Object.hasOwn(c,e.source.manifest)?c[e.source.manifest]:JSON.stringify(n?.source)===JSON.stringify(e.source)?t?.components[e.id]:void 0;return r?[[e.id,r]]:[]}));return{digest:t?.digest??`0`.repeat(64),definition:e,components:n,...t?.layout?{layout:t.layout}:{},diagnostics:ie(e,new Map(Object.entries(n)))}},[s,t,c]),error:s.error,locked:o,edit:t=>{let n=i.model;if(!n||o)return!1;try{let r=fe.parse(JSON.parse(n.getValue())),i=fe.parse(t(r));if(i.id!==e.huddle_id)throw Error(`Cannot change the huddle directory id`);return n.pushStackElement(),mn(n,`${JSON.stringify(i,null,2)}\n`),n.pushStackElement(),!0}catch(e){return W.error(ai(e,`Cannot edit this graph`)),!1}}}}function li(e,t){let n=Zt(),i=R().data?.protocol,a=n&&r(i,{major:28,minor:3}),o=e=>n&&r(i,{major:28,minor:e===`builtin`?30:M.find(t=>t.template===e).minor});return{supported:a,supportsTemplate:o,...He({retry:!1,mutationFn:async n=>{if(!e||!o(n.template))throw Error(`This node template requires a supporting host`);return xe.parse(await L(`POST`,`/api/huddle/${e}/definitions/${t.huddle_id}/components`,{...n,project_id:t.project_id,worktree:t.worktree_path}))}})}}var ui=[{id:`triggers`,title:`Triggers`,colour:`text-identity-gold`,colourKey:`gold`},{id:`agents`,title:`Agents`,colour:`text-icon-blue`,colourKey:`blue`},{id:`flow`,title:`Logic & data`,colour:`text-icon-violet`,colourKey:`violet`},{id:`readouts`,title:`Readouts`,colour:`text-icon-green`,colourKey:`green`}],di={manual:`play`,interval:`clock`,calendar:`calendar-days`,date:`calendar-clock`,"calendar-date":`calendar-range`,filetree:`folder-tree`,git:`git-branch`,session:`activity`,"turn-completed":`check-check`,result:`file-output`,file:`file-output`,prompt:`message-square`,review:`check-check`,spawn:`plus`,resume:`play`,restart:`rotate-ccw`,"native-prompt":`message-square`,"native-review":`check-check`,"prompt-spawned":`message-square`,"review-spawned":`check-check`,transform:`braces`,format:`type`,condition:`git-fork`,merge:`merge`,join:`combine`};function fi(e){let t=e.category===`trigger`?`triggers`:e.category===`readout`?`readouts`:e.id.startsWith(`puddle.agent.`)?`agents`:`flow`,n=di[e.id.split(`.`).at(-1)]??(t===`agents`?`message-square`:t===`triggers`?`radio`:`code`);return{group:t,Icon:Yr[n],appearance:{icon:n,colour:ui.find(e=>e.id===t).colourKey}}}function pi({edit:e,profile:t,session:n}){let i=(0,J.useId)(),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),l=ee.safeParse(s),u=li(t,n),d=R().data?.protocol,f=(0,J.useRef)(e);return(0,J.useLayoutEffect)(()=>{f.current=e},[e]),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-label":`Add node`,children:[(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 flex flex-col gap-3 bg-elevated pb-3`,children:[(0,Y.jsx)(K,{htmlFor:`${i}-search`,children:`Find a node`}),(0,Y.jsx)(G,{id:`${i}-search`,value:a,onChange:e=>o(e.target.value),placeholder:`Search nodes`})]}),ui.map(t=>{let n=[...[...he.values()].filter(e=>e.id!==E.id||r(d,{major:28,minor:28})).map(t=>({component:t,disabled:!1,add:()=>e(e=>Or(e,{kind:`builtin`,component:t.id,version:t.version},t.id.endsWith(`.manual`)?`run`:t.id.split(`.`).at(-1),fi(t).appearance))})),...u.supported?M.filter(e=>u.supportsTemplate(e.template)).map(e=>({component:e.component,disabled:u.isPending,add:()=>{let t=`${e.template}-${crypto.randomUUID().replaceAll(`-`,``)}`;u.mutate({template:e.template,component:t},{onSuccess:t=>{f.current(n=>({...n,nodes:[...n.nodes,te.parse({id:Dr(n.nodes,e.template),source:{kind:`local`,manifest:t.manifest},appearance:fi(e.component).appearance,parameters:Object.fromEntries(Object.entries(t.component.parameters).flatMap(([e,t])=>t.default===void 0?[]:[[e,{kind:`literal`,value:t.default}]]))})]}))}})}})):[]].filter(({component:e})=>fi(e).group===t.id&&`${t.title} ${e.title} ${e.category}`.toLowerCase().includes(a.toLowerCase()));return n.length?(0,Y.jsxs)(`section`,{className:`${Z} flex flex-col gap-1`,"aria-label":t.title,children:[(0,Y.jsx)(`h3`,{className:`px-2 pb-2 text-xs font-medium ${t.colour}`,children:t.title}),n.map(({component:e,disabled:n,add:r})=>{let{Icon:i}=fi(e);return(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Add ${e.title}`,className:`${$} flex items-center gap-3 text-left`,disabled:n,onClick:r,children:[(0,Y.jsx)(i,{className:`size-4 shrink-0 ${t.colour}`}),(0,Y.jsx)(`span`,{children:e.title})]},e.id)})]},t.id):null}),u.error&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[u.error.message,`. Inspect the component files before trying again.`]}),(0,Y.jsxs)(`section`,{className:`${Z} flex flex-col gap-3`,"aria-label":`Custom nodes`,children:[(0,Y.jsx)(K,{htmlFor:`${i}-local`,children:`Local component contract`}),(0,Y.jsx)(G,{id:`${i}-local`,value:s,onChange:e=>c(e.target.value),placeholder:`nodes/review/node.json`}),(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex items-center gap-2`,disabled:!l.success,onClick:()=>{l.success&&e(e=>Or(e,{kind:`local`,manifest:l.data},`script`,{icon:`file-code`,colour:`violet`}))},children:[(0,Y.jsx)(Ft,{className:`size-4 text-icon-violet`}),` Add local node`]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Paths are relative to this huddle directory. Node templates create editable source files.`})]})]})}function mi({node:e,component:t,edit:n}){let[r,i]=(0,J.useState)(!1),a=e.appearance??t?.appearance??{icon:null,colour:null},o=a.icon&&Yr[a.icon]||Bt,s=r=>n(n=>({...n,nodes:n.nodes.map(n=>n.id===e.id?{...n,appearance:{...n.appearance??t?.appearance??{icon:null,colour:null},...r}}:n)}));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(fn,{open:r,onOpenChange:i,children:[(0,Y.jsx)(dn,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`size-4`}),`Choose node icon`]})}),(0,Y.jsx)(un,{className:`w-80`,children:(0,Y.jsx)(Xr,{value:a.icon,onSelect:e=>{s({icon:e}),i(!1)}})})]}),(0,Y.jsx)(xt,{label:`Node colour`,value:a.colour,onChange:e=>s({colour:e}),onCustomChange:e=>s({colour:e})})]})}function hi({template:e}){let t=(0,J.useId)(),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(`null`),[o,s]=(0,J.useState)(``),c=``,l;if(n)try{let t=JSON.parse(i);if(!be(t))throw Error(`Sample input exceeds the supported JSON limits`);c=Sn(e??o,t)}catch(e){l=e instanceof Error?e.message:`Cannot preview this prompt`}let u=`w-full resize-y rounded-md bg-surface p-2 text-sm text-fg outline-none focus-visible:ring-1 focus-visible:ring-ring`;return(0,Y.jsx)(nn,{onToggle:e=>r(e.currentTarget.open),summary:`Preview prompt`,summaryClassName:`rounded-md px-2 py-1 text-xs hover:bg-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:n&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Uses standard `,`{{input}}`,` substitutions with sample data. Custom script formatting may differ. Preview data is not saved or sent to an agent.`]}),e===void 0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{htmlFor:`${t}-template`,children:`Sample prompt template`}),(0,Y.jsx)(`textarea`,{id:`${t}-template`,value:o,rows:3,maxLength:131072,className:u,onChange:e=>s(e.target.value)}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`This variable has no text default. Enter a sample template to preview; the host resolves the actual variable when starting the huddle.`})]}),(0,Y.jsx)(K,{htmlFor:`${t}-input`,children:`Sample input (JSON)`}),(0,Y.jsx)(`textarea`,{id:`${t}-input`,value:i,rows:4,maxLength:262144,className:u,onChange:e=>a(e.target.value)}),l?(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,children:l}):(0,Y.jsx)(`pre`,{"aria-label":`Rendered prompt`,role:`region`,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-sm`,children:c||`(Empty prompt)`})]})})}function gi(e){return JSON.stringify(Object.fromEntries(Object.entries(e.variables).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]])),null,2)}function _i(e,t){let n=S.shape.variables.parse(JSON.parse(t));return ve(e,n),n}function vi(e){return I.parse(JSON.parse(e))}function yi(e){let[t,n]=(0,J.useState)(!1);return(0,Y.jsx)(nn,{className:`py-2`,onToggle:e=>n(e.currentTarget.open),summary:`Preview bindings`,summaryClassName:`rounded-md px-2 py-1 text-xs hover:bg-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:t&&(0,Y.jsx)(bi,{...e})})}function bi({definition:e,node:t,component:n}){let r=(0,J.useId)(),[i,a]=(0,J.useState)(()=>gi(e)),o,s;try{o=JSON.stringify(pe(e,t,n,_i(e,i)),null,2)}catch(e){s=e instanceof Error?e.message:`Cannot resolve these settings`}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2 text-xs`,children:[(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Current draft settings after Apply setting, using the sample variables below. These samples are not saved or used to start a huddle.`}),(0,Y.jsx)(K,{htmlFor:r,children:`Sample variables (JSON)`}),(0,Y.jsx)(vt,{id:r,rows:5,maxLength:262144,className:`font-mono text-xs`,value:i,spellCheck:!1,onChange:e=>a(e.target.value)}),s?(0,Y.jsx)(`p`,{role:`status`,className:`whitespace-pre-wrap break-words text-fg-muted`,children:s}):(0,Y.jsx)(`pre`,{role:`region`,"aria-label":`Resolved node settings`,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words`,children:o}),(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Resource values are requested selectors. Start or Apply checks the host, worktrees, accounts and sessions. Active revision shows the resource bindings captured by a running huddle.`})]})}function xi(e,t,n,r){let i=Me(n?e.project_id:void 0),a=Oe(n?i.data?.project.repo_id:void 0),o=Fe(n?e.project_id:void 0),s=n&&Object.values(r?.parameters??{}).some(e=>[`account`,`agent`,`project`].includes(e.editor))?i.data?.project.profile_id:void 0,c=We(s),l=z({queryKey:[`puddlang-context`,s],queryFn:async({signal:e})=>Se.parse(await L(`GET`,`/api/puddlang/${s}/context`,void 0,e)),enabled:!!s,retry:!1}),u=l.data?.agents.filter(e=>e.scripted_turns)??[],d=Object.entries(r?.parameters??{}).flatMap(([e,n])=>{let r=t.parameters[e];return n.editor===`agent`&&r?.kind===`literal`&&typeof r.value==`string`?[r.value]:[]}),f=O(t,r)?.id===F.id,p=t.parameters.worktree,m=p?.kind===`literal`&&typeof p.value==`string`?p.value:void 0;return{projects:i.data?[{value:i.data.project.id,label:i.data.project.name}]:[],providers:u.map(e=>({value:e.id,label:e.id})),accounts:c.data?.filter(e=>e.profile_id===s&&e.logged_in&&u.some(t=>t.id===e.agent_type)&&(!d.length||d.includes(e.agent_type))).map(e=>({value:String(e.id),label:`${e.label} · ${e.agent_type} · #${e.id}`}))??[],worktrees:a.data?.worktrees.map(e=>({value:e.path,label:`${e.branch??`Detached`} · ${e.path}`}))??[],sessions:o.data?.filter(t=>t.project_id===e.project_id&&(f?t.kind!==`huddle`:t.kind===`agent`&&(r?.lifecycle===`resume`?[`exited`,`interrupted`].includes(t.status):![`archived`,`exited`,`interrupted`].includes(t.status)))&&(!m||t.worktree_path===m)).map(e=>({value:e.id,label:`${e.title??e.agent_title??e.agent_type??(e.kind===`terminal`?`Terminal`:`Agent`)} · ${e.id.slice(0,8)} · ${e.worktree_path}`}))??[],error:i.error?.message??a.error?.message??o.error?.message??c.error?.message??l.error?.message}}function Si({node:e,component:t,definition:n,components:r,edit:i,session:a}){let{variables:o,nodes:s}=n,c=xi(a,e,Object.values(t?.parameters??{}).some(e=>[`worktree`,`session`,`account`,`agent`,`project`].includes(e.editor)),t),l=(t,n)=>i(r=>({...r,nodes:r.nodes.map(r=>{if(r.id!==e.id)return r;let i={...r.parameters};return n?i[t]=n:delete i[t],{...r,parameters:i}})}));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[Object.entries(t?.parameters??{}).map(([n,i])=>(0,Y.jsx)(Ci,{name:n,parameter:i,binding:e.parameters[n],variables:o,resources:c,completionChoices:t?.nativeCompletion===n?s.filter(e=>O(e,r[e.id])?.id===ne.id).map(e=>({value:e.id,label:e.id})):void 0,set:e=>l(n,e)},`${n}:${JSON.stringify(e.parameters[n])}`)),c.error&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Resource choices: `,c.error]}),!t&&(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(e.parameters,null,2)}),t&&Object.keys(t.parameters).length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No settings for this node.`}),t&&Object.keys(t.parameters).length>0&&(0,Y.jsx)(yi,{definition:n,node:e,component:t})]})}function Ci({name:e,parameter:t,binding:n,variables:r,set:i,resources:a,completionChoices:o}){let s=(0,J.useId)(),[c,l]=(0,J.useState)(n?.kind??`literal`),u=n?.kind===`literal`?n.value:n?void 0:t.default,d=t.schema.type===`string`,[f,p]=(0,J.useState)(n?.kind===`variable`?n.name:u===void 0?``:d?String(u):JSON.stringify(u)),m;try{t.editor===`secret`&&c===`literal`&&j.parse(f),m=D.parse(c===`variable`?{kind:c,name:f}:{kind:c,value:d?f:JSON.parse(f)})}catch{}let h=o??(t.editor===`worktree`?a.worktrees:t.editor===`session`?a.sessions:t.editor===`account`?a.accounts:t.editor===`project`?a.projects:t.editor===`agent`?a.providers:void 0);return(0,Y.jsxs)(`div`,{className:`${Z} flex min-w-0 flex-col gap-2`,role:`group`,"aria-label":t.title??e,children:[(0,Y.jsxs)(K,{htmlFor:s,children:[t.title??e,t.required?` *`:``]}),(0,Y.jsx)(Q,{label:`${e} binding`,value:c,onValueChange:e=>{l(e),p(``)},options:[{value:`literal`,label:`Value`},{value:`variable`,label:`Variable`}]}),c===`variable`?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose variable`,options:Object.keys(r).map(e=>({value:e,label:e}))}):h?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose ${o?`completion trigger`:t.editor===`agent`?`provider`:t.editor}`,options:f&&!h.some(e=>e.value===f)?[{value:f,label:`${f} · unavailable`},...h]:h}):t.schema.enum?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose value`,options:[...f&&!t.schema.enum.some(e=>(d?String(e):JSON.stringify(e))===f)?[{value:f,label:`${f} · not in options`}]:[],...t.schema.enum.map(e=>({value:d?String(e):JSON.stringify(e),label:typeof e==`string`?e||`(empty string)`:JSON.stringify(e)}))]}):t.editor===`prompt`?(0,Y.jsx)(`textarea`,{id:s,value:f,rows:5,className:`min-h-24 w-full resize-y rounded-md bg-surface p-2 text-sm text-fg outline-none focus-visible:ring-1 focus-visible:ring-ring`,onChange:e=>p(e.target.value)}):t.schema.type===`boolean`?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose value`,options:[{value:`true`,label:`True`},{value:`false`,label:`False`}]}):(0,Y.jsx)(G,{id:s,type:[`number`,`integer`].includes(String(t.schema.type))?`number`:`text`,min:t.schema.minimum,max:t.schema.maximum,step:t.schema.type===`integer`?1:`any`,value:f,onChange:e=>p(e.target.value),placeholder:d?t.description:`JSON value`}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!m,onClick:()=>m&&i(m),children:`Apply setting`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!n,onClick:()=>i(void 0),children:`Clear setting`})]}),t.description&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.description}),t.editor===`prompt`&&(0,Y.jsxs)(Y.Fragment,{children:[c===`variable`&&typeof r[f]?.default==`string`&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Preview uses the variable default. Start bindings may supply another template.`}),(0,Y.jsx)(hi,{template:c===`literal`?f:typeof r[f]?.default==`string`?r[f].default:void 0})]}),!n&&t.default!==void 0&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Default: `,JSON.stringify(t.default)]}),t.editor===`secret`&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Enter a private host reference, never the secret value. Start/Apply checks availability for this huddle and worktree; workers recheck before running.`}),t.editor===`worktree`&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Use an explicit worktree root or a worktree variable.`})]})}async function wi(e,t,n,r){if(ge()||!Lt())throw Error(`Trigger inspection requires a supporting local or SSH connection`);let i=f.parse({target:n});return ce(i.target,await L(`POST`,`/api/huddle/${e}/sessions/${t}/triggers`,i,r))}var Ti=e=>new Date(e).toLocaleString();function Ei({profile:e,session:t,target:n,stale:r,focused:i,onClose:a}){let o=z({queryKey:[`huddle-triggers`,e,t,n],queryFn:({signal:r})=>wi(e,t,n,r),enabled:i&&!r,retry:!1,networkMode:`always`,gcTime:0,refetchInterval:e=>i&&!r&&!e.state.error?5e3:!1,refetchIntervalInBackground:!1}),s=o.data;return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||a()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Huddle triggers`}),(0,Y.jsx)(B,{children:`Installed subscriptions and accepted work. Ready means the subscription is installed; it does not prove an external service is reachable. Counts describe retained events, not unseen work at the source.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,Y.jsx)(`span`,{children:s?`Observed ${Ti(s.observed_at)}`:`Waiting for observation…`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:r||!i||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh`})]}),r&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:`The runtime changed. Close and reopen Triggers to inspect the current activation.`}),o.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:o.error.message}),s&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-xs`,children:[s.backlog.queued,` queued · `,s.backlog.running,` running ·`,` `,s.backlog.uncertain_operations,` uncertain operations`,s.queue_limit!==null&&(0,Y.jsxs)(`span`,{className:`text-fg-muted`,children:[` · queue limit `,s.queue_limit]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Backlog includes earlier activations. Source totals below cover this activation only.`}),(0,Y.jsx)(`ul`,{className:`max-h-[55vh] space-y-5 overflow-auto py-2 text-xs`,"aria-label":`Trigger health and backlog`,children:s.sources.map(e=>(0,Y.jsxs)(`li`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,Y.jsx)(`span`,{children:e.node}),(0,Y.jsx)(`span`,{className:`text-fg-muted`,children:e.health})]}),(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:e.component}),e.message&&(0,Y.jsx)(`p`,{className:`break-words`,children:e.message}),(0,Y.jsxs)(`p`,{children:[e.queued,` queued · `,e.running,` running · `,e.admitted,` admitted`]}),e.last_event_at&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Last accepted event `,Ti(e.last_event_at)]}),e.next_at&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Next scheduled `,Ti(e.next_at)]}),e.missed&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Missed policy: `,e.missed,` · `,e.coalesced,` combined occurrences ·`,` `,e.skipped,` skipped occurrences`]}),e.disposition&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`One-off date: `,e.disposition]})]},e.node))}),!s.sources.length&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No triggers in this activation.`})]})]})})}function Di({enabled:e,target:t,disabled:n,send:r}){return(0,Y.jsx)(X,{icon:rn,label:`Auto-start after reboot`,"aria-pressed":e,disabled:n,title:`Auto-start after reboot: ${e?`on`:`off`}. Recover this run when the host starts; stopped or interrupted huddles stay stopped.`,onClick:()=>void r({action:`auto-start`,input:{target:t,expected:e,enabled:!e}}).catch(()=>{})})}function Oi(){let e=Zt(),t=R();return e&&r(t.data?.protocol,{major:28,minor:12})}function ki(e,t){if(ge())throw Error(`Huddle history requires a local or SSH connection`);return`/api/huddle/${e}/sessions/${t}/history`}async function Ai(e,t,n,r){return s.parse(await L(`POST`,`${ki(e,t)}/owners`,c.parse(n),r))}async function ji(e,t,n,r){let a=i.parse(n);return ae(a,await L(`POST`,`${ki(e,t)}/input`,a,r))}async function Mi(e,t,n,r){let i=g.parse(n);return x(i,await L(`POST`,`${ki(e,t)}/retained`,i,r))}function Ni(){let e=Zt(),t=R().data?.protocol;return e&&r(t,{major:28,minor:10})}async function Pi(e,t,n,r){if(ge()||!Lt())throw Error(`Huddle revision review requires a supporting local or SSH connection`);let i=`expected_digest`in n,a=(i?Ce:o).parse(n);return k(a,await L(`POST`,`/api/huddle/${e}/sessions/${t}/${i?`diff`:`revision`}`,a,r))}function Fi(){let e=Zt(),t=R().data?.protocol;return e&&r(t,{major:28,minor:13})}async function Ii(e,t,n,r){if(ge()||!Lt())throw Error(`Retained revision review requires a supporting local or SSH connection`);let i=b.parse(n);return we(i,await L(`POST`,`/api/huddle/${e}/sessions/${t}/revision/retained`,i,r))}function Li({profile:e,session:t,review:n}){let r=(0,J.useId)(),i=`source`in n,a=i?n.revision:n.active.revision,o=i?n.activation:n.active,[s,c]=(0,J.useState)(()=>(n.entries.find(e=>![`retained`,`unchanged`].includes(e.change))??n.entries[0])?.entry??null),[l,u]=(0,J.useState)(!n.saved),d=z({queryKey:[`huddle-revision-content`,e,t,i?[`retained`,n.owner,a]:n.target,n.saved?.digest,s],queryFn:({signal:r})=>i?Ii(e,t,{owner:n.owner,revision:a,entry:s,...n.saved?{expected_digest:n.saved.digest}:{}},r):Pi(e,t,{target:n.target,entry:s,...n.saved?{expected_digest:n.saved.digest}:{}},r),enabled:s!==null,retry:!1,staleTime:1/0,gcTime:0,refetchOnWindowFocus:!1}),f=n.entries.filter(e=>![`unchanged`,`retained`].includes(e.change)),p=l?n.entries:f,m=d.data?.content,h=s?.kind===`component`?`${s.path}.json`:s?.path??``;return(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-3`,"aria-label":`Revision review`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Y.jsxs)(`p`,{className:`break-all`,children:[i?`Recorded revision`:`Active revision`,` `,a]}),n.saved&&(0,Y.jsxs)(`p`,{className:`break-all`,children:[`Saved revision `,n.saved.digest]}),(0,Y.jsx)(`p`,{children:n.saved?`${f.length} changed ${f.length===1?`entry`:`entries`}`:`${p.length} retained entries`}),o&&(0,Y.jsx)(nn,{summary:`${i?`Recorded`:`Active`} variables and resolved bindings`,children:(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-words p-2`,children:JSON.stringify({worktree:o.worktree,appliedAt:new Date(o.appliedAt).toLocaleString(),variables:o.variables,bindings:o.bindings},null,2)})}),n.saved?.diagnostics.map((e,t)=>(0,Y.jsxs)(`p`,{children:[e.severity,`: `,e.message]},t))]}),n.saved&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,"aria-pressed":l,onClick:()=>u(!l),children:l?`Show changes only`:`Show all entries`}),(0,Y.jsx)(`div`,{className:`max-h-32 overflow-auto`,"aria-label":`Revision entries`,children:p.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex w-full items-center justify-between gap-3 text-left aria-pressed:bg-explorer-selection`,"aria-pressed":s?.kind===e.entry.kind&&s.path===e.entry.path,onClick:()=>c(e.entry),children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.entry.kind===`component`?`Contract · `:``,e.entry.path]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.change})]},`${e.entry.kind}:${e.entry.path}`))}),d.error&&(0,Y.jsxs)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:[d.error.message,` Close and inspect again to review current source.`]}),d.isFetching&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading retained source…`}),m&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[s?.path,` ·`,` `,n.saved?`${i?`Retained`:`Active`} on the left · Saved on the right`:`Retained source`,n.saved&&(m.before===null?` · Added`:m.after===null?` · Removed`:``)]}),(0,Y.jsx)(`div`,{className:`h-72 min-w-0`,"aria-label":`Revision source`,children:n.saved?(0,Y.jsx)(Pt,{session:t,originalRef:`huddle:${a}`,originalPath:h,originalContent:m.before??``,modifiedRef:`huddle:${n.saved.digest}`,modifiedPath:h,modifiedContent:m.after??``},`${s?.kind}:${h}`):(0,Y.jsx)(At,{session:`${t}:${r}`,refName:`huddle:${a}`,path:h,content:m.before??``},`${s?.kind}:${h}`)})]})]})}function Ri({profile:e,session:t,request:n,onBack:r,onClose:i}){let a=z({queryKey:[`huddle-retained-revision`,e,t,n],queryFn:({signal:r})=>Ii(e,t,n,r),retry:!1,staleTime:1/0,gcTime:0,refetchOnWindowFocus:!1});return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||i()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Recorded huddle revision`}),(0,Y.jsx)(B,{children:`Retained source from this runtime. Recorded settings describe the last saved activation; they do not establish current activity.`}),(0,Y.jsx)(`button`,{type:`button`,className:`${$} w-fit`,onClick:r,children:`Back to history`}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[`Runtime `,n.owner.runtimeId]}),a.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading recorded revision…`}),a.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:a.error.message}),a.data&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Read `,new Date(a.data.observed_at).toLocaleString()]}),(0,Y.jsx)(Li,{profile:e,session:t,review:a.data})]})]})})}var zi=(e,t)=>`/api/huddle/${e}/sessions/${t}`;function Bi(){if(ge()||!Lt())throw Error(`Huddle execution requires a supporting local or SSH connection`)}async function Vi(e,t,n,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1){Bi();let l=new URLSearchParams;return r&&l.set(`include_readout_observation`,`true`),i&&l.set(`include_custom_triggers`,`true`),a&&l.set(`include_recovery`,`true`),o&&l.set(`include_auto_start`,`true`),s&&l.set(`include_trigger_inspection`,`true`),c&&l.set(`include_crash_recovery`,`true`),d.parse(await L(`GET`,`${zi(e,t)}/runtime${l.size?`?`+l.toString():``}`,void 0,n))}async function Hi(e,t,n,r){return Bi(),_.parse(await L(`POST`,`${zi(e,t)}/history`,l.parse(n),r))}async function Ui(e,t,n){Bi();let r={"auto-start":h,recover:Te,"readouts/observe":y,"readouts/observe-retained":oe,start:S,apply:m,run:C,rearm:f,interrupt:f,stop:f}[n.action].parse(n.input),i=await L(`POST`,`${zi(e,t)}/${n.action}`,r);return n.action===`readouts/observe`||n.action===`readouts/observe-retained`?{action:`observing`,value:p.parse(i)}:n.action===`run`?{action:`run`,value:a.parse(i),target:n.input.target}:n.action===`stop`?{action:`stop`,value:w.parse(i)}:{action:`state`,value:d.parse(i)}}async function Wi(e,t,n){let r=S.parse(n.input),i=C.omit({target:!0}).parse(n.event),a=Ee.get(),o=ge(),s=()=>{if(Ee.get()!==a||ge()!==o)throw Error(`The connection changed`)},c=`start`;try{let n=await Ui(e,t,{action:`start`,input:r});if(c=`verify`,s(),n.action!==`state`||n.value.session_id!==t)throw Error(`Start returned another session`);let a=n.value.owner;if(n.value.unresolved||!a?.connected||a.stopping||a.lifecycle!==`armed`||!a.target.activationId)throw Error(`The started graph is not available`);let o=await Pi(e,t,{target:a.target});if(s(),o.active.revision!==r.expected_digest||le(o.active.variables)!==le(r.variables))throw Error(`The active revision or variables changed`);c=`run`;let l=await Ui(e,t,{action:`run`,input:{...i,target:a.target}});return s(),l}catch(e){let t=e instanceof Error?e.message:`Request failed`;throw Error(`${c===`start`?`Start was not confirmed; manual input was not sent.`:c===`verify`?`Start succeeded, but manual input was not sent.`:`Start succeeded; the manual input outcome needs inspection.`} ${t}`,{cause:e})}}var Gi=(e,t)=>[`huddle-runtime`,e,t],Ki=(e,t)=>[`huddle-history`,e,t];function qi(){let e=Zt(),t=R().data?.protocol;return e&&r(t,{major:28,minor:2})}function Ji(e,t,n){let i=qi(),a=R().data?.protocol;return z({queryKey:Gi(e,t),queryFn:({signal:n})=>Vi(e,t,n,r(a,{major:28,minor:6}),r(a,{major:28,minor:7}),r(a,{major:28,minor:15}),r(a,{major:28,minor:16}),r(a,{major:28,minor:17}),r(a,{major:28,minor:18})),enabled:i&&!!e&&n,retry:!1,networkMode:`always`,staleTime:0,refetchInterval:e=>n&&!e.state.error?3e3:!1,refetchIntervalInBackground:!1})}var Yi={pending:!1,review:!1,error:null,executionId:null};function Xi(e,t){let n=qi(),r=Ni(),i=Ke(),a=[`huddle-command`,e,t],o=z({queryKey:a,queryFn:()=>Yi,initialData:Yi,enabled:!1,staleTime:1/0,gcTime:1/0}).data,s=He({mutationKey:a,retry:!1,networkMode:`always`,mutationFn:n=>n.action===`start-and-run`?Wi(e,t,n):Ui(e,t,n),onSuccess:n=>{n.action===`state`&&i.setQueryData(Gi(e,t),n.value),i.setQueryData(a,{...Yi,executionId:n.action===`run`?n.value.executionId:null})},onError:e=>i.setQueryData(a,{...Yi,review:!0,error:e.message}),onSettled:()=>{i.invalidateQueries({queryKey:Gi(e,t)}),i.invalidateQueries({queryKey:Ki(e,t)}),i.invalidateQueries({queryKey:[`sessions`]})}});return{status:o,async send(t){let o=i.getQueryData(a)??Yi;if(!n||!e)throw Error(`This host does not support huddle execution`);if(t.action===`start-and-run`&&!r)throw Error(`Start and run requires a host supporting revision review`);if(o.pending||o.review||i.isMutating({mutationKey:a}))throw Error(`Inspect the previous command before another action`);return i.setQueryData(a,{...Yi,pending:!0}),s.mutateAsync(t)},reviewed(){let e=i.getQueryData(a)??Yi;e.pending||i.setQueryData(a,{...e,review:!1,error:null})}}}function Zi({operation:e,target:t,owner:n,disabled:r,send:i,inspect:a}){let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null);return(0,Y.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Check whether the destination received this delivery.`}),(0,Y.jsxs)(ln,{label:`Delivery observation`,className:`w-fit`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:r||o,onClick:()=>{s(!0),l(null),i(n?{action:`readouts/observe-retained`,input:{owner:n,operation_id:e}}:{action:`readouts/observe`,input:{target:t,operation_id:e}}).catch(e=>{l(e instanceof Error?e.message:`Cannot check delivery`)})},children:`Check delivery`}),o&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:r,onClick:()=>{a().then(()=>{s(!1),l(null)},e=>{l(e instanceof Error?e.message:`Cannot inspect delivery`)})},children:`Refresh delivery`})]}),o&&!c&&(0,Y.jsx)(`p`,{role:`status`,className:`text-fg-muted`,children:`Check requested. The delivery result will refresh here; the ended graph stays ended.`}),c&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-fg-muted`,children:c})]})}function Qi({agent:e,onOpen:t}){return(0,Y.jsxs)(`div`,{className:`space-y-1 py-1`,children:[(0,Y.jsx)($e,{to:`/project/${encodeURIComponent(e.projectId)}/session/${encodeURIComponent(e.sessionId)}`,onClick:t,className:`${$} inline-block`,children:`Open agent session`}),(0,Y.jsxs)(`p`,{className:`break-all text-fg-muted`,children:[`Recorded worktree: `,e.worktree]}),(0,Y.jsxs)(nn,{className:`text-fg-muted`,summary:`Recorded agent identity`,children:[(0,Y.jsxs)(`p`,{className:`break-all`,children:[`Session `,e.sessionId]}),e.runtimeId&&(0,Y.jsxs)(`p`,{className:`break-all`,children:[`Runtime `,e.runtimeId]}),(0,Y.jsx)(`p`,{children:`The session may now use a different runtime or conversation.`})]})]})}function $i({profile:e,session:t,request:n}){let[r,i]=(0,J.useState)(!1),a=z({queryKey:[`huddle-trigger-input`,e,t,n],queryFn:({signal:r})=>ji(e,t,n,r),enabled:r,retry:!1,staleTime:1/0,refetchOnWindowFocus:!1}),o=a.data?.event,s=o?JSON.stringify(o.data,null,2):``;return(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,"aria-expanded":r,onClick:()=>i(!r),children:`Trigger input`}),r&&(0,Y.jsxs)(`div`,{className:`space-y-1`,"aria-label":`Recorded trigger input`,children:[a.isPending&&(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Reading recorded input…`}),a.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-fg-muted`,children:a.error.message}),a.error&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:a.isFetching,onClick:()=>void a.refetch(),children:`Refresh input`}),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{children:[o.source.node,`.`,o.port,` · `,o.source.component,`@`,o.source.version]}),(0,Y.jsxs)(`p`,{className:`break-all text-fg-muted`,children:[`Event `,o.id]}),(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Observed `,new Date(o.observedAt).toLocaleString()]}),o.occurredAt&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Occurred `,new Date(o.occurredAt).toLocaleString()]}),(0,Y.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:s.length>16384?`${s.slice(0,16384)}\n… Preview truncated`:s})]})]})]})}function ea(e,t,n,r=!1){return z({queryKey:[...Ki(e,t),...r?[`retained`]:[],n],queryFn:({signal:i})=>r?Mi(e,t,n,i).then(e=>({...e.history,observedAt:e.observed_at})):Hi(e,t,n,i),retry:!1,networkMode:`always`,staleTime:0,refetchInterval:e=>r||e.state.error?!1:3e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:!r})}function ta({profile:e,session:t,owner:n,initialExecution:i,retained:a=!1,onRecordedRuntimes:o,onClose:s}){let c=Fi(),l=r(R().data?.protocol,{major:28,minor:33}),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)([0]),[m,h]=(0,J.useState)(i??null),g=f.at(-1),_=ea(e,t,{owner:n,collection:`executions`,after:g},a),v=_.data?.collection===`executions`?_.data:void 0,y=v?.records.find(({record:e})=>e.id===m)?.record;return u?(0,Y.jsx)(Ri,{profile:e,session:t,request:{owner:n,...u.digest?{revision:u.digest}:{}},onBack:()=>d(null),onClose:s}):(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||s()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Huddle history`}),(0,Y.jsx)(B,{children:a?`Recorded ledger history. Pending, running and unknown records do not establish current activity or completion. Nothing is restarted or reconciled.`:`Execution acceptance and completion are separate. This view reads the connected runtime.`}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[`Runtime `,n.runtimeId]}),a&&_.data?.observedAt&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Read `,new Date(_.data.observedAt).toLocaleString()]}),(0,Y.jsxs)(ln,{label:`History pages`,className:`w-fit`,children:[o&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:o,children:`Recorded runtimes`}),c&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:()=>d({}),children:`Recorded activation`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:_.isFetching,onClick:()=>void _.refetch(),children:`Refresh executions`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:f.length===1||_.isFetching,onClick:()=>p(f.slice(0,-1)),children:`Previous page`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!v?.records.length||v.next<=g||_.isFetching,onClick:()=>p([...f,v.next]),children:`Next page`})]}),_.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:_.error.message}),_.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading executions…`}),v?.records.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No executions on this page.`}),(0,Y.jsxs)(`div`,{className:`grid min-h-0 gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]`,children:[(0,Y.jsxs)(`div`,{className:`max-h-80 space-y-1 overflow-auto`,"aria-label":`Executions`,children:[v?.records.map(({record:e})=>(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":m===e.id,onClick:()=>h(e.id),className:`${$} flex w-full flex-col items-start gap-1 text-left aria-pressed:bg-explorer-selection`,children:[(0,Y.jsxs)(`span`,{children:[e.state,` · `,e.id.slice(0,8)]}),(0,Y.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.acceptedAt).toLocaleString()})]},e.id)),(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-fg-muted`,children:`Earlier entries appear first. Refresh a page to see changed outcomes.`})]}),m?(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,Y.jsxs)(`p`,{className:`break-all text-xs`,children:[`Execution `,m]}),l&&(0,Y.jsx)($i,{profile:e,session:t,request:{owner:n,execution_id:m}},`trigger-input:${m}`),y&&(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Y.jsxs)(`p`,{children:[y.state,` · revision `,y.revision.slice(0,12)]}),(0,Y.jsxs)(`p`,{children:[y.turns,` turns · `,y.spawns,` spawns ·`,` `,y.invocations,` node invocations`]}),y.error&&(0,Y.jsx)(`p`,{role:`alert`,children:y.error}),c&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:()=>d({digest:y.revision}),children:`Execution source`})]}),(0,Y.jsx)(na,{profile:e,session:t,owner:n,execution:m,retained:a,onOpenAgent:s},m)]}):(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Choose an execution to inspect nodes and results.`})]})]})})}function na({profile:e,session:t,owner:n,execution:i,retained:a,onOpenAgent:o}){let[s,c]=(0,J.useState)(`invocations`),[l,u]=(0,J.useState)([0]),d=l.at(-1),f=R().data?.protocol,p=r(f,{major:28,minor:a?21:6}),m=ea(e,t,{owner:n,collection:s,after:d,parent:i,...p?{include_readout_observation:!0}:{},...r(f,{major:28,minor:32})?{include_agent:!0}:{}},a),h=Ji(e,t,!a),g=Xi(e,t),_=h.data?.owner,v=p&&!h.error&&_?.connected&&_.readout_observation&&!_.stopping&&!_.failure&&_.target.runtimeId===n.runtimeId&&_.target.incarnation===n.incarnation?_.target:null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(ln,{label:`Execution detail`,className:`w-fit flex-wrap`,children:[[`invocations`,`operations`].map(e=>(0,Y.jsx)(`button`,{type:`button`,className:$,"aria-pressed":s===e,onClick:()=>{c(e),u([0])},children:e===`invocations`?`Nodes`:`Operations`},e)),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:l.length===1||m.isFetching,onClick:()=>u(l.slice(0,-1)),children:`Previous details`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!m.data?.records.length||m.data.next<=d||m.isFetching,onClick:()=>u([...l,m.data.next]),children:`Next details`})]}),m.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:m.error.message}),g.status.review&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:m.isFetching||h.isFetching,onClick:()=>{Promise.all([m.refetch(),h.refetch()]).then(([e,t])=>{!e.error&&!t.error&&g.reviewed()})},children:`Inspect previous command`}),m.data?.records.length===0&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No `,s,` on this page.`]}),(0,Y.jsx)(`div`,{className:`max-h-80 space-y-3 overflow-auto`,children:m.data?.records.map(({record:e})=>(0,Y.jsxs)(nn,{className:`text-xs`,open:!0,summary:`${`node`in e?e.node:`kind`in e?e.kind:e.id} · ${e.state}`,summaryClassName:`py-1 text-fg`,children:[`error`in e&&e.error&&(0,Y.jsx)(`p`,{className:`py-1 text-fg-muted`,children:e.error}),`inputs`in e&&(0,Y.jsx)(ra,{label:`Inputs`,value:e.inputs}),`agent`in e&&e.agent&&(0,Y.jsx)(Qi,{agent:e.agent,onOpen:o}),`result`in e&&e.result!==void 0&&(0,Y.jsx)(ra,{label:`Result`,value:e.result}),`consumed`in e&&(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:e.consumed?`Dispatch consumed`:`Not dispatched`}),`readout_observation`in e&&e.readout_observation&&(v||a&&p)&&(0,Y.jsx)(Zi,{operation:e.id,target:v??void 0,owner:a?n:void 0,disabled:g.status.pending||g.status.review,send:g.send,inspect:async()=>{if(a){let e=await m.refetch();if(e.error)throw e.error;g.reviewed();return}let[e,t]=await Promise.all([m.refetch(),h.refetch()]);if(e.error)throw e.error;if(t.error)throw t.error}})]},e.id))})]})}function ra({label:e,value:t}){let n=JSON.stringify(t,null,2);return(0,Y.jsxs)(`div`,{className:`py-1`,children:[(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:e}),(0,Y.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:n.length>16384?`${n.slice(0,16384)}\n… Preview truncated`:n})]})}function ia({profile:e,session:t,onClose:n}){let[r,i]=(0,J.useState)([void 0]),[a,o]=(0,J.useState)(null),s=r.at(-1),c=z({queryKey:[`huddle-history-owners`,e,t,s],queryFn:({signal:n})=>Ai(e,t,{after:s},n),enabled:!a,retry:!1,networkMode:`always`,refetchOnWindowFocus:!1});return a?(0,Y.jsx)(ta,{profile:e,session:t,owner:a,retained:!0,onRecordedRuntimes:()=>o(null),onClose:n},`${a.runtimeId}:${a.incarnation}`):(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||n()},children:(0,Y.jsxs)(V,{children:[(0,Y.jsx)(H,{children:`Recorded huddle runtimes`}),(0,Y.jsx)(B,{children:`Choose a retained runtime to inspect its ledger. Recorded states do not prove that a runtime is connected or stopped.`}),(0,Y.jsxs)(ln,{label:`Recorded runtime pages`,className:`w-fit`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:c.isFetching,onClick:()=>void c.refetch(),children:`Refresh runtimes`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:c.isFetching||r.length===1,onClick:()=>i(r.slice(0,-1)),children:`Previous runtimes`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:c.isFetching||!c.data?.next,onClick:()=>i([...r,c.data.next]),children:`Older runtimes`})]}),c.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:c.error.message}),c.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading recorded runtimes…`}),c.data?.records.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No recorded runtimes on this page.`}),(0,Y.jsx)(`div`,{className:`max-h-80 space-y-1 overflow-auto`,"aria-label":`Recorded runtimes`,children:c.data?.records.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex w-full flex-col items-start text-left`,onClick:()=>o(e.owner),children:[(0,Y.jsxs)(`span`,{children:[new Date(e.created_at).toLocaleString(),` · `,e.recorded_state]}),(0,Y.jsxs)(`span`,{className:`break-all text-fg-muted`,children:[e.owner.runtimeId,` · `,e.build]})]},e.owner.runtimeId))})]})})}function aa(e){let t=yn(e.id,`.puddle/huddle/${e.huddle_id}/`);return(0,J.useSyncExternalStore)(gn,()=>hn().some(e=>e.startsWith(t)&&e.split(`:`).length===2),()=>!1)}function oa({review:e,profile:t,session:n,worktree:r,blocked:i,pending:a,error:o,send:s,onClose:c}){let l=(0,J.useId)(),[u]=(0,J.useState)(()=>crypto.randomUUID()),d=e.document?.definition.nodes.filter(t=>O(t,e.document?.components[t.id])?.id===ue.id)??[],[f,p]=(0,J.useState)(d[0]?.id??``),[m,h]=(0,J.useState)(()=>e.kind===`run`?`null`:e.kind===`apply`&&e.comparison?JSON.stringify(e.comparison.active.variables,null,2):e.document?gi(e.document.definition):`{}`),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(`null`),b=e.kind===`run`,x=e.kind===`start-and-run`,S=b?`Run huddle`:x?`Start and run`:e.kind===`start`?`Start saved graph`:`Apply saved graph`,C=async()=>{if(!(i||a)){_(null);try{if(e.kind===`run`){if(!f.trim())throw Error(`Choose a manual trigger`);await s({action:`run`,input:{target:e.target,node:f.trim(),event_id:u,data:vi(m)}})}else{if(!e.document)throw Error(`Inspect saved source before continuing`);if(e.document.diagnostics.some(e=>e.severity===`error`))throw Error(`Fix the saved graph validation errors first`);let t={expected_digest:e.document.digest,variables:_i(e.document.definition,m)};if(e.kind===`start-and-run`){if(!d.some(e=>e.id===f.trim()))throw Error(`Choose a manual trigger from the saved graph`);await s({action:`start-and-run`,input:t,event:{node:f.trim(),event_id:u,data:vi(v)}})}else await s(e.kind===`start`?{action:`start`,input:t}:{action:`apply`,input:{...t,target:e.target}})}}catch(e){_(e instanceof Error?e.message:`Cannot send this command`)}}};return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{!e&&!a&&c()},children:(0,Y.jsxs)(V,{showCloseButton:!a,wide:e.kind===`apply`&&!!e.comparison,children:[(0,Y.jsx)(H,{children:S}),(0,Y.jsx)(B,{children:b?`Send one input to the active graph. Apply saved edits to use them in future runs.`:x?`Start the saved revision with these variables, then send one manual input after confirming the active revision. Starting also arms automatic triggers, including past one-off dates set to fire. If either step is uncertain, inspect the outcome before continuing.`:`Use the saved files and the variables below. Unsaved script edits are not included. Start arms automatic triggers; Apply resets their schedules. Both create a new activation, so past one-off dates set to fire may run again. Manual input is sent separately.`}),!b&&(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:e.document?.definition.name}),(0,Y.jsx)(`p`,{className:`break-all`,children:r}),(0,Y.jsxs)(`p`,{children:[`Saved revision `,e.document?.digest.slice(0,12)]}),Object.entries(e.document?.definition.variables??{}).map(([e,t])=>(0,Y.jsxs)(`p`,{children:[e,t.required?` · required`:` · optional`,t.description?` · ${t.description}`:``]},e))]}),e.kind===`apply`&&e.comparison&&(0,Y.jsx)(Li,{profile:t,session:n,review:e.comparison}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(b||x)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(K,{htmlFor:`${l}-node`,children:`Manual trigger`}),(0,Y.jsx)(G,{id:`${l}-node`,value:f,disabled:a,list:`${l}-triggers`,onChange:e=>p(e.target.value)}),(0,Y.jsx)(`datalist`,{id:`${l}-triggers`,children:d.map(e=>(0,Y.jsx)(`option`,{value:e.id},e.id))}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:x?`Choose a manual trigger in this saved revision.`:`Suggestions come from saved source. Enter an existing trigger id if the active graph differs.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(K,{htmlFor:`${l}-json`,children:b?`Input (JSON)`:`Variables (JSON)`}),(0,Y.jsx)(`textarea`,{id:`${l}-json`,className:`${it} min-h-28 resize-y p-2 font-mono text-xs`,value:m,disabled:a,spellCheck:!1,onChange:e=>{h(e.target.value),_(null)}})]}),x&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(K,{htmlFor:`${l}-input`,children:`Input (JSON)`}),(0,Y.jsx)(`textarea`,{id:`${l}-input`,className:`rounded-[var(--ui-radius)] bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 host-accent:bg-explorer-hover host-accent:hover:bg-explorer-selection/50 host-accent:focus:bg-explorer-selection/50 disabled:cursor-not-allowed disabled:opacity-50 min-h-28 resize-y p-2 font-mono text-xs`,value:v,disabled:a,spellCheck:!1,onChange:e=>{y(e.target.value),_(null)}})]}),(i||o||g)&&(0,Y.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap break-words text-xs text-fg-muted`,children:x&&o?o:i??o??g}),(0,Y.jsxs)(nt,{children:[(0,Y.jsx)(_t,{type:`button`,variant:`ghost`,disabled:a,onClick:c,children:`Cancel`}),(0,Y.jsx)(_t,{type:`submit`,disabled:a||!!i,children:a?`Sending…`:b?`Send input`:S})]})]})]})})}function sa({sources:e}){return e.length?(0,Y.jsxs)(nn,{className:`px-4 pb-2 text-xs`,open:e.some(e=>e.health.state===`gap`),summary:`Custom triggers · ${e.filter(e=>e.health.state===`ready`).length} ready`,summaryClassName:`py-1 text-fg-muted`,children:[(0,Y.jsx)(`ul`,{className:`space-y-1 py-1`,"aria-label":`Custom trigger health`,children:e.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`span`,{children:[e.node,` · `,e.health.state]}),`message`in e.health&&(0,Y.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,e.health.message]})]},e.node))}),e.some(e=>e.health.state===`gap`)&&(0,Y.jsx)(`p`,{className:`py-1 text-fg-muted`,children:`Inspect the source, then interrupt and resume to reopen its subscription. Other sources may still be running.`})]}):null}function ca({profile:e,session:t,target:n,stale:r,onClose:i}){let a=z({queryKey:[`huddle-active-revision`,e,t,n],queryFn:({signal:r})=>Pi(e,t,{target:n},r),retry:!1,staleTime:1/0,gcTime:0});return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||i()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Active huddle revision`}),(0,Y.jsx)(B,{children:`Retained source and bindings for this activation. Inspecting does not run code or apply saved edits.`}),r&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:`The runtime changed. This view refers to the inspected activation; close and inspect again for the current revision.`}),a.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading active revision…`}),a.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:a.error.message}),a.data&&(0,Y.jsx)(Li,{profile:e,session:t,review:a.data})]})})}function la(e,t){return e.runtimeId===t.runtimeId&&e.incarnation===t.incarnation&&e.generation===t.generation&&e.activationId===t.activationId}var ua=e=>({runtimeId:e.runtimeId,incarnation:e.incarnation});function da({profile:e,session:t,focused:n,locked:r}){let i=qi(),a=Oi(),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),u=Ni(),d=Ji(e,t.id,n),f=zt(e,t),p=Xi(e,t.id),m=Ke(),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),C=aa(t),w=d.data?.owner,T=w?.connected?w:null,ee=qt(e,i&&n&&!w);if(!i)return null;let E=p.status.pending||x,D=!d.data||d.isError||d.data.unresolved||w?.connected===!1,k=!E&&!p.status.review&&!D&&!T?.stopping,te=k&&!w&&ee.data?.available&&t.status!==`archived`,A=k&&!!T&&t.status!==`archived`,j=async n=>{if(!k)return;if(n!==`run`&&(C||r)){W.warning(`Save or resolve source edits before Start or Apply.`);return}let i=n===`start`||n===`start-and-run`;S(!0);try{let r=await d.refetch({throwOnError:!0}),a=r.data?.owner;if(!r.data||r.data.unresolved||a?.connected===!1)throw Error(`Runtime observation is unavailable`);if(i&&a)throw Error(`An owner already exists; inspect it before starting`);if(!i&&(!a?.connected||a.stopping))throw Error(`No available owner to control`);let o=f.data;if(n!==`run`&&(o=(await f.refetch({throwOnError:!0})).data),n===`start`||n===`start-and-run`){if(!o)throw Error(`Saved source is unavailable`);g({kind:n,document:o})}else if(a?.connected){let r=n===`apply`&&u&&o?await Pi(e,t.id,{target:a.target,expected_digest:o.digest}):void 0;g({kind:n,document:o,target:a.target,...r?{comparison:r}:{}})}}catch(e){W.error(e instanceof Error?e.message:`Cannot inspect huddle`)}finally{S(!1)}},M=async e=>{let t=await p.send(e).catch(e=>{throw W.error(e instanceof Error?e.message:`Huddle command failed`,{description:`The command was not repeated. Inspect the outcome before another action.`}),e});g(null),t.action===`run`&&b({owner:ua(t.target),execution:t.value.executionId})},N=async()=>{if(!E){S(!0);try{let n=(await d.refetch({throwOnError:!0})).data;if(!n)throw Error(`Runtime outcome is still unavailable`);if(n.unresolved||n.owner?.connected===!1){if(!n.recovery)throw Error(`Runtime outcome is still unavailable`);p.reviewed();return}if(n.owner?.connected){let r=ua(n.owner.target),i={owner:r,collection:`executions`,after:0},a=await Hi(e,t.id,i);m.setQueryData([...Ki(e,t.id),i],a),p.status.review&&b({owner:r})}else await ee.refetch();p.reviewed(),n.owner?.failure?W.warning(n.owner.failure):!n.owner&&ee.data?.available===!1?W.warning(ee.data.reason):W.info(F,{description:n.owner?.lifetime===`host_session`?`Runtime lifetime is limited to this host session.`:void 0})}catch(e){W.error(e instanceof Error?e.message:`Cannot inspect outcome`)}finally{S(!1)}}},P=p.status.review?`Close this review and inspect the previous outcome before another action.`:null;h&&!P&&!p.status.pending&&(d.isError||!d.data||d.data.unresolved||w?.connected===!1?P=`Runtime observation is unavailable. Close and inspect again.`:(h.kind===`start`||h.kind===`start-and-run`?w:!T||!la(T.target,h.target))?P=`The active graph changed. Close and inspect again.`:h.kind!==`run`&&(C||r)&&(P=`Save or resolve the source edits before continuing.`));let F=E?`Working…`:D?`Runtime unavailable`:T?T.stopping?`Stopping`:T.executing?`Executing`:T.lifecycle===`armed`?`Armed · idle`:T.lifecycle===`interrupted`?`Interrupted`:`Ready to start`:`Stopped`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-3`,"aria-label":`Huddle execution`,children:(0,Y.jsxs)(ln,{label:`Huddle execution actions`,variant:`island`,className:`max-w-full flex-wrap`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,role:`status`,children:F}),d.data?.recovery&&(0,Y.jsx)(X,{icon:rn,label:`Recover after reboot`,title:`Restore the last active graph and retained trigger cursors after a host reboot. Running scripts remain interrupted.`,disabled:E||p.status.review||t.status===`archived`||r,onClick:()=>void M({action:`recover`,input:{owner:d.data.recovery.owner}}).catch(()=>{})}),d.data?.recovery?.crash_recovery&&(0,Y.jsx)(X,{icon:rn,label:`Recover after crash`,title:`Recover a crashed owner after its recorded kernel scope confirms that script descendants have stopped. Queued events resume; interrupted scripts are not replayed.`,disabled:E||p.status.review||t.status===`archived`||r,onClick:()=>void M({action:`recover`,input:{owner:d.data.recovery.owner,after:`owner-crash`}}).catch(()=>{})}),!w&&!d.data?.recovery&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(X,{icon:Je,label:`Start`,disabled:!te,onClick:()=>void j(`start`)}),u&&f.data?.definition.nodes.some(e=>O(e,f.data?.components[e.id])?.id===ue.id)&&(0,Y.jsx)(X,{icon:In,label:`Start and run`,disabled:!te,onClick:()=>void j(`start-and-run`)})]}),T&&(0,Y.jsxs)(Y.Fragment,{children:[u&&(0,Y.jsx)(X,{icon:Yn,label:`Active revision`,disabled:E||!T.target.activationId,onClick:()=>v(T.target)}),(0,Y.jsx)(X,{icon:Vt,label:`Apply saved`,disabled:!A,onClick:()=>void j(`apply`)}),T.lifecycle===`armed`?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(X,{icon:Je,label:`Run`,disabled:!k,onClick:()=>void j(`run`)})}):(0,Y.jsx)(X,{icon:Je,label:`Resume`,disabled:!k,onClick:()=>void M({action:`rearm`,input:{target:T.target}}).catch(()=>{})}),(0,Y.jsx)(X,{icon:Ze,label:`Stop`,disabled:!k,onClick:()=>void M({action:`stop`,input:{target:T.target}}).catch(()=>{})})]}),(0,Y.jsx)(X,{icon:ur,label:`Interrupt`,disabled:!k||T?.lifecycle!==`armed`,onClick:()=>{T?.lifecycle===`armed`&&M({action:`interrupt`,input:{target:T.target}}).catch(()=>{})}}),(0,Y.jsx)(X,{title:`${F}${T?.failure?` · ${T.failure}`:``}`,icon:en,label:p.status.review?`Inspect outcome`:`Inspect runtime`,disabled:E||d.isFetching,onClick:()=>void N()}),T?.trigger_inspection&&(0,Y.jsx)(X,{icon:Et,label:`Triggers`,onClick:()=>l(T.target)}),(T||a)&&(0,Y.jsx)(X,{icon:Qn,label:`History`,disabled:E,onClick:()=>T?b({owner:ua(T.target)}):s(!0)}),T&&T.auto_start!==void 0&&(0,Y.jsx)(Di,{enabled:T.auto_start,target:T.target,disabled:!k||t.status===`archived`||r,send:M})]})}),T?.custom_triggers&&!T.trigger_inspection&&(0,Y.jsx)(sa,{sources:T.custom_triggers}),c&&(0,Y.jsx)(Ei,{profile:e,session:t.id,target:c,focused:n,stale:D||!T||!la(T.target,c),onClose:()=>l(null)}),h&&(0,Y.jsx)(oa,{review:h,profile:e,session:t.id,worktree:t.worktree_path,blocked:P,pending:p.status.pending,error:p.status.error,send:M,onClose:()=>g(null)}),_&&(0,Y.jsx)(ca,{profile:e,session:t.id,target:_,stale:D||!T||!la(T.target,_),onClose:()=>v(null)}),o&&(0,Y.jsx)(ia,{profile:e,session:t.id,onClose:()=>s(!1)}),y&&(0,Y.jsx)(ta,{profile:e,session:t.id,owner:y.owner,initialExecution:y.execution,onRecordedRuntimes:a?()=>{b(null),s(!0)}:void 0,onClose:()=>b(null)})]})}function fa(e,t,n){let i=oi(e.id,re(e.huddle_id)[1],t),a=R().data?.protocol,o=(0,J.useMemo)(()=>{try{return{layout:_e.parse(JSON.parse(i.text))}}catch(e){return{error:e instanceof Error?e.message:`Invalid layout`}}},[i.text]),s=i.locked||!o.layout||!r(a,{major:28,minor:4}),c=i.buffer.model?.getAlternativeVersionId()??0,l=(e,t,r)=>{let a=i.buffer.model;if(s||!a||!n?.nodes.some(t=>t.id===e))return!1;if(a.getAlternativeVersionId()!==r)return W.error(`The layout changed while moving this node. Move it again from its current position.`),!1;try{let r=_e.parse(JSON.parse(a.getValue())),i=_e.parse({...r,nodes:Object.fromEntries(n.nodes.map((n,i)=>[n.id,n.id===e?t:r.nodes[n.id]??Br(i)]))});return a.pushStackElement(),mn(a,JSON.stringify(i,null,2)+`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{C as r}from"./protocol-support-DIWnYJkt.js";import{At as i,Bt as a,Ct as o,Dt as s,Et as c,Ft as l,Gn as u,Ht as d,It as f,Lt as p,Mt as m,Nt as h,Ot as g,Pt as _,Qt as v,Rt as y,St as b,Tt as x,Ut as S,Vt as C,Wt as w,Zt as T,_n as ee,_t as E,an as D,at as O,bt as k,cn as te,ct as A,dn as j,dt as M,en as N,ft as P,gt as F,hn as I,ht as ne,in as re,it as ie,jt as ae,kt as oe,ln as se,lt as ce,mn as le,mt as ue,n as de,on as fe,ot as pe,pn as me,pt as he,r as ge,sn as _e,st as ve,un as ye,vn as be,vt as xe,wt as Se,xt as Ce,yt as we,zt as Te}from"./local-store-DKFKEHML.js";import{r as Ee}from"./auth-BPXeEntX.js";import{n as L}from"./api-DhfvolrJ.js";import{Ft as De,J as Oe,Nt as ke,Rt as Ae,Tt as je,U as Me,b as R,bt as Ne,dt as Pe,et as Fe,ft as Ie,gt as Le,ht as Re,jt as ze,lt as Be,mt as Ve,ot as He,pt as Ue,s as We,st as z,ut as Ge,vt as Ke,y as qe}from"./queries-C9DYtGQW.js";import{J as Je,m as Ye,n as Xe,q as Ze}from"./editor-context-Bijx3uIG.js";import{c as Qe,r as $e,t as et}from"./square-terminal-CrlDquCd.js";import{t as tt}from"./utils-B6KiDbIe.js";import{a as nt,i as B,r as V,s as H,t as U}from"./dialog-DfdBRe6G.js";import{n as W}from"./dist-DMpqv5CF.js";import{t as rt}from"./x-CbfJFzGo.js";import{a as it,d as at,r as ot,u as st}from"./dist-CNoWjXWo.js";import{a as ct,i as lt,n as ut,r as dt,s as ft,t as pt}from"./select-DHaYbZVV.js";import{i as mt,n as ht,t as gt}from"./tooltip-CtT-5xHL.js";import{t as _t}from"./button-BNH9tKwf.js";import{n as G,r as vt}from"./chevron-right-6pjfw_yV.js";import{n as yt,o as K,r as bt,t as xt}from"./colour-picker-Dwq4M4eT.js";import{t as q}from"./createLucideIcon-DyMAgLa3.js";import{n as St}from"./profile-icons-BmQVYS_o.js";import{n as Ct,t as wt}from"./shield-check-CY69Ons-.js";import{a as Tt,n as Et,r as Dt,t as Ot}from"./switch-DZ2lisDt.js";import{t as kt}from"./code-DRWf9a5s.js";import{a as At,g as jt,p as Mt,s as Nt,t as Pt}from"./ReadOnlyDiff-BwUPy5CW.js";import{S as Ft,_ as It,a as Lt,b as Rt,c as zt,d as Bt,f as Vt,g as Ht,h as Ut,i as Wt,m as Gt,n as Kt,o as qt,p as Jt,r as Yt,t as Xt,u as Zt,v as Qt,x as $t,y as en}from"./state-BegCSQn_.js";import{n as tn,t as nn}from"./disclosure-oYVpfMYO.js";import{t as rn}from"./rotate-ccw-CNjR2LSi.js";import{t as an}from"./save-BT7q_AMN.js";import{t as on}from"./settings-2-CInoy48z.js";import{i as sn,t as cn}from"./profile-store-BnferXV3.js";import{t as ln}from"./control-tray-jUtkASPS.js";import{n as un,r as dn,t as fn}from"./popover-CNEMQBFf.js";import{r as pn}from"./view-state-store-Cr1BaTzj.js";import{r as mn}from"./buffer-logic-D9FvoilV.js";import{a as hn,m as gn,p as _n,s as vn,t as yn,u as bn}from"./buffer-store-OTFEYxTw.js";import{t as xn}from"./zoom-intent-vemBFIak.js";function Sn(e,t){let n=new TextEncoder,r=n.encode(e).length;if(r>128*1024)throw Error(`Prompt exceeds its byte limit`);return e.replace(/\{\{\s*input((?:\.[a-zA-Z0-9_-]+)*)\s*\}\}/g,(e,i)=>{let a=t;for(let e of i.split(`.`).filter(Boolean)){if(!a||typeof a!=`object`||!Object.hasOwn(a,e))throw Error(`Missing prompt input field: `+i);a=a[e]}let o=typeof a==`string`?a:JSON.stringify(a);if(o===void 0)throw Error(`Missing prompt input value`);if(r+=n.encode(o).length-n.encode(e).length,r>128*1024)throw Error(`Prompt exceeds its byte limit`);return o})}function Cn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function wn(e,t,n){let r=e.slice(0);return r[t]=n,r}var Tn=class extends Ae{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,je.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!De(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Cn(e,n).forEach(e=>{e.destroy()}),Cn(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=ke(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Ne(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=wn(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&je.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},J=e(t(),1);function En({queries:e,...t},n){let r=Ke(n),i=Le(),a=Re(),o=J.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Be(e);let t=r.getQueryCache().get(e.queryHash);Ie(e,a,t)}),Ve(a);let[s]=J.useState(()=>new Tn(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;J.useSyncExternalStore(J.useCallback(e=>d?s.subscribe(je.batchCalls(e)):ze,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),J.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Pe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Pe(n,e)?Ge(n,new Ne(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Ue({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var Dn=q(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),On=q(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),kn=q(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),An=q(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),jn=q(`calendar-check`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`m9 16 2 2 4-4`,key:`19s6y9`}]]),Mn=q(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),Nn=q(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Pn=q(`calendar-range`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M17 14h-6`,key:`bkmgh3`}],[`path`,{d:`M13 18H7`,key:`bb0bb7`}],[`path`,{d:`M7 14h.01`,key:`1qa3f1`}],[`path`,{d:`M17 18h.01`,key:`1bdyru`}]]),Fn=q(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),In=q(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ln=q(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),Rn=q(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),zn=q(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Bn=q(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Vn=q(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),Hn=q(`file-input`,[[`path`,{d:`M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-1`,key:`1q9hii`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 15h10`,key:`jfw4w8`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Un=q(`file-output`,[[`path`,{d:`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`,key:`wfxp4w`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 11-3 3`,key:`1dgrs4`}],[`path`,{d:`m5 17-3-3h10`,key:`1mvvaf`}]]),Wn=q(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Gn=q(`focus`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),Kn=q(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),qn=q(`folder-output`,[[`path`,{d:`M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5`,key:`1yk7aj`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m5 10-3 3 3 3`,key:`1r8ie0`}]]),Jn=q(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),Yn=q(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),Xn=q(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Zn=q(`hard-drive`,[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]),Qn=q(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),$n=q(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),er=q(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),tr=q(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),nr=q(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),rr=q(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),ir=q(`merge`,[[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}],[`path`,{d:`M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22`,key:`1hyw0i`}],[`path`,{d:`m20 22-5-5`,key:`1m27yz`}]]),ar=q(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),or=q(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),sr=q(`package-open`,[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]),cr=q(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),lr=q(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),ur=q(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),dr=q(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),fr=q(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),pr=q(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),mr=q(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),hr=q(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),gr=q(`scan`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),_r=q(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),vr=q(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),yr=q(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),br=q(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),xr=q(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),Sr=q(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),Cr=q(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),wr=q(`webhook`,[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]),Tr=q(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Y=n();function X({icon:e,label:t,title:n,className:r,...i}){return(0,Y.jsxs)(gt,{children:[(0,Y.jsx)(mt,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":t,className:tt(ot,r),...i,children:(0,Y.jsx)(e,{className:`size-4`})})}),(0,Y.jsx)(ht,{side:`bottom`,children:n??t})]})}var Z=`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`;function Er({title:e,label:t=e,onClose:n,children:r}){return(0,Y.jsxs)(`aside`,{"aria-label":t,"data-state":`open`,className:`${at} ${st} absolute right-3 top-[var(--huddle-toolbar-bottom,4rem)] bottom-16 z-20 flex w-80 max-w-[calc(100%-1.5rem)] flex-col overflow-hidden text-sm`,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.stopPropagation(),n())},children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-4 py-2`,children:[(0,Y.jsx)(`h2`,{className:`min-w-0 truncate`,children:e}),(0,Y.jsx)(X,{label:`Close ${t.toLowerCase()}`,icon:rt,onClick:n})]}),(0,Y.jsx)(`div`,{className:`no-scrollbar min-h-0 overflow-y-auto overscroll-contain px-3 pb-3`,children:r})]})}function Q({id:e,label:t,value:n,onValueChange:r,options:i,placeholder:a,disabled:o}){return(0,Y.jsxs)(pt,{value:i.some(e=>e.value===n)?`value:${n}`:``,onValueChange:e=>r(e.slice(6)),disabled:o,children:[(0,Y.jsx)(lt,{"data-value":n,id:e,"aria-label":t,className:`min-w-0`,children:(0,Y.jsx)(ct,{placeholder:a})}),(0,Y.jsx)(ut,{children:i.map(e=>(0,Y.jsx)(dt,{"data-value":e.value,value:`value:${e.value}`,disabled:e.disabled,children:e.label},e.value))})]})}function Dr(e,t){let n=new Set(e.map(e=>e.id));if(!n.has(t))return t;for(let e=2;;e++)if(!n.has(`${t}-${e}`))return`${t}-${e}`}function Or(e,t,n,r){let i=te.parse({id:Dr(e.nodes,n),source:t,...r?{appearance:r}:{}});return{...e,nodes:[...e.nodes,i]}}function kr(e,t){let{triggerAdmission:n,...r}=e.execution,i={...n};return delete i[t],{...e,nodes:e.nodes.filter(e=>e.id!==t),edges:e.edges.filter(e=>e.from.node!==t&&e.to.node!==t),execution:{...r,...Object.keys(i).length?{triggerAdmission:i}:{}}}}function Ar(e,t,n){let r=e.components[t.node]?.outputs[t.port],i=e.components[n.node]?.inputs[n.port];if(!e.definition.nodes.some(e=>e.id===t.node)||!r)return`The output no longer exists.`;if(!e.definition.nodes.some(e=>e.id===n.node)||!i)return`The input no longer exists.`;if(e.definition.edges.some(e=>e.from.node===t.node&&e.from.port===t.port&&e.to.node===n.node&&e.to.port===n.port))return`This connection already exists.`;if(A(r.schema,i.schema)===`incompatible`)return`These ports have incompatible types.`}function jr(e,t,n){let r=Ar(e,t,n);if(r)throw Error(r);return{...e.definition,edges:[...e.definition.edges,{id:Dr(e.definition.edges,`connection`),from:t,to:n}]}}function Mr(e,t=[]){return!e||t.length>16?[]:e.type===`boolean`&&t.length?[t]:Object.entries(e.properties??{}).flatMap(([e,n])=>Mr(n,[...t,e]))}function Nr({edge:e,schema:t,edit:n}){let r=(0,J.useId)(),i=Mr(t),[a,o]=(0,J.useState)(null),s=t=>n(n=>({...n,edges:n.edges.map(n=>{if(n.id!==e.id)return n;let{feedback:r,...i}=n;return t?{...i,feedback:t}:i})}));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 text-xs`,children:[(0,Y.jsxs)(`label`,{htmlFor:`${r}-enabled`,className:`flex cursor-pointer items-center gap-2`,children:[(0,Y.jsx)(Ot,{id:`${r}-enabled`,checked:!!e.feedback,disabled:!e.feedback&&!i.length,onCheckedChange:e=>s(e?{maxRounds:5,while:{path:i[0],equals:!1}}:void 0)}),`Bounded feedback`]}),e.feedback&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{htmlFor:`${r}-condition`,children:`Continue while`}),(0,Y.jsx)(Q,{id:`${r}-condition`,value:JSON.stringify(e.feedback.while.path),onValueChange:t=>s({...e.feedback,while:{...e.feedback.while,path:JSON.parse(t)}}),options:[...i.some(t=>JSON.stringify(t)===JSON.stringify(e.feedback.while.path))?[]:[{value:JSON.stringify(e.feedback.while.path),label:`${e.feedback.while.path.join(`.`)} · unavailable`}],...i.map(e=>({value:JSON.stringify(e),label:e.join(`.`)}))]}),(0,Y.jsx)(Q,{label:`Feedback condition value`,value:String(e.feedback.while.equals),onValueChange:t=>s({...e.feedback,while:{...e.feedback.while,equals:t===`true`}}),options:[{value:`false`,label:`False`},{value:`true`,label:`True`}]}),(0,Y.jsx)(K,{htmlFor:`${r}-rounds`,children:`Maximum rounds`}),(0,Y.jsx)(G,{id:`${r}-rounds`,type:`number`,min:1,max:1e3,value:a??String(e.feedback.maxRounds),onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:()=>{let t=Number(a);a!==null&&Number.isInteger(t)&&t>=1&&t<=1e3&&s({...e.feedback,maxRounds:t}),o(null)}})]})]})}var $=`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`;function Pr({graph:e,edit:t}){let n=(0,J.useId)(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),s=t=>e.definition.nodes.flatMap(n=>Object.keys(e.components[n.id]?.[t]??{}).map(e=>({node:n.id,port:e}))),c=s(`outputs`),l=s(`inputs`),u=c.find(e=>JSON.stringify(e)===r),d=l.find(e=>JSON.stringify(e)===a);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-label":`Edit connections`,children:[(0,Y.jsx)(K,{htmlFor:`${n}-output`,children:`Output`}),(0,Y.jsx)(Q,{id:`${n}-output`,value:u?r:``,onValueChange:i,placeholder:`Choose output`,options:c.map(e=>({value:JSON.stringify(e),label:`${e.node}.${e.port}`}))}),(0,Y.jsx)(K,{htmlFor:`${n}-input`,children:`Input`}),(0,Y.jsx)(Q,{id:`${n}-input`,value:d?a:``,onValueChange:o,placeholder:`Choose input`,options:l.map(e=>({value:JSON.stringify(e),label:`${e.node}.${e.port}`}))}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!u||!d,onClick:()=>{u&&d&&t(t=>jr({...e,definition:t},u,d))},children:`Connect`}),e.definition.edges.map(n=>(0,Y.jsxs)(`div`,{className:`${Z} flex flex-col gap-2 text-xs`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[n.from.node,`.`,n.from.port,` → `,n.to.node,`.`,n.to.port]}),(0,Y.jsx)(Nr,{edge:n,schema:e.components[n.from.node]?.outputs[n.from.port]?.schema,edit:t}),(0,Y.jsx)(`button`,{type:`button`,className:$,"aria-label":`Disconnect ${n.id}`,onClick:()=>t(e=>({...e,edges:e.edges.filter(e=>e.id!==n.id)})),children:`Disconnect`})]},n.id))]})}function Fr({value:e,fallback:t,disabled:n,rename:r}){let i=(0,J.useId)(),[a,o]=(0,J.useState)(null);return(0,Y.jsxs)(`form`,{className:`${Z} flex flex-col gap-2`,onSubmit:t=>{t.preventDefault(),n||(r(a??e),o(null))},children:[(0,Y.jsx)(K,{htmlFor:i,children:`Node name`}),(0,Y.jsx)(G,{id:i,value:a??e,placeholder:t,maxLength:200,disabled:n,onChange:e=>o(e.target.value)}),(0,Y.jsx)(`button`,{type:`submit`,className:$,disabled:n||a===null,children:`Rename node`}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Renaming requires a host supporting node labels.`})]})}var Ir=e=>({x:e.reduce((e,t)=>e+t.x,0)/e.length,y:e.reduce((e,t)=>e+t.y,0)/e.length}),Lr=e=>e.length<2?1:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y);function Rr(e,t,n){let r=(0,J.useRef)(new Map),i=(0,J.useRef)(!1),a=(0,J.useRef)(!1),o=(0,J.useRef)({x:0,y:0}),s=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let n=e.current,i=xn(n.ownerDocument.defaultView);s.current=i;let a=e=>{e.preventDefault();let a=i.wheel(e);if(a===`ignore`||r.current.size>1)return;let o=e.deltaMode===1?16:e.deltaMode===2?n.clientHeight:1;if(a===`zoom`){let r=n.getBoundingClientRect(),i={x:e.clientX-r.left,y:e.clientY-r.top};t.current?.gesture(Math.exp(-e.deltaY*o*.005),i,i)}else t.current?.gesture(1,{x:0,y:0},{x:-(e.shiftKey&&!e.deltaX?e.deltaY:e.deltaX)*o,y:e.shiftKey&&!e.deltaX?0:-e.deltaY*o})};return n.addEventListener(`wheel`,a,{passive:!1}),()=>{n.removeEventListener(`wheel`,a),i.dispose(),s.current=null}},[e,t]);let c=t=>{let n=e.current.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},l=e=>{r.current.delete(e.pointerId),a.current&&e.stopPropagation(),r.current.size||(i.current=!1,e.currentTarget.style.cursor=``)};return{onPointerDownCapture(e){if(![0,1].includes(e.button))return;r.current.size||(a.current=!1),r.current.set(e.pointerId,c(e));let t=!e.target.closest(`button, [data-huddle-node]`);r.current.size>=2&&(a.current||(o.current=Ir([...r.current.values()])),a.current=!0,n()),(t||a.current||e.button===1)&&(e.preventDefault(),e.stopPropagation(),i.current=!0,e.currentTarget.style.cursor=`grabbing`,e.currentTarget.setPointerCapture(e.pointerId),t&&e.currentTarget.focus({preventScroll:!0}))},onPointerMoveCapture(e){if(!r.current.has(e.pointerId))return;let n=[...r.current.values()];if(r.current.set(e.pointerId,c(e)),!i.current)return;e.preventDefault(),e.stopPropagation();let l=[...r.current.values()];a.current?(s.current?.suppressPan(),l.length>=2&&t.current?.gesture(Lr(l)/Math.max(1,Lr(n)),o.current,o.current)):!e.metaKey&&!e.ctrlKey&&!s.current?.panBlocked()&&t.current?.gesture(1,Ir(n),Ir(l))},onPointerUpCapture:l,onPointerCancelCapture:l,onLostPointerCaptureCapture:l,onClickCapture(e){a.current&&(e.preventDefault(),e.stopPropagation())},onKeyDown(e){if(e.target!==e.currentTarget)return;let n={ArrowLeft:[64,0],ArrowRight:[-64,0],ArrowUp:[0,64],ArrowDown:[0,-64]}[e.key];n&&(e.preventDefault(),t.current?.gesture(1,{x:0,y:0},{x:n[0],y:n[1]}))}}}function zr({locked:e,canUndo:t,canRedo:n,undo:r,redo:i,selected:a,fit:o,zoom:s,setZoom:c}){return(0,Y.jsx)(`div`,{className:`absolute bottom-3 left-3 z-10 max-w-[calc(100%-1.5rem)]`,children:(0,Y.jsxs)(ln,{label:`Graph navigation`,variant:`island`,className:`max-w-full flex-wrap`,children:[(0,Y.jsx)(X,{label:`Undo move`,icon:Jt,onClick:r,disabled:e||!t}),(0,Y.jsx)(X,{label:`Redo move`,icon:pr,onClick:i,disabled:e||!n}),(0,Y.jsx)(X,{label:`Fit graph`,icon:gr,onClick:()=>o(!1)}),(0,Y.jsx)(X,{label:`Fit selected`,icon:Gn,disabled:!a,onClick:()=>o(!0)}),(0,Y.jsx)(X,{label:`Zoom out`,icon:Ut,onClick:()=>c(Math.max(.001,s/1.25))}),(0,Y.jsxs)(`button`,{type:`button`,className:`px-2 text-xs tabular-nums`,"aria-label":`Reset zoom`,onClick:()=>c(1),children:[Math.round(s*100),`%`]}),(0,Y.jsx)(X,{label:`Zoom in`,icon:tn,onClick:()=>c(Math.min(2,s*1.25))})]})})}function Br(e){return{x:e%3*320,y:Math.floor(e/3)*220}}function Vr(e,t,n){let r=e=>Math.min(1e6,Math.max(-1e6,Math.round(e)));return{x:r(e.x+t),y:r(e.y+n)}}function Hr(e,t){return!!t&&e.x<=t.right&&e.right>=t.x&&e.y<=t.bottom&&e.bottom>=t.y}function Ur(e,t,n){return{...e,right:e.x+240,bottom:e.y+90+24*Math.max(t,n)}}function Wr(e,t){return{x:Math.min(e.x,t.x-80,t.x),right:Math.max(e.x,e.x+80,t.x),y:Math.min(e.y,t.y),bottom:Math.max(e.y,t.y)}}function Gr(e,t){return!e.clientWidth||!e.clientHeight?null:{x:(e.scrollLeft-200)/t,y:(e.scrollTop-200)/t,right:(e.scrollLeft+e.clientWidth+200)/t,bottom:(e.scrollTop+e.clientHeight+200)/t}}function Kr(e,t){return`M ${e.x} ${e.y} C ${e.x+80} ${e.y}, ${t.x-80} ${t.y}, ${t.x} ${t.y}`}function qr({edges:e,width:t,height:n,socket:r,selected:i,select:a,locked:o,disconnect:s,wire:c,visible:l,focused:u}){let d=c.pending&&r(c.pending.from,`outputs`);return(0,Y.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 text-fg-muted`,width:t,height:n,children:[e.map(e=>{let t=r(e.from,`outputs`),n=r(e.to,`inputs`);if(!t||!n||e.id!==i&&e.id!==u&&!Hr(Wr(t,n),l))return null;let d=Kr(t,n);return(0,Y.jsxs)(`g`,{"data-huddle-edge":e.id,children:[(0,Y.jsx)(`path`,{d,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,"aria-hidden":!0,className:i===e.id?`text-accent`:void 0,strokeDasharray:e.feedback?`5 4`:void 0}),(0,Y.jsx)(`path`,{d,fill:`none`,stroke:`transparent`,strokeWidth:14,vectorEffect:`non-scaling-stroke`,className:`pointer-events-auto cursor-pointer hover:stroke-accent/30 focus-visible:stroke-accent/30 focus-visible:outline-none`,role:`button`,tabIndex:0,"aria-pressed":i===e.id,"aria-label":`Connection ${e.from.node}.${e.from.port} to ${e.to.node}.${e.to.port}`,onPointerDown:e=>e.stopPropagation(),onClick:()=>{c.pending&&c.cancel(),a(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id)),(t.key===`Delete`||t.key===`Backspace`)&&!o&&(t.preventDefault(),s(e.id))},children:(0,Y.jsx)(`title`,{children:`Select connection; Delete disconnects`})})]},e.id)}),d&&c.pending?.point&&(0,Y.jsx)(`path`,{d:Kr(d,c.pending.point),fill:`none`,stroke:`currentColor`,"aria-hidden":!0,strokeWidth:1.5,strokeDasharray:`5 4`,className:`text-accent`})]})}var Jr=[{name:`play`,Icon:Je},{name:`clock`,Icon:zn},{name:`calendar-days`,Icon:Nn},{name:`calendar-clock`,Icon:Mn},{name:`calendar-range`,Icon:Pn},{name:`folder-tree`,Icon:$t},{name:`git-branch`,Icon:Rt},{name:`activity`,Icon:Dn},{name:`message-square`,Icon:ar},{name:`check-check`,Icon:Fn},{name:`rotate-ccw`,Icon:rn},{name:`plus`,Icon:tn},{name:`file-output`,Icon:Un},{name:`code`,Icon:kt},{name:`type`,Icon:Sr},{name:`git-fork`,Icon:Xn},{name:`merge`,Icon:ir},{name:`combine`,Icon:jt},{name:`radio`,Icon:fr},{name:`braces`,Icon:kn},{name:`file-code`,Icon:Ft},{name:`workflow`,Icon:Tr},{name:`network`,Icon:or},{name:`route`,Icon:hr},{name:`split`,Icon:vr},{name:`filter`,Icon:Jn},{name:`repeat`,Icon:mr},{name:`shuffle`,Icon:_r},{name:`list-checks`,Icon:nr},{name:`check`,Icon:ft},{name:`square`,Icon:Ze},{name:`pause`,Icon:ur},{name:`timer`,Icon:xr},{name:`hourglass`,Icon:$n},{name:`calendar-check`,Icon:jn},{name:`clipboard-check`,Icon:Ln},{name:`clipboard-list`,Icon:Rn},{name:`database`,Icon:Bn},{name:`table`,Icon:yr},{name:`layers`,Icon:tr},{name:`boxes`,Icon:On},{name:`package`,Icon:cr},{name:`package-open`,Icon:sr},{name:`file-input`,Icon:Hn},{name:`file-json`,Icon:Vn},{name:`file-text`,Icon:Wn},{name:`folder-input`,Icon:Kn},{name:`folder-output`,Icon:qn},{name:`hard-drive`,Icon:Zn},{name:`terminal`,Icon:br},{name:`square-terminal`,Icon:et},{name:`webhook`,Icon:wr},{name:`plug`,Icon:dr},{name:`cable`,Icon:An},{name:`link`,Icon:Qt},{name:`unlink`,Icon:Cr},{name:`send`,Icon:Gt},{name:`inbox`,Icon:er},{name:`bell`,Icon:Ct},{name:`mail`,Icon:rr},{name:`shield-check`,Icon:wt},{name:`lock`,Icon:Ht},{name:`settings2`,Icon:on}],Yr={...St,...Object.fromEntries(Jr.map(({name:e,Icon:t})=>[e,t]))};function Xr({value:e,onSelect:t}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,"aria-label":`Node icons`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Default node icon`,className:ot,onClick:()=>t(null),children:(0,Y.jsx)(Bt,{className:`size-4`})}),Jr.map(({name:n,Icon:r})=>(0,Y.jsx)(`button`,{type:`button`,title:n,"aria-label":n,"aria-pressed":e===n,className:ot,onClick:()=>t(n),children:(0,Y.jsx)(r,{className:`size-4`})},n))]})}function Zr({title:e,label:t,icon:n,selected:r,canRename:i,locked:a,rename:o,changeIcon:s,onKeyDown:c}){let[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(!1),p=(0,J.useRef)(!1),m=(0,J.useRef)(null),h=(0,J.useRef)(!1),g=(0,J.useRef)(null),_=l!==null;(0,J.useLayoutEffect)(()=>{if(_){let e=m.current?.querySelector(`input`);e?.focus({preventScroll:!0}),e?.select()}else h.current&&g.current?.focus({preventScroll:!0});h.current=_},[_]);let v=()=>{p.current&&(p.current=!1,l!==null&&l.trim()!==e&&o(l),u(null))},y=n&&Yr[n]||Bt;return(0,Y.jsxs)(`div`,{ref:m,className:`mb-1 flex h-8 items-center gap-2`,"data-node-identity":!0,children:[(0,Y.jsxs)(fn,{open:d,onOpenChange:f,children:[(0,Y.jsx)(dn,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Change icon for ${e}`,disabled:a,className:`flex size-7 shrink-0 cursor-grab items-center justify-center rounded-md hover:bg-explorer-hover disabled:opacity-50`,children:(0,Y.jsx)(y,{className:`size-4`})})}),(0,Y.jsx)(un,{className:`w-80`,onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsx)(Xr,{value:n,onSelect:e=>{s(e),f(!1)}})})]}),_?(0,Y.jsx)(G,{"aria-label":`Node name`,"data-node-control":!0,maxLength:200,className:`h-8 min-w-0 flex-1`,value:l,onChange:e=>u(e.target.value),onBlur:v,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),v()),e.key===`Escape`&&(e.preventDefault(),p.current=!1,u(null))}}):(0,Y.jsx)(`button`,{ref:g,type:`button`,"data-node-name":!0,"aria-label":t,"aria-pressed":r,title:`Rename node`,onKeyDown:c,className:`flex h-8 min-w-0 flex-1 cursor-grab touch-none items-center rounded-md text-left text-sm transition-colors hover:bg-explorer-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>{if(!i){W.warning(`Node renaming requires a supporting host and an editable layout.`);return}p.current=!0,u(e)},children:(0,Y.jsx)(`span`,{className:`truncate`,children:e})})]})}function Qr({node:e,title:t,rename:n,changeIcon:r,canRename:i,contract:a,position:o,shown:s,selected:c,locked:l,version:u,drag:d,wire:f,onSelect:p,move:m,undo:h,redo:g,onDelete:_}){let v=Object.keys(a?.inputs??{}),y=Object.keys(a?.outputs??{}),b=e.appearance??a?.appearance,x=!!b?.colour,S=`flex h-6 max-w-full items-center gap-2 rounded-sm text-xs hover:bg-explorer-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;return(0,Y.jsxs)(`div`,{"data-huddle-node":e.id,className:tt(`island-outline absolute w-60 touch-none select-none rounded-xl p-3`,!l&&(d.preview?.id===e.id?`cursor-grabbing`:`cursor-grab`),c?`bg-elevated text-accent`:`bg-surface text-fg`,yt(b?.colour)),style:{left:s.x,top:s.y,...bt(b?.colour),...x?{backgroundColor:`color-mix(in srgb, currentColor ${c?14:7}%, var(--bg-surface))`,outlineColor:`color-mix(in srgb, currentColor 35%, var(--border))`}:{}},...d.handlers(e.id,o),onClickCapture:e=>{d.suppressClick()&&(e.preventDefault(),e.stopPropagation())},onClick:t=>{t.currentTarget.contains(t.target)&&!t.target.closest(`button, input`)&&p(e.id)},children:[(0,Y.jsx)(Zr,{title:t,label:[t,...v,...y,...!v.length&&!y.length?[a?.category??`Unresolved component`]:[]].join(` `),icon:b?.icon,selected:c,canRename:i,locked:l,rename:n,changeIcon:r,onKeyDown:t=>{if(t.key===`Escape`){d.cancel();return}if((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()===`z`){t.preventDefault(),t.shiftKey?g():h();return}if(t.key===`Delete`||t.key===`Backspace`){t.preventDefault(),_(e.id);return}let n={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[t.key];if(!n||l)return;t.preventDefault(),p(e.id);let r=t.shiftKey?50:10;m(e.id,Vr(o,n[0]*r,n[1]*r),u)}}),(0,Y.jsxs)(`div`,{className:tt(`flex justify-between gap-3`,x?`text-current`:`text-fg-muted`),children:[(0,Y.jsx)(`div`,{className:`min-w-0`,children:v.map(t=>{let n={node:e.id,port:t},r=f.problem(n);return(0,Y.jsxs)(`button`,{type:`button`,"data-huddle-socket":!0,"aria-label":`Input ${e.id}.${t}`,title:r??`Input ${e.id}.${t}${a?.inputs[t]?.scope===`execution`?` · retained for this execution`:``}`,"aria-description":a?.inputs[t]?.scope===`execution`?`Retained for this execution, including feedback rounds`:void 0,...f.input(n),className:tt(S,f.pending&&!r&&`text-accent`,f.pending&&r&&`opacity-50`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-current`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t})]},t)})}),(0,Y.jsx)(`div`,{className:`min-w-0`,children:y.map(t=>(0,Y.jsxs)(`button`,{type:`button`,"data-huddle-socket":!0,"aria-label":`Output ${e.id}.${t}`,...f.output({node:e.id,port:t}),className:tt(S,`ml-auto touch-none justify-end disabled:opacity-50`),children:[(0,Y.jsx)(`span`,{className:`truncate`,children:t}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-current`})]},t))})]}),!v.length&&!y.length&&(0,Y.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a?.category??`Unresolved component`})]})}function $r({graph:e,version:t,locked:n,canvas:r,connect:i}){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(``),l=(0,J.useRef)(null),u=(0,J.useRef)(!1),d=!n&&a?.version===t?a:null,f=()=>{o(null),l.current=null},p=t=>{if(!d){f();return}let n=Ar(e,d.from,t);if(n){o({...d,point:void 0}),c(n);return}if(!i(d.from,t,d.version)){f(),c(`Connection was not added. Choose the output again.`);return}c(`Connected ${d.from.node}.${d.from.port} to ${t.node}.${t.port}.`),f()},m=e=>{let t=r.current;if(!t)return;let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)*t.offsetWidth/n.width,y:(e.clientY-n.top)*t.offsetHeight/n.height}};return{pending:d,message:a&&!d?`Connection cancelled because the graph changed.`:s,cancel:()=>{f(),u.current=!0,c(`Connection cancelled.`)},input(e){return{"data-huddle-input-node":e.node,"data-huddle-input-port":e.port,"aria-disabled":n,onClick(){n||p(e)}}},output(e){return{"aria-pressed":d?.from.node===e.node&&d.from.port===e.port,disabled:n,onClick(n){if(u.current&&n.detail!==0){u.current=!1;return}o({from:e,version:t}),c(`Choose an input for ${e.node}.${e.port}. Escape cancels.`)},onPointerDown(r){n||r.button!==0||!r.isPrimary||(r.stopPropagation(),u.current=!1,r.currentTarget.setPointerCapture(r.pointerId),l.current={id:r.pointerId,x:r.clientX,y:r.clientY,moved:!1},o({from:e,version:t}),c(`Choose an input for ${e.node}.${e.port}. Escape cancels.`))},onPointerMove(e){let t=l.current;if(!(!t||t.id!==e.pointerId)){if(!d){f(),u.current=!0;return}!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<4||(t.moved=!0,o({...d,point:m(e)}))}},onPointerUp(e){let t=l.current;if(!(!t||t.id!==e.pointerId)){if(l.current=null,t.moved){u.current=!0;let t=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-huddle-input-node]`);t&&r.current?.contains(t)?p({node:t.dataset.huddleInputNode,port:t.dataset.huddleInputPort}):(f(),c(`Connection cancelled. Drop on an input socket.`))}e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}},onPointerCancel(){f(),u.current=!0,c(`Connection cancelled.`)},onLostPointerCapture(){l.current&&(f(),u.current=!0)}}},problem(t){return d?Ar(e,d.from,t):void 0}}}function ei({viewport:e,zoom:t,version:n,locked:r,move:i,select:a}){let o=(0,J.useRef)(!1),s=(0,J.useRef)(null),[c,l]=(0,J.useState)(null),u=(t,n)=>Vr(t.origin,(n.clientX-t.x+(e.current?.scrollLeft??0)-t.scrollX)/t.zoom,(n.clientY-t.y+(e.current?.scrollTop??0)-t.scrollY)/t.zoom),d=()=>{s.current=null,l(null)};return{preview:c,cancel:d,suppressClick:()=>{let e=o.current;return o.current=!1,e},handlers:(c,f)=>({onPointerDown(i){if(i.button!==0||!i.isPrimary||r||!i.currentTarget.contains(i.target)||i.target.closest(`[data-huddle-socket], [data-node-control]`))return;i.stopPropagation(),o.current=!1,(i.currentTarget.querySelector(`[data-node-name]`)??i.currentTarget).focus({preventScroll:!0});let l=i.target.closest(`button`)??i.currentTarget;l.setPointerCapture(i.pointerId),s.current={captured:l,id:c,origin:f,pointer:i.pointerId,x:i.clientX,y:i.clientY,scrollX:e.current?.scrollLeft??0,scrollY:e.current?.scrollTop??0,zoom:t,version:n,moved:!1},i.target.closest(`[data-node-identity]`)||a(c)},onPointerMove(e){let t=s.current;if(!(!t||t.pointer!==e.pointerId)){if(r||n!==t.version){d();return}!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<4||(t.moved=!0,o.current=!0,l({id:c,position:u(t,e)}))}},onPointerUp(e){let t=s.current;!t||t.pointer!==e.pointerId||(t.moved&&!r&&i(c,u(t,e),t.version),d(),t.captured.hasPointerCapture(e.pointerId)&&t.captured.releasePointerCapture(e.pointerId))},onPointerCancel:d,onLostPointerCapture:d})}}function ti(e,t,n,r,i){let a=n??{x:t.left,y:t.top,zoom:1},o={left:e.scrollLeft,top:e.scrollTop},s=``,c=()=>[e.clientWidth,e.clientHeight,e.scrollWidth,e.scrollHeight].join(`:`),l=()=>e.clientWidth>0&&e.clientHeight>0,u=()=>{l()&&(s=c(),e.scrollLeft=(a.x-t.left)*a.zoom,e.scrollTop=(a.y-t.top)*a.zoom,o={left:e.scrollLeft,top:e.scrollTop})},d=()=>{if(l()){if(s!==c()){u();return}e.scrollLeft===o.left&&e.scrollTop===o.top||(a={zoom:a.zoom,x:e.scrollLeft/a.zoom+t.left,y:e.scrollTop/a.zoom+t.top},o={left:e.scrollLeft,top:e.scrollTop},r(a))}},f=e=>{a=e,r(a),i(a.zoom),u()};u(),e.addEventListener(`scroll`,d,{passive:!0});let p=new ResizeObserver(u);return p.observe(e),{geometry:e=>{t=e,u()},zoom:e=>{Number.isFinite(e)&&(d(),f({...a,zoom:Math.min(2,Math.max(.001,e))}))},gesture:(e,t,n)=>{if(!Number.isFinite(e)||e<=0)return;d();let r=Math.min(2,Math.max(.001,a.zoom*e));f({zoom:r,x:a.x+t.x/a.zoom-n.x/r,y:a.y+t.y/a.zoom-n.y/r})},fit:t=>{if(!l())return;let n=Math.min(2,Math.max(.001,Math.min((e.clientWidth-64)/Math.max(1,t.right-t.x),(e.clientHeight-64)/Math.max(1,t.bottom-t.y))));f({zoom:n,x:t.x-(e.clientWidth/n-(t.right-t.x))/2,y:t.y-(e.clientHeight/n-(t.bottom-t.y))/2})},dispose:()=>{d(),p.disconnect(),e.removeEventListener(`scroll`,d)}}}function ni(e,t,{left:n,top:r,width:i,height:a}){let[o,s]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{let n=e.current,r,i=()=>{r=void 0;let e=Gr(n,t);s(t=>t?.x===e?.x&&t?.y===e?.y&&t?.right===e?.right&&t?.bottom===e?.bottom?t:e)},a=()=>{r===void 0&&(r=requestAnimationFrame(i))};i(),n.addEventListener(`scroll`,a,{passive:!0});let o=new ResizeObserver(a);return o.observe(n),()=>{n.removeEventListener(`scroll`,a),o.disconnect(),r!==void 0&&cancelAnimationFrame(r)}},[e,t,n,r,i,a]),o}function ri(){let[e,t]=(0,J.useState)({}),n=(e,n)=>{let r=n instanceof Element&&e.contains(n)?n:null,i=r?.closest(`[data-huddle-node]`)?.getAttribute(`data-huddle-node`)??void 0,a=r?.closest(`[data-huddle-edge]`)?.getAttribute(`data-huddle-edge`)??void 0;t(e=>e.node===i&&e.edge===a?e:{node:i,edge:a})};return{focused:e,handlers:{onFocusCapture:e=>n(e.currentTarget,e.target),onBlurCapture:e=>n(e.currentTarget,e.relatedTarget)}}}function ii({document:e,selected:t,onSelect:n,rename:r,changeIcon:i,canRename:a,move:o,version:s,locked:c,undo:l,redo:u,canUndo:d,canRedo:f,onDelete:p,connect:m,graphVersion:h,graphLocked:g,disconnect:_,camera:v,rememberCamera:y,selectedEdge:b,setSelectedEdge:x}){let[S]=(0,J.useState)(v),[C,w]=(0,J.useState)(v?.zoom??1),T=(0,J.useRef)(null),ee=(0,J.useRef)(null),E=ri(),D=$r({graph:e,version:h,locked:g,canvas:ee,connect:m}),O=(0,J.useRef)(null),k=ei({viewport:O,zoom:C,version:s,locked:c,move:o,select:n}),te=Rr(O,T,()=>{k.cancel(),D.pending&&D.cancel()}),A=e.definition.nodes.map((t,n)=>{let r=e.components[t.id];return{node:t,contract:r,position:e.layout?.nodes[t.id]??Br(n),inputs:Object.keys(r?.inputs??{}),outputs:Object.keys(r?.outputs??{})}}),j=1600/C,M={x:Math.min(0,...A.map(({position:e})=>e.x))-32,y:Math.min(0,...A.map(({position:e})=>e.y))-32},N=M.x-j,P=M.y-j,F=Math.max(640,...A.map(({position:e})=>e.x-N+272+j)),I=Math.max(400,...A.map(({position:e,inputs:t,outputs:n})=>e.y-P+j+90+Math.max(t.length,n.length)*24)),[ne]=(0,J.useState)({left:N,top:P,width:F,height:I});(0,J.useLayoutEffect)(()=>{let e=ti(O.current,ne,S??{x:ne.left+1600,y:ne.top+1600,zoom:1},y,w);return T.current=e,()=>{e.dispose(),T.current=null}},[S,ne,y]),(0,J.useLayoutEffect)(()=>{T.current?.geometry({left:N,top:P,width:F,height:I})},[N,P,F,I,C]);let re=ni(O,C,{left:N,top:P,width:F,height:I}),ie=new Map(A.map(e=>[e.node.id,e])),ae=(e,t)=>k.preview?.id===e?k.preview.position:t;return(0,Y.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,onKeyDown:e=>{e.key===`Escape`&&D.cancel()},children:[(0,Y.jsx)(zr,{locked:c,canUndo:d,canRedo:f,undo:l,redo:u,selected:t,fit:e=>{let n=O.current,r=A.filter(n=>!e||n.node.id===t);if(!n||!r.length)return;let i=Math.min(...r.map(e=>e.position.x)),a=Math.min(...r.map(e=>e.position.y)),o=Math.max(...r.map(e=>e.position.x+240)),s=Math.max(...r.map(e=>e.position.y+90+24*Math.max(e.inputs.length,e.outputs.length)));T.current?.fit({x:i,y:a,right:o,bottom:s})},zoom:C,setZoom:e=>T.current?.zoom(e)}),(b||D.message||D.pending)&&(0,Y.jsxs)(`div`,{className:`island-outline absolute left-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center gap-2 rounded-[var(--ui-surface-radius)] bg-tray px-3 py-2 text-xs text-fg-muted`,children:[e.definition.edges.some(e=>e.id===b)&&(0,Y.jsx)(`button`,{type:`button`,disabled:g,className:`rounded px-2 hover:bg-elevated disabled:opacity-50`,onClick:()=>{_(b),x(null)},children:`Disconnect selected`}),(0,Y.jsx)(`span`,{role:`status`,children:D.message}),D.pending&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded px-2 hover:bg-elevated`,onClick:D.cancel,children:`Cancel connection`})]}),(0,Y.jsx)(`div`,{ref:O,className:`no-scrollbar min-h-0 flex-1 cursor-grab overflow-hidden touch-none overscroll-none [overflow-anchor:none]`,"aria-label":`Huddle graph`,"aria-description":`Only nearby nodes and connections are drawn. Use Node list to browse all nodes, then Fit selected to reveal one.`,tabIndex:0,...te,children:(0,Y.jsx)(`div`,{style:{width:F*C,height:I*C},children:(0,Y.jsxs)(`div`,{ref:ee,...E.handlers,className:`relative origin-top-left`,style:{width:F,height:I,transform:`scale(${C})`},children:[(0,Y.jsx)(qr,{edges:e.definition.edges,width:F,height:I,wire:D,visible:re,focused:E.focused.edge,selected:b,select:x,locked:g,disconnect:e=>{_(e),x(null)},socket:(e,t)=>{let n=ie.get(e.node);if(!n)return;let r=ae(e.node,n.position);return{x:r.x-N+(t===`outputs`?225:15),y:r.y-P+60+Math.max(0,n[t].indexOf(e.port))*24}}}),A.map(({node:d,contract:f,position:m,inputs:h,outputs:g})=>{let _=ae(d.id,m),v={x:_.x-N,y:_.y-P};return d.id!==t&&d.id!==E.focused.node&&d.id!==k.preview?.id&&d.id!==D.pending?.from.node&&!Hr(Ur(v,h.length,g.length),re)?null:(0,Y.jsx)(Qr,{node:d,contract:f,position:m,locked:c,version:s,drag:k,wire:D,onSelect:n,move:o,undo:l,redo:u,onDelete:p,title:e.layout?.labels?.[d.id]??f?.title??d.id,rename:e=>r(d.id,e),changeIcon:e=>i(d.id,e),canRename:a,selected:t===d.id,shown:v},d.id)})]})})})]})}function ai(e,t){if(e instanceof u){let n=e.issues[0];if(!n)return t;if(n.path.includes(`colour`))return`Choose a preset node colour or a six-digit hex colour.`;let r=n.path.map(String).join(`.`);return`${r?`${r}: `:``}${n.message}`}return e instanceof Error?e.message:t}function oi(e,t,n){let r=Nt(e,t,null,void 0,{focused:n,live:!0}),i=yn(e,t);return(0,J.useEffect)(()=>(bn(i),()=>vn(i)),[i]),{path:t,buffer:r,text:(0,J.useSyncExternalStore)((0,J.useCallback)(e=>_n(i,e),[i]),()=>r.model?.getValue()??``),locked:r.status!==`ready`||Ye(r.conflict)}}function si(e,t){let n=[...new Set(t?.nodes.flatMap(e=>e.source.kind===`local`?[e.source.manifest]:[])??[])];return En({queries:n.map(t=>{let n=`.puddle/huddle/${e.huddle_id}/${t.replace(/^\.\//,``)}`;return{queryKey:[`wt-file`,e.id,n],queryFn:({signal:t})=>L(`GET`,`/api/worktrees/${e.id}/file?path=${encodeURIComponent(n)}`,void 0,t),retry:!1}}),combine:e=>{let t={};for(let[r,i]of e.entries()){let e=i.data;if(i.isPending||(t[n[r]]=void 0),e?.content&&!e.binary&&e.size<=me.fileBytes)try{t[n[r]]=ye.parse(JSON.parse(e.content))}catch{}}return t}})}function ci(e,t,n){let r=N(e.huddle_id),{buffer:i,text:a,locked:o}=oi(e.id,r,n),s=(0,J.useMemo)(()=>{try{let t=fe.parse(JSON.parse(a));if(t.id!==e.huddle_id)throw Error(`The definition id must match this huddle directory.`);return{definition:t}}catch(e){return{error:e instanceof Error?e.message:`Invalid huddle definition`}}},[a,e.huddle_id]),c=si(e,s.definition);return{path:r,buffer:i,graph:(0,J.useMemo)(()=>{let e=s.definition;if(!e)return;let n=Object.fromEntries(e.nodes.flatMap(e=>{let n=t?.definition.nodes.find(t=>t.id===e.id),r=e.source.kind===`builtin`?he.get(`${e.source.component}@${e.source.version}`):Object.hasOwn(c,e.source.manifest)?c[e.source.manifest]:JSON.stringify(n?.source)===JSON.stringify(e.source)?t?.components[e.id]:void 0;return r?[[e.id,r]]:[]}));return{digest:t?.digest??`0`.repeat(64),definition:e,components:n,...t?.layout?{layout:t.layout}:{},diagnostics:ie(e,new Map(Object.entries(n)))}},[s,t,c]),error:s.error,locked:o,edit:t=>{let n=i.model;if(!n||o)return!1;try{let r=fe.parse(JSON.parse(n.getValue())),i=fe.parse(t(r));if(i.id!==e.huddle_id)throw Error(`Cannot change the huddle directory id`);return n.pushStackElement(),mn(n,`${JSON.stringify(i,null,2)}\n`),n.pushStackElement(),!0}catch(e){return W.error(ai(e,`Cannot edit this graph`)),!1}}}}function li(e,t){let n=Zt(),i=R().data?.protocol,a=n&&r(i,{major:28,minor:3}),o=e=>n&&r(i,{major:28,minor:e===`builtin`?30:M.find(t=>t.template===e).minor});return{supported:a,supportsTemplate:o,...He({retry:!1,mutationFn:async n=>{if(!e||!o(n.template))throw Error(`This node template requires a supporting host`);return xe.parse(await L(`POST`,`/api/huddle/${e}/definitions/${t.huddle_id}/components`,{...n,project_id:t.project_id,worktree:t.worktree_path}))}})}}var ui=[{id:`triggers`,title:`Triggers`,colour:`text-identity-gold`,colourKey:`gold`},{id:`agents`,title:`Agents`,colour:`text-icon-blue`,colourKey:`blue`},{id:`flow`,title:`Logic & data`,colour:`text-icon-violet`,colourKey:`violet`},{id:`readouts`,title:`Readouts`,colour:`text-icon-green`,colourKey:`green`}],di={manual:`play`,interval:`clock`,calendar:`calendar-days`,date:`calendar-clock`,"calendar-date":`calendar-range`,filetree:`folder-tree`,git:`git-branch`,session:`activity`,"turn-completed":`check-check`,result:`file-output`,file:`file-output`,prompt:`message-square`,review:`check-check`,spawn:`plus`,resume:`play`,restart:`rotate-ccw`,"native-prompt":`message-square`,"native-review":`check-check`,"prompt-spawned":`message-square`,"review-spawned":`check-check`,transform:`braces`,format:`type`,condition:`git-fork`,merge:`merge`,join:`combine`};function fi(e){let t=e.category===`trigger`?`triggers`:e.category===`readout`?`readouts`:e.id.startsWith(`puddle.agent.`)?`agents`:`flow`,n=di[e.id.split(`.`).at(-1)]??(t===`agents`?`message-square`:t===`triggers`?`radio`:`code`);return{group:t,Icon:Yr[n],appearance:{icon:n,colour:ui.find(e=>e.id===t).colourKey}}}function pi({edit:e,profile:t,session:n}){let i=(0,J.useId)(),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),l=ee.safeParse(s),u=li(t,n),d=R().data?.protocol,f=(0,J.useRef)(e);return(0,J.useLayoutEffect)(()=>{f.current=e},[e]),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-label":`Add node`,children:[(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 flex flex-col gap-3 bg-elevated pb-3`,children:[(0,Y.jsx)(K,{htmlFor:`${i}-search`,children:`Find a node`}),(0,Y.jsx)(G,{id:`${i}-search`,value:a,onChange:e=>o(e.target.value),placeholder:`Search nodes`})]}),ui.map(t=>{let n=[...[...he.values()].filter(e=>e.id!==E.id||r(d,{major:28,minor:28})).map(t=>({component:t,disabled:!1,add:()=>e(e=>Or(e,{kind:`builtin`,component:t.id,version:t.version},t.id.endsWith(`.manual`)?`run`:t.id.split(`.`).at(-1),fi(t).appearance))})),...u.supported?M.filter(e=>u.supportsTemplate(e.template)).map(e=>({component:e.component,disabled:u.isPending,add:()=>{let t=`${e.template}-${crypto.randomUUID().replaceAll(`-`,``)}`;u.mutate({template:e.template,component:t},{onSuccess:t=>{f.current(n=>({...n,nodes:[...n.nodes,te.parse({id:Dr(n.nodes,e.template),source:{kind:`local`,manifest:t.manifest},appearance:fi(e.component).appearance,parameters:Object.fromEntries(Object.entries(t.component.parameters).flatMap(([e,t])=>t.default===void 0?[]:[[e,{kind:`literal`,value:t.default}]]))})]}))}})}})):[]].filter(({component:e})=>fi(e).group===t.id&&`${t.title} ${e.title} ${e.category}`.toLowerCase().includes(a.toLowerCase()));return n.length?(0,Y.jsxs)(`section`,{className:`${Z} flex flex-col gap-1`,"aria-label":t.title,children:[(0,Y.jsx)(`h3`,{className:`px-2 pb-2 text-xs font-medium ${t.colour}`,children:t.title}),n.map(({component:e,disabled:n,add:r})=>{let{Icon:i}=fi(e);return(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Add ${e.title}`,className:`${$} flex items-center gap-3 text-left`,disabled:n,onClick:r,children:[(0,Y.jsx)(i,{className:`size-4 shrink-0 ${t.colour}`}),(0,Y.jsx)(`span`,{children:e.title})]},e.id)})]},t.id):null}),u.error&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[u.error.message,`. Inspect the component files before trying again.`]}),(0,Y.jsxs)(`section`,{className:`${Z} flex flex-col gap-3`,"aria-label":`Custom nodes`,children:[(0,Y.jsx)(K,{htmlFor:`${i}-local`,children:`Local component contract`}),(0,Y.jsx)(G,{id:`${i}-local`,value:s,onChange:e=>c(e.target.value),placeholder:`nodes/review/node.json`}),(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex items-center gap-2`,disabled:!l.success,onClick:()=>{l.success&&e(e=>Or(e,{kind:`local`,manifest:l.data},`script`,{icon:`file-code`,colour:`violet`}))},children:[(0,Y.jsx)(Ft,{className:`size-4 text-icon-violet`}),` Add local node`]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Paths are relative to this huddle directory. Node templates create editable source files.`})]})]})}function mi({node:e,component:t,edit:n}){let[r,i]=(0,J.useState)(!1),a=e.appearance??t?.appearance??{icon:null,colour:null},o=a.icon&&Yr[a.icon]||Bt,s=r=>n(n=>({...n,nodes:n.nodes.map(n=>n.id===e.id?{...n,appearance:{...n.appearance??t?.appearance??{icon:null,colour:null},...r}}:n)}));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(fn,{open:r,onOpenChange:i,children:[(0,Y.jsx)(dn,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`size-4`}),`Choose node icon`]})}),(0,Y.jsx)(un,{className:`w-80`,children:(0,Y.jsx)(Xr,{value:a.icon,onSelect:e=>{s({icon:e}),i(!1)}})})]}),(0,Y.jsx)(xt,{label:`Node colour`,value:a.colour,onChange:e=>s({colour:e}),onCustomChange:e=>s({colour:e})})]})}function hi({template:e}){let t=(0,J.useId)(),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(`null`),[o,s]=(0,J.useState)(``),c=``,l;if(n)try{let t=JSON.parse(i);if(!be(t))throw Error(`Sample input exceeds the supported JSON limits`);c=Sn(e??o,t)}catch(e){l=e instanceof Error?e.message:`Cannot preview this prompt`}let u=`w-full resize-y rounded-md bg-surface p-2 text-sm text-fg outline-none focus-visible:ring-1 focus-visible:ring-ring`;return(0,Y.jsx)(nn,{onToggle:e=>r(e.currentTarget.open),summary:`Preview prompt`,summaryClassName:`rounded-md px-2 py-1 text-xs hover:bg-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:n&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Uses standard `,`{{input}}`,` substitutions with sample data. Custom script formatting may differ. Preview data is not saved or sent to an agent.`]}),e===void 0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{htmlFor:`${t}-template`,children:`Sample prompt template`}),(0,Y.jsx)(`textarea`,{id:`${t}-template`,value:o,rows:3,maxLength:131072,className:u,onChange:e=>s(e.target.value)}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`This variable has no text default. Enter a sample template to preview; the host resolves the actual variable when starting the huddle.`})]}),(0,Y.jsx)(K,{htmlFor:`${t}-input`,children:`Sample input (JSON)`}),(0,Y.jsx)(`textarea`,{id:`${t}-input`,value:i,rows:4,maxLength:262144,className:u,onChange:e=>a(e.target.value)}),l?(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,children:l}):(0,Y.jsx)(`pre`,{"aria-label":`Rendered prompt`,role:`region`,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-sm`,children:c||`(Empty prompt)`})]})})}function gi(e){return JSON.stringify(Object.fromEntries(Object.entries(e.variables).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]])),null,2)}function _i(e,t){let n=S.shape.variables.parse(JSON.parse(t));return ve(e,n),n}function vi(e){return I.parse(JSON.parse(e))}function yi(e){let[t,n]=(0,J.useState)(!1);return(0,Y.jsx)(nn,{className:`py-2`,onToggle:e=>n(e.currentTarget.open),summary:`Preview bindings`,summaryClassName:`rounded-md px-2 py-1 text-xs hover:bg-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:t&&(0,Y.jsx)(bi,{...e})})}function bi({definition:e,node:t,component:n}){let r=(0,J.useId)(),[i,a]=(0,J.useState)(()=>gi(e)),o,s;try{o=JSON.stringify(pe(e,t,n,_i(e,i)),null,2)}catch(e){s=e instanceof Error?e.message:`Cannot resolve these settings`}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2 text-xs`,children:[(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Current draft settings after Apply setting, using the sample variables below. These samples are not saved or used to start a huddle.`}),(0,Y.jsx)(K,{htmlFor:r,children:`Sample variables (JSON)`}),(0,Y.jsx)(vt,{id:r,rows:5,maxLength:262144,className:`font-mono text-xs`,value:i,spellCheck:!1,onChange:e=>a(e.target.value)}),s?(0,Y.jsx)(`p`,{role:`status`,className:`whitespace-pre-wrap break-words text-fg-muted`,children:s}):(0,Y.jsx)(`pre`,{role:`region`,"aria-label":`Resolved node settings`,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words`,children:o}),(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Resource values are requested selectors. Start or Apply checks the host, worktrees, accounts and sessions. Active revision shows the resource bindings captured by a running huddle.`})]})}function xi(e,t,n,r){let i=Me(n?e.project_id:void 0),a=Oe(n?i.data?.project.repo_id:void 0),o=Fe(n?e.project_id:void 0),s=n&&Object.values(r?.parameters??{}).some(e=>[`account`,`agent`,`project`].includes(e.editor))?i.data?.project.profile_id:void 0,c=We(s),l=z({queryKey:[`puddlang-context`,s],queryFn:async({signal:e})=>Se.parse(await L(`GET`,`/api/puddlang/${s}/context`,void 0,e)),enabled:!!s,retry:!1}),u=l.data?.agents.filter(e=>e.scripted_turns)??[],d=Object.entries(r?.parameters??{}).flatMap(([e,n])=>{let r=t.parameters[e];return n.editor===`agent`&&r?.kind===`literal`&&typeof r.value==`string`?[r.value]:[]}),f=O(t,r)?.id===F.id,p=t.parameters.worktree,m=p?.kind===`literal`&&typeof p.value==`string`?p.value:void 0;return{projects:i.data?[{value:i.data.project.id,label:i.data.project.name}]:[],providers:u.map(e=>({value:e.id,label:e.id})),accounts:c.data?.filter(e=>e.profile_id===s&&e.logged_in&&u.some(t=>t.id===e.agent_type)&&(!d.length||d.includes(e.agent_type))).map(e=>({value:String(e.id),label:`${e.label} · ${e.agent_type} · #${e.id}`}))??[],worktrees:a.data?.worktrees.map(e=>({value:e.path,label:`${e.branch??`Detached`} · ${e.path}`}))??[],sessions:o.data?.filter(t=>t.project_id===e.project_id&&(f?t.kind!==`huddle`:t.kind===`agent`&&(r?.lifecycle===`resume`?[`exited`,`interrupted`].includes(t.status):![`archived`,`exited`,`interrupted`].includes(t.status)))&&(!m||t.worktree_path===m)).map(e=>({value:e.id,label:`${e.title??e.agent_title??e.agent_type??(e.kind===`terminal`?`Terminal`:`Agent`)} · ${e.id.slice(0,8)} · ${e.worktree_path}`}))??[],error:i.error?.message??a.error?.message??o.error?.message??c.error?.message??l.error?.message}}function Si({node:e,component:t,definition:n,components:r,edit:i,session:a}){let{variables:o,nodes:s}=n,c=xi(a,e,Object.values(t?.parameters??{}).some(e=>[`worktree`,`session`,`account`,`agent`,`project`].includes(e.editor)),t),l=(t,n)=>i(r=>({...r,nodes:r.nodes.map(r=>{if(r.id!==e.id)return r;let i={...r.parameters};return n?i[t]=n:delete i[t],{...r,parameters:i}})}));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[Object.entries(t?.parameters??{}).map(([n,i])=>(0,Y.jsx)(Ci,{name:n,parameter:i,binding:e.parameters[n],variables:o,resources:c,completionChoices:t?.nativeCompletion===n?s.filter(e=>O(e,r[e.id])?.id===ne.id).map(e=>({value:e.id,label:e.id})):void 0,set:e=>l(n,e)},`${n}:${JSON.stringify(e.parameters[n])}`)),c.error&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Resource choices: `,c.error]}),!t&&(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(e.parameters,null,2)}),t&&Object.keys(t.parameters).length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No settings for this node.`}),t&&Object.keys(t.parameters).length>0&&(0,Y.jsx)(yi,{definition:n,node:e,component:t})]})}function Ci({name:e,parameter:t,binding:n,variables:r,set:i,resources:a,completionChoices:o}){let s=(0,J.useId)(),[c,l]=(0,J.useState)(n?.kind??`literal`),u=n?.kind===`literal`?n.value:n?void 0:t.default,d=t.schema.type===`string`,[f,p]=(0,J.useState)(n?.kind===`variable`?n.name:u===void 0?``:d?String(u):JSON.stringify(u)),m;try{t.editor===`secret`&&c===`literal`&&j.parse(f),m=D.parse(c===`variable`?{kind:c,name:f}:{kind:c,value:d?f:JSON.parse(f)})}catch{}let h=o??(t.editor===`worktree`?a.worktrees:t.editor===`session`?a.sessions:t.editor===`account`?a.accounts:t.editor===`project`?a.projects:t.editor===`agent`?a.providers:void 0);return(0,Y.jsxs)(`div`,{className:`${Z} flex min-w-0 flex-col gap-2`,role:`group`,"aria-label":t.title??e,children:[(0,Y.jsxs)(K,{htmlFor:s,children:[t.title??e,t.required?` *`:``]}),(0,Y.jsx)(Q,{label:`${e} binding`,value:c,onValueChange:e=>{l(e),p(``)},options:[{value:`literal`,label:`Value`},{value:`variable`,label:`Variable`}]}),c===`variable`?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose variable`,options:Object.keys(r).map(e=>({value:e,label:e}))}):h?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose ${o?`completion trigger`:t.editor===`agent`?`provider`:t.editor}`,options:f&&!h.some(e=>e.value===f)?[{value:f,label:`${f} · unavailable`},...h]:h}):t.schema.enum?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose value`,options:[...f&&!t.schema.enum.some(e=>(d?String(e):JSON.stringify(e))===f)?[{value:f,label:`${f} · not in options`}]:[],...t.schema.enum.map(e=>({value:d?String(e):JSON.stringify(e),label:typeof e==`string`?e||`(empty string)`:JSON.stringify(e)}))]}):t.editor===`prompt`?(0,Y.jsx)(`textarea`,{id:s,value:f,rows:5,className:`min-h-24 w-full resize-y rounded-md bg-surface p-2 text-sm text-fg outline-none focus-visible:ring-1 focus-visible:ring-ring`,onChange:e=>p(e.target.value)}):t.schema.type===`boolean`?(0,Y.jsx)(Q,{id:s,value:f,onValueChange:p,placeholder:`Choose value`,options:[{value:`true`,label:`True`},{value:`false`,label:`False`}]}):(0,Y.jsx)(G,{id:s,type:[`number`,`integer`].includes(String(t.schema.type))?`number`:`text`,min:t.schema.minimum,max:t.schema.maximum,step:t.schema.type===`integer`?1:`any`,value:f,onChange:e=>p(e.target.value),placeholder:d?t.description:`JSON value`}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!m,onClick:()=>m&&i(m),children:`Apply setting`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!n,onClick:()=>i(void 0),children:`Clear setting`})]}),t.description&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.description}),t.editor===`prompt`&&(0,Y.jsxs)(Y.Fragment,{children:[c===`variable`&&typeof r[f]?.default==`string`&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Preview uses the variable default. Start bindings may supply another template.`}),(0,Y.jsx)(hi,{template:c===`literal`?f:typeof r[f]?.default==`string`?r[f].default:void 0})]}),!n&&t.default!==void 0&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Default: `,JSON.stringify(t.default)]}),t.editor===`secret`&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Enter a private host reference, never the secret value. Start/Apply checks availability for this huddle and worktree; workers recheck before running.`}),t.editor===`worktree`&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Use an explicit worktree root or a worktree variable.`})]})}async function wi(e,t,n,r){if(ge()||!Lt())throw Error(`Trigger inspection requires a supporting local or SSH connection`);let i=f.parse({target:n});return ce(i.target,await L(`POST`,`/api/huddle/${e}/sessions/${t}/triggers`,i,r))}var Ti=e=>new Date(e).toLocaleString();function Ei({profile:e,session:t,target:n,stale:r,focused:i,onClose:a}){let o=z({queryKey:[`huddle-triggers`,e,t,n],queryFn:({signal:r})=>wi(e,t,n,r),enabled:i&&!r,retry:!1,networkMode:`always`,gcTime:0,refetchInterval:e=>i&&!r&&!e.state.error?5e3:!1,refetchIntervalInBackground:!1}),s=o.data;return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||a()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Huddle triggers`}),(0,Y.jsx)(B,{children:`Installed subscriptions and accepted work. Ready means the subscription is installed; it does not prove an external service is reachable. Counts describe retained events, not unseen work at the source.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,Y.jsx)(`span`,{children:s?`Observed ${Ti(s.observed_at)}`:`Waiting for observation…`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:r||!i||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh`})]}),r&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:`The runtime changed. Close and reopen Triggers to inspect the current activation.`}),o.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:o.error.message}),s&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-xs`,children:[s.backlog.queued,` queued · `,s.backlog.running,` running ·`,` `,s.backlog.uncertain_operations,` uncertain operations`,s.queue_limit!==null&&(0,Y.jsxs)(`span`,{className:`text-fg-muted`,children:[` · queue limit `,s.queue_limit]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Backlog includes earlier activations. Source totals below cover this activation only.`}),(0,Y.jsx)(`ul`,{className:`max-h-[55vh] space-y-5 overflow-auto py-2 text-xs`,"aria-label":`Trigger health and backlog`,children:s.sources.map(e=>(0,Y.jsxs)(`li`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,Y.jsx)(`span`,{children:e.node}),(0,Y.jsx)(`span`,{className:`text-fg-muted`,children:e.health})]}),(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:e.component}),e.message&&(0,Y.jsx)(`p`,{className:`break-words`,children:e.message}),(0,Y.jsxs)(`p`,{children:[e.queued,` queued · `,e.running,` running · `,e.admitted,` admitted`]}),e.last_event_at&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Last accepted event `,Ti(e.last_event_at)]}),e.next_at&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Next scheduled `,Ti(e.next_at)]}),e.missed&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Missed policy: `,e.missed,` · `,e.coalesced,` combined occurrences ·`,` `,e.skipped,` skipped occurrences`]}),e.disposition&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`One-off date: `,e.disposition]})]},e.node))}),!s.sources.length&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No triggers in this activation.`})]})]})})}function Di({enabled:e,target:t,disabled:n,send:r}){return(0,Y.jsx)(X,{icon:rn,label:`Auto-start after reboot`,"aria-pressed":e,disabled:n,title:`Auto-start after reboot: ${e?`on`:`off`}. Recover this run when the host starts; stopped or interrupted huddles stay stopped.`,onClick:()=>void r({action:`auto-start`,input:{target:t,expected:e,enabled:!e}}).catch(()=>{})})}function Oi(){let e=Zt(),t=R();return e&&r(t.data?.protocol,{major:28,minor:12})}function ki(e,t){if(ge())throw Error(`Huddle history requires a local or SSH connection`);return`/api/huddle/${e}/sessions/${t}/history`}async function Ai(e,t,n,r){return s.parse(await L(`POST`,`${ki(e,t)}/owners`,c.parse(n),r))}async function ji(e,t,n,r){let a=i.parse(n);return ae(a,await L(`POST`,`${ki(e,t)}/input`,a,r))}async function Mi(e,t,n,r){let i=g.parse(n);return x(i,await L(`POST`,`${ki(e,t)}/retained`,i,r))}function Ni(){let e=Zt(),t=R().data?.protocol;return e&&r(t,{major:28,minor:10})}async function Pi(e,t,n,r){if(ge()||!Lt())throw Error(`Huddle revision review requires a supporting local or SSH connection`);let i=`expected_digest`in n,a=(i?Ce:o).parse(n);return k(a,await L(`POST`,`/api/huddle/${e}/sessions/${t}/${i?`diff`:`revision`}`,a,r))}function Fi(){let e=Zt(),t=R().data?.protocol;return e&&r(t,{major:28,minor:13})}async function Ii(e,t,n,r){if(ge()||!Lt())throw Error(`Retained revision review requires a supporting local or SSH connection`);let i=b.parse(n);return we(i,await L(`POST`,`/api/huddle/${e}/sessions/${t}/revision/retained`,i,r))}function Li({profile:e,session:t,review:n}){let r=(0,J.useId)(),i=`source`in n,a=i?n.revision:n.active.revision,o=i?n.activation:n.active,[s,c]=(0,J.useState)(()=>(n.entries.find(e=>![`retained`,`unchanged`].includes(e.change))??n.entries[0])?.entry??null),[l,u]=(0,J.useState)(!n.saved),d=z({queryKey:[`huddle-revision-content`,e,t,i?[`retained`,n.owner,a]:n.target,n.saved?.digest,s],queryFn:({signal:r})=>i?Ii(e,t,{owner:n.owner,revision:a,entry:s,...n.saved?{expected_digest:n.saved.digest}:{}},r):Pi(e,t,{target:n.target,entry:s,...n.saved?{expected_digest:n.saved.digest}:{}},r),enabled:s!==null,retry:!1,staleTime:1/0,gcTime:0,refetchOnWindowFocus:!1}),f=n.entries.filter(e=>![`unchanged`,`retained`].includes(e.change)),p=l?n.entries:f,m=d.data?.content,h=s?.kind===`component`?`${s.path}.json`:s?.path??``;return(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-3`,"aria-label":`Revision review`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Y.jsxs)(`p`,{className:`break-all`,children:[i?`Recorded revision`:`Active revision`,` `,a]}),n.saved&&(0,Y.jsxs)(`p`,{className:`break-all`,children:[`Saved revision `,n.saved.digest]}),(0,Y.jsx)(`p`,{children:n.saved?`${f.length} changed ${f.length===1?`entry`:`entries`}`:`${p.length} retained entries`}),o&&(0,Y.jsx)(nn,{summary:`${i?`Recorded`:`Active`} variables and resolved bindings`,children:(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-words p-2`,children:JSON.stringify({worktree:o.worktree,appliedAt:new Date(o.appliedAt).toLocaleString(),variables:o.variables,bindings:o.bindings},null,2)})}),n.saved?.diagnostics.map((e,t)=>(0,Y.jsxs)(`p`,{children:[e.severity,`: `,e.message]},t))]}),n.saved&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,"aria-pressed":l,onClick:()=>u(!l),children:l?`Show changes only`:`Show all entries`}),(0,Y.jsx)(`div`,{className:`max-h-32 overflow-auto`,"aria-label":`Revision entries`,children:p.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex w-full items-center justify-between gap-3 text-left aria-pressed:bg-explorer-selection`,"aria-pressed":s?.kind===e.entry.kind&&s.path===e.entry.path,onClick:()=>c(e.entry),children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.entry.kind===`component`?`Contract · `:``,e.entry.path]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.change})]},`${e.entry.kind}:${e.entry.path}`))}),d.error&&(0,Y.jsxs)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:[d.error.message,` Close and inspect again to review current source.`]}),d.isFetching&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading retained source…`}),m&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[s?.path,` ·`,` `,n.saved?`${i?`Retained`:`Active`} on the left · Saved on the right`:`Retained source`,n.saved&&(m.before===null?` · Added`:m.after===null?` · Removed`:``)]}),(0,Y.jsx)(`div`,{className:`h-72 min-w-0`,"aria-label":`Revision source`,children:n.saved?(0,Y.jsx)(Pt,{session:t,originalRef:`huddle:${a}`,originalPath:h,originalContent:m.before??``,modifiedRef:`huddle:${n.saved.digest}`,modifiedPath:h,modifiedContent:m.after??``},`${s?.kind}:${h}`):(0,Y.jsx)(At,{session:`${t}:${r}`,refName:`huddle:${a}`,path:h,content:m.before??``},`${s?.kind}:${h}`)})]})]})}function Ri({profile:e,session:t,request:n,onBack:r,onClose:i}){let a=z({queryKey:[`huddle-retained-revision`,e,t,n],queryFn:({signal:r})=>Ii(e,t,n,r),retry:!1,staleTime:1/0,gcTime:0,refetchOnWindowFocus:!1});return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||i()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Recorded huddle revision`}),(0,Y.jsx)(B,{children:`Retained source from this runtime. Recorded settings describe the last saved activation; they do not establish current activity.`}),(0,Y.jsx)(`button`,{type:`button`,className:`${$} w-fit`,onClick:r,children:`Back to history`}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[`Runtime `,n.owner.runtimeId]}),a.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading recorded revision…`}),a.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:a.error.message}),a.data&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Read `,new Date(a.data.observed_at).toLocaleString()]}),(0,Y.jsx)(Li,{profile:e,session:t,review:a.data})]})]})})}var zi=(e,t)=>`/api/huddle/${e}/sessions/${t}`;function Bi(){if(ge()||!Lt())throw Error(`Huddle execution requires a supporting local or SSH connection`)}async function Vi(e,t,n,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1){Bi();let l=new URLSearchParams;return r&&l.set(`include_readout_observation`,`true`),i&&l.set(`include_custom_triggers`,`true`),a&&l.set(`include_recovery`,`true`),o&&l.set(`include_auto_start`,`true`),s&&l.set(`include_trigger_inspection`,`true`),c&&l.set(`include_crash_recovery`,`true`),d.parse(await L(`GET`,`${zi(e,t)}/runtime${l.size?`?`+l.toString():``}`,void 0,n))}async function Hi(e,t,n,r){return Bi(),_.parse(await L(`POST`,`${zi(e,t)}/history`,l.parse(n),r))}async function Ui(e,t,n){Bi();let r={"auto-start":h,recover:Te,"readouts/observe":y,"readouts/observe-retained":oe,start:S,apply:m,run:C,rearm:f,interrupt:f,stop:f}[n.action].parse(n.input),i=await L(`POST`,`${zi(e,t)}/${n.action}`,r);return n.action===`readouts/observe`||n.action===`readouts/observe-retained`?{action:`observing`,value:p.parse(i)}:n.action===`run`?{action:`run`,value:a.parse(i),target:n.input.target}:n.action===`stop`?{action:`stop`,value:w.parse(i)}:{action:`state`,value:d.parse(i)}}async function Wi(e,t,n){let r=S.parse(n.input),i=C.omit({target:!0}).parse(n.event),a=Ee.get(),o=ge(),s=()=>{if(Ee.get()!==a||ge()!==o)throw Error(`The connection changed`)},c=`start`;try{let n=await Ui(e,t,{action:`start`,input:r});if(c=`verify`,s(),n.action!==`state`||n.value.session_id!==t)throw Error(`Start returned another session`);let a=n.value.owner;if(n.value.unresolved||!a?.connected||a.stopping||a.lifecycle!==`armed`||!a.target.activationId)throw Error(`The started graph is not available`);let o=await Pi(e,t,{target:a.target});if(s(),o.active.revision!==r.expected_digest||le(o.active.variables)!==le(r.variables))throw Error(`The active revision or variables changed`);c=`run`;let l=await Ui(e,t,{action:`run`,input:{...i,target:a.target}});return s(),l}catch(e){let t=e instanceof Error?e.message:`Request failed`;throw Error(`${c===`start`?`Start was not confirmed; manual input was not sent.`:c===`verify`?`Start succeeded, but manual input was not sent.`:`Start succeeded; the manual input outcome needs inspection.`} ${t}`,{cause:e})}}var Gi=(e,t)=>[`huddle-runtime`,e,t],Ki=(e,t)=>[`huddle-history`,e,t];function qi(){let e=Zt(),t=R().data?.protocol;return e&&r(t,{major:28,minor:2})}function Ji(e,t,n){let i=qi(),a=R().data?.protocol;return z({queryKey:Gi(e,t),queryFn:({signal:n})=>Vi(e,t,n,r(a,{major:28,minor:6}),r(a,{major:28,minor:7}),r(a,{major:28,minor:15}),r(a,{major:28,minor:16}),r(a,{major:28,minor:17}),r(a,{major:28,minor:18})),enabled:i&&!!e&&n,retry:!1,networkMode:`always`,staleTime:0,refetchInterval:e=>n&&!e.state.error?3e3:!1,refetchIntervalInBackground:!1})}var Yi={pending:!1,review:!1,error:null,executionId:null};function Xi(e,t){let n=qi(),r=Ni(),i=Ke(),a=[`huddle-command`,e,t],o=z({queryKey:a,queryFn:()=>Yi,initialData:Yi,enabled:!1,staleTime:1/0,gcTime:1/0}).data,s=He({mutationKey:a,retry:!1,networkMode:`always`,mutationFn:n=>n.action===`start-and-run`?Wi(e,t,n):Ui(e,t,n),onSuccess:n=>{n.action===`state`&&i.setQueryData(Gi(e,t),n.value),i.setQueryData(a,{...Yi,executionId:n.action===`run`?n.value.executionId:null})},onError:e=>i.setQueryData(a,{...Yi,review:!0,error:e.message}),onSettled:()=>{i.invalidateQueries({queryKey:Gi(e,t)}),i.invalidateQueries({queryKey:Ki(e,t)}),i.invalidateQueries({queryKey:[`sessions`]})}});return{status:o,async send(t){let o=i.getQueryData(a)??Yi;if(!n||!e)throw Error(`This host does not support huddle execution`);if(t.action===`start-and-run`&&!r)throw Error(`Start and run requires a host supporting revision review`);if(o.pending||o.review||i.isMutating({mutationKey:a}))throw Error(`Inspect the previous command before another action`);return i.setQueryData(a,{...Yi,pending:!0}),s.mutateAsync(t)},reviewed(){let e=i.getQueryData(a)??Yi;e.pending||i.setQueryData(a,{...e,review:!1,error:null})}}}function Zi({operation:e,target:t,owner:n,disabled:r,send:i,inspect:a}){let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null);return(0,Y.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Check whether the destination received this delivery.`}),(0,Y.jsxs)(ln,{label:`Delivery observation`,className:`w-fit`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:r||o,onClick:()=>{s(!0),l(null),i(n?{action:`readouts/observe-retained`,input:{owner:n,operation_id:e}}:{action:`readouts/observe`,input:{target:t,operation_id:e}}).catch(e=>{l(e instanceof Error?e.message:`Cannot check delivery`)})},children:`Check delivery`}),o&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:r,onClick:()=>{a().then(()=>{s(!1),l(null)},e=>{l(e instanceof Error?e.message:`Cannot inspect delivery`)})},children:`Refresh delivery`})]}),o&&!c&&(0,Y.jsx)(`p`,{role:`status`,className:`text-fg-muted`,children:`Check requested. The delivery result will refresh here; the ended graph stays ended.`}),c&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-fg-muted`,children:c})]})}function Qi({agent:e,onOpen:t}){return(0,Y.jsxs)(`div`,{className:`space-y-1 py-1`,children:[(0,Y.jsx)($e,{to:`/project/${encodeURIComponent(e.projectId)}/session/${encodeURIComponent(e.sessionId)}`,onClick:t,className:`${$} inline-block`,children:`Open agent session`}),(0,Y.jsxs)(`p`,{className:`break-all text-fg-muted`,children:[`Recorded worktree: `,e.worktree]}),(0,Y.jsxs)(nn,{className:`text-fg-muted`,summary:`Recorded agent identity`,children:[(0,Y.jsxs)(`p`,{className:`break-all`,children:[`Session `,e.sessionId]}),e.runtimeId&&(0,Y.jsxs)(`p`,{className:`break-all`,children:[`Runtime `,e.runtimeId]}),(0,Y.jsx)(`p`,{children:`The session may now use a different runtime or conversation.`})]})]})}function $i({profile:e,session:t,request:n}){let[r,i]=(0,J.useState)(!1),a=z({queryKey:[`huddle-trigger-input`,e,t,n],queryFn:({signal:r})=>ji(e,t,n,r),enabled:r,retry:!1,staleTime:1/0,refetchOnWindowFocus:!1}),o=a.data?.event,s=o?JSON.stringify(o.data,null,2):``;return(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,"aria-expanded":r,onClick:()=>i(!r),children:`Trigger input`}),r&&(0,Y.jsxs)(`div`,{className:`space-y-1`,"aria-label":`Recorded trigger input`,children:[a.isPending&&(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:`Reading recorded input…`}),a.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-fg-muted`,children:a.error.message}),a.error&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:a.isFetching,onClick:()=>void a.refetch(),children:`Refresh input`}),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{children:[o.source.node,`.`,o.port,` · `,o.source.component,`@`,o.source.version]}),(0,Y.jsxs)(`p`,{className:`break-all text-fg-muted`,children:[`Event `,o.id]}),(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Observed `,new Date(o.observedAt).toLocaleString()]}),o.occurredAt&&(0,Y.jsxs)(`p`,{className:`text-fg-muted`,children:[`Occurred `,new Date(o.occurredAt).toLocaleString()]}),(0,Y.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:s.length>16384?`${s.slice(0,16384)}\n… Preview truncated`:s})]})]})]})}function ea(e,t,n,r=!1){return z({queryKey:[...Ki(e,t),...r?[`retained`]:[],n],queryFn:({signal:i})=>r?Mi(e,t,n,i).then(e=>({...e.history,observedAt:e.observed_at})):Hi(e,t,n,i),retry:!1,networkMode:`always`,staleTime:0,refetchInterval:e=>r||e.state.error?!1:3e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:!r})}function ta({profile:e,session:t,owner:n,initialExecution:i,retained:a=!1,onRecordedRuntimes:o,onClose:s}){let c=Fi(),l=r(R().data?.protocol,{major:28,minor:33}),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)([0]),[m,h]=(0,J.useState)(i??null),g=f.at(-1),_=ea(e,t,{owner:n,collection:`executions`,after:g},a),v=_.data?.collection===`executions`?_.data:void 0,y=v?.records.find(({record:e})=>e.id===m)?.record;return u?(0,Y.jsx)(Ri,{profile:e,session:t,request:{owner:n,...u.digest?{revision:u.digest}:{}},onBack:()=>d(null),onClose:s}):(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||s()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Huddle history`}),(0,Y.jsx)(B,{children:a?`Recorded ledger history. Pending, running and unknown records do not establish current activity or completion. Nothing is restarted or reconciled.`:`Execution acceptance and completion are separate. This view reads the connected runtime.`}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[`Runtime `,n.runtimeId]}),a&&_.data?.observedAt&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Read `,new Date(_.data.observedAt).toLocaleString()]}),(0,Y.jsxs)(ln,{label:`History pages`,className:`w-fit`,children:[o&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:o,children:`Recorded runtimes`}),c&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:()=>d({}),children:`Recorded activation`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:_.isFetching,onClick:()=>void _.refetch(),children:`Refresh executions`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:f.length===1||_.isFetching,onClick:()=>p(f.slice(0,-1)),children:`Previous page`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!v?.records.length||v.next<=g||_.isFetching,onClick:()=>p([...f,v.next]),children:`Next page`})]}),_.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:_.error.message}),_.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading executions…`}),v?.records.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No executions on this page.`}),(0,Y.jsxs)(`div`,{className:`grid min-h-0 gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]`,children:[(0,Y.jsxs)(`div`,{className:`max-h-80 space-y-1 overflow-auto`,"aria-label":`Executions`,children:[v?.records.map(({record:e})=>(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":m===e.id,onClick:()=>h(e.id),className:`${$} flex w-full flex-col items-start gap-1 text-left aria-pressed:bg-explorer-selection`,children:[(0,Y.jsxs)(`span`,{children:[e.state,` · `,e.id.slice(0,8)]}),(0,Y.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.acceptedAt).toLocaleString()})]},e.id)),(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-fg-muted`,children:`Earlier entries appear first. Refresh a page to see changed outcomes.`})]}),m?(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,Y.jsxs)(`p`,{className:`break-all text-xs`,children:[`Execution `,m]}),l&&(0,Y.jsx)($i,{profile:e,session:t,request:{owner:n,execution_id:m}},`trigger-input:${m}`),y&&(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Y.jsxs)(`p`,{children:[y.state,` · revision `,y.revision.slice(0,12)]}),(0,Y.jsxs)(`p`,{children:[y.turns,` turns · `,y.spawns,` spawns ·`,` `,y.invocations,` node invocations`]}),y.error&&(0,Y.jsx)(`p`,{role:`alert`,children:y.error}),c&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:()=>d({digest:y.revision}),children:`Execution source`})]}),(0,Y.jsx)(na,{profile:e,session:t,owner:n,execution:m,retained:a,onOpenAgent:s},m)]}):(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Choose an execution to inspect nodes and results.`})]})]})})}function na({profile:e,session:t,owner:n,execution:i,retained:a,onOpenAgent:o}){let[s,c]=(0,J.useState)(`invocations`),[l,u]=(0,J.useState)([0]),d=l.at(-1),f=R().data?.protocol,p=r(f,{major:28,minor:a?21:6}),m=ea(e,t,{owner:n,collection:s,after:d,parent:i,...p?{include_readout_observation:!0}:{},...r(f,{major:28,minor:32})?{include_agent:!0}:{}},a),h=Ji(e,t,!a),g=Xi(e,t),_=h.data?.owner,v=p&&!h.error&&_?.connected&&_.readout_observation&&!_.stopping&&!_.failure&&_.target.runtimeId===n.runtimeId&&_.target.incarnation===n.incarnation?_.target:null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(ln,{label:`Execution detail`,className:`w-fit flex-wrap`,children:[[`invocations`,`operations`].map(e=>(0,Y.jsx)(`button`,{type:`button`,className:$,"aria-pressed":s===e,onClick:()=>{c(e),u([0])},children:e===`invocations`?`Nodes`:`Operations`},e)),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:l.length===1||m.isFetching,onClick:()=>u(l.slice(0,-1)),children:`Previous details`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!m.data?.records.length||m.data.next<=d||m.isFetching,onClick:()=>u([...l,m.data.next]),children:`Next details`})]}),m.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:m.error.message}),g.status.review&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:m.isFetching||h.isFetching,onClick:()=>{Promise.all([m.refetch(),h.refetch()]).then(([e,t])=>{!e.error&&!t.error&&g.reviewed()})},children:`Inspect previous command`}),m.data?.records.length===0&&(0,Y.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No `,s,` on this page.`]}),(0,Y.jsx)(`div`,{className:`max-h-80 space-y-3 overflow-auto`,children:m.data?.records.map(({record:e})=>(0,Y.jsxs)(nn,{className:`text-xs`,open:!0,summary:`${`node`in e?e.node:`kind`in e?e.kind:e.id} · ${e.state}`,summaryClassName:`py-1 text-fg`,children:[`error`in e&&e.error&&(0,Y.jsx)(`p`,{className:`py-1 text-fg-muted`,children:e.error}),`inputs`in e&&(0,Y.jsx)(ra,{label:`Inputs`,value:e.inputs}),`agent`in e&&e.agent&&(0,Y.jsx)(Qi,{agent:e.agent,onOpen:o}),`result`in e&&e.result!==void 0&&(0,Y.jsx)(ra,{label:`Result`,value:e.result}),`consumed`in e&&(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:e.consumed?`Dispatch consumed`:`Not dispatched`}),`readout_observation`in e&&e.readout_observation&&(v||a&&p)&&(0,Y.jsx)(Zi,{operation:e.id,target:v??void 0,owner:a?n:void 0,disabled:g.status.pending||g.status.review,send:g.send,inspect:async()=>{if(a){let e=await m.refetch();if(e.error)throw e.error;g.reviewed();return}let[e,t]=await Promise.all([m.refetch(),h.refetch()]);if(e.error)throw e.error;if(t.error)throw t.error}})]},e.id))})]})}function ra({label:e,value:t}){let n=JSON.stringify(t,null,2);return(0,Y.jsxs)(`div`,{className:`py-1`,children:[(0,Y.jsx)(`p`,{className:`text-fg-muted`,children:e}),(0,Y.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:n.length>16384?`${n.slice(0,16384)}\n… Preview truncated`:n})]})}function ia({profile:e,session:t,onClose:n}){let[r,i]=(0,J.useState)([void 0]),[a,o]=(0,J.useState)(null),s=r.at(-1),c=z({queryKey:[`huddle-history-owners`,e,t,s],queryFn:({signal:n})=>Ai(e,t,{after:s},n),enabled:!a,retry:!1,networkMode:`always`,refetchOnWindowFocus:!1});return a?(0,Y.jsx)(ta,{profile:e,session:t,owner:a,retained:!0,onRecordedRuntimes:()=>o(null),onClose:n},`${a.runtimeId}:${a.incarnation}`):(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||n()},children:(0,Y.jsxs)(V,{children:[(0,Y.jsx)(H,{children:`Recorded huddle runtimes`}),(0,Y.jsx)(B,{children:`Choose a retained runtime to inspect its ledger. Recorded states do not prove that a runtime is connected or stopped.`}),(0,Y.jsxs)(ln,{label:`Recorded runtime pages`,className:`w-fit`,children:[(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:c.isFetching,onClick:()=>void c.refetch(),children:`Refresh runtimes`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:c.isFetching||r.length===1,onClick:()=>i(r.slice(0,-1)),children:`Previous runtimes`}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:c.isFetching||!c.data?.next,onClick:()=>i([...r,c.data.next]),children:`Older runtimes`})]}),c.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:c.error.message}),c.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading recorded runtimes…`}),c.data?.records.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No recorded runtimes on this page.`}),(0,Y.jsx)(`div`,{className:`max-h-80 space-y-1 overflow-auto`,"aria-label":`Recorded runtimes`,children:c.data?.records.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`${$} flex w-full flex-col items-start text-left`,onClick:()=>o(e.owner),children:[(0,Y.jsxs)(`span`,{children:[new Date(e.created_at).toLocaleString(),` · `,e.recorded_state]}),(0,Y.jsxs)(`span`,{className:`break-all text-fg-muted`,children:[e.owner.runtimeId,` · `,e.build]})]},e.owner.runtimeId))})]})})}function aa(e){let t=yn(e.id,`.puddle/huddle/${e.huddle_id}/`);return(0,J.useSyncExternalStore)(gn,()=>hn().some(e=>e.startsWith(t)&&e.split(`:`).length===2),()=>!1)}function oa({review:e,profile:t,session:n,worktree:r,blocked:i,pending:a,error:o,send:s,onClose:c}){let l=(0,J.useId)(),[u]=(0,J.useState)(()=>crypto.randomUUID()),d=e.document?.definition.nodes.filter(t=>O(t,e.document?.components[t.id])?.id===ue.id)??[],[f,p]=(0,J.useState)(d[0]?.id??``),[m,h]=(0,J.useState)(()=>e.kind===`run`?`null`:e.kind===`apply`&&e.comparison?JSON.stringify(e.comparison.active.variables,null,2):e.document?gi(e.document.definition):`{}`),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(`null`),b=e.kind===`run`,x=e.kind===`start-and-run`,S=b?`Run huddle`:x?`Start and run`:e.kind===`start`?`Start saved graph`:`Apply saved graph`,C=async()=>{if(!(i||a)){_(null);try{if(e.kind===`run`){if(!f.trim())throw Error(`Choose a manual trigger`);await s({action:`run`,input:{target:e.target,node:f.trim(),event_id:u,data:vi(m)}})}else{if(!e.document)throw Error(`Inspect saved source before continuing`);if(e.document.diagnostics.some(e=>e.severity===`error`))throw Error(`Fix the saved graph validation errors first`);let t={expected_digest:e.document.digest,variables:_i(e.document.definition,m)};if(e.kind===`start-and-run`){if(!d.some(e=>e.id===f.trim()))throw Error(`Choose a manual trigger from the saved graph`);await s({action:`start-and-run`,input:t,event:{node:f.trim(),event_id:u,data:vi(v)}})}else await s(e.kind===`start`?{action:`start`,input:t}:{action:`apply`,input:{...t,target:e.target}})}}catch(e){_(e instanceof Error?e.message:`Cannot send this command`)}}};return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{!e&&!a&&c()},children:(0,Y.jsxs)(V,{showCloseButton:!a,wide:e.kind===`apply`&&!!e.comparison,children:[(0,Y.jsx)(H,{children:S}),(0,Y.jsx)(B,{children:b?`Send one input to the active graph. Apply saved edits to use them in future runs.`:x?`Start the saved revision with these variables, then send one manual input after confirming the active revision. Starting also arms automatic triggers, including past one-off dates set to fire. If either step is uncertain, inspect the outcome before continuing.`:`Use the saved files and the variables below. Unsaved script edits are not included. Start arms automatic triggers; Apply resets their schedules. Both create a new activation, so past one-off dates set to fire may run again. Manual input is sent separately.`}),!b&&(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:e.document?.definition.name}),(0,Y.jsx)(`p`,{className:`break-all`,children:r}),(0,Y.jsxs)(`p`,{children:[`Saved revision `,e.document?.digest.slice(0,12)]}),Object.entries(e.document?.definition.variables??{}).map(([e,t])=>(0,Y.jsxs)(`p`,{children:[e,t.required?` · required`:` · optional`,t.description?` · ${t.description}`:``]},e))]}),e.kind===`apply`&&e.comparison&&(0,Y.jsx)(Li,{profile:t,session:n,review:e.comparison}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(b||x)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(K,{htmlFor:`${l}-node`,children:`Manual trigger`}),(0,Y.jsx)(G,{id:`${l}-node`,value:f,disabled:a,list:`${l}-triggers`,onChange:e=>p(e.target.value)}),(0,Y.jsx)(`datalist`,{id:`${l}-triggers`,children:d.map(e=>(0,Y.jsx)(`option`,{value:e.id},e.id))}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:x?`Choose a manual trigger in this saved revision.`:`Suggestions come from saved source. Enter an existing trigger id if the active graph differs.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(K,{htmlFor:`${l}-json`,children:b?`Input (JSON)`:`Variables (JSON)`}),(0,Y.jsx)(`textarea`,{id:`${l}-json`,className:`${it} min-h-28 resize-y p-2 font-mono text-xs`,value:m,disabled:a,spellCheck:!1,onChange:e=>{h(e.target.value),_(null)}})]}),x&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(K,{htmlFor:`${l}-input`,children:`Input (JSON)`}),(0,Y.jsx)(`textarea`,{id:`${l}-input`,className:`rounded-[var(--ui-radius)] bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 host-accent:bg-explorer-hover host-accent:hover:bg-explorer-selection/50 host-accent:focus:bg-explorer-selection/50 disabled:cursor-not-allowed disabled:opacity-50 min-h-28 resize-y p-2 font-mono text-xs`,value:v,disabled:a,spellCheck:!1,onChange:e=>{y(e.target.value),_(null)}})]}),(i||o||g)&&(0,Y.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap break-words text-xs text-fg-muted`,children:x&&o?o:i??o??g}),(0,Y.jsxs)(nt,{children:[(0,Y.jsx)(_t,{type:`button`,variant:`ghost`,disabled:a,onClick:c,children:`Cancel`}),(0,Y.jsx)(_t,{type:`submit`,disabled:a||!!i,children:a?`Sending…`:b?`Send input`:S})]})]})]})})}function sa({sources:e}){return e.length?(0,Y.jsxs)(nn,{className:`px-4 pb-2 text-xs`,open:e.some(e=>e.health.state===`gap`),summary:`Custom triggers · ${e.filter(e=>e.health.state===`ready`).length} ready`,summaryClassName:`py-1 text-fg-muted`,children:[(0,Y.jsx)(`ul`,{className:`space-y-1 py-1`,"aria-label":`Custom trigger health`,children:e.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`span`,{children:[e.node,` · `,e.health.state]}),`message`in e.health&&(0,Y.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,e.health.message]})]},e.node))}),e.some(e=>e.health.state===`gap`)&&(0,Y.jsx)(`p`,{className:`py-1 text-fg-muted`,children:`Inspect the source, then interrupt and resume to reopen its subscription. Other sources may still be running.`})]}):null}function ca({profile:e,session:t,target:n,stale:r,onClose:i}){let a=z({queryKey:[`huddle-active-revision`,e,t,n],queryFn:({signal:r})=>Pi(e,t,{target:n},r),retry:!1,staleTime:1/0,gcTime:0});return(0,Y.jsx)(U,{open:!0,onOpenChange:e=>{e||i()},children:(0,Y.jsxs)(V,{wide:!0,children:[(0,Y.jsx)(H,{children:`Active huddle revision`}),(0,Y.jsx)(B,{children:`Retained source and bindings for this activation. Inspecting does not run code or apply saved edits.`}),r&&(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:`The runtime changed. This view refers to the inspected activation; close and inspect again for the current revision.`}),a.isPending&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading active revision…`}),a.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:a.error.message}),a.data&&(0,Y.jsx)(Li,{profile:e,session:t,review:a.data})]})})}function la(e,t){return e.runtimeId===t.runtimeId&&e.incarnation===t.incarnation&&e.generation===t.generation&&e.activationId===t.activationId}var ua=e=>({runtimeId:e.runtimeId,incarnation:e.incarnation});function da({profile:e,session:t,focused:n,locked:r}){let i=qi(),a=Oi(),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),u=Ni(),d=Ji(e,t.id,n),f=zt(e,t),p=Xi(e,t.id),m=Ke(),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),C=aa(t),w=d.data?.owner,T=w?.connected?w:null,ee=qt(e,i&&n&&!w);if(!i)return null;let E=p.status.pending||x,D=!d.data||d.isError||d.data.unresolved||w?.connected===!1,k=!E&&!p.status.review&&!D&&!T?.stopping,te=k&&!w&&ee.data?.available&&t.status!==`archived`,A=k&&!!T&&t.status!==`archived`,j=async n=>{if(!k)return;if(n!==`run`&&(C||r)){W.warning(`Save or resolve source edits before Start or Apply.`);return}let i=n===`start`||n===`start-and-run`;S(!0);try{let r=await d.refetch({throwOnError:!0}),a=r.data?.owner;if(!r.data||r.data.unresolved||a?.connected===!1)throw Error(`Runtime observation is unavailable`);if(i&&a)throw Error(`An owner already exists; inspect it before starting`);if(!i&&(!a?.connected||a.stopping))throw Error(`No available owner to control`);let o=f.data;if(n!==`run`&&(o=(await f.refetch({throwOnError:!0})).data),n===`start`||n===`start-and-run`){if(!o)throw Error(`Saved source is unavailable`);g({kind:n,document:o})}else if(a?.connected){let r=n===`apply`&&u&&o?await Pi(e,t.id,{target:a.target,expected_digest:o.digest}):void 0;g({kind:n,document:o,target:a.target,...r?{comparison:r}:{}})}}catch(e){W.error(e instanceof Error?e.message:`Cannot inspect huddle`)}finally{S(!1)}},M=async e=>{let t=await p.send(e).catch(e=>{throw W.error(e instanceof Error?e.message:`Huddle command failed`,{description:`The command was not repeated. Inspect the outcome before another action.`}),e});g(null),t.action===`run`&&b({owner:ua(t.target),execution:t.value.executionId})},N=async()=>{if(!E){S(!0);try{let n=(await d.refetch({throwOnError:!0})).data;if(!n)throw Error(`Runtime outcome is still unavailable`);if(n.unresolved||n.owner?.connected===!1){if(!n.recovery)throw Error(`Runtime outcome is still unavailable`);p.reviewed();return}if(n.owner?.connected){let r=ua(n.owner.target),i={owner:r,collection:`executions`,after:0},a=await Hi(e,t.id,i);m.setQueryData([...Ki(e,t.id),i],a),p.status.review&&b({owner:r})}else await ee.refetch();p.reviewed(),n.owner?.failure?W.warning(n.owner.failure):!n.owner&&ee.data?.available===!1?W.warning(ee.data.reason):W.info(F,{description:n.owner?.lifetime===`host_session`?`Runtime lifetime is limited to this host session.`:void 0})}catch(e){W.error(e instanceof Error?e.message:`Cannot inspect outcome`)}finally{S(!1)}}},P=p.status.review?`Close this review and inspect the previous outcome before another action.`:null;h&&!P&&!p.status.pending&&(d.isError||!d.data||d.data.unresolved||w?.connected===!1?P=`Runtime observation is unavailable. Close and inspect again.`:(h.kind===`start`||h.kind===`start-and-run`?w:!T||!la(T.target,h.target))?P=`The active graph changed. Close and inspect again.`:h.kind!==`run`&&(C||r)&&(P=`Save or resolve the source edits before continuing.`));let F=E?`Working…`:D?`Runtime unavailable`:T?T.stopping?`Stopping`:T.executing?`Executing`:T.lifecycle===`armed`?`Armed · idle`:T.lifecycle===`interrupted`?`Interrupted`:`Ready to start`:`Stopped`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-3`,"aria-label":`Huddle execution`,children:(0,Y.jsxs)(ln,{label:`Huddle execution actions`,variant:`island`,className:`max-w-full flex-wrap`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,role:`status`,children:F}),d.data?.recovery&&(0,Y.jsx)(X,{icon:rn,label:`Recover after reboot`,title:`Restore the last active graph and retained trigger cursors after a host reboot. Running scripts remain interrupted.`,disabled:E||p.status.review||t.status===`archived`||r,onClick:()=>void M({action:`recover`,input:{owner:d.data.recovery.owner}}).catch(()=>{})}),d.data?.recovery?.crash_recovery&&(0,Y.jsx)(X,{icon:rn,label:`Recover after crash`,title:`Recover a crashed owner after its recorded kernel scope confirms that script descendants have stopped. Queued events resume; interrupted scripts are not replayed.`,disabled:E||p.status.review||t.status===`archived`||r,onClick:()=>void M({action:`recover`,input:{owner:d.data.recovery.owner,after:`owner-crash`}}).catch(()=>{})}),!w&&!d.data?.recovery&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(X,{icon:Je,label:`Start`,disabled:!te,onClick:()=>void j(`start`)}),u&&f.data?.definition.nodes.some(e=>O(e,f.data?.components[e.id])?.id===ue.id)&&(0,Y.jsx)(X,{icon:In,label:`Start and run`,disabled:!te,onClick:()=>void j(`start-and-run`)})]}),T&&(0,Y.jsxs)(Y.Fragment,{children:[u&&(0,Y.jsx)(X,{icon:Yn,label:`Active revision`,disabled:E||!T.target.activationId,onClick:()=>v(T.target)}),(0,Y.jsx)(X,{icon:Vt,label:`Apply saved`,disabled:!A,onClick:()=>void j(`apply`)}),T.lifecycle===`armed`?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(X,{icon:Je,label:`Run`,disabled:!k,onClick:()=>void j(`run`)})}):(0,Y.jsx)(X,{icon:Je,label:`Resume`,disabled:!k,onClick:()=>void M({action:`rearm`,input:{target:T.target}}).catch(()=>{})}),(0,Y.jsx)(X,{icon:Ze,label:`Stop`,disabled:!k,onClick:()=>void M({action:`stop`,input:{target:T.target}}).catch(()=>{})})]}),(0,Y.jsx)(X,{icon:ur,label:`Interrupt`,disabled:!k||T?.lifecycle!==`armed`,onClick:()=>{T?.lifecycle===`armed`&&M({action:`interrupt`,input:{target:T.target}}).catch(()=>{})}}),(0,Y.jsx)(X,{title:`${F}${T?.failure?` · ${T.failure}`:``}`,icon:en,label:p.status.review?`Inspect outcome`:`Inspect runtime`,disabled:E||d.isFetching,onClick:()=>void N()}),T?.trigger_inspection&&(0,Y.jsx)(X,{icon:Et,label:`Triggers`,onClick:()=>l(T.target)}),(T||a)&&(0,Y.jsx)(X,{icon:Qn,label:`History`,disabled:E,onClick:()=>T?b({owner:ua(T.target)}):s(!0)}),T&&T.auto_start!==void 0&&(0,Y.jsx)(Di,{enabled:T.auto_start,target:T.target,disabled:!k||t.status===`archived`||r,send:M})]})}),T?.custom_triggers&&!T.trigger_inspection&&(0,Y.jsx)(sa,{sources:T.custom_triggers}),c&&(0,Y.jsx)(Ei,{profile:e,session:t.id,target:c,focused:n,stale:D||!T||!la(T.target,c),onClose:()=>l(null)}),h&&(0,Y.jsx)(oa,{review:h,profile:e,session:t.id,worktree:t.worktree_path,blocked:P,pending:p.status.pending,error:p.status.error,send:M,onClose:()=>g(null)}),_&&(0,Y.jsx)(ca,{profile:e,session:t.id,target:_,stale:D||!T||!la(T.target,_),onClose:()=>v(null)}),o&&(0,Y.jsx)(ia,{profile:e,session:t.id,onClose:()=>s(!1)}),y&&(0,Y.jsx)(ta,{profile:e,session:t.id,owner:y.owner,initialExecution:y.execution,onRecordedRuntimes:a?()=>{b(null),s(!0)}:void 0,onClose:()=>b(null)})]})}function fa(e,t,n){let i=oi(e.id,re(e.huddle_id)[1],t),a=R().data?.protocol,o=(0,J.useMemo)(()=>{try{return{layout:_e.parse(JSON.parse(i.text))}}catch(e){return{error:e instanceof Error?e.message:`Invalid layout`}}},[i.text]),s=i.locked||!o.layout||!r(a,{major:28,minor:4}),c=i.buffer.model?.getAlternativeVersionId()??0,l=(e,t,r)=>{let a=i.buffer.model;if(s||!a||!n?.nodes.some(t=>t.id===e))return!1;if(a.getAlternativeVersionId()!==r)return W.error(`The layout changed while moving this node. Move it again from its current position.`),!1;try{let r=_e.parse(JSON.parse(a.getValue())),i=_e.parse({...r,nodes:Object.fromEntries(n.nodes.map((n,i)=>[n.id,n.id===e?t:r.nodes[n.id]??Br(i)]))});return a.pushStackElement(),mn(a,JSON.stringify(i,null,2)+`
2
2
  `),a.pushStackElement(),!0}catch(e){return W.error(ai(e,`Cannot move this node`)),!1}},u=!s&&r(a,{major:28,minor:34}),d=(e,t)=>{let r=i.buffer.model;if(!(!u||!r||!n?.nodes.some(t=>t.id===e)))try{let n=_e.parse(JSON.parse(r.getValue())),i={...n.labels};t.trim()?i[e]=t.trim():delete i[e];let{labels:a,...o}=n,s=_e.parse({...o,...Object.keys(i).length?{labels:i}:{}});r.pushStackElement(),mn(r,JSON.stringify(s,null,2)+`
3
3
  `),r.pushStackElement()}catch(e){W.error(ai(e,`Cannot rename this node`))}};return{...i,...o,locked:s,version:c,move:l,rename:d,canRename:u}}function pa({position:e,locked:t,apply:n}){let r=(0,J.useId)(),[i,a]=(0,J.useState)(String(e.x)),[o,s]=(0,J.useState)(String(e.y)),c=[i,o].every(e=>e.trim()!==``&&Number.isFinite(Number(e))&&Math.abs(Number(e))<=1e6);return(0,Y.jsxs)(`fieldset`,{className:`my-4 flex flex-col gap-2`,disabled:t,children:[(0,Y.jsx)(`legend`,{className:`mb-2 text-xs text-fg-muted`,children:`Position`}),(0,Y.jsx)(K,{htmlFor:`${r}-x`,children:`X`}),(0,Y.jsx)(G,{id:`${r}-x`,type:`number`,value:i,onChange:e=>a(e.target.value)}),(0,Y.jsx)(K,{htmlFor:`${r}-y`,children:`Y`}),(0,Y.jsx)(G,{id:`${r}-y`,type:`number`,value:o,onChange:e=>s(e.target.value)}),(0,Y.jsx)(`button`,{type:`button`,className:$,disabled:!c,onClick:()=>n({x:Number(i),y:Number(o)}),children:`Apply position`}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Drag a node or use its arrow keys. Shift moves farther.`})]})}var ma=`---
4
4
  name: puddle-huddle
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-_I1S2ZXt.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/protocol-support-C2shbX3-.js","assets/local-store-3IuC2qMo.js","assets/client-settings-BdKglwtW.js","assets/theme-swfNLod9.js","assets/preload-helper-Czpn1I53.js","assets/forward-link-Kt311XAU.js","assets/api-BLc59FAZ.js","assets/auth-tYM1depE.js","assets/window-context-Euxqnh6S.js","assets/queries-essOjrjZ.js","assets/editor-links-DFaQQsK-.js","assets/motion-Bd_MB9cH.js","assets/utils-B6KiDbIe.js","assets/dist-DMpqv5CF.js","assets/FindWidget-FJWGUnZT.js","assets/x-CbfJFzGo.js","assets/createLucideIcon-DyMAgLa3.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-Bis7oo_z.js","assets/button-BNH9tKwf.js","assets/copy-CGsu8426.js","assets/ws-Du8jZ4aQ.js","assets/code-DRWf9a5s.js","assets/profile-store-BDrSK8Qs.js","assets/hotkeys-ChnvTHTH.js","assets/errors-CV02t999.js","assets/preferences-sJF-HcJf.js","assets/file-links-JFyQw_0a.js","assets/render-rich-content-DlSv3j1S.js","assets/math-delimiters-BCnTi7Ii.js","assets/render-rich-content-BoTeqQfi.css","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{t as i}from"./utils-B6KiDbIe.js";import"./dist-CNoWjXWo.js";import{n as a}from"./chevron-right-6pjfw_yV.js";import{t as o}from"./createLucideIcon-DyMAgLa3.js";function s(e){return e.trim().slice(0,5).toUpperCase()}function c(e){return e.abbrev??s(e.name)}function l(e){return e.trim().toUpperCase().slice(0,5)}var u=o(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),d=e(t(),1),f=n();function p({id:e,value:t,onValueChange:n,onChoose:r,hints:o,placeholder:s,className:c,hintsClassName:l,autoFocus:u}){let[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(0),_=e=>{n(e.value),r?.(e),m(!1)};return(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(a,{id:e,value:t,onChange:e=>{n(e.target.value),m(!0),g(0)},onFocus:()=>m(!0),onBlur:()=>m(!1),onKeyDown:e=>{if(!(!p||o.length===0))if(e.key===`ArrowDown`)e.preventDefault(),g(e=>(e+1)%o.length);else if(e.key===`ArrowUp`)e.preventDefault(),g(e=>(e-1+o.length)%o.length);else if(e.key===`Enter`||e.key===`Tab`){let t=o[h]??o[0];t&&(e.preventDefault(),_(t))}else e.key===`Escape`&&(e.stopPropagation(),m(!1))},placeholder:s,className:c,autoComplete:`off`,spellCheck:!1,autoFocus:u}),p&&o.length>0&&(0,f.jsx)(`ul`,{className:i(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,l??`w-full`),children:o.map((e,t)=>(0,f.jsx)(`li`,{children:(0,f.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),_(e)},onMouseEnter:()=>g(t),className:i(`relative flex cursor-pointer select-none items-center gap-2 rounded-[var(--ui-menu-radius)] px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===h,children:[(0,f.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,f.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var m=(0,d.lazy)(()=>r(()=>import(`./Terminal-_I1S2ZXt.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))),h=null;async function g(){h=(await r(()=>import(`./Terminal-_I1S2ZXt.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))).Terminal}function _(e){return h?(0,f.jsx)(h,{...e}):(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,f.jsx)(m,{...e})})}export{s as a,u as i,g as n,l as o,p as r,c as s,_ as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-J5WMTjuY.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/protocol-support-DIWnYJkt.js","assets/local-store-DKFKEHML.js","assets/client-settings-BdKglwtW.js","assets/theme-swfNLod9.js","assets/preload-helper-Czpn1I53.js","assets/forward-link-BT0QTRVB.js","assets/api-DhfvolrJ.js","assets/auth-BPXeEntX.js","assets/window-context-DddmcmmO.js","assets/queries-C9DYtGQW.js","assets/editor-links-Djdkea3i.js","assets/motion-Bd_MB9cH.js","assets/utils-B6KiDbIe.js","assets/dist-DMpqv5CF.js","assets/FindWidget-FJWGUnZT.js","assets/x-CbfJFzGo.js","assets/createLucideIcon-DyMAgLa3.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-DX3EnNRv.js","assets/button-BNH9tKwf.js","assets/copy-CGsu8426.js","assets/ws-fD2y3o7n.js","assets/code-DRWf9a5s.js","assets/profile-store-BnferXV3.js","assets/hotkeys-B417biB9.js","assets/errors-SnGDjajv.js","assets/preferences-BP2Incj1.js","assets/file-links-CEjYCLBn.js","assets/render-rich-content-Br9yR6jZ.js","assets/math-delimiters-BCnTi7Ii.js","assets/render-rich-content-BoTeqQfi.css","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{t as i}from"./utils-B6KiDbIe.js";import"./dist-CNoWjXWo.js";import{n as a}from"./chevron-right-6pjfw_yV.js";import{t as o}from"./createLucideIcon-DyMAgLa3.js";function s(e){return e.trim().slice(0,5).toUpperCase()}function c(e){return e.abbrev??s(e.name)}function l(e){return e.trim().toUpperCase().slice(0,5)}var u=o(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),d=e(t(),1),f=n();function p({id:e,value:t,onValueChange:n,onChoose:r,hints:o,placeholder:s,className:c,hintsClassName:l,autoFocus:u}){let[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(0),_=e=>{n(e.value),r?.(e),m(!1)};return(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(a,{id:e,value:t,onChange:e=>{n(e.target.value),m(!0),g(0)},onFocus:()=>m(!0),onBlur:()=>m(!1),onKeyDown:e=>{if(!(!p||o.length===0))if(e.key===`ArrowDown`)e.preventDefault(),g(e=>(e+1)%o.length);else if(e.key===`ArrowUp`)e.preventDefault(),g(e=>(e-1+o.length)%o.length);else if(e.key===`Enter`||e.key===`Tab`){let t=o[h]??o[0];t&&(e.preventDefault(),_(t))}else e.key===`Escape`&&(e.stopPropagation(),m(!1))},placeholder:s,className:c,autoComplete:`off`,spellCheck:!1,autoFocus:u}),p&&o.length>0&&(0,f.jsx)(`ul`,{className:i(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,l??`w-full`),children:o.map((e,t)=>(0,f.jsx)(`li`,{children:(0,f.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),_(e)},onMouseEnter:()=>g(t),className:i(`relative flex cursor-pointer select-none items-center gap-2 rounded-[var(--ui-menu-radius)] px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===h,children:[(0,f.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,f.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var m=(0,d.lazy)(()=>r(()=>import(`./Terminal-J5WMTjuY.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))),h=null;async function g(){h=(await r(()=>import(`./Terminal-J5WMTjuY.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))).Terminal}function _(e){return h?(0,f.jsx)(h,{...e}):(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,f.jsx)(m,{...e})})}export{s as a,u as i,g as n,l as o,p as r,c as s,_ as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{y as r}from"./local-store-3IuC2qMo.js";import{t as i}from"./context-C632GWyy.js";import{r as a,s as o}from"./theme-swfNLod9.js";import{t as s}from"./preload-helper-Czpn1I53.js";var c=e(t(),1),l=n(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(i),r=n?.session,a=(0,c.useSyncExternalStore)(r?.subscribe??u,r?.getSnapshot??f),o=!!r?.state.state[e]&&!!a.generation&&!a.error,s=o?r.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?r:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(r?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:n,generation:i,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(o,a,a)]),(0,c.useEffect)(()=>{let t=!1,a,o=o=>{if(o.source!==f.current?.contentWindow||o.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let a=e.data;if(a.type===`height`&&Number.isFinite(a.height)&&x(Math.max(24,Math.min(2e3,a.height))),a.type===`error`&&C(String(a.error).slice(0,1024)),a.type===`extension`&&T(String(a.name).slice(0,256)),a.type!==`comm`||!n||!i)return;let o=r.safeParse({source:n.source,generation:i,message:a.message});if(!o.success||JSON.stringify(o.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}n.send(i,o.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:o.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(n?.state??h.current),modelId:e,live:!!i,extensions:u,theme:m()}),a=n?.subscribe(e=>{e.generation!==i||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,a?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,o),(async()=>{let{default:e}=await s(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-RX_hqyhn.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{y as r}from"./local-store-DKFKEHML.js";import{t as i}from"./context-CvPVX4oN.js";import{r as a,s as o}from"./theme-swfNLod9.js";import{t as s}from"./preload-helper-Czpn1I53.js";var c=e(t(),1),l=n(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(i),r=n?.session,a=(0,c.useSyncExternalStore)(r?.subscribe??u,r?.getSnapshot??f),o=!!r?.state.state[e]&&!!a.generation&&!a.error,s=o?r.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?r:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(r?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:n,generation:i,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(o,a,a)]),(0,c.useEffect)(()=>{let t=!1,a,o=o=>{if(o.source!==f.current?.contentWindow||o.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let a=e.data;if(a.type===`height`&&Number.isFinite(a.height)&&x(Math.max(24,Math.min(2e3,a.height))),a.type===`error`&&C(String(a.error).slice(0,1024)),a.type===`extension`&&T(String(a.name).slice(0,256)),a.type!==`comm`||!n||!i)return;let o=r.safeParse({source:n.source,generation:i,message:a.message});if(!o.success||JSON.stringify(o.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}n.send(i,o.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:o.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(n?.state??h.current),modelId:e,live:!!i,extensions:u,theme:m()}),a=n?.subscribe(e=>{e.generation!==i||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,a?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,o),(async()=>{let{default:e}=await s(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-RX_hqyhn.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
2
2
  html,body{margin:0;background:var(--jp-layout-color0)!important;color:var(--jp-ui-font-color1)!important;font-family:var(--jp-ui-font-family)!important}
3
3
  .jupyter-widgets input,.jupyter-widgets select,.jupyter-widgets textarea,.jupyter-widgets button{border:0!important;color:var(--jp-ui-font-color1);background:var(--jp-layout-color1)}
4
4
  .jupyter-widgets button,.jupyter-widgets select,.jupyter-widgets input[type=range]{cursor:pointer}